ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
23  function __construct($a_id = 0, $a_old_nr = 0)
24  {
25  parent::__construct("sahs", $a_id, $a_old_nr);
26  $this->mobs_contained = array();
27  $this->files_contained = array();
28  }
29 
35  function setScormLmId($a_scormlmid)
36  {
37  $this->scormlmid = $a_scormlmid;
38  }
39 
45  function getScormLmId()
46  {
47  return $this->scormlmid;
48  }
49 
55  function setGlossaryId($a_val)
56  {
57  $this->glossary_id = $a_val;
58  }
59 
65  function getGlossaryId()
66  {
67  return $this->glossary_id;
68  }
69 
73  function create()
74  {
75  global $ilDB;
76 
77  // maybe we need an additional table here?
78 
79  // create page object
81  }
82 
83 
87  function createWithLayoutId($a_layout_id)
88  {
89 
90  include_once("./Services/Style/classes/class.ilPageLayout.php");
91 
92  //get XML Data for Layout
93  $layout_obj = new ilPageLayout($a_layout_id);
94 
95  parent::setXMLContent($layout_obj->getXMLContent());
96  // create page object
98  }
99 
106  function update($a_validate = true, $a_no_history = false)
107  {
108  global $ilDB;
109 
110  // maybe we need an additional table here?
111 
112  parent::update($a_validate, $a_no_history);
113 
114  return true;
115  }
116 
120  function read()
121  {
122  global $ilDB;
123 
124  // maybe we need an additional table here?
125 
126  // get co page
127  parent::read();
128  }
129 
130 
136  function delete()
137  {
138  global $ilDB;
139 
140  // maybe we need an additional table here?
141 
142  // delete co page
143  parent::delete();
144 
145  return true;
146  }
147 
148 
149 
156  function exportXML(&$a_xml_writer, $a_mode = "normal", $a_inst = 0)
157  {
158  global $ilBench;
159 
160  $attrs = array();
161  $a_xml_writer->xmlStartTag("PageObject", $attrs);
162 
163  switch ($a_mode)
164  {
165  case "normal":
166  // MetaData
167  $ilBench->start("ContentObjectExport", "exportPageObject_XML_Meta");
168  $this->exportXMLMetaData($a_xml_writer);
169  $ilBench->stop("ContentObjectExport", "exportPageObject_XML_Meta");
170 
171  // PageContent
172  $ilBench->start("ContentObjectExport", "exportPageObject_XML_PageContent");
173  $this->exportXMLPageContent($a_xml_writer, $a_inst);
174  $ilBench->stop("ContentObjectExport", "exportPageObject_XML_PageContent");
175  break;
176 
177  case "alias":
178  $attrs = array();
179  $attrs["OriginId"] = "il_".$a_inst.
180  "_pg_".$this->getId();
181  $a_xml_writer->xmlElement("PageAlias", $attrs);
182  break;
183  }
184 
185  $a_xml_writer->xmlEndTag("PageObject");
186  }
187 
188 
192  /* todo: this needs to be adopted
193  function _exportXMLAlias(&$a_xml_writer, $a_id, $a_inst = 0)
194  {
195  $attrs = array();
196  $a_xml_writer->xmlStartTag("PageObject", $attrs);
197 
198  $attrs = array();
199  $attrs["OriginId"] = "il_".$a_inst.
200  "_pg_".$a_id;
201  $a_xml_writer->xmlElement("PageAlias", $attrs);
202 
203  $a_xml_writer->xmlEndTag("PageObject");
204  }
205  */
206 
213  function exportXMLMetaData(&$a_xml_writer)
214  {
215  include_once("Services/MetaData/classes/class.ilMD2XML.php");
216  $md2xml = new ilMD2XML($this->getParentId(), $this->getId(), gettype($this));
217  $md2xml->setExportMode(true);
218  $md2xml->startExport();
219  $a_xml_writer->appendXML($md2xml->getXML());
220  }
221 
222 
223  /* todo: this needs to be adopted
224  function modifyExportIdentifier($a_tag, $a_param, $a_value)
225  {
226  if ($a_tag == "Identifier" && $a_param == "Entry")
227  {
228  $a_value = "il_".IL_INST_ID."_pg_".$this->getId();
229  //$a_value = ilUtil::insertInstIntoID($a_value);
230  }
231 
232  return $a_value;
233  }
234  */
235 
243  function exportXMLPageContent(&$a_xml_writer, $a_inst = 0)
244  {
245  $this->buildDom();
246  $this->insertInstIntoIDs($a_inst);
247  $cont_obj =& $this->getContentObject("pg");
248  $this->mobs_contained = $this->collectMediaObjects(false);
249  $this->files_contained = $this->collectFileItems();
250  $xml = $this->getXMLFromDom(false, false, false, "", true);
251  $xml = str_replace("&","&amp;", $xml);
252  $a_xml_writer->appendXML($xml);
253 
254  $this->freeDom();
255  }
256 
257 
263  function getMediaObjectIds()
264  {
265  return $this->mobs_contained;
266  }
267 
273  function getFileItemIds()
274  {
275  return $this->files_contained;
276  }
277 
282  {
283  if ($this->getGlossaryId() > 0)
284  {
285  // we fix glossary links here
286  $this->buildDom();
287  $xpc = xpath_new_context($this->dom);
288  $path = "//IntLink[@Type='GlossaryItem']";
289  $res =& xpath_eval($xpc, $path);
290  for ($i=0; $i < count($res->nodeset); $i++)
291  {
292  $target = $res->nodeset[$i]->get_attribute("Target");
293 //echo "<br>".$target;
294  $tarr = explode("_", $target);
295  $term_id = $tarr[count($tarr) - 1];
296  if (is_int(strpos($target, "__")) && $term_id > 0)
297  {
298  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
299 //echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-";
300  if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId())
301  {
302  // copy the glossary term from glossary a to b
303  $new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId());
304  $res->nodeset[$i]->set_attribute("Target", "il__git_".$new_id);
305  }
306  }
307  }
308  }
309 //exit;
310  }
311 
312 }
313 ?>