ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMContObjectManifestBuilder.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
16{
17 public $db; // database object
18 public $cont_obj; // content object (learning module | digilib book)
19 public $inst_id; // installation id
20
25 public function __construct($a_cont_obj)
26 {
27 global $DIC;
28
29 $ilDB = $DIC->database();
30
31 $this->cont_obj = $a_cont_obj;
32
33 $this->db = $ilDB;
34
35 $this->inst_id = IL_INST_ID;
36 }
37
41 public function buildManifest()
42 {
43 $this->writer = new ilXmlWriter;
44
45 // set xml header
46 $this->writer->xmlHeader();
47
48 // manifest start tag
49 $attrs = array();
50 $attrs["identifier"] = "il_" . IL_INST_ID . "_" . "man" .
51 "_" . $this->cont_obj->getId();
52 $attrs["version"] = "";
53 $attrs["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
54 $attrs["xsi:schemaLocation"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2" .
55 " imscp_rootv1p1p2.xsd" .
56 " http://www.imsglobal.org/xsd/imsmd_rootv1p2p1" .
57 " imsmd_rootv1p2p1.xsd" .
58 " http://www.adlnet.org/xsd/adlcp_rootv1p2" .
59 " adlcp_rootv1p2.xsd";
60 $attrs["xmlns:imsmd"] = "http://www.imsproject.org/xsd/imsmd_rootv1p2p1";
61 $attrs["xmlns:adlcp"] = "http://www.adlnet.org/xsd/adlcp_rootv1p2";
62 $attrs["xmlns"] = "http://www.imsproject.org/xsd/imscp_rootv1p1p2";
63 $this->writer->xmlStartTag("manifest", $attrs);
64
65 // organizations start tag
66 $attrs = array();
67 $this->writer->xmlStartTag("organizations", $attrs);
68
69 // organization start tag
70 $attrs = array();
71 $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $this->cont_obj->getType() .
72 "_" . $this->cont_obj->getId();
73 $attrs["structure"] = "hierarchical";
74 $this->writer->xmlStartTag("organization", $attrs);
75
76 // title element
77 $attrs = array();
78 $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
79
80 // write item hierarchy
81 $this->writeItemHierarchy();
82
83 // organization end tag
84 $this->writer->xmlEndTag("organization");
85
86 // organizations end tag
87 $this->writer->xmlEndTag("organizations");
88
89 // resources start tag
90 $attrs = array();
91 $this->writer->xmlStartTag("resources", $attrs);
92
93 // write resources
94 $this->writeResources();
95
96 // resources end tag
97 $this->writer->xmlEndTag("resources");
98
99 // manifest end tag
100 $this->writer->xmlEndTag("manifest");
101
102 // write manifest file
103 //$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
104 // , false);
105
106 // destroy writer object
107 $this->writer->_XmlWriter;
108 }
109
113 public function dump($a_target_dir)
114 {
115 $this->writer->xmlDumpFile($a_target_dir . "/imsmanifest.xml", false);
116 }
117
123 public function writeItemHierarchy()
124 {
125 // start item
126 $attrs = array();
127 $attrs["identifier"] = "INDEX";
128 $attrs["identifierref"] = "RINDEX";
129 $this->writer->xmlStartTag("item", $attrs);
130
131 // title element
132 $attrs = array();
133 $this->writer->xmlElement("title", $attrs, $this->cont_obj->getTitle());
134
135 // end item
136 $this->writer->xmlEndTag("item");
137 }
138
139
145 public function writeResources()
146 {
147 $attrs = array();
148 $attrs["identifier"] = "RINDEX";
149 $attrs["type"] = "webcontent";
150 $attrs["adlcp:scormtype"] = "asset";
151 $attrs["href"] = "res/index.html";
152 $this->writer->xmlElement("resource", $attrs, "");
153 }
154}
An exception for terminatinating execution or to throw for unit testing.
Content Object (ILIAS native learning module / digilib book) Manifest export class.
__construct($a_cont_obj)
Constructor @access public.
dump($a_target_dir)
dump manifest file into directory
XML writer class.
xmlHeader()
Writes xml header @access public.
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24
global $ilDB