ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
5 require_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  var $id;
31 
36  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  {
47  $this->read();
48  }
49  }
50 
54  function __destruct()
55  {
56  if(is_object($this->page_object))
57  {
58  unset($this->page_object);
59  }
60  }
61 
65  function read()
66  {
67  parent::read();
68 
69  $this->page_object = new ilSCORM2004Page($this->id, 0);
70  }
71 
77  function create($a_upload = false,$a_layout_id = 0)
78  {
79  parent::create($a_upload);
80 
81  // create scorm2004 page
82  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
83  if(!is_object($this->page_object))
84  {
85  $this->page_object = new ilSCORM2004Page($this->slm_object->getType());
86  }
87  $this->page_object->setId($this->getId());
88  $this->page_object->setParentId($this->getSLMId());
89  if ($a_layout_id == 0) {
90  $this->page_object->create($a_upload);
91  } else{
92  $this->page_object->createWithLayoutId($a_layout_id);
93  }
94  }
95 
101  function delete($a_delete_meta_data = true)
102  {
103  parent::delete($a_delete_meta_data);
104  $this->page_object->delete();
105  }
106 
107 
111  function copy($a_target_slm)
112  {
113  // copy page
114  $slm_page = new ilSCORM2004PageNode($a_target_slm);
115  $slm_page->setTitle($this->getTitle());
116  $slm_page->setSLMId($a_target_slm->getId());
117  $slm_page->setType($this->getType());
118  $slm_page->setDescription($this->getDescription());
119  $slm_page->setImportId("il__page_".$this->getId());
120  $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
121 
122  // copy meta data
123  include_once("Services/MetaData/classes/class.ilMD.php");
124  $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
125  $new_md = $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), $this->getType());
126 
127  // copy page content
128  $page = $slm_page->getPageObject();
129  // clone media objects, if source and target lm are not the same
130  $clone_mobs = ($this->getSLMId() == $a_target_slm->getId())
131  ? false
132  : true;
133 
134  $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
135 
136  //$page->setXMLContent($this->page_object->copyXMLContent($clone_mobs));
137  //$page->buildDom();
138  //$page->update();
139 
140  return $slm_page;
141  }
142 
146  static function copyPageFromLM($a_target_slm, $a_lm_page)
147  {
148  // copy page
149  $slm_page = new ilSCORM2004PageNode($a_target_slm);
150  $slm_page->setTitle($a_lm_page->getTitle());
151  $slm_page->setSLMId($a_target_slm->getId());
152  $slm_page->setType("page");
153  $slm_page->create(true); // setting "upload" flag to true prevents creating of meta data
154 
155  // copy meta data
156  include_once("Services/MetaData/classes/class.ilMD.php");
157  $md = new ilMD($a_lm_page->getLMId(), $a_lm_page->getId(), $a_lm_page->getType());
158  $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), "page");
159 
160  // copy page content
161  $page = $slm_page->getPageObject();
162  $clone_mobs = true;
163  $a_lm_page->getPageObject()->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
164 
165  $slm_page = new ilSCORM2004PageNode($a_target_slm, $slm_page->getId());
166  $slm_page->getPageObject()->removeInvalidLinks();
167 
168  return $slm_page;
169  }
170 
171 
175  function &copyToOtherContObject(&$a_cont_obj)
176  {
177  // @todo
178  /*
179  // copy page
180  $lm_page = new ilLMPageObject($a_cont_obj);
181  $lm_page->setTitle($this->getTitle());
182  $lm_page->setLMId($a_cont_obj->getId());
183  $lm_page->setType($this->getType());
184  $lm_page->setDescription($this->getDescription());
185  $lm_page->create(true); // setting "upload" flag to true prevents creating of meta data
186 
187  // copy meta data
188  include_once("Services/MetaData/classes/class.ilMD.php");
189  $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
190  $new_md =& $md->cloneMD($a_cont_obj->getId(), $lm_page->getId(), $this->getType());
191 
192  // copy page content
193  $page =& $lm_page->getPageObject();
194  $page->setXMLContent($this->page_object->getXMLContent());
195  $page->buildDom();
196  $page->update();
197 
198  return $lm_page;
199  */
200  }
201 
202 
208  function assignPageObject(&$a_page_obj)
209  {
210  $this->page_object = $a_page_obj;
211  }
212 
213 
219  function &getPageObject()
220  {
221  return $this->page_object;
222  }
223 
224 
230  function setId($a_id)
231  {
232  $this->id = $a_id;
233  }
234 
240  function getId()
241  {
242  return $this->id;
243  }
244 
248  function setAlias($a_is_alias)
249  {
250  $this->is_alias = $a_is_alias;
251  }
252 
253  function isAlias()
254  {
255  return $this->is_alias;
256  }
257 
258  // only for page aliases
259  function setOriginID($a_id)
260  {
261  return $this->origin_id = $a_id;
262  }
263 
264  // only for page aliases
265  function getOriginID()
266  {
267  return $this->origin_id;
268  }
269 
275  function getMediaObjectIds()
276  {
277  return $this->mobs_contained;
278  }
279 
285  function getFileItemIds()
286  {
287  return $this->files_contained;
288  }
289 
290 }
291 ?>
& cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
Definition: class.ilMD.php:346
Class ilSCORM2004PageNode.
getMediaObjectIds()
get ids of all media objects within the page
setAlias($a_is_alias)
Set wether page object is an alias.
& getPageObject()
Get assigned page object.
static copyPageFromLM($a_target_slm, $a_lm_page)
Copy page from learning module.
copy($a_target_slm)
copy page node
read()
Read data from database.
getSLMId()
Get ID of parent Scorm Learning Module Object.
Class ilSCORM2004Page.
create($a_upload=false, $a_layout_id=0)
Create Scorm Page.
setId($a_id)
set id
getDescription()
Get description.
Create styles array
The data for the language used.
__construct($a_slm_object, $a_id=0)
Constructor public.
setType($a_type)
Set type.
getFileItemIds()
get ids of all file items within the page
& copyToOtherContObject(&$a_cont_obj)
copy a page to another content object (learning module / dlib book)
assignPageObject(&$a_page_obj)
Assign page object.