ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContObjParser.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 require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
5 require_once("./Services/COPage/classes/class.ilPageObject.php");
6 require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
7 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
8 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
9 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
10 require_once("./Services/COPage/classes/class.ilPCTable.php");
11 require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
12 require_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
13 require_once("./Services/MediaObjects/classes/class.ilMapArea.php");
14 require_once("./Modules/LearningModule/classes/class.ilBibItem.php");
15 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
16 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
17 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
18 require_once("./Services/COPage/classes/class.ilInternalLink.php");
19 require_once("./Modules/File/classes/class.ilObjFile.php");
20 
21 include_once("Services/MetaData/classes/class.ilMDSaxParser.php");
22 include_once("Services/MetaData/classes/class.ilMD.php");
23 
33 {
34  var $lng;
35  var $tree;
36  var $cnt; // counts open elements
37  var $current_element; // store current element type
38  var $learning_module; // current learning module
39  var $page_object; // current page object
41  var $structure_objects; // array of current structure objects
43  var $current_object; // at the time a LearningModule, PageObject or StructureObject
44  var $meta_data; // current meta data object
46  var $table;
47  var $lm_tree;
51  var $in_page_object; // are we currently within a PageObject? true/false
52  var $in_meta_data; // are we currently within MetaData? true/false
64  var $subdir;
65  var $media_item; // current media item
66  var $loc_type; // current location type
67  var $bib_item; // current bib item object
68  var $map_area; // current map area
69  var $in_bib_item; // are we currently within BibItem? true/false
70  var $link_targets; // stores all objects by import id
73  var $in_meta_meta_data = false;
74  protected $glossary_term_map = array();
75 
85  function ilContObjParser(&$a_content_object, $a_xml_file, $a_subdir)
86  {
87  global $lng, $tree;
88 
89  parent::ilMDSaxParser($a_xml_file);
90  $this->cnt = array();
91  $this->current_element = array();
92  $this->structure_objects = array();
93  $this->content_object = $a_content_object;
94  //$this->lm_id = $a_lm_id;
95  $this->st_into_tree = array();
96  $this->pg_into_tree = array();
97  $this->pages_to_parse = array();
98  $this->mobs_with_int_links = array();
99  $this->mob_mapping = array();
100  $this->file_item_mapping = array();
101  $this->pg_mapping = array();
102  $this->link_targets = array();
103  $this->subdir = $a_subdir;
104  $this->lng = $lng;
105  $this->tree = $tree;
106  $this->inside_code = false;
107  $this->qst_mapping = array();
108  $this->coType = $this->content_object->getType();
109  $this->metadata_parsing_disabled = false;
110 
111  if (($this->coType != "tst") and ($this->coType != "qpl"))
112  {
113  $this->lm_tree = new ilTree($this->content_object->getId());
114  $this->lm_tree->setTreeTablePK("lm_id");
115  $this->lm_tree->setTableNames('lm_tree','lm_data');
116  }
117  //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI
118 
119  }
120 
127  function setHandlers($a_xml_parser)
128  {
129  xml_set_object($a_xml_parser,$this);
130  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
131  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
132  }
133 
134 
138  function startParsing()
139  {
140 //echo "<b>start parsing</b><br>";
142 //echo "<b>storeTree</b><br>";
143  $this->storeTree();
144 //echo "<b>processPagesToParse</b><br>";
145  $this->processPagesToParse();
146 //echo "<b>copyMobFiles</b><br>";
147  $this->copyMobFiles();
148 //echo "<b>copyFileItems</b><br>";
149  $this->copyFileItems();
150 //echo "<br>END Parsing"; exit;
151  }
152 
153 
157  function storeTree()
158  {
159  global $ilLog;
160 
161 //echo "<b>Storing the tree</b><br>";
162  foreach($this->st_into_tree as $st)
163  {
164 //echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>";
165  $this->lm_tree->insertNode($st["id"], $st["parent"]);
166 //echo "done<br>";
167 //var_dump($this->pg_into_tree[$st["id"]]);
168 //echo "<br>";
169  if (is_array($this->pg_into_tree[$st["id"]]))
170  {
171  foreach($this->pg_into_tree[$st["id"]] as $pg)
172  {
173  switch ($pg["type"])
174  {
175  case "pg_alias":
176  if ($this->pg_mapping[$pg["id"]] == "")
177  {
178  $ilLog->write("LM Import: No PageObject for PageAlias ".
179  $pg["id"]." found! (Please update export installation to ILIAS 3.3.0)");
180 
181  // Jump two levels up. First level is switch
182  continue 2;
183  }
184  $pg_id = $this->pg_mapping[$pg["id"]];
185  break;
186 
187  case "pg":
188  $pg_id = $pg["id"];
189  break;
190  }
191  if (!$this->lm_tree->isInTree($pg_id))
192  {
193  $this->lm_tree->insertNode($pg_id, $st["id"]);
194  }
195  }
196  }
197  }
198 //echo "<b>END: storing the tree</b>";
199 //exit;
200  }
201 
202 
207  {
208  /*
209  $pg_mapping = array();
210  foreach($this->pg_mapping as $key => $value)
211  {
212  $pg_mapping[$key] = "il__pg_".$value;
213  }*/
214 //echo "<br><b>processIntLinks</b>"; flush();
215 
216  // outgoin internal links
217  foreach($this->pages_to_parse as $page_id)
218  {
219  $page_arr = explode(":", $page_id);
220 //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
221  switch($page_arr[0])
222  {
223  case "lm":
224  switch ($this->content_object->getType())
225  {
226  case "lm":
227  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
228  $page_obj = new ilLMPage($page_arr[1]);
229  break;
230 
231  default:
232  die("Unknown content type ".$this->content_object->getType());
233  }
234 
235  break;
236 
237  case "gdf":
238  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
239  $page_obj = new ilGlossaryDefPage($page_arr[1]);
240  break;
241 
242  case "qpl":
243  $page_obj = new ilAssQuestionPage($page_arr[1]);
244  break;
245  }
246  $page_obj->buildDom();
247  $page_obj->resolveIntLinks();
248  $page_obj->resolveIIMMediaAliases($this->mob_mapping);
249  if (in_array($this->coType, array("lm", "dbk")))
250  {
251  $page_obj->resolveQuestionReferences($this->qst_mapping);
252  }
253  $page_obj->update(false);
254 
255  if ($page_arr[0] == "gdf")
256  {
257  $def = new ilGlossaryDefinition($page_arr[1]);
258  $def->updateShortText();
259  }
260 
261  unset($page_obj);
262  }
263 
264 //echo "<br><b>map area internal links</b>"; flush();
265  // outgoins map area (mob) internal links
266  foreach($this->mobs_with_int_links as $mob_id)
267  {
269  }
270 
271 //echo "<br><b>incoming interna links</b>"; flush();
272  // incoming internal links
273  $done = array();
274  foreach ($this->link_targets as $link_target)
275  {
276 //echo "doin link target:".$link_target.":<br>";
277  $link_arr = explode("_", $link_target);
278  $target_inst = $link_arr[1];
279  $target_type = $link_arr[2];
280  $target_id = $link_arr[3];
281 //echo "<br>-".$target_type."-".$target_id."-".$target_inst."-";
283  foreach($sources as $key => $source)
284  {
285 //echo "got source:".$key.":<br>";
286  if(in_array($key, $done))
287  {
288  continue;
289  }
290  $type_arr = explode(":", $source["type"]);
291 
292  // content object pages
293  if ($type_arr[1] == "pg")
294  {
295  if (ilPageObject::_exists($type_arr[0],$source["id"]))
296  {
297  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
298  $page_object = ilPageObjectFactory::getInstance($type_arr[0], $source["id"]);
299  $page_object->buildDom();
300  $page_object->resolveIntLinks();
301  $page_object->update();
302  unset($page_object);
303  }
304  }
305 
306  // eventually correct links in questions to learning modules
307  if ($type_arr[0] == "qst")
308  {
309  require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
310  assQuestion::_resolveIntLinks($source["id"]);
311  }
312  // eventually correct links in survey questions to learning modules
313  if ($type_arr[0] == "sqst")
314  {
315  require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
316  SurveyQuestion::_resolveIntLinks($source["id"]);
317  }
318  $done[$key] = $key;
319  }
320  }
321  }
322 
323 
327  function copyMobFiles()
328  {
329  $imp_dir = $this->content_object->getImportDirectory();
330 
331  foreach ($this->mob_mapping as $origin_id => $mob_id)
332  {
333  if(empty($origin_id))
334  {
335  continue;
336  }
337 
338  /*
339  $origin_arr = explode("_", $origin_id);
340  if ($origin_arr[2] == "el") // imagemap
341  {
342  $obj_dir = "imagemap".$origin_arr[3];
343  }
344  else // normal media object
345  {
346  $obj_dir = "mm".$origin_arr[3];
347  }*/
348 
349  $obj_dir = $origin_id;
350  $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
351  $target_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$mob_id;
352 
353 //echo "copy from $source_dir to $target_dir <br>";
354  if (@is_dir($source_dir))
355  {
356  // make target directory
357  ilUtil::makeDir($target_dir);
358  //@mkdir($target_dir);
359  //@chmod($target_dir, 0755);
360 
361  if (@is_dir($target_dir))
362  {
363  ilUtil::rCopy($source_dir, $target_dir);
364  }
365  }
366  }
367  }
368 
372  function copyFileItems()
373  {
374  $imp_dir = $this->content_object->getImportDirectory();
375  foreach ($this->file_item_mapping as $origin_id => $file_id)
376  {
377  if(empty($origin_id))
378  {
379  continue;
380  }
381  $obj_dir = $origin_id;
382  $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
383 
384  include_once("./Modules/File/classes/class.ilObjFile.php");
385  $file_obj = new ilObjFile($file_id, false);
386  //$target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
387  $target_dir = $file_obj->getDirectory();
388  if (@is_dir($source_dir))
389  {
390  // make target directory
391  ilUtil::makeDir($target_dir);
392  //@mkdir($target_dir);
393  //@chmod($target_dir, 0755);
394 
395  if (@is_dir($target_dir))
396  {
397  ilUtil::rCopy($source_dir, $target_dir);
398  }
399  }
400  $test = $file_obj->determineFilesize();
401  $file_obj->update();
402  }
403  }
404 
408  function setQuestionMapping($a_map)
409  {
410  $this->qst_mapping = $a_map;
411  }
412 
413 
414  /*
415  * update parsing status for a element begin
416  */
417  function beginElement($a_name)
418  {
419  if(!isset($this->status["$a_name"]))
420  {
421  $this->cnt[$a_name] == 1;
422  }
423  else
424  {
425  $this->cnt[$a_name]++;
426  }
427  $this->current_element[count($this->current_element)] = $a_name;
428  }
429 
430  /*
431  * update parsing status for an element ending
432  *
433  * @param string $a_name element name
434  */
435  function endElement($a_name)
436  {
437  $this->cnt[$a_name]--;
438  unset ($this->current_element[count($this->current_element) - 1]);
439  }
440 
441  /*
442  * returns current element
443  */
444  function getCurrentElement()
445  {
446  return ($this->current_element[count($this->current_element) - 1]);
447  }
448 
449  /*
450  * returns number of current open elements of type $a_name
451  *
452  * @param string $a_name element name
453  */
454  function getOpenCount($a_name)
455  {
456  if (isset($this->cnt[$a_name]))
457  {
458  return $this->cnt[$a_name];
459  }
460  else
461  {
462  return 0;
463  }
464 
465  }
466 
474  function buildTag ($type, $name, $attr="")
475  {
476  $tag = "<";
477 
478  if ($type == "end")
479  $tag.= "/";
480 
481  $tag.= $name;
482 
483  if (is_array($attr))
484  {
485  while (list($k,$v) = each($attr))
486  $tag.= " ".$k."=\"$v\"";
487  }
488 
489  $tag.= ">";
490 
491  return $tag;
492  }
493 
501  function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
502  {
503 //echo "<b>BEGIN TAG: $a_name <br></b>"; flush();
504  switch($a_name)
505  {
506  case "ContentObject":
507  $this->current_object = $this->content_object;
508 //echo "<br>Parser:CObjType:".$a_attribs["Type"];
509  if ($a_attribs["Type"] == "Glossary")
510  {
511  $this->glossary_object = $this->content_object;
512  }
513  break;
514 
515  case "StructureObject":
516 //echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>";
517  $this->structure_objects[count($this->structure_objects)]
518  = new ilStructureObject($this->content_object);
519  $this->current_object = $this->structure_objects[count($this->structure_objects) - 1];
520  $this->current_object->setLMId($this->content_object->getId());
521  // new meta data handling: we create the structure
522  // object already here, this should also create a
523  // md entry
524  $this->current_object->create(true);
525  break;
526 
527  case "PageObject":
528  $this->in_page_object = true;
529  $this->cur_qid = "";
530  if (($this->coType != "tst") and ($this->coType != "qpl"))
531  {
532  $this->lm_page_object = new ilLMPageObject($this->content_object);
533  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
534  $this->page_object = new ilLMPage();
535  $this->lm_page_object->setLMId($this->content_object->getId());
536  $this->lm_page_object->assignPageObject($this->page_object);
537  $this->current_object = $this->lm_page_object;
538  }
539  else
540  {
541  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
542  $this->page_object = new ilAssQuestionPage();
543  }
544  break;
545 
546  case "PageAlias":
547  if (($this->coType != "tst") and ($this->coType != "qpl"))
548  {
549  $this->lm_page_object->setAlias(true);
550  $this->lm_page_object->setOriginID($a_attribs["OriginId"]);
551  }
552  break;
553 
554  case "MediaObject":
555  $this->in_media_object = true;
556 case "InteractiveImage":
557 
558  $this->media_meta_start = true;
559  $this->media_meta_cache = array();
560  $this->media_object = new ilObjMediaObject();
561  break;
562 
563  case "MediaAlias":
564 //echo "<br>---NEW MEDIAALIAS---<br>";
565  $this->media_object->setAlias(true);
566  $this->media_object->setImportId($a_attribs["OriginId"]);
567  if (is_object($this->page_object))
568  {
569  $this->page_object->needsImportParsing(true);
570  }
571  break;
572 
573  case "MediaItem":
574  case "MediaAliasItem":
575  $this->in_media_item = true;
576  $this->media_item = new ilMediaItem();
577  $this->media_item->setPurpose($a_attribs["Purpose"]);
578  /*if ($a_name == "MediaItem")
579  {
580  $this->media_item->setHighlightMode($a_attribs["MapHighlightMode"]);
581  $this->media_item->setHighlightClass($a_attribs["MapHighlightClass"]);
582  }*/
583  break;
584 
585  case "Layout":
586  if (is_object($this->media_object) && $this->in_media_object)
587  {
588  $this->media_item->setWidth($a_attribs["Width"]);
589  $this->media_item->setHeight($a_attribs["Height"]);
590  $this->media_item->setHAlign($a_attribs["HorizontalAlign"]);
591  }
592  break;
593 
594  case "Parameter":
595  if (is_object($this->media_object) && $this->in_media_object)
596  {
597  $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]);
598  }
599  break;
600 
601  case "MapArea":
602  $this->in_map_area = true;
603  $this->map_area = new ilMapArea();
604  $this->map_area->setShape($a_attribs["Shape"]);
605  $this->map_area->setCoords($a_attribs["Coords"]);
606  $this->map_area->setHighlightMode($a_attribs["HighlightMode"]);
607  $this->map_area->setHighlightClass($a_attribs["HighlightClass"]);
608  break;
609 
610  case "Glossary":
611  $this->in_glossary = true;
612  if ($this->content_object->getType() != "glo")
613  {
614  $this->glossary_object = new ilObjGlossary();
615  $this->glossary_object->setTitle("");
616  $this->glossary_object->setDescription("");
617  $this->glossary_object->create(true);
618  $this->glossary_object->createReference();
619  $parent = $this->tree->getParentNodeData($this->content_object->getRefId());
620  $this->glossary_object->putInTree($parent["child"]);
621  $this->glossary_object->setPermissions($parent["child"]);
622  $this->glossary_object->notify("new", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$this->glossary_object->getRefId());
623  }
624  $this->current_object = $this->glossary_object;
625  break;
626 
627  case "GlossaryItem":
628  $this->glossary_term = new ilGlossaryTerm();
629  $this->glossary_term->setGlossaryId($this->glossary_object->getId());
630  $this->glossary_term->setLanguage($a_attribs["Language"]);
631  $this->glossary_term->setImportId($a_attribs["Id"]);
632  $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"];
633  break;
634 
635  case "Definition":
636  $this->in_glossary_definition = true;
637  $this->glossary_definition = new ilGlossaryDefinition();
638  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
639  $this->page_object = new ilGlossaryDefPage();
640  $this->page_object->setParentId($this->glossary_term->getGlossaryId());
641  $this->glossary_definition->setTermId($this->glossary_term->getId());
642  $this->glossary_definition->assignPageObject($this->page_object);
643  $this->current_object = $this->glossary_definition;
644  $this->glossary_definition->create(true);
645  // see bug #12465, we need to clear xml after creation, since it will be <PageObject></PageObject>
646  // otherwise, and appendXML calls will lead to "<PageObject></PageObject><PageObject>....</PageObject>"
647  $this->page_object->setXMLContent("");
648  break;
649 
650  case "FileItem":
651  $this->in_file_item = true;
652  $this->file_item = new ilObjFile();
653  $this->file_item->setTitle("dummy");
654  $this->file_item->setMode("filelist");
655  if (is_object($this->page_object))
656  {
657  $this->page_object->needsImportParsing(true);
658  }
659  break;
660 
661  case "Paragraph":
662  if ($a_attribs["Characteristic"] == "Code")
663  {
664  $this->inside_code = true;
665  }
666  break;
667 
668  case "Properties":
669  $this->in_properties = true;
670  break;
671 
672  case "Property":
673  if ($this->content_object->getType() == "lm"
674  || $this->content_object->getType() == "dbk")
675  {
676  switch($a_attribs["Name"])
677  {
678  case "Layout":
679  $this->content_object->setLayout($a_attribs["Value"]);
680  break;
681 
682  case "PageHeader":
683  $this->content_object->setPageHeader($a_attribs["Value"]);
684  break;
685 
686  case "TOCMode":
687  $this->content_object->setTOCMode($a_attribs["Value"]);
688  break;
689 
690  case "ActiveLMMenu":
691  $this->content_object->setActiveLMMenu(
692  ilUtil::yn2tf($a_attribs["Value"]));
693  break;
694 
695  case "ActiveNumbering":
696  $this->content_object->setActiveNumbering(
697  ilUtil::yn2tf($a_attribs["Value"]));
698  break;
699 
700  case "ActiveTOC":
701  $this->content_object->setActiveTOC(
702  ilUtil::yn2tf($a_attribs["Value"]));
703  break;
704 
705  case "ActivePrintView":
706  $this->content_object->setActivePrintView(
707  ilUtil::yn2tf($a_attribs["Value"]));
708  break;
709 
710  case "CleanFrames":
711  $this->content_object->setCleanFrames(
712  ilUtil::yn2tf($a_attribs["Value"]));
713  break;
714 
715  case "PublicNotes":
716  $this->content_object->setPublicNotes(
717  ilUtil::yn2tf($a_attribs["Value"]));
718  break;
719 
720  case "HistoryUserComments":
721  $this->content_object->setHistoryUserComments(
722  ilUtil::yn2tf($a_attribs["Value"]));
723  break;
724 
725  case "Rating":
726  $this->content_object->setRating(
727  ilUtil::yn2tf($a_attribs["Value"]));
728  break;
729 
730  case "RatingPages":
731  $this->content_object->setRatingPages(
732  ilUtil::yn2tf($a_attribs["Value"]));
733  break;
734 
735  case "HeaderPage":
736  if ($a_attribs["Value"] != "")
737  {
738  if ($this->pg_mapping[$a_attribs["Value"]] > 0)
739  {
740  $this->content_object->setHeaderPage(
741  $this->pg_mapping[$a_attribs["Value"]]);
742  }
743  }
744  break;
745 
746  case "FooterPage":
747  if ($a_attribs["Value"] != "")
748  {
749  if ($this->pg_mapping[$a_attribs["Value"]] > 0)
750  {
751  $this->content_object->setFooterPage(
752  $this->pg_mapping[$a_attribs["Value"]]);
753  }
754  }
755  break;
756  }
757  //echo "<br>+".$a_attribs["Name"]."+";
758  }
759  break;
760 
764  case "MetaData":
765  $this->in_meta_data = true;
766 //echo "<br>begin meta data section -".$this->current_object->getType()."-";
767  // media obejct meta data handling
768  // is done in the "Identifier" begin tag processing
769  // the rest is done here
770  if(!$this->in_media_object)
771  {
772  if (($this->coType != "tst") and ($this->coType != "qpl"))
773  {
774  // type pg/st
775  if ($this->current_object->getType() == "st" ||
776  $this->current_object->getType() == "pg")
777  {
778  // late creation of page object
779  if ($this->current_object->getType() == "pg")
780  {
781  $this->lm_page_object->create(true);
782  }
783  $this->md = new ilMD($this->content_object->getId() ,
784  $this->current_object->getId(),
785  $this->current_object->getType());
786  }
787  // type gdf
788  else if ($this->current_object->getType() == "gdf")
789  {
790  $this->md = new ilMD($this->glossary_object->getId() ,
791  $this->current_object->getId(),
792  $this->current_object->getType());
793  }
794  // type lm, dbk, glo
795  else
796  {
797  if ($this->processMeta())
798  {
799  $this->md = new ilMD($this->current_object->getId() ,
800  0,
801  $this->current_object->getType());
802  }
803  }
804  }
805  else
806  {
807  // type qpl or tst
808  $this->md = new ilMD($this->content_object->getId() ,
809  0,
810  $this->current_object->getType()
811  );
812  if ($this->md->getGeneral() != false)
813  {
814  $this->metadata_parsing_disabled = true;
815  $this->enableMDParsing(false);
816  }
817  }
818  }
819  break;
820 
821  // Identifier
822  case "Identifier":
823 
824  // please note: Meta-Metadata and MetaData are different tags!
825  if (!$this->in_meta_meta_data)
826  {
827  if ($this->in_meta_data && !$this->in_glossary_definition)
828  {
829  if (!$this->in_media_object)
830  {
831  $this->current_object->setImportId($a_attribs["Entry"]);
832  }
833  $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
834  }
835  if ($this->in_file_item)
836  {
837  if ($this->file_item_mapping[$a_attribs["Entry"]] == "")
838  {
839  $this->file_item->create();
840  $this->file_item->setImportId($a_attribs["Entry"]);
841  $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
842  }
843  }
844  if ($this->in_meta_data && $this->in_media_object)
845  {
846 //echo "looking for -".$a_attribs["Entry"]."-<br>";
847 
848  $mob_id = $this->mob_mapping[$a_attribs["Entry"]];
849 
850  // within learning module import, usually a media object
851  // has already been created with a media alias tag
852  if ($mob_id > 0)
853  {
854  $this->media_object = new ilObjMediaObject($mob_id);
855  }
856  else // in glossaries the media objects precede the definitions
857  // so we don't have an object already
858  {
859  $this->media_object = new ilObjMediaObject();
860  $this->media_object->create(true, false);
861  $this->mob_mapping[$a_attribs["Entry"]]
862  = $this->media_object->getId();
863  }
864  $this->media_object->setImportId($a_attribs["Entry"]);
865  $this->md = new ilMD(0 ,
866  $this->media_object->getId(),
867  "mob");
868  $this->emptyMediaMetaCache($a_xml_parser);
869  }
870  }
871  break;
872 
873  case "Meta-Metadata":
874  $this->in_meta_meta_data = true;
875  break;
876 
877  // Internal Link
878  case "IntLink":
879  if (is_object($this->page_object))
880  {
881  $this->page_object->setContainsIntLink(true);
882  }
883  if ($this->in_map_area)
884  {
885 //echo "intlink:maparea:<br>";
886  $this->map_area->setLinkType(IL_INT_LINK);
887  $this->map_area->setTarget($a_attribs["Target"]);
888  $this->map_area->setType($a_attribs["Type"]);
889  $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
890  if (is_object($this->media_object))
891  {
892 //echo ":setContainsLink:<br>";
893  $this->media_object->setContainsIntLink(true);
894  }
895  }
896  break;
897 
898  // External Link
899  case "ExtLink":
900  if ($this->in_map_area)
901  {
902  $this->map_area->setLinkType(IL_EXT_LINK);
903  $this->map_area->setHref($a_attribs["Href"]);
904  $this->map_area->setExtTitle($a_attribs["Title"]);
905  }
906  break;
907 
908  // Question
909  case "Question":
910  $this->cur_qid = $a_attribs["QRef"];
911  $this->page_object->setContainsQuestion(true);
912  break;
913 
914  case "Location":
915  $this->loc_type = $a_attribs["Type"];
916  break;
917 
918  case "Bibliography":
919  $this->in_bib_item = true;
920 //echo "<br>---NEW BIBLIOGRAPHY---<br>";
921  $this->bib_item = new ilBibItem();
922  break;
923 
924  }
925  $this->beginElement($a_name);
926 
927  // append content to page xml content
928  if(($this->in_page_object || $this->in_glossary_definition)
929  && !$this->in_meta_data && !$this->in_media_object)
930  {
931  if ($a_name == "Definition")
932  {
933  $app_name = "PageObject";
934  $app_attribs = array();
935  }
936  else
937  {
938  $app_name = $a_name;
939  $app_attribs = $a_attribs;
940  }
941 
942  // change identifier entry of file items to new local file id
943  if ($this->in_file_item && $app_name == "Identifier")
944  {
945  $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]];
946  //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
947  }
948 
949  $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
950 //echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
951  }
952 
953  // append content to bibitem xml content
954  if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
955  {
956  $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
957  }
958 
959  // call meta data handler
960  if ($this->in_meta_data && $this->processMeta())
961  {
962  // cache beginning of meta data within media object tags
963  // (we need to know the id at the begin of meta elements within
964  // media objects, after the "Identifier" tag has been processed
965  // we send the cached data to the meta xml handler)
966  if ($this->in_media_object && $this->media_meta_start)
967  {
968  $this->media_meta_cache[] =
969  array("type" => "handlerBeginTag", "par1" => $a_name, "par2" => $a_attribs);
970  }
971  else
972  {
973  if ($a_name == "Identifier")
974  {
975  if (!$this->in_media_object)
976  {
977  $a_attribs["Entry"] = "il__".$this->current_object->getType().
978  "_".$this->current_object->getId();
979  }
980  else
981  {
982  $a_attribs["Entry"] = "il__mob".
983  "_".$this->media_object->getId();
984  }
985  $a_attribs["Catalog"] = "ILIAS";
986  }
987 
988  parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
989  }
990  }
991  }
992 
996  function processMeta()
997  {
998  // do not process second meta block in (ilias3) glossaries
999  // which comes right after the "Glossary" tag
1000  if ($this->content_object->getType() == "glo" &&
1001  $this->in_glossary && !$this->in_media_object
1002  && !$this->in_glossary_definition)
1003  {
1004  return false;
1005  }
1006 
1007  return true;
1008  }
1009 
1010 
1017  function handlerEndTag($a_xml_parser,$a_name)
1018  {
1019  // call meta data handler
1020  if ($this->in_meta_data && $this->processMeta())
1021  {
1022  // cache beginning of meta data within media object tags
1023  // (we need to know the id, after that we send the cached data
1024  // to the meta xml handler)
1025  if ($this->in_media_object && $this->media_meta_start)
1026  {
1027  $this->media_meta_cache[] =
1028  array("type" => "handlerEndTag", "par1" => $a_name);
1029  }
1030  else
1031  {
1032  parent::handlerEndTag($a_xml_parser,$a_name);
1033  }
1034  }
1035 
1036 //echo "<b>END TAG: $a_name <br></b>"; flush();
1037  // append content to page xml content
1038  if (($this->in_page_object || $this->in_glossary_definition)
1039  && !$this->in_meta_data && !$this->in_media_object)
1040  {
1041  $app_name = ($a_name == "Definition")
1042  ? "PageObject"
1043  : $a_name;
1044  $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
1045  }
1046 
1047  // append content to bibitemxml content
1048  if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
1049  {
1050  if($a_name == "BibItem")
1051  {
1052  $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name));
1053  }
1054  else
1055  {
1056  $this->bib_item->appendXMLContent($this->buildTag("end", $a_name));
1057  }
1058 
1059  }
1060 
1061  switch($a_name)
1062  {
1063  case "StructureObject":
1064  //unset($this->meta_data);
1065  unset($this->structure_objects[count($this->structure_objects) - 1]);
1066  break;
1067 
1068  case "PageObject":
1069 
1070  $this->in_page_object = false;
1071  if (($this->coType != "tst") and ($this->coType != "qpl"))
1072  {
1073  if (!$this->lm_page_object->isAlias())
1074  {
1075  //$this->page_object->createFromXML();
1076  $this->page_object->updateFromXML();
1077  $this->pg_mapping[$this->lm_page_object->getImportId()]
1078  = $this->lm_page_object->getId();
1079 
1080  // collect pages with internal links
1081  if ($this->page_object->containsIntLink())
1082  {
1083  $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1084  }
1085 
1086  // collect pages with mobs or files
1087  if ($this->page_object->needsImportParsing())
1088  {
1089  $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1090  }
1091 
1092  // collect pages with questions
1093  if ($this->page_object->getContainsQuestion())
1094  {
1095  $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1096  }
1097 
1098  }
1099  }
1100  else
1101  {
1102  $xml = $this->page_object->getXMLContent();
1103  if ($this->cur_qid != "")
1104  {
1105  $ids = $this->qst_mapping[$this->cur_qid];
1106  if ($ids["pool"] > 0)
1107  {
1108  // question pool question
1109  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1110  $page = new ilAssQuestionPage($ids["pool"]);
1111  $xmlcontent = str_replace($this->cur_qid,
1112  "il__qst_".$ids["pool"], $xml);
1113  $page->setXMLContent($xmlcontent);
1114  $page->updateFromXML();
1115  if( $this->page_object->needsImportParsing() )
1116  {
1117  $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1118  }
1119  unset($page);
1120  }
1121  if ($ids["test"] > 0)
1122  {
1123  // test question
1124  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1125  $page = new ilAssQuestionPage($ids["test"]);
1126  $xmlcontent = str_replace($this->cur_qid,
1127  "il__qst_".$ids["test"], $xml);
1128  $page->setXMLContent($xmlcontent);
1129  $page->updateFromXML();
1130  if( $this->page_object->needsImportParsing() )
1131  {
1132  $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1133  }
1134  unset($page);
1135  }
1136  }
1137  }
1138 
1139  // if we are within a structure object: put page in tree
1140  $cnt = count($this->structure_objects);
1141 //echo "1";
1142  if ($cnt > 0)
1143  {
1144 //echo "B-$cnt-<br>";
1145 //echo "<br>"; var_dump($this->structure_objects); echo "<br>";
1146  $parent_id = $this->structure_objects[$cnt - 1]->getId();
1147  if ($this->lm_page_object->isAlias())
1148  {
1149 //echo "3";
1150  $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
1151 //echo "<br>"; var_dump($this->pg_into_tree); echo "<br>";
1152  }
1153  else
1154  {
1155 //echo "4";
1156  $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
1157  }
1158  }
1159 
1160  unset($this->page_object);
1161  unset($this->lm_page_object);
1162  unset ($this->container[count($this->container) - 1]);
1163  break;
1164 
1165  case "MediaObject":
1166  $this->in_media_object = false;
1167 case "InteractiveImage":
1168 
1169 //echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
1170  // create media object on first occurence of an Id
1171 
1172 
1173  if(empty($this->mob_mapping[$this->media_object->getImportId()]))
1174  {
1175 //echo "No mapping found --creating media object:title:".$this->media_object->getTitle().":<br>";
1176 
1177  // create media object
1178  // media items are saves for mobs outside of
1179  // pages only
1180  $this->media_object->create(true, false);
1181 
1182 //echo "<br>creating mob ".$this->media_object->getId().":".$this->media_object->getTitle().":";
1183 
1184  // collect mobs with internal links
1185  if ($this->media_object->containsIntLink())
1186  {
1187 //echo "got int link :".$this->media_object->getId().":<br>";
1188  $this->mobs_with_int_links[] = $this->media_object->getId();
1189  }
1190 
1191  $this->mob_mapping[$this->media_object->getImportId()]
1192  = $this->media_object->getId();
1193 //echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
1194  }
1195  else
1196  {
1197 //echo "Mapping found<br>";
1198  // get the id from mapping
1199  $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
1200 
1201  // update "real" (no alias) media object
1202  // (note: we overwrite any data from the media object
1203  // created by an MediaAlias, only the data of the real
1204  // object is stored in db separately; data of the
1205  // MediaAliases are within the page XML
1206  if (!$this->media_object->isAlias())
1207  {
1208  // now the media items are saved within the db
1209  $this->media_object->update();
1210 
1211 //echo "<br>update media object :".$this->media_object->getId().":";
1212 
1213  // collect mobs with internal links
1214  if ($this->media_object->containsIntLink())
1215  {
1216 //echo "got int link :".$this->media_object->getId().":<br>";
1217  $this->mobs_with_int_links[] = $this->media_object->getId();
1218  }
1219  }
1220  }
1221 
1222  // append media alias to page, if we are in a page
1223  if ($this->in_page_object || $this->in_glossary_definition)
1224  {
1225  if ($a_name != "InteractiveImage")
1226  {
1227  $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
1228 //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
1229  }
1230  }
1231 
1232  break;
1233 
1234  case "MediaItem":
1235  case "MediaAliasItem":
1236  $this->in_media_item = false;
1237  $this->media_object->addMediaItem($this->media_item);
1238 //echo "adding media item -".$this->media_item->getId()."-".$this->media_item->getLocation()."- to object -".$this->media_object->getId()."-";
1239  break;
1240 
1241  case "MapArea":
1242  $this->in_map_area = false;
1243  $this->media_item->addMapArea($this->map_area);
1244  break;
1245 
1246  case "Properties":
1247  $this->in_properties = false;
1248  if ($this->content_object->getType() == "lm"
1249  || $this->content_object->getType() == "dbk")
1250  {
1251  $this->content_object->update();
1252  }
1253  break;
1254 
1255  case "MetaData":
1256  $this->in_meta_data = false;
1257  if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object)
1258  {
1259  // Metadaten eines PageObjects sichern in NestedSet
1260  if (is_object($this->lm_page_object))
1261  {
1262  // update title/description of page object
1263  $this->current_object->MDUpdateListener('General');
1264  ilLMObject::_writeImportId($this->current_object->getId(),
1265  $this->current_object->getImportId());
1266  }
1267  }
1268  else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
1269  strtolower(get_class($this->current_object)) == "ilobjtest") &&
1271 // !$this->in_media_object && !$this->in_page_object)
1272 // changed for imports of ILIAS 2 Tests where PageObjects could have
1273 // Metadata sections (Helmut Schottmüller, 2005-12-02)
1274  {
1275  if ($this->metadata_parsing_disabled)
1276  {
1277  $this->enableMDParsing(true);
1278  }
1279  else
1280  {
1281  if ($this->in_page_object)
1282  {
1283  $this->page_object->MDUpdateListener('General');
1284  ilLMObject::_writeImportId($this->page_object->getId(),
1285  $this->page_object->getImportId());
1286  }
1287  else
1288  {
1289  $this->current_object->MDUpdateListener('General');
1290  ilLMObject::_writeImportId($this->current_object->getId(),
1291  $this->current_object->getImportId());
1292  }
1293  }
1294  }
1295  else if(strtolower(get_class($this->current_object)) == "ilstructureobject")
1296  { // save structure object at the end of its meta block
1297  // determine parent
1298  $cnt = count($this->structure_objects);
1299  if ($cnt > 1)
1300  {
1301  $parent_id = $this->structure_objects[$cnt - 2]->getId();
1302  }
1303  else
1304  {
1305  $parent_id = $this->lm_tree->getRootId();
1306  }
1307 
1308  // create structure object and put it in tree
1309  //$this->current_object->create(true); // now on top
1310  $this->st_into_tree[] = array ("id" => $this->current_object->getId(),
1311  "parent" => $parent_id);
1312 
1313  // update title/description of structure object
1314  $this->current_object->MDUpdateListener('General');
1315  ilLMObject::_writeImportId($this->current_object->getId(),
1316  $this->current_object->getImportId());
1317  }
1318  else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1319  strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
1320  (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary))
1321  {
1322  // todo: saving of md? getting title/descr and
1323  // set it for current object
1324  }
1325  else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object)
1326  {
1327  // now on top
1328  //$this->glossary_definition->create();
1329 
1330  $this->page_object->setId($this->glossary_definition->getId());
1331  $this->page_object->updateFromXML();
1332 
1333  // todo: saving of md? getting title/descr and
1334  // set it for current object
1335  }
1336 
1337 
1338  if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1339  strtolower(get_class($this->current_object)) == "ilobjdlbook" ||
1340  strtolower(get_class($this->current_object)) == "ilobjglossary")
1341  {
1342  if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
1343  $this->content_object->getType() != "glo")
1344  {
1345 //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
1346  $this->current_object->setTitle($this->content_object->getTitle()." - ".
1347  $this->lng->txt("glossary"));
1348  }
1349 
1350  $this->current_object->MDUpdateListener('General');
1351  /*
1352  if (!$this->in_media_object && $this->processMeta())
1353  {
1354  $this->current_object->update();
1355  }
1356  */
1357  }
1358 
1359  if ($this->in_media_object)
1360  {
1361 //echo "<br>call media object update listener";
1362  $this->media_object->MDUpdateListener('General');
1363  }
1364 
1365  if ($this->in_glossary_definition)
1366  {
1367  $this->glossary_definition->MDUpdateListener('General');
1368  }
1369 
1370  break;
1371 
1372  case "Meta-Metadata":
1373  $this->in_meta_meta_data = false;
1374  break;
1375 
1376  case "FileItem":
1377  $this->in_file_item = false;
1378  // only update new file items
1379  if ($this->file_item->getImportId($a_attribs["Entry"] != ""))
1380  {
1381  $this->file_item->update();
1382  }
1383  break;
1384 
1385  case "Bibliography":
1386 
1387  $this->in_bib_item = false;
1388 
1389  $nested = new ilNestedSetXML();
1390  $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib");
1391  break;
1392 
1393  case "Table":
1394  unset ($this->container[count($this->container) - 1]);
1395  break;
1396 
1397  case "Glossary":
1398  $this->in_glossary = false;
1399  break;
1400 
1401  case "GlossaryTerm":
1402  $term = trim($this->chr_data);
1403  $term = str_replace("&lt;", "<", $term);
1404  $term = str_replace("&gt;", ">", $term);
1405  $this->glossary_term->setTerm($term);
1406  $this->glossary_term->create();
1407  $iia = explode("_", $this->glossary_term->getImportId());
1408  $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1409  break;
1410 
1411  case "Paragraph":
1412  $this->inside_code = false;
1413  break;
1414 
1415  case "Definition":
1416  $this->in_glossary_definition = false;
1417  $this->page_object->updateFromXML();
1418 //echo "&nbsp;&nbsp;after def update, xml:".htmlentities($this->page_object->getXMLContent()).":<br>";
1419 //echo "<br>".$this->page_object->getId()."-".$this->page_object->getParentType()."-";
1420  $this->page_object->buildDom();
1421  $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
1422  $this->glossary_definition->update();
1423  //$this->pg_mapping[$this->lm_page_object->getImportId()]
1424  // = $this->lm_page_object->getId();
1425  if ($this->page_object->containsIntLink())
1426  {
1427 //echo "<br>Definition contains Int Link:".$this->page_object->getId();
1428  $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1429  }
1430  if ($this->page_object->needsImportParsing())
1431  {
1432  $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1433  }
1434  break;
1435 
1436  case "Format":
1437  if ($this->in_media_item)
1438  {
1439  $this->media_item->setFormat(trim($this->chr_data));
1440  }
1441  if ($this->in_file_item)
1442  {
1443  $this->file_item->setFileType(trim($this->chr_data));
1444  }
1445  break;
1446 
1447  case "Title":
1448  if (!$this->in_media_object)
1449  {
1450  $this->current_object->setTitle(trim($this->chr_data));
1451  //$this->meta_data->setTitle(trim($this->chr_data));
1452  }
1453  else
1454  {
1455  $this->media_object->setTitle(trim($this->chr_data));
1456  //$this->meta_data->setTitle(trim($this->chr_data));
1457  }
1458  break;
1459 
1460  case "Language":
1461  /*
1462  if (is_object($this->meta_data))
1463  {
1464  $this->meta_data->setLanguage(trim($this->chr_data));
1465  }*/
1466 
1467  if (is_object($this->bib_item))
1468  {
1469  $this->bib_item->setLanguage(trim($this->chr_data));
1470  }
1471  break;
1472 
1473  case "Description":
1474  //$this->meta_data->setDescription(trim($this->chr_data));
1475  break;
1476 
1477  case "Caption":
1478  if ($this->in_media_object)
1479  {
1480  $this->media_item->setCaption(trim($this->chr_data));
1481  }
1482  break;
1483 
1484  case "TextRepresentation":
1485  if ($this->in_media_object)
1486  {
1487  $this->media_item->setTextRepresentation(trim($this->chr_data));
1488  }
1489  break;
1490 
1491  // Location
1492  case "Location":
1493  // TODO: adapt for files in "real" subdirectories
1494  if ($this->in_media_item)
1495  {
1496  $this->media_item->setLocationType($this->loc_type);
1497  if ($this->loc_type == "Reference")
1498  {
1499  $this->media_item->setLocation(str_replace("&", "&amp;", trim($this->chr_data)));
1500  }
1501  else
1502  {
1503  $this->media_item->setLocation(trim($this->chr_data));
1504  }
1505  //echo "-".$this->media_item->getLocation()."-";
1506  }
1507  if ($this->in_file_item)
1508  {
1509  // set file name from xml file
1510  $this->file_item->setFileName(trim($this->chr_data));
1511 
1512  // special handling for file names with special characters
1513  // (e.g. "&gt;")
1514  if ($this->file_item->getType() == "file" &&
1515  is_int(strpos($this->chr_data, "&")) &&
1516  is_int(strpos($this->chr_data, ";")))
1517  {
1518  $imp_dir = $this->content_object->getImportDirectory();
1519  $source_dir = $imp_dir."/".$this->subdir."/objects/".
1520  $this->file_item->getImportId();
1521 
1522  // read "physical" file name from directory
1523  if ($dir = opendir($source_dir))
1524  {
1525  while (false !== ($file = readdir($dir)))
1526  {
1527  if ($file != "." && $file != "..")
1528  {
1529  $this->file_item->setFileName($file);
1530  }
1531  }
1532  closedir($dir);
1533  }
1534  }
1535 
1536  // set file item title
1537  $this->file_item->setTitle(trim($this->chr_data));
1538  }
1539  break;
1540 
1541  }
1542  $this->endElement($a_name);
1543  $this->chr_data = "";
1544  }
1545 
1552  function handlerCharacterData($a_xml_parser,$a_data)
1553  {
1554  // call meta data handler
1555  if ($this->in_meta_data && $this->processMeta())
1556  {
1557  // cache beginning of meta data within media object tags
1558  // (we need to know the id, after that we send the cached data
1559  // to the meta xml handler)
1560  if ($this->in_media_object && $this->media_meta_start)
1561  {
1562  $this->media_meta_cache[] =
1563  array("type" => "handlerCharacterData", "par1" => $a_data);
1564  }
1565  else
1566  {
1567  parent::handlerCharacterData($a_xml_parser,$a_data);
1568  }
1569  }
1570 
1571  // the parser converts "&gt;" to ">" and "&lt;" to "<"
1572  // in character data, but we don't want that, because it's the
1573  // way we mask user html in our content, so we convert back...
1574 
1575  $a_data = str_replace("<","&lt;",$a_data);
1576  $a_data = str_replace(">","&gt;",$a_data);
1577 
1578 
1579  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1580  $a_data = preg_replace("/\n/","",$a_data);
1581  if (!$this->inside_code)
1582  {
1583  $a_data = preg_replace("/\t+/","",$a_data);
1584  }
1585 
1586  $this->chr_data .= $a_data;
1587 
1588  if(!empty($a_data) || $a_data === "0")
1589  {
1590  // append all data to page, if we are within PageObject,
1591  // but not within MetaData or MediaObject
1592  if (($this->in_page_object || $this->in_glossary_definition)
1593  && !$this->in_meta_data && !$this->in_media_object)
1594  {
1595  $this->page_object->appendXMLContent($a_data);
1596  }
1597 
1598  if ($this->in_meta_data)
1599  {
1600  //$this->meta_data->appendXMLContent($a_data);
1601 //echo "<br>".$a_data;
1602  }
1603 
1604  if ($this->in_bib_item )
1605  {
1606  $this->bib_item->appendXMLContent($a_data);
1607  }
1608 
1609  switch($this->getCurrentElement())
1610  {
1611 
1612  case "IntLink":
1613  case "ExtLink":
1614  if($this->in_map_area)
1615  {
1616  $this->map_area->appendTitle($a_data);
1617  }
1618  break;
1619 
1620  }
1621  }
1622 
1623  }
1624 
1625 
1630  function emptyMediaMetaCache(&$a_xml_parser)
1631  {
1632  foreach ($this->media_meta_cache as $cache_entry)
1633  {
1634  switch($cache_entry["type"])
1635  {
1636  case "handlerBeginTag":
1637  parent::handlerBeginTag($a_xml_parser,
1638  $cache_entry["par1"], $cache_entry["par2"]);
1639  break;
1640 
1641  case "handlerEndTag":
1642  parent::handlerEndTag($a_xml_parser,
1643  $cache_entry["par1"]);
1644  break;
1645 
1646  case "handlerCharacterData":
1647  parent::handlerCharacterData($a_xml_parser,
1648  $cache_entry["par1"]);
1649  break;
1650  }
1651  }
1652 
1653  $this->media_meta_start = false;
1654  $this->media_meta_cache[] = array();
1655  }
1656 
1664  {
1665  return $this->glossary_term_map;
1666  }
1667 
1668 }
1669 ?>