ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContObjectManifestBuilder.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
25 
37 {
38  var $db; // database object
39  var $ilias; // ilias object
40  var $cont_obj; // content object (learning module | digilib book)
41  var $inst_id; // installation id
42 
47  function ilContObjectManifestBuilder(&$a_cont_obj)
48  {
49  global $ilDB, $ilias;
50 
51  $this->cont_obj =& $a_cont_obj;
52 
53  $this->ilias =& $ilias;
54  $this->db =& $ilDB;
55 
56  $this->inst_id = IL_INST_ID;
57 
58  }
59 
63  function buildManifest()
64  {
65  require_once("classes/class.ilXmlWriter.php");
66 
67  $this->writer = new ilXmlWriter;
68 
69  // set xml header
70  $this->writer->xmlHeader();
71 
72  // manifest start tag
73  $attrs = array();
74  $attrs["identifier"] = "il_".IL_INST_ID."_"."man".
75  "_".$this->cont_obj->getId();
76  $attrs["version"] = "";
77  $attrs["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
78  $attrs["xsi:schemaLocation"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2".
79  " imscp_rootv1p1p2.xsd".
80  " http://www.imsglobal.org/xsd/imsmd_rootv1p2p1".
81  " imsmd_rootv1p2p1.xsd".
82  " http://www.adlnet.org/xsd/adlcp_rootv1p2".
83  " adlcp_rootv1p2.xsd";
84  $attrs["xmlns:imsmd"] = "http://www.imsproject.org/xsd/imsmd_rootv1p2p1";
85  $attrs["xmlns:adlcp"] = "http://www.adlnet.org/xsd/adlcp_rootv1p2";
86  $attrs["xmlns"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2";
87  $this->writer->xmlStartTag("manifest", $attrs);
88 
89  // organizations start tag
90  $attrs = array();
91  $this->writer->xmlStartTag("organizations", $attrs);
92 
93  // organization start tag
94  $attrs = array();
95  $attrs["identifier"] = "il_".IL_INST_ID."_".$this->cont_obj->getType().
96  "_".$this->cont_obj->getId();
97  $attrs["structure"] = "hierarchical";
98  $this->writer->xmlStartTag("organization", $attrs);
99 
100  // title element
101  $attrs = array();
102  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
103 
104  // write item hierarchy
105  $this->writeItemHierarchy();
106 
107  // organization end tag
108  $this->writer->xmlEndTag("organization");
109 
110  // organizations end tag
111  $this->writer->xmlEndTag("organizations");
112 
113  // resources start tag
114  $attrs = array();
115  $this->writer->xmlStartTag("resources", $attrs);
116 
117  // write resources
118  $this->writeResources();
119 
120  // resources end tag
121  $this->writer->xmlEndTag("resources");
122 
123  // manifest end tag
124  $this->writer->xmlEndTag("manifest");
125 
126  // write manifest file
127  //$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
128  // , false);
129 
130  // destroy writer object
131  $this->writer->_XmlWriter;
132  }
133 
137  function dump($a_target_dir)
138  {
139  $this->writer->xmlDumpFile($a_target_dir."/imsmanifest.xml", false);
140  }
141 
148  {
149  // start item
150  $attrs = array();
151  $attrs["identifier"] = "INDEX";
152  $attrs["identifierref"] = "RINDEX";
153  $this->writer->xmlStartTag("item", $attrs);
154 
155  // title element
156  $attrs = array();
157  $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
158 
159  // end item
160  $this->writer->xmlEndTag("item");
161  }
162 
163 
169  function writeResources()
170  {
171  $attrs = array();
172  $attrs["identifier"] = "RINDEX";
173  $attrs["type"] = "webcontent";
174  $attrs["adlcp:scormtype"] = "asset";
175  $attrs["href"] = "res/index.html";
176  $this->writer->xmlElement("resource", $attrs, "");
177  }
178 
179 }
180 
181 ?>