ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSCORM2004Page.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/COPage/classes/class.ilPageObject.php");
5 
15 {
16  protected $glossary_id = 0;
17  protected $mobs_contained = array();
18  protected $files_contained = array();
19 
25  function getParentType()
26  {
27  return "sahs";
28  }
29 
36  function afterConstructor()
37  {
38  $this->getPageConfig()->configureByObjectId($this->getParentId());
39  }
40 
41 
47  function setScormLmId($a_scormlmid)
48  {
49  $this->scormlmid = $a_scormlmid;
50  }
51 
57  function getScormLmId()
58  {
59  return $this->scormlmid;
60  }
61 
67  function setGlossaryId($a_val)
68  {
69  $this->glossary_id = $a_val;
70  }
71 
77  function getGlossaryId()
78  {
79  return $this->glossary_id;
80  }
81 
85  function create()
86  {
87  global $ilDB;
88 
89  // maybe we need an additional table here?
90 
91  // create page object
92  parent::create();
93  }
94 
95 
99  function createWithLayoutId($a_layout_id)
100  {
101 
102  include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
103 
104  //get XML Data for Layout
105  $layout_obj = new ilPageLayout($a_layout_id);
106 
107  parent::setXMLContent($layout_obj->getXMLContent());
108  // create page object
109  parent::create();
110  }
111 
118  function update($a_validate = true, $a_no_history = false)
119  {
120  global $ilDB;
121 
122  // maybe we need an additional table here?
123 
124  parent::update($a_validate, $a_no_history);
125 
126  return true;
127  }
128 
132  function read()
133  {
134  global $ilDB;
135 
136  // maybe we need an additional table here?
137 
138  // get co page
139  parent::read();
140  }
141 
142 
148  function delete()
149  {
150  global $ilDB;
151 
152  // maybe we need an additional table here?
153 
154  // delete co page
155  parent::delete();
156 
157  return true;
158  }
159 
160 
161 
168  function exportXML(&$a_xml_writer, $a_mode = "normal", $a_inst = 0)
169  {
170  global $ilBench;
171 
172  $attrs = array();
173  $a_xml_writer->xmlStartTag("PageObject", $attrs);
174 
175  switch ($a_mode)
176  {
177  case "normal":
178  // MetaData
179  $ilBench->start("ContentObjectExport", "exportPageObject_XML_Meta");
180  $this->exportXMLMetaData($a_xml_writer);
181  $ilBench->stop("ContentObjectExport", "exportPageObject_XML_Meta");
182 
183  // PageContent
184  $ilBench->start("ContentObjectExport", "exportPageObject_XML_PageContent");
185  $this->exportXMLPageContent($a_xml_writer, $a_inst);
186  $ilBench->stop("ContentObjectExport", "exportPageObject_XML_PageContent");
187  break;
188 
189  case "alias":
190  $attrs = array();
191  $attrs["OriginId"] = "il_".$a_inst.
192  "_pg_".$this->getId();
193  $a_xml_writer->xmlElement("PageAlias", $attrs);
194  break;
195  }
196 
197  $a_xml_writer->xmlEndTag("PageObject");
198  }
199 
200 
204  /* todo: this needs to be adopted
205  function _exportXMLAlias(&$a_xml_writer, $a_id, $a_inst = 0)
206  {
207  $attrs = array();
208  $a_xml_writer->xmlStartTag("PageObject", $attrs);
209 
210  $attrs = array();
211  $attrs["OriginId"] = "il_".$a_inst.
212  "_pg_".$a_id;
213  $a_xml_writer->xmlElement("PageAlias", $attrs);
214 
215  $a_xml_writer->xmlEndTag("PageObject");
216  }
217  */
218 
225  function exportXMLMetaData(&$a_xml_writer)
226  {
227  include_once("Services/MetaData/classes/class.ilMD2XML.php");
228  $md2xml = new ilMD2XML($this->getParentId(), $this->getId(), gettype($this));
229  $md2xml->setExportMode(true);
230  $md2xml->startExport();
231  $a_xml_writer->appendXML($md2xml->getXML());
232  }
233 
234 
235  /* todo: this needs to be adopted
236  function modifyExportIdentifier($a_tag, $a_param, $a_value)
237  {
238  if ($a_tag == "Identifier" && $a_param == "Entry")
239  {
240  $a_value = "il_".IL_INST_ID."_pg_".$this->getId();
241  //$a_value = ilUtil::insertInstIntoID($a_value);
242  }
243 
244  return $a_value;
245  }
246  */
247 
255  function exportXMLPageContent(&$a_xml_writer, $a_inst = 0)
256  {
257  $this->buildDom();
258  $this->insertInstIntoIDs($a_inst);
259  $cont_obj = $this->getContentObject("pg");
260  $this->mobs_contained = $this->collectMediaObjects(false);
261  include_once("./Services/COPage/classes/class.ilPCFileList.php");
262  $this->files_contained = ilPCFileList::collectFileItems($this, $this->getDomDoc());
263  $xml = $this->getXMLFromDom(false, false, false, "", true);
264  $xml = str_replace("&","&amp;", $xml);
265  $a_xml_writer->appendXML($xml);
266 
267  $this->freeDom();
268  }
269 
270 
276  function getMediaObjectIds()
277  {
278  return $this->mobs_contained;
279  }
280 
286  function getFileItemIds()
287  {
288  return $this->files_contained;
289  }
290 
295  {
296  // disabled this due to #0011195
297  // this does not really work well. Besides creating duplicates, it does not ensure that all
298  // glossary terms are in the assigned glossary. Copying whole pages does not trigger
299  // this procedure. Moreover if no glossary is attached copying pages will still create links
300  // in the target SCORM LM. The SCORM Export seesm to work well, even if terms are in other glossaries
301 
302  return;
303 
304  if ($this->getGlossaryId() > 0)
305  {
306  // we fix glossary links here
307  $this->buildDom();
308  $xpc = xpath_new_context($this->dom);
309  $path = "//IntLink[@Type='GlossaryItem']";
310  $res = xpath_eval($xpc, $path);
311  for ($i=0; $i < count($res->nodeset); $i++)
312  {
313  $target = $res->nodeset[$i]->get_attribute("Target");
314 //echo "<br>".$target;
315  $tarr = explode("_", $target);
316  $term_id = $tarr[count($tarr) - 1];
317  if (is_int(strpos($target, "__")) && $term_id > 0)
318  {
319  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
320 //echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-";
321  if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId())
322  {
323  // copy the glossary term from glossary a to b
324  $new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId());
325  $res->nodeset[$i]->set_attribute("Target", "il__git_".$new_id);
326  }
327  }
328  }
329  }
330 //exit;
331  }
332 
340  {
341  $this->buildDom();
342 
343  // find all Keyw tags
344  $xpath = new DOMXPath($this->getDomDoc());
345  $nodes = $xpath->query('//Paragraph//IntLink');
346  $to_del = array();
347  foreach($nodes as $node)
348  {
349  if (in_array($node->getAttribute("Type"), array("File", "GlossaryItem")))
350  {
351  continue;
352  }
353  $to_del[] = $node;
354  $parent = $node->parentNode;
355  $childs = array();
356  foreach ($node->childNodes as $c)
357  {
358  $childs[] = $c;
359  }
360  foreach ($childs as $c)
361  {
362  $node->removeChild($c);
363  $parent->insertBefore($c, $node);
364  }
365  }
366  foreach ($to_del as $n)
367  {
368  $p = $n->parentNode;
369  $p->removeChild($n);
370  }
371  $this->update();
372  }
373 
374 }
375 ?>
exportXMLMetaData(&$a_xml_writer)
export page alias to xml
buildDom($a_force=false)
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
afterConstructor()
After constructor.
read()
Read wiki data.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
exportXMLPageContent(&$a_xml_writer, $a_inst=0)
export page objects meta data to xml (see ilias_co.dtd)
getScormLmId()
Get Scorm LM ID.
setGlossaryId($a_val)
Set glossary id.
getDomDoc()
Get dom doc (php5 dom document)
Class ilPageLayout.
getMediaObjectIds()
get ids of all media objects within the page
update($a_validate=true, $a_no_history=false)
update object data
createWithLayoutId($a_layout_id)
Create new scorm 2004 with page-layout.
getContentObject($a_hier_id, $a_pc_id="")
Get a content object of the page.
create()
Create new scorm 2004.
getXMLFromDom($a_incl_head=false, $a_append_mobs=false, $a_append_bib=false, $a_append_str="", $a_omit_pageobject_tag=false)
get xml content of page from dom (use this, if any changes are made to the document) ...
performAutomaticModifications()
Perform automatic modifications (may be overwritten by sub classes)
collectMediaObjects($a_inline_only=true)
get all media objects, that are referenced and used within the page
Class ilSCORM2004Page.
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
Class ilPageObject.
getParentType()
Get parent type.
exportXML(&$a_xml_writer, $a_mode="normal", $a_inst=0)
export page object to xml (see ilias_co.dtd)
$n
Definition: RandomTest.php:80
getFileItemIds()
get ids of all file items within the page
Create styles array
The data for the language used.
insertInstIntoIDs($a_inst, $a_res_ref_to_obj_id=true)
inserts installation id into ids (e.g.
static _lookGlossaryID($term_id)
get glossary id form term id
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
getGlossaryId()
Get glossary id.
getPageConfig()
Get page config object.
global $ilBench
Definition: ilias.php:18
global $ilDB
removeInvalidLinks()
Remove invalid links.
setScormLmId($a_scormlmid)
Set Scorm LM ID.