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