ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
24{
25 public $id;
27
32 public function __construct($a_slm_object, $a_id = 0)
33 {
34 parent::__construct($a_slm_object, $a_id);
35 $this->setType("page");
36 $this->id = $a_id;
37
38 $this->mobs_contained = array();
39 $this->files_contained = array();
40
41 if ($a_id != 0) {
42 $this->read();
43 }
44 }
45
49 public function __destruct()
50 {
51 if (is_object($this->page_object)) {
52 unset($this->page_object);
53 }
54 }
55
59 public function read()
60 {
61 parent::read();
62
63 $this->page_object = new ilSCORM2004Page($this->id, 0);
64 }
65
71 public function create($a_upload = false, $a_layout_id = 0)
72 {
73 parent::create($a_upload);
74
75 // create scorm2004 page
76 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
77 if (!is_object($this->page_object)) {
78 $this->page_object = new ilSCORM2004Page($this->slm_object->getType());
79 }
80 $this->page_object->setId($this->getId());
81 $this->page_object->setParentId($this->getSLMId());
82 if ($a_layout_id == 0) {
83 $this->page_object->create($a_upload);
84 } else {
85 $this->page_object->createWithLayoutId($a_layout_id);
86 }
87 }
88
94 public function delete($a_delete_meta_data = true)
95 {
96 parent::delete($a_delete_meta_data);
97 $this->page_object->delete();
98 }
99
100
104 public function copy($a_target_slm)
105 {
106 // copy page
107 $slm_page = new ilSCORM2004PageNode($a_target_slm);
108 $slm_page->setTitle($this->getTitle());
109 $slm_page->setSLMId($a_target_slm->getId());
110 $slm_page->setType($this->getType());
111 $slm_page->setDescription($this->getDescription());
112 $slm_page->setImportId("il__page_" . $this->getId());
113 $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
114
115 // copy meta data
116 include_once("Services/MetaData/classes/class.ilMD.php");
117 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
118 $new_md = $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), $this->getType());
119
120 // copy page content
121 $page = $slm_page->getPageObject();
122 // clone media objects, if source and target lm are not the same
123 $clone_mobs = ($this->getSLMId() == $a_target_slm->getId())
124 ? false
125 : true;
126
127 $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
128
129 //$page->setXMLContent($this->page_object->copyXMLContent($clone_mobs));
130 //$page->buildDom();
131 //$page->update();
132
133 return $slm_page;
134 }
135
139 public static function copyPageFromLM($a_target_slm, $a_lm_page)
140 {
141 // copy page
142 $slm_page = new ilSCORM2004PageNode($a_target_slm);
143 $slm_page->setTitle($a_lm_page->getTitle());
144 $slm_page->setSLMId($a_target_slm->getId());
145 $slm_page->setType("page");
146 $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
147
148 // copy meta data
149 include_once("Services/MetaData/classes/class.ilMD.php");
150 $md = new ilMD($a_lm_page->getLMId(), $a_lm_page->getId(), $a_lm_page->getType());
151 $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), "page");
152
153 // copy page content
154 $page = $slm_page->getPageObject();
155 $clone_mobs = true;
156 $a_lm_page->getPageObject()->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
157
158 $slm_page = new ilSCORM2004PageNode($a_target_slm, $slm_page->getId());
159 $slm_page->getPageObject()->removeInvalidLinks();
160
161 return $slm_page;
162 }
163
164
168 public function &copyToOtherContObject(&$a_cont_obj)
169 {
170 // @todo
171 /*
172 // copy page
173 $lm_page = new ilLMPageObject($a_cont_obj);
174 $lm_page->setTitle($this->getTitle());
175 $lm_page->setLMId($a_cont_obj->getId());
176 $lm_page->setType($this->getType());
177 $lm_page->setDescription($this->getDescription());
178 $lm_page->create(true); // setting "upload" flag to true prevents creating of meta data
179
180 // copy meta data
181 include_once("Services/MetaData/classes/class.ilMD.php");
182 $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
183 $new_md =& $md->cloneMD($a_cont_obj->getId(), $lm_page->getId(), $this->getType());
184
185 // copy page content
186 $page =& $lm_page->getPageObject();
187 $page->setXMLContent($this->page_object->getXMLContent());
188 $page->buildDom();
189 $page->update();
190
191 return $lm_page;
192 */
193 }
194
195
201 public function assignPageObject(&$a_page_obj)
202 {
203 $this->page_object = $a_page_obj;
204 }
205
206
212 public function &getPageObject()
213 {
214 return $this->page_object;
215 }
216
217
223 public function setId($a_id)
224 {
225 $this->id = $a_id;
226 }
227
233 public function getId()
234 {
235 return $this->id;
236 }
237
241 public function setAlias($a_is_alias)
242 {
243 $this->is_alias = $a_is_alias;
244 }
245
246 public function isAlias()
247 {
248 return $this->is_alias;
249 }
250
251 // only for page aliases
252 public function setOriginID($a_id)
253 {
254 return $this->origin_id = $a_id;
255 }
256
257 // only for page aliases
258 public function getOriginID()
259 {
260 return $this->origin_id;
261 }
262
268 public function getMediaObjectIds()
269 {
270 return $this->mobs_contained;
271 }
272
278 public function getFileItemIds()
279 {
280 return $this->files_contained;
281 }
282}
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc