ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilContObjectManifestBuilder.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
5 
17 {
18  var $db; // database object
19  var $ilias; // ilias object
20  var $cont_obj; // content object (learning module | digilib book)
21  var $inst_id; // installation id
22 
27  function ilContObjectManifestBuilder(&$a_cont_obj)
28  {
29  global $ilDB, $ilias;
30 
31  $this->cont_obj =& $a_cont_obj;
32 
33  $this->ilias =& $ilias;
34  $this->db =& $ilDB;
35 
36  $this->inst_id = IL_INST_ID;
37 
38  }
39 
43  function buildManifest()
44  {
45  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
46 
47  $this->writer = new ilXmlWriter;
48 
49  // set xml header
50  $this->writer->xmlHeader();
51 
52  // manifest start tag
53  $attrs = array();
54  $attrs["identifier"] = "il_".IL_INST_ID."_"."man".
55  "_".$this->cont_obj->getId();
56  $attrs["version"] = "";
57  $attrs["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
58  $attrs["xsi:schemaLocation"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2".
59  " imscp_rootv1p1p2.xsd".
60  " http://www.imsglobal.org/xsd/imsmd_rootv1p2p1".
61  " imsmd_rootv1p2p1.xsd".
62  " http://www.adlnet.org/xsd/adlcp_rootv1p2".
63  " adlcp_rootv1p2.xsd";
64  $attrs["xmlns:imsmd"] = "http://www.imsproject.org/xsd/imsmd_rootv1p2p1";
65  $attrs["xmlns:adlcp"] = "http://www.adlnet.org/xsd/adlcp_rootv1p2";
66  $attrs["xmlns"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2";
67  $this->writer->xmlStartTag("manifest", $attrs);
68 
69  // organizations start tag
70  $attrs = array();
71  $this->writer->xmlStartTag("organizations", $attrs);
72 
73  // organization start tag
74  $attrs = array();
75  $attrs["identifier"] = "il_".IL_INST_ID."_".$this->cont_obj->getType().
76  "_".$this->cont_obj->getId();
77  $attrs["structure"] = "hierarchical";
78  $this->writer->xmlStartTag("organization", $attrs);
79 
80  // title element
81  $attrs = array();
82  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
83 
84  // write item hierarchy
85  $this->writeItemHierarchy();
86 
87  // organization end tag
88  $this->writer->xmlEndTag("organization");
89 
90  // organizations end tag
91  $this->writer->xmlEndTag("organizations");
92 
93  // resources start tag
94  $attrs = array();
95  $this->writer->xmlStartTag("resources", $attrs);
96 
97  // write resources
98  $this->writeResources();
99 
100  // resources end tag
101  $this->writer->xmlEndTag("resources");
102 
103  // manifest end tag
104  $this->writer->xmlEndTag("manifest");
105 
106  // write manifest file
107  //$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
108  // , false);
109 
110  // destroy writer object
111  $this->writer->_XmlWriter;
112  }
113 
117  function dump($a_target_dir)
118  {
119  $this->writer->xmlDumpFile($a_target_dir."/imsmanifest.xml", false);
120  }
121 
128  {
129  // start item
130  $attrs = array();
131  $attrs["identifier"] = "INDEX";
132  $attrs["identifierref"] = "RINDEX";
133  $this->writer->xmlStartTag("item", $attrs);
134 
135  // title element
136  $attrs = array();
137  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
138 
139  // end item
140  $this->writer->xmlEndTag("item");
141  }
142 
143 
149  function writeResources()
150  {
151  $attrs = array();
152  $attrs["identifier"] = "RINDEX";
153  $attrs["type"] = "webcontent";
154  $attrs["adlcp:scormtype"] = "asset";
155  $attrs["href"] = "res/index.html";
156  $this->writer->xmlElement("resource", $attrs, "");
157  }
158 
159 }
160 
161 ?>
XML writer class.
ilContObjectManifestBuilder(&$a_cont_obj)
Constructor public.
redirection script todo: (a better solution should control the processing via a xml file) ...
xmlHeader()
Writes xml header public.
dump($a_target_dir)
dump manifest file into directory
global $ilDB
Content Object (ILIAS native learning module / digilib book) Manifest export class.