ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
5require_once("./Services/COPage/classes/class.ilPageObject.php");
6require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
7require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
8require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
9require_once("./Services/COPage/classes/class.ilPCParagraph.php");
10require_once("./Services/COPage/classes/class.ilPCTable.php");
11require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
12require_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
13require_once("./Services/MediaObjects/classes/class.ilMapArea.php");
14require_once("./Modules/LearningModule/classes/class.ilBibItem.php");
15require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
16require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
17require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
18require_once("./Services/Link/classes/class.ilInternalLink.php");
19require_once("./Modules/File/classes/class.ilObjFile.php");
20
21include_once("Services/MetaData/classes/class.ilMDSaxParser.php");
22include_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;
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
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>";
141 parent::startParsing();
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";
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 */
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;
556case "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 case "LayoutPerPage":
758 $this->content_object->setLayoutPerPage($a_attribs["Value"]);
759 break;
760
761 case "ProgressIcons":
762 $this->content_object->setProgressIcons($a_attribs["Value"]);
763 break;
764
765 case "StoreTries":
766 $this->content_object->setStoreTries($a_attribs["Value"]);
767 break;
768
769 case "RestrictForwardNavigation":
770 $this->content_object->setRestrictForwardNavigation($a_attribs["Value"]);
771 break;
772
773 case "DisableDefaultFeedback":
774 $this->content_object->setDisableDefaultFeedback($a_attribs["Value"]);
775 break;
776
777 }
778 //echo "<br>+".$a_attribs["Name"]."+";
779 }
780 break;
781
785 case "MetaData":
786 $this->in_meta_data = true;
787//echo "<br>begin meta data section -".$this->current_object->getType()."-";
788 // media obejct meta data handling
789 // is done in the "Identifier" begin tag processing
790 // the rest is done here
791 if(!$this->in_media_object)
792 {
793 if (($this->coType != "tst") and ($this->coType != "qpl"))
794 {
795 // type pg/st
796 if ($this->current_object->getType() == "st" ||
797 $this->current_object->getType() == "pg")
798 {
799 // late creation of page object
800 if ($this->current_object->getType() == "pg")
801 {
802 $this->lm_page_object->create(true);
803 }
804 $this->md = new ilMD($this->content_object->getId() ,
805 $this->current_object->getId(),
806 $this->current_object->getType());
807 }
808 // type gdf
809 else if ($this->current_object->getType() == "gdf")
810 {
811 $this->md = new ilMD($this->glossary_object->getId() ,
812 $this->current_object->getId(),
813 $this->current_object->getType());
814 }
815 // type lm, dbk, glo
816 else
817 {
818 if ($this->processMeta())
819 {
820 $this->md = new ilMD($this->current_object->getId() ,
821 0,
822 $this->current_object->getType());
823 }
824 }
825 }
826 else
827 {
828 // type qpl or tst
829 $this->md = new ilMD($this->content_object->getId() ,
830 0,
831 $this->current_object->getType()
832 );
833 if ($this->md->getGeneral() != false)
834 {
835 $this->metadata_parsing_disabled = true;
836 $this->enableMDParsing(false);
837 }
838 }
839 }
840 break;
841
842 // Identifier
843 case "Identifier":
844
845 // please note: Meta-Metadata and MetaData are different tags!
846 if (!$this->in_meta_meta_data)
847 {
848 if ($this->in_meta_data && !$this->in_glossary_definition)
849 {
850 if (!$this->in_media_object)
851 {
852 $this->current_object->setImportId($a_attribs["Entry"]);
853 }
854 $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
855 }
856 if ($this->in_file_item)
857 {
858 if ($this->file_item_mapping[$a_attribs["Entry"]] == "")
859 {
860 $this->file_item->create();
861 $this->file_item->setImportId($a_attribs["Entry"]);
862 $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
863 }
864 }
865 if ($this->in_meta_data && $this->in_media_object)
866 {
867//echo "looking for -".$a_attribs["Entry"]."-<br>";
868
869 $mob_id = $this->mob_mapping[$a_attribs["Entry"]];
870
871 // within learning module import, usually a media object
872 // has already been created with a media alias tag
873 if ($mob_id > 0)
874 {
875 $this->media_object = new ilObjMediaObject($mob_id);
876 }
877 else // in glossaries the media objects precede the definitions
878 // so we don't have an object already
879 {
880 $this->media_object = new ilObjMediaObject();
881 $this->media_object->create(true, false);
882 $this->mob_mapping[$a_attribs["Entry"]]
883 = $this->media_object->getId();
884 }
885 $this->media_object->setImportId($a_attribs["Entry"]);
886 $this->md = new ilMD(0 ,
887 $this->media_object->getId(),
888 "mob");
889 $this->emptyMediaMetaCache($a_xml_parser);
890 }
891 }
892 break;
893
894 case "Meta-Metadata":
895 $this->in_meta_meta_data = true;
896 break;
897
898 // Internal Link
899 case "IntLink":
900 if (is_object($this->page_object))
901 {
902 $this->page_object->setContainsIntLink(true);
903 }
904 if ($this->in_map_area)
905 {
906//echo "intlink:maparea:<br>";
907 $this->map_area->setLinkType(IL_INT_LINK);
908 $this->map_area->setTarget($a_attribs["Target"]);
909 $this->map_area->setType($a_attribs["Type"]);
910 $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
911 if (is_object($this->media_object))
912 {
913//echo ":setContainsLink:<br>";
914 $this->media_object->setContainsIntLink(true);
915 }
916 }
917 break;
918
919 // External Link
920 case "ExtLink":
921 if ($this->in_map_area)
922 {
923 $this->map_area->setLinkType(IL_EXT_LINK);
924 $this->map_area->setHref($a_attribs["Href"]);
925 $this->map_area->setExtTitle($a_attribs["Title"]);
926 }
927 break;
928
929 // Question
930 case "Question":
931 $this->cur_qid = $a_attribs["QRef"];
932 $this->page_object->setContainsQuestion(true);
933 break;
934
935 case "Location":
936 $this->loc_type = $a_attribs["Type"];
937 break;
938
939 case "Bibliography":
940 $this->in_bib_item = true;
941//echo "<br>---NEW BIBLIOGRAPHY---<br>";
942 $this->bib_item = new ilBibItem();
943 break;
944
945 }
946 $this->beginElement($a_name);
947
948 // append content to page xml content
949 if(($this->in_page_object || $this->in_glossary_definition)
950 && !$this->in_meta_data && !$this->in_media_object)
951 {
952 if ($a_name == "Definition")
953 {
954 $app_name = "PageObject";
955 $app_attribs = array();
956 }
957 else
958 {
959 $app_name = $a_name;
960 $app_attribs = $a_attribs;
961 }
962
963 // change identifier entry of file items to new local file id
964 if ($this->in_file_item && $app_name == "Identifier")
965 {
966 $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]];
967 //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
968 }
969
970 $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
971//echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
972 }
973
974 // append content to bibitem xml content
975 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
976 {
977 $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
978 }
979
980 // call meta data handler
981 if ($this->in_meta_data && $this->processMeta())
982 {
983 // cache beginning of meta data within media object tags
984 // (we need to know the id at the begin of meta elements within
985 // media objects, after the "Identifier" tag has been processed
986 // we send the cached data to the meta xml handler)
987 if ($this->in_media_object && $this->media_meta_start)
988 {
989 $this->media_meta_cache[] =
990 array("type" => "handlerBeginTag", "par1" => $a_name, "par2" => $a_attribs);
991 }
992 else
993 {
994 if ($a_name == "Identifier")
995 {
996 if (!$this->in_media_object)
997 {
998 $a_attribs["Entry"] = "il__".$this->current_object->getType().
999 "_".$this->current_object->getId();
1000 }
1001 else
1002 {
1003 $a_attribs["Entry"] = "il__mob".
1004 "_".$this->media_object->getId();
1005 }
1006 $a_attribs["Catalog"] = "ILIAS";
1007 }
1008
1009 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
1010 }
1011 }
1012 }
1013
1017 function processMeta()
1018 {
1019 // do not process second meta block in (ilias3) glossaries
1020 // which comes right after the "Glossary" tag
1021 if ($this->content_object->getType() == "glo" &&
1022 $this->in_glossary && !$this->in_media_object
1023 && !$this->in_glossary_definition)
1024 {
1025 return false;
1026 }
1027
1028 return true;
1029 }
1030
1031
1038 function handlerEndTag($a_xml_parser,$a_name)
1039 {
1040 // call meta data handler
1041 if ($this->in_meta_data && $this->processMeta())
1042 {
1043 // cache beginning of meta data within media object tags
1044 // (we need to know the id, after that we send the cached data
1045 // to the meta xml handler)
1046 if ($this->in_media_object && $this->media_meta_start)
1047 {
1048 $this->media_meta_cache[] =
1049 array("type" => "handlerEndTag", "par1" => $a_name);
1050 }
1051 else
1052 {
1053 parent::handlerEndTag($a_xml_parser,$a_name);
1054 }
1055 }
1056
1057//echo "<b>END TAG: $a_name <br></b>"; flush();
1058 // append content to page xml content
1059 if (($this->in_page_object || $this->in_glossary_definition)
1060 && !$this->in_meta_data && !$this->in_media_object)
1061 {
1062 $app_name = ($a_name == "Definition")
1063 ? "PageObject"
1064 : $a_name;
1065 $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
1066 }
1067
1068 // append content to bibitemxml content
1069 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
1070 {
1071 if($a_name == "BibItem")
1072 {
1073 $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name));
1074 }
1075 else
1076 {
1077 $this->bib_item->appendXMLContent($this->buildTag("end", $a_name));
1078 }
1079
1080 }
1081
1082 switch($a_name)
1083 {
1084 case "StructureObject":
1085 //unset($this->meta_data);
1086 unset($this->structure_objects[count($this->structure_objects) - 1]);
1087 break;
1088
1089 case "PageObject":
1090
1091 $this->in_page_object = false;
1092 if (($this->coType != "tst") and ($this->coType != "qpl"))
1093 {
1094 if (!$this->lm_page_object->isAlias())
1095 {
1096 //$this->page_object->createFromXML();
1097 $this->page_object->updateFromXML();
1098 $this->pg_mapping[$this->lm_page_object->getImportId()]
1099 = $this->lm_page_object->getId();
1100
1101 // collect pages with internal links
1102 if ($this->page_object->containsIntLink())
1103 {
1104 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1105 }
1106
1107 // collect pages with mobs or files
1108 if ($this->page_object->needsImportParsing())
1109 {
1110 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1111 }
1112
1113 // collect pages with questions
1114 if ($this->page_object->getContainsQuestion())
1115 {
1116 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1117 }
1118
1119 }
1120 }
1121 else
1122 {
1123 $xml = $this->page_object->getXMLContent();
1124 if ($this->cur_qid != "")
1125 {
1126 $ids = $this->qst_mapping[$this->cur_qid];
1127 if ($ids["pool"] > 0)
1128 {
1129 // question pool question
1130 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1131 $page = new ilAssQuestionPage($ids["pool"]);
1132 $xmlcontent = str_replace($this->cur_qid,
1133 "il__qst_".$ids["pool"], $xml);
1134 $page->setXMLContent($xmlcontent);
1135 $page->updateFromXML();
1136 if( $this->page_object->needsImportParsing() )
1137 {
1138 $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1139 }
1140 unset($page);
1141 }
1142 if ($ids["test"] > 0)
1143 {
1144 // test question
1145 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1146 $page = new ilAssQuestionPage($ids["test"]);
1147 $xmlcontent = str_replace($this->cur_qid,
1148 "il__qst_".$ids["test"], $xml);
1149 $page->setXMLContent($xmlcontent);
1150 $page->updateFromXML();
1151 if( $this->page_object->needsImportParsing() )
1152 {
1153 $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1154 }
1155 unset($page);
1156 }
1157 }
1158 }
1159
1160 // if we are within a structure object: put page in tree
1161 $cnt = count($this->structure_objects);
1162//echo "1";
1163 if ($cnt > 0)
1164 {
1165//echo "B-$cnt-<br>";
1166//echo "<br>"; var_dump($this->structure_objects); echo "<br>";
1167 $parent_id = $this->structure_objects[$cnt - 1]->getId();
1168 if ($this->lm_page_object->isAlias())
1169 {
1170//echo "3";
1171 $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
1172//echo "<br>"; var_dump($this->pg_into_tree); echo "<br>";
1173 }
1174 else
1175 {
1176//echo "4";
1177 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
1178 }
1179 }
1180
1181 unset($this->page_object);
1182 unset($this->lm_page_object);
1183 unset ($this->container[count($this->container) - 1]);
1184 break;
1185
1186 case "MediaObject":
1187 $this->in_media_object = false;
1188case "InteractiveImage":
1189
1190//echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
1191 // create media object on first occurence of an Id
1192
1193
1194 if(empty($this->mob_mapping[$this->media_object->getImportId()]))
1195 {
1196//echo "No mapping found --creating media object:title:".$this->media_object->getTitle().":<br>";
1197
1198 // create media object
1199 // media items are saves for mobs outside of
1200 // pages only
1201 $this->media_object->create(true, false);
1202
1203//echo "<br>creating mob ".$this->media_object->getId().":".$this->media_object->getTitle().":";
1204
1205 // collect mobs with internal links
1206 if ($this->media_object->containsIntLink())
1207 {
1208//echo "got int link :".$this->media_object->getId().":<br>";
1209 $this->mobs_with_int_links[] = $this->media_object->getId();
1210 }
1211
1212 $this->mob_mapping[$this->media_object->getImportId()]
1213 = $this->media_object->getId();
1214//echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
1215 }
1216 else
1217 {
1218//echo "Mapping found<br>";
1219 // get the id from mapping
1220 $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
1221
1222 // update "real" (no alias) media object
1223 // (note: we overwrite any data from the media object
1224 // created by an MediaAlias, only the data of the real
1225 // object is stored in db separately; data of the
1226 // MediaAliases are within the page XML
1227 if (!$this->media_object->isAlias())
1228 {
1229 // now the media items are saved within the db
1230 $this->media_object->update();
1231
1232//echo "<br>update media object :".$this->media_object->getId().":";
1233
1234 // collect mobs with internal links
1235 if ($this->media_object->containsIntLink())
1236 {
1237//echo "got int link :".$this->media_object->getId().":<br>";
1238 $this->mobs_with_int_links[] = $this->media_object->getId();
1239 }
1240 }
1241 }
1242
1243 // append media alias to page, if we are in a page
1244 if ($this->in_page_object || $this->in_glossary_definition)
1245 {
1246 if ($a_name != "InteractiveImage")
1247 {
1248 $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
1249//echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
1250 }
1251 }
1252
1253 break;
1254
1255 case "MediaItem":
1256 case "MediaAliasItem":
1257 $this->in_media_item = false;
1258 $this->media_object->addMediaItem($this->media_item);
1259//echo "adding media item -".$this->media_item->getId()."-".$this->media_item->getLocation()."- to object -".$this->media_object->getId()."-";
1260 break;
1261
1262 case "MapArea":
1263 $this->in_map_area = false;
1264 $this->media_item->addMapArea($this->map_area);
1265 break;
1266
1267 case "Properties":
1268 $this->in_properties = false;
1269 if ($this->content_object->getType() == "lm"
1270 || $this->content_object->getType() == "dbk")
1271 {
1272 $this->content_object->update();
1273 }
1274 break;
1275
1276 case "MetaData":
1277 $this->in_meta_data = false;
1278 if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object)
1279 {
1280 // Metadaten eines PageObjects sichern in NestedSet
1281 if (is_object($this->lm_page_object))
1282 {
1283 // update title/description of page object
1284 $this->current_object->MDUpdateListener('General');
1285 ilLMObject::_writeImportId($this->current_object->getId(),
1286 $this->current_object->getImportId());
1287 }
1288 }
1289 else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
1290 strtolower(get_class($this->current_object)) == "ilobjtest") &&
1291 !$this->in_media_object)
1292// !$this->in_media_object && !$this->in_page_object)
1293// changed for imports of ILIAS 2 Tests where PageObjects could have
1294// Metadata sections (Helmut Schottmüller, 2005-12-02)
1295 {
1296 if ($this->metadata_parsing_disabled)
1297 {
1298 $this->enableMDParsing(true);
1299 }
1300 else
1301 {
1302 if ($this->in_page_object)
1303 {
1304 $this->page_object->MDUpdateListener('General');
1305 ilLMObject::_writeImportId($this->page_object->getId(),
1306 $this->page_object->getImportId());
1307 }
1308 else
1309 {
1310 $this->current_object->MDUpdateListener('General');
1311 ilLMObject::_writeImportId($this->current_object->getId(),
1312 $this->current_object->getImportId());
1313 }
1314 }
1315 }
1316 else if(strtolower(get_class($this->current_object)) == "ilstructureobject")
1317 { // save structure object at the end of its meta block
1318 // determine parent
1319 $cnt = count($this->structure_objects);
1320 if ($cnt > 1)
1321 {
1322 $parent_id = $this->structure_objects[$cnt - 2]->getId();
1323 }
1324 else
1325 {
1326 $parent_id = $this->lm_tree->getRootId();
1327 }
1328
1329 // create structure object and put it in tree
1330 //$this->current_object->create(true); // now on top
1331 $this->st_into_tree[] = array ("id" => $this->current_object->getId(),
1332 "parent" => $parent_id);
1333
1334 // update title/description of structure object
1335 $this->current_object->MDUpdateListener('General');
1336 ilLMObject::_writeImportId($this->current_object->getId(),
1337 $this->current_object->getImportId());
1338 }
1339 else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1340 strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
1341 (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary))
1342 {
1343 // todo: saving of md? getting title/descr and
1344 // set it for current object
1345 }
1346 else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object)
1347 {
1348 // now on top
1349 //$this->glossary_definition->create();
1350
1351 $this->page_object->setId($this->glossary_definition->getId());
1352 $this->page_object->updateFromXML();
1353
1354 // todo: saving of md? getting title/descr and
1355 // set it for current object
1356 }
1357
1358
1359 if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1360 strtolower(get_class($this->current_object)) == "ilobjdlbook" ||
1361 strtolower(get_class($this->current_object)) == "ilobjglossary")
1362 {
1363 if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
1364 $this->content_object->getType() != "glo")
1365 {
1366//echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
1367 $this->current_object->setTitle($this->content_object->getTitle()." - ".
1368 $this->lng->txt("glossary"));
1369 }
1370
1371 $this->current_object->MDUpdateListener('General');
1372 /*
1373 if (!$this->in_media_object && $this->processMeta())
1374 {
1375 $this->current_object->update();
1376 }
1377 */
1378 }
1379
1380 if ($this->in_media_object)
1381 {
1382//echo "<br>call media object update listener";
1383 $this->media_object->MDUpdateListener('General');
1384 }
1385
1386 if ($this->in_glossary_definition)
1387 {
1388 $this->glossary_definition->MDUpdateListener('General');
1389 }
1390
1391 break;
1392
1393 case "Meta-Metadata":
1394 $this->in_meta_meta_data = false;
1395 break;
1396
1397 case "FileItem":
1398 $this->in_file_item = false;
1399 // only update new file items
1400 if ($this->file_item->getImportId($a_attribs["Entry"] != ""))
1401 {
1402 $this->file_item->update();
1403 }
1404 break;
1405
1406 case "Bibliography":
1407
1408 $this->in_bib_item = false;
1409
1410 $nested = new ilNestedSetXML();
1411 $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib");
1412 break;
1413
1414 case "Table":
1415 unset ($this->container[count($this->container) - 1]);
1416 break;
1417
1418 case "Glossary":
1419 $this->in_glossary = false;
1420 break;
1421
1422 case "GlossaryTerm":
1423 $term = trim($this->chr_data);
1424 $term = str_replace("&lt;", "<", $term);
1425 $term = str_replace("&gt;", ">", $term);
1426 $this->glossary_term->setTerm($term);
1427 $this->glossary_term->create();
1428 $iia = explode("_", $this->glossary_term->getImportId());
1429 $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1430 break;
1431
1432 case "Paragraph":
1433 $this->inside_code = false;
1434 break;
1435
1436 case "Definition":
1437 $this->in_glossary_definition = false;
1438 $this->page_object->updateFromXML();
1439//echo "&nbsp;&nbsp;after def update, xml:".htmlentities($this->page_object->getXMLContent()).":<br>";
1440//echo "<br>".$this->page_object->getId()."-".$this->page_object->getParentType()."-";
1441 $this->page_object->buildDom();
1442 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
1443 $this->glossary_definition->update();
1444 //$this->pg_mapping[$this->lm_page_object->getImportId()]
1445 // = $this->lm_page_object->getId();
1446 if ($this->page_object->containsIntLink())
1447 {
1448//echo "<br>Definition contains Int Link:".$this->page_object->getId();
1449 $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1450 }
1451 if ($this->page_object->needsImportParsing())
1452 {
1453 $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1454 }
1455 break;
1456
1457 case "Format":
1458 if ($this->in_media_item)
1459 {
1460 $this->media_item->setFormat(trim($this->chr_data));
1461 }
1462 if ($this->in_file_item)
1463 {
1464 $this->file_item->setFileType(trim($this->chr_data));
1465 }
1466 break;
1467
1468 case "Title":
1469 if (!$this->in_media_object)
1470 {
1471 $this->current_object->setTitle(trim($this->chr_data));
1472 //$this->meta_data->setTitle(trim($this->chr_data));
1473 }
1474 else
1475 {
1476 $this->media_object->setTitle(trim($this->chr_data));
1477 //$this->meta_data->setTitle(trim($this->chr_data));
1478 }
1479 break;
1480
1481 case "Language":
1482 /*
1483 if (is_object($this->meta_data))
1484 {
1485 $this->meta_data->setLanguage(trim($this->chr_data));
1486 }*/
1487
1488 if (is_object($this->bib_item))
1489 {
1490 $this->bib_item->setLanguage(trim($this->chr_data));
1491 }
1492 break;
1493
1494 case "Description":
1495 //$this->meta_data->setDescription(trim($this->chr_data));
1496 break;
1497
1498 case "Caption":
1499 if ($this->in_media_object)
1500 {
1501 $this->media_item->setCaption(trim($this->chr_data));
1502 }
1503 break;
1504
1505 case "TextRepresentation":
1506 if ($this->in_media_object)
1507 {
1508 $this->media_item->setTextRepresentation(trim($this->chr_data));
1509 }
1510 break;
1511
1512 // Location
1513 case "Location":
1514 // TODO: adapt for files in "real" subdirectories
1515 if ($this->in_media_item)
1516 {
1517 $this->media_item->setLocationType($this->loc_type);
1518 if ($this->loc_type == "Reference")
1519 {
1520 $this->media_item->setLocation(str_replace("&", "&amp;", trim($this->chr_data)));
1521 }
1522 else
1523 {
1524 $this->media_item->setLocation(trim($this->chr_data));
1525 }
1526 //echo "-".$this->media_item->getLocation()."-";
1527 }
1528 if ($this->in_file_item)
1529 {
1530 // set file name from xml file
1531 $this->file_item->setFileName(trim($this->chr_data));
1532
1533 // special handling for file names with special characters
1534 // (e.g. "&gt;")
1535 if ($this->file_item->getType() == "file" &&
1536 is_int(strpos($this->chr_data, "&")) &&
1537 is_int(strpos($this->chr_data, ";")))
1538 {
1539 $imp_dir = $this->content_object->getImportDirectory();
1540 $source_dir = $imp_dir."/".$this->subdir."/objects/".
1541 $this->file_item->getImportId();
1542
1543 // read "physical" file name from directory
1544 if ($dir = opendir($source_dir))
1545 {
1546 while (false !== ($file = readdir($dir)))
1547 {
1548 if ($file != "." && $file != "..")
1549 {
1550 $this->file_item->setFileName($file);
1551 }
1552 }
1553 closedir($dir);
1554 }
1555 }
1556
1557 // set file item title
1558 $this->file_item->setTitle(trim($this->chr_data));
1559 }
1560 break;
1561
1562 }
1563 $this->endElement($a_name);
1564 $this->chr_data = "";
1565 }
1566
1573 function handlerCharacterData($a_xml_parser,$a_data)
1574 {
1575 // call meta data handler
1576 if ($this->in_meta_data && $this->processMeta())
1577 {
1578 // cache beginning of meta data within media object tags
1579 // (we need to know the id, after that we send the cached data
1580 // to the meta xml handler)
1581 if ($this->in_media_object && $this->media_meta_start)
1582 {
1583 $this->media_meta_cache[] =
1584 array("type" => "handlerCharacterData", "par1" => $a_data);
1585 }
1586 else
1587 {
1588 parent::handlerCharacterData($a_xml_parser,$a_data);
1589 }
1590 }
1591
1592 // the parser converts "&gt;" to ">" and "&lt;" to "<"
1593 // in character data, but we don't want that, because it's the
1594 // way we mask user html in our content, so we convert back...
1595
1596 $a_data = str_replace("<","&lt;",$a_data);
1597 $a_data = str_replace(">","&gt;",$a_data);
1598
1599
1600 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1601 $a_data = preg_replace("/\n/","",$a_data);
1602 if (!$this->inside_code)
1603 {
1604 $a_data = preg_replace("/\t+/","",$a_data);
1605 }
1606
1607 $this->chr_data .= $a_data;
1608
1609 if(!empty($a_data) || $a_data === "0")
1610 {
1611 // append all data to page, if we are within PageObject,
1612 // but not within MetaData or MediaObject
1613 if (($this->in_page_object || $this->in_glossary_definition)
1614 && !$this->in_meta_data && !$this->in_media_object)
1615 {
1616 $this->page_object->appendXMLContent($a_data);
1617 }
1618
1619 if ($this->in_meta_data)
1620 {
1621 //$this->meta_data->appendXMLContent($a_data);
1622//echo "<br>".$a_data;
1623 }
1624
1625 if ($this->in_bib_item )
1626 {
1627 $this->bib_item->appendXMLContent($a_data);
1628 }
1629
1630 switch($this->getCurrentElement())
1631 {
1632
1633 case "IntLink":
1634 case "ExtLink":
1635 if($this->in_map_area)
1636 {
1637 $this->map_area->appendTitle($a_data);
1638 }
1639 break;
1640
1641 }
1642 }
1643
1644 }
1645
1646
1651 function emptyMediaMetaCache(&$a_xml_parser)
1652 {
1653 foreach ($this->media_meta_cache as $cache_entry)
1654 {
1655 switch($cache_entry["type"])
1656 {
1657 case "handlerBeginTag":
1658 parent::handlerBeginTag($a_xml_parser,
1659 $cache_entry["par1"], $cache_entry["par2"]);
1660 break;
1661
1662 case "handlerEndTag":
1663 parent::handlerEndTag($a_xml_parser,
1664 $cache_entry["par1"]);
1665 break;
1666
1667 case "handlerCharacterData":
1668 parent::handlerCharacterData($a_xml_parser,
1669 $cache_entry["par1"]);
1670 break;
1671 }
1672 }
1673
1674 $this->media_meta_start = false;
1675 $this->media_meta_cache[] = array();
1676 }
1677
1685 {
1687 }
1688
1689}
1690?>
print $file
$test
Definition: Utf8Test.php:85
$_GET["client_id"]
_resolveIntLinks($question_id)
const IL_INT_LINK
const IL_EXT_LINK
const IL_MODE_ALIAS
_resolveIntLinks($question_id)
Question page object.
Class ilBibItem.
Content Object Parser.
setQuestionMapping($a_map)
set question import ident to pool/test question id mapping
storeTree()
insert StructureObjects and PageObjects into tree
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
buildTag($type, $name, $attr="")
generate a tag with given name and attributes
emptyMediaMetaCache(&$a_xml_parser)
send all cached tags to the meta data parser and clear the cache
startParsing()
start parser
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
getGlossaryTermMap()
Get glossary term map (imported ids to new ids)
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
processPagesToParse()
parse pages that contain files, mobs and/or internal links
copyMobFiles()
copy multimedia object files from import zip file to mob directory
setHandlers($a_xml_parser)
set event handlers
processMeta()
check whether meta data should be processed
copyFileItems()
copy files of file items
ilContObjParser(&$a_content_object, $a_xml_file, $a_subdir)
Constructor.
Glossary definition page object.
Class ilGlossaryDefinition.
Class ilGlossaryTerm.
_writeImportId($a_id, $a_import_id)
write import id to db (static)
Class ilLMPageObject.
Extension of ilPageObject for learning modules.
enableMDParsing($a_status)
Class ilMapArea.
Class ilMediaItem.
_resolveMapAreaLinks($a_mob_id)
resolve internal links of all media items of a media object
Class NestedSetXML functions for storing XML-Data into nested-set-database-strcture.
Class ilObjFile.
Class ilObjGlossary.
Class ilObjMediaObject.
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
static _exists($a_parent_type, $a_id, $a_lang="")
Checks whether page exists.
Class ilStructreObject.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
$target_id
Definition: goto.php:88
$target_type
Definition: goto.php:87