ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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/Style/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  if ($this->getGlossaryId() > 0)
297  {
298  // we fix glossary links here
299  $this->buildDom();
300  $xpc = xpath_new_context($this->dom);
301  $path = "//IntLink[@Type='GlossaryItem']";
302  $res =& xpath_eval($xpc, $path);
303  for ($i=0; $i < count($res->nodeset); $i++)
304  {
305  $target = $res->nodeset[$i]->get_attribute("Target");
306 //echo "<br>".$target;
307  $tarr = explode("_", $target);
308  $term_id = $tarr[count($tarr) - 1];
309  if (is_int(strpos($target, "__")) && $term_id > 0)
310  {
311  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
312 //echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-";
313  if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId())
314  {
315  // copy the glossary term from glossary a to b
316  $new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId());
317  $res->nodeset[$i]->set_attribute("Target", "il__git_".$new_id);
318  }
319  }
320  }
321  }
322 //exit;
323  }
324 
325 }
326 ?>
exportXMLMetaData(&$a_xml_writer)
export page alias to xml
buildDom($a_force=false)
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
_copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
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)
getFileItemIds()
get ids of all file items within the page
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
getGlossaryId()
Get glossary id.
getPageConfig()
Get page config object.
$path
Definition: index.php:22
global $ilBench
Definition: ilias.php:18
global $ilDB
setScormLmId($a_scormlmid)
Set Scorm LM ID.