ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLMContObjectManifestBuilder.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  public $db; // database object
19  public $cont_obj; // content object (learning module | digilib book)
20  public $inst_id; // installation id
21 
26  public function __construct($a_cont_obj)
27  {
28  global $DIC;
29 
30  $ilDB = $DIC->database();
31 
32  $this->cont_obj = $a_cont_obj;
33 
34  $this->db = $ilDB;
35 
36  $this->inst_id = IL_INST_ID;
37  }
38 
42  public function buildManifest()
43  {
44  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
45 
46  $this->writer = new ilXmlWriter;
47 
48  // set xml header
49  $this->writer->xmlHeader();
50 
51  // manifest start tag
52  $attrs = array();
53  $attrs["identifier"] = "il_" . IL_INST_ID . "_" . "man" .
54  "_" . $this->cont_obj->getId();
55  $attrs["version"] = "";
56  $attrs["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
57  $attrs["xsi:schemaLocation"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2" .
58  " imscp_rootv1p1p2.xsd" .
59  " http://www.imsglobal.org/xsd/imsmd_rootv1p2p1" .
60  " imsmd_rootv1p2p1.xsd" .
61  " http://www.adlnet.org/xsd/adlcp_rootv1p2" .
62  " adlcp_rootv1p2.xsd";
63  $attrs["xmlns:imsmd"] = "http://www.imsproject.org/xsd/imsmd_rootv1p2p1";
64  $attrs["xmlns:adlcp"] = "http://www.adlnet.org/xsd/adlcp_rootv1p2";
65  $attrs["xmlns"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2";
66  $this->writer->xmlStartTag("manifest", $attrs);
67 
68  // organizations start tag
69  $attrs = array();
70  $this->writer->xmlStartTag("organizations", $attrs);
71 
72  // organization start tag
73  $attrs = array();
74  $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $this->cont_obj->getType() .
75  "_" . $this->cont_obj->getId();
76  $attrs["structure"] = "hierarchical";
77  $this->writer->xmlStartTag("organization", $attrs);
78 
79  // title element
80  $attrs = array();
81  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
82 
83  // write item hierarchy
84  $this->writeItemHierarchy();
85 
86  // organization end tag
87  $this->writer->xmlEndTag("organization");
88 
89  // organizations end tag
90  $this->writer->xmlEndTag("organizations");
91 
92  // resources start tag
93  $attrs = array();
94  $this->writer->xmlStartTag("resources", $attrs);
95 
96  // write resources
97  $this->writeResources();
98 
99  // resources end tag
100  $this->writer->xmlEndTag("resources");
101 
102  // manifest end tag
103  $this->writer->xmlEndTag("manifest");
104 
105  // write manifest file
106  //$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
107  // , false);
108 
109  // destroy writer object
110  $this->writer->_XmlWriter;
111  }
112 
116  public function dump($a_target_dir)
117  {
118  $this->writer->xmlDumpFile($a_target_dir . "/imsmanifest.xml", false);
119  }
120 
126  public function writeItemHierarchy()
127  {
128  // start item
129  $attrs = array();
130  $attrs["identifier"] = "INDEX";
131  $attrs["identifierref"] = "RINDEX";
132  $this->writer->xmlStartTag("item", $attrs);
133 
134  // title element
135  $attrs = array();
136  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
137 
138  // end item
139  $this->writer->xmlEndTag("item");
140  }
141 
142 
148  public function writeResources()
149  {
150  $attrs = array();
151  $attrs["identifier"] = "RINDEX";
152  $attrs["type"] = "webcontent";
153  $attrs["adlcp:scormtype"] = "asset";
154  $attrs["href"] = "res/index.html";
155  $this->writer->xmlElement("resource", $attrs, "");
156  }
157 }
__construct($a_cont_obj)
Constructor public.
dump($a_target_dir)
dump manifest file into directory
global $DIC
Definition: saml.php:7
Content Object (ILIAS native learning module / digilib book) Manifest export class.
XML writer class.
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
global $ilDB