• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilContObjectManifestBuilder.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once("content/classes/class.ilObjContentObject.php");
00025 
00036 class ilContObjectManifestBuilder
00037 {
00038         var $db;                        // database object
00039         var $ilias;                     // ilias object
00040         var $cont_obj;          // content object (learning module | digilib book)
00041         var $inst_id;           // installation id
00042 
00047         function ilContObjectManifestBuilder(&$a_cont_obj)
00048         {
00049                 global $ilDB, $ilias;
00050 
00051                 $this->cont_obj =& $a_cont_obj;
00052 
00053                 $this->ilias =& $ilias;
00054                 $this->db =& $ilDB;
00055 
00056                 $this->inst_id = IL_INST_ID;
00057 
00058         }
00059 
00063         function buildManifest()
00064         {
00065                 require_once("classes/class.ilXmlWriter.php");
00066 
00067                 $this->writer = new ilXmlWriter;
00068 
00069                 // set xml header
00070                 $this->writer->xmlHeader();
00071 
00072                 // manifest start tag
00073                 $attrs = array();
00074                 $attrs["identifier"] = "il_".IL_INST_ID."_"."man".
00075                         "_".$this->cont_obj->getId();
00076                 $attrs["version"] = "";
00077                 $attrs["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
00078                 $attrs["xsi:schemaLocation"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2".
00079                         " imscp_rootv1p1p2.xsd".
00080                         " http://www.imsglobal.org/xsd/imsmd_rootv1p2p1".
00081                         " imsmd_rootv1p2p1.xsd".
00082                         " http://www.adlnet.org/xsd/adlcp_rootv1p2".
00083                         " adlcp_rootv1p2.xsd";
00084                 $attrs["xmlns:imsmd"] = "http://www.imsproject.org/xsd/imsmd_rootv1p2p1";
00085                 $attrs["xmlns:adlcp"] = "http://www.adlnet.org/xsd/adlcp_rootv1p2";
00086                 $attrs["xmlns"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2";
00087                 $this->writer->xmlStartTag("manifest", $attrs);
00088 
00089                 // organizations start tag
00090                 $attrs = array();
00091                 $this->writer->xmlStartTag("organizations", $attrs);
00092 
00093                 // organization start tag
00094                 $attrs = array();
00095                 $attrs["identifier"] =  "il_".IL_INST_ID."_".$this->cont_obj->getType().
00096                         "_".$this->cont_obj->getId();
00097                 $attrs["structure"] = "hierarchical"; 
00098                 $this->writer->xmlStartTag("organization", $attrs);
00099                 
00100                 // title element
00101                 $attrs = array();
00102                 $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
00103                 
00104                 // write item hierarchy
00105                 $this->writeItemHierarchy();
00106 
00107                 // organization end tag
00108                 $this->writer->xmlEndTag("organization");
00109                 
00110                 // organizations end tag
00111                 $this->writer->xmlEndTag("organizations");
00112                 
00113                 // resources start tag
00114                 $attrs = array();
00115                 $this->writer->xmlStartTag("resources", $attrs);
00116                 
00117                 // write resources
00118                 $this->writeResources();
00119 
00120                 // resources end tag
00121                 $this->writer->xmlEndTag("resources");
00122                 
00123                 // manifest end tag
00124                 $this->writer->xmlEndTag("manifest");
00125                 
00126                 // write manifest file
00127                 //$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
00128                 //      , false);
00129                         
00130                 // destroy writer object
00131                 $this->writer->_XmlWriter;
00132         }
00133         
00137         function dump($a_target_dir)
00138         {
00139                 $this->writer->xmlDumpFile($a_target_dir."/imsmanifest.xml", false);
00140         }
00141         
00147         function writeItemHierarchy()
00148         {
00149                 // start item
00150                 $attrs = array();
00151                 $attrs["identifier"] = "INDEX";
00152                 $attrs["identifierref"] = "RINDEX";
00153                 $this->writer->xmlStartTag("item", $attrs);
00154                 
00155                 // title element
00156                 $attrs = array();
00157                 $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
00158                 
00159                 // end item
00160                 $this->writer->xmlEndTag("item");
00161         }
00162         
00163         
00169         function writeResources()
00170         {
00171                 $attrs = array();
00172                 $attrs["identifier"] = "RINDEX";
00173                 $attrs["type"] = "webcontent";
00174                 $attrs["adlcp:scormtype"] = "asset";
00175                 $attrs["href"] = "res/index.html";
00176                 $this->writer->xmlElement("resource", $attrs, "");
00177         }
00178 
00179 }
00180 
00181 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1