ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSCORM2004PageNode.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
5require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
6
7// unclear whether we need this somehow...
8//define ("IL_CHAPTER_TITLE", "st_title");
9//define ("IL_PAGE_TITLE", "pg_title");
10//define ("IL_NO_HEADER", "none");
11
28{
29 public $id;
31
36 public function __construct($a_slm_object, $a_id = 0)
37 {
38 parent::__construct($a_slm_object, $a_id);
39 $this->setType("page");
40 $this->id = $a_id;
41
42 $this->mobs_contained = array();
43 $this->files_contained = array();
44
45 if ($a_id != 0) {
46 $this->read();
47 }
48 }
49
53 public function __destruct()
54 {
55 if (is_object($this->page_object)) {
56 unset($this->page_object);
57 }
58 }
59
63 public function read()
64 {
65 parent::read();
66
67 $this->page_object = new ilSCORM2004Page($this->id, 0);
68 }
69
75 public function create($a_upload = false, $a_layout_id = 0)
76 {
77 parent::create($a_upload);
78
79 // create scorm2004 page
80 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
81 if (!is_object($this->page_object)) {
82 $this->page_object = new ilSCORM2004Page($this->slm_object->getType());
83 }
84 $this->page_object->setId($this->getId());
85 $this->page_object->setParentId($this->getSLMId());
86 if ($a_layout_id == 0) {
87 $this->page_object->create($a_upload);
88 } else {
89 $this->page_object->createWithLayoutId($a_layout_id);
90 }
91 }
92
98 public function delete($a_delete_meta_data = true)
99 {
100 parent::delete($a_delete_meta_data);
101 $this->page_object->delete();
102 }
103
104
108 public function copy($a_target_slm)
109 {
110 // copy page
111 $slm_page = new ilSCORM2004PageNode($a_target_slm);
112 $slm_page->setTitle($this->getTitle());
113 $slm_page->setSLMId($a_target_slm->getId());
114 $slm_page->setType($this->getType());
115 $slm_page->setDescription($this->getDescription());
116 $slm_page->setImportId("il__page_" . $this->getId());
117 $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
118
119 // copy meta data
120 include_once("Services/MetaData/classes/class.ilMD.php");
121 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
122 $new_md = $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), $this->getType());
123
124 // copy page content
125 $page = $slm_page->getPageObject();
126 // clone media objects, if source and target lm are not the same
127 $clone_mobs = ($this->getSLMId() == $a_target_slm->getId())
128 ? false
129 : true;
130
131 $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
132
133 //$page->setXMLContent($this->page_object->copyXMLContent($clone_mobs));
134 //$page->buildDom();
135 //$page->update();
136
137 return $slm_page;
138 }
139
143 public static function copyPageFromLM($a_target_slm, $a_lm_page)
144 {
145 // copy page
146 $slm_page = new ilSCORM2004PageNode($a_target_slm);
147 $slm_page->setTitle($a_lm_page->getTitle());
148 $slm_page->setSLMId($a_target_slm->getId());
149 $slm_page->setType("page");
150 $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
151
152 // copy meta data
153 include_once("Services/MetaData/classes/class.ilMD.php");
154 $md = new ilMD($a_lm_page->getLMId(), $a_lm_page->getId(), $a_lm_page->getType());
155 $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), "page");
156
157 // copy page content
158 $page = $slm_page->getPageObject();
159 $clone_mobs = true;
160 $a_lm_page->getPageObject()->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
161
162 $slm_page = new ilSCORM2004PageNode($a_target_slm, $slm_page->getId());
163 $slm_page->getPageObject()->removeInvalidLinks();
164
165 return $slm_page;
166 }
167
168
172 public function &copyToOtherContObject(&$a_cont_obj)
173 {
174 // @todo
175 /*
176 // copy page
177 $lm_page = new ilLMPageObject($a_cont_obj);
178 $lm_page->setTitle($this->getTitle());
179 $lm_page->setLMId($a_cont_obj->getId());
180 $lm_page->setType($this->getType());
181 $lm_page->setDescription($this->getDescription());
182 $lm_page->create(true); // setting "upload" flag to true prevents creating of meta data
183
184 // copy meta data
185 include_once("Services/MetaData/classes/class.ilMD.php");
186 $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
187 $new_md =& $md->cloneMD($a_cont_obj->getId(), $lm_page->getId(), $this->getType());
188
189 // copy page content
190 $page =& $lm_page->getPageObject();
191 $page->setXMLContent($this->page_object->getXMLContent());
192 $page->buildDom();
193 $page->update();
194
195 return $lm_page;
196 */
197 }
198
199
205 public function assignPageObject(&$a_page_obj)
206 {
207 $this->page_object = $a_page_obj;
208 }
209
210
216 public function &getPageObject()
217 {
218 return $this->page_object;
219 }
220
221
227 public function setId($a_id)
228 {
229 $this->id = $a_id;
230 }
231
237 public function getId()
238 {
239 return $this->id;
240 }
241
245 public function setAlias($a_is_alias)
246 {
247 $this->is_alias = $a_is_alias;
248 }
249
250 public function isAlias()
251 {
252 return $this->is_alias;
253 }
254
255 // only for page aliases
256 public function setOriginID($a_id)
257 {
258 return $this->origin_id = $a_id;
259 }
260
261 // only for page aliases
262 public function getOriginID()
263 {
264 return $this->origin_id;
265 }
266
272 public function getMediaObjectIds()
273 {
274 return $this->mobs_contained;
275 }
276
282 public function getFileItemIds()
283 {
284 return $this->files_contained;
285 }
286}
An exception for terminatinating execution or to throw for unit testing.
getSLMId()
Get ID of parent Scorm Learning Module Object.
setType($a_type)
Set type.
getDescription()
Get description.
Class ilSCORM2004PageNode.
assignPageObject(&$a_page_obj)
Assign page object.
read()
Read data from database.
create($a_upload=false, $a_layout_id=0)
Create Scorm Page.
& getPageObject()
Get assigned page object.
setAlias($a_is_alias)
Set wether page object is an alias.
__construct($a_slm_object, $a_id=0)
Constructor @access public.
& copyToOtherContObject(&$a_cont_obj)
copy a page to another content object (learning module / dlib book)
getMediaObjectIds()
get ids of all media objects within the page
copy($a_target_slm)
copy page node
getFileItemIds()
get ids of all file items within the page
static copyPageFromLM($a_target_slm, $a_lm_page)
Copy page from learning module.
Class ilSCORM2004Page.