ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilContObjParser Class Reference

Content Object Parser. More...

+ Inheritance diagram for ilContObjParser:
+ Collaboration diagram for ilContObjParser:

Public Member Functions

 ilContObjParser (&$a_content_object, $a_xml_file, $a_subdir, $a_import_dir="")
 Constructor. More...
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 setImportMapping (ilImportMapping $mapping=null)
 Set import mapping. More...
 
 startParsing ()
 start parser More...
 
 storeTree ()
 insert StructureObjects and PageObjects into tree More...
 
 processPagesToParse ()
 parse pages that contain files, mobs and/or internal links More...
 
 copyMobFiles ()
 copy multimedia object files from import zip file to mob directory More...
 
 copyFileItems ()
 copy files of file items More...
 
 setQuestionMapping ($a_map)
 set question import ident to pool/test question id mapping More...
 
 beginElement ($a_name)
 
 endElement ($a_name)
 
 getCurrentElement ()
 
 getOpenCount ($a_name)
 
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 processMeta ()
 check whether meta data should be processed More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 emptyMediaMetaCache (&$a_xml_parser)
 send all cached tags to the meta data parser and clear the cache More...
 
 getGlossaryTermMap ()
 Get glossary term map (imported ids to new ids) More...
 
- Public Member Functions inherited from ilMDSaxParser
 ilMDSaxParser ($a_xml_file='')
 Constructor. More...
 
 enableMDParsing ($a_status)
 
 getMDParsingStatus ()
 
 setMDObject (&$md)
 
getMDObject ()
 
 inMetaData ()
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 __getCharacterData ()
 
 __pushParent (&$md_obj)
 
__popParent ()
 
__getParent ()
 
 ilMDSaxParser ($a_xml_file='')
 Constructor. More...
 
 setMDObject (&$md)
 
 inMetaData ()
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 __getCharacterData ()
 
 __pushParent (&$md_obj)
 
__popParent ()
 
__getParent ()
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $lng
 
 $tree
 
 $cnt
 
 $current_element
 
 $learning_module
 
 $page_object
 
 $lm_page_object
 
 $structure_objects
 
 $media_object
 
 $current_object
 
 $meta_data
 
 $paragraph
 
 $table
 
 $lm_tree
 
 $pg_into_tree
 
 $st_into_tree
 
 $container
 
 $in_page_object
 
 $in_meta_data
 
 $in_media_object
 
 $in_file_item
 
 $in_glossary
 
 $in_map_area
 
 $content_object
 
 $glossary_object
 
 $file_item
 
 $keyword_language
 
 $pages_to_parse
 
 $mob_mapping
 
 $file_item_mapping
 
 $subdir
 
 $media_item
 
 $loc_type
 
 $bib_item
 
 $map_area
 
 $in_bib_item
 
 $link_targets
 
 $qst_mapping
 
 $metadata_parsing_disabled
 
 $in_meta_meta_data = false
 
- Data Fields inherited from ilMDSaxParser
 $md_in_md = false
 
 $md_chr_data = ''
 
 $md_cur_el = null
 
 $md_parsing_enabled = null
 
 $md = null
 
 $md_gen
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Protected Attributes

 $glossary_term_map = array()
 
 $log
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Content Object Parser.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 32 of file class.ilContObjParser.php.

Member Function Documentation

◆ beginElement()

ilContObjParser::beginElement (   $a_name)

Definition at line 437 of file class.ilContObjParser.php.

438 {
439 if(!isset($this->status["$a_name"]))
440 {
441 $this->cnt[$a_name] = 1;
442 }
443 else
444 {
445 $this->cnt[$a_name]++;
446 }
447 $this->current_element[count($this->current_element)] = $a_name;
448 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ buildTag()

ilContObjParser::buildTag (   $type,
  $name,
  $attr = "" 
)

generate a tag with given name and attributes

Parameters
string"start" | "end" for starting or ending tag
stringelement/tag name
arrayarray of attributes

Definition at line 494 of file class.ilContObjParser.php.

495 {
496 $tag = "<";
497
498 if ($type == "end")
499 $tag.= "/";
500
501 $tag.= $name;
502
503 if (is_array($attr))
504 {
505 while (list($k,$v) = each($attr))
506 $tag.= " ".$k."=\"$v\"";
507 }
508
509 $tag.= ">";
510
511 return $tag;
512 }

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ copyFileItems()

ilContObjParser::copyFileItems ( )

copy files of file items

Definition at line 392 of file class.ilContObjParser.php.

393 {
394 $imp_dir = $this->import_dir;
395 foreach ($this->file_item_mapping as $origin_id => $file_id)
396 {
397 if(empty($origin_id))
398 {
399 continue;
400 }
401 $obj_dir = $origin_id;
402 $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
403
404 include_once("./Modules/File/classes/class.ilObjFile.php");
405 $file_obj = new ilObjFile($file_id, false);
406 //$target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
407 $target_dir = $file_obj->getDirectory();
408 if (@is_dir($source_dir))
409 {
410 // make target directory
411 ilUtil::makeDir($target_dir);
412 //@mkdir($target_dir);
413 //@chmod($target_dir, 0755);
414
415 if (@is_dir($target_dir))
416 {
417 ilUtil::rCopy($source_dir, $target_dir);
418 }
419 }
420 $test = $file_obj->determineFilesize();
421 $file_obj->update();
422 }
423 }
$test
Definition: Utf8Test.php:85
Class ilObjFile.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $test, ilUtil\makeDir(), and ilUtil\rCopy().

Referenced by startParsing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyMobFiles()

ilContObjParser::copyMobFiles ( )

copy multimedia object files from import zip file to mob directory

Definition at line 349 of file class.ilContObjParser.php.

350 {
351 $imp_dir = $this->import_dir;
352 foreach ($this->mob_mapping as $origin_id => $mob_id)
353 {
354 if(empty($origin_id))
355 {
356 continue;
357 }
358
359 /*
360 $origin_arr = explode("_", $origin_id);
361 if ($origin_arr[2] == "el") // imagemap
362 {
363 $obj_dir = "imagemap".$origin_arr[3];
364 }
365 else // normal media object
366 {
367 $obj_dir = "mm".$origin_arr[3];
368 }*/
369
370 $obj_dir = $origin_id;
371 $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir;
372 $target_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$mob_id;
373
374 if (@is_dir($source_dir))
375 {
376 // make target directory
377 ilUtil::makeDir($target_dir);
378 //@mkdir($target_dir);
379 //@chmod($target_dir, 0755);
380
381 if (@is_dir($target_dir))
382 {
383 ilUtil::rCopy($source_dir, $target_dir);
384 }
385 }
386 }
387 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References ilUtil\getWebspaceDir(), ilUtil\makeDir(), and ilUtil\rCopy().

Referenced by startParsing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emptyMediaMetaCache()

ilContObjParser::emptyMediaMetaCache ( $a_xml_parser)

send all cached tags to the meta data parser and clear the cache

Definition at line 1705 of file class.ilContObjParser.php.

1706 {
1707 foreach ($this->media_meta_cache as $cache_entry)
1708 {
1709 switch($cache_entry["type"])
1710 {
1711 case "handlerBeginTag":
1712 parent::handlerBeginTag($a_xml_parser,
1713 $cache_entry["par1"], $cache_entry["par2"]);
1714 break;
1715
1716 case "handlerEndTag":
1717 parent::handlerEndTag($a_xml_parser,
1718 $cache_entry["par1"]);
1719 break;
1720
1721 case "handlerCharacterData":
1722 parent::handlerCharacterData($a_xml_parser,
1723 $cache_entry["par1"]);
1724 break;
1725 }
1726 }
1727
1728 $this->media_meta_start = false;
1729 $this->media_meta_cache[] = array();
1730 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ endElement()

ilContObjParser::endElement (   $a_name)

Definition at line 455 of file class.ilContObjParser.php.

456 {
457 $this->cnt[$a_name]--;
458 unset ($this->current_element[count($this->current_element) - 1]);
459 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getCurrentElement()

ilContObjParser::getCurrentElement ( )

Definition at line 464 of file class.ilContObjParser.php.

465 {
466 return ($this->current_element[count($this->current_element) - 1]);
467 }

Referenced by handlerCharacterData().

+ Here is the caller graph for this function:

◆ getGlossaryTermMap()

ilContObjParser::getGlossaryTermMap ( )

Get glossary term map (imported ids to new ids)

Parameters

return

Definition at line 1738 of file class.ilContObjParser.php.

1739 {
1741 }

References $glossary_term_map.

◆ getOpenCount()

ilContObjParser::getOpenCount (   $a_name)

Definition at line 474 of file class.ilContObjParser.php.

475 {
476 if (isset($this->cnt[$a_name]))
477 {
478 return $this->cnt[$a_name];
479 }
480 else
481 {
482 return 0;
483 }
484
485 }

◆ handlerBeginTag()

ilContObjParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

Meta Data Section

Reimplemented from ilMDSaxParser.

Definition at line 521 of file class.ilContObjParser.php.

522 {
523//echo "<b>BEGIN TAG: $a_name <br></b>"; flush();
524 switch($a_name)
525 {
526 case "ContentObject":
527 $this->current_object = $this->content_object;
528//echo "<br>Parser:CObjType:".$a_attribs["Type"];
529 if ($a_attribs["Type"] == "Glossary")
530 {
531 $this->glossary_object = $this->content_object;
532 }
533 break;
534
535 case "StructureObject":
536//echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>";
537 $this->structure_objects[count($this->structure_objects)]
538 = new ilStructureObject($this->content_object);
539 $this->current_object = $this->structure_objects[count($this->structure_objects) - 1];
540 $this->current_object->setLMId($this->content_object->getId());
541 // new meta data handling: we create the structure
542 // object already here, this should also create a
543 // md entry
544 $this->current_object->create(true);
545 break;
546
547 case "PageObject":
548 $this->in_page_object = true;
549 $this->cur_qid = "";
550 if (($this->coType != "tst") and ($this->coType != "qpl"))
551 {
552 $this->lm_page_object = new ilLMPageObject($this->content_object);
553 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
554 $this->page_object = new ilLMPage();
555 $this->lm_page_object->setLMId($this->content_object->getId());
556 $this->lm_page_object->assignPageObject($this->page_object);
557 $this->current_object = $this->lm_page_object;
558 }
559 else
560 {
561 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
562 $this->page_object = new ilAssQuestionPage();
563 }
564 break;
565
566 case "PageAlias":
567 if (($this->coType != "tst") and ($this->coType != "qpl"))
568 {
569 $this->lm_page_object->setAlias(true);
570 $this->lm_page_object->setOriginID($a_attribs["OriginId"]);
571 }
572 break;
573
574 case "MediaObject":
575 $this->in_media_object = true;
576case "InteractiveImage":
577
578 $this->media_meta_start = true;
579 $this->media_meta_cache = array();
580 $this->media_object = new ilObjMediaObject();
581 break;
582
583 case "MediaAlias":
584//echo "<br>---NEW MEDIAALIAS---<br>";
585 $this->media_object->setAlias(true);
586 $this->media_object->setImportId($a_attribs["OriginId"]);
587 if (is_object($this->page_object))
588 {
589 $this->page_object->needsImportParsing(true);
590 }
591 break;
592
593 case "MediaItem":
594 case "MediaAliasItem":
595 $this->in_media_item = true;
596 $this->media_item = new ilMediaItem();
597 $this->media_item->setPurpose($a_attribs["Purpose"]);
598 /*if ($a_name == "MediaItem")
599 {
600 $this->media_item->setHighlightMode($a_attribs["MapHighlightMode"]);
601 $this->media_item->setHighlightClass($a_attribs["MapHighlightClass"]);
602 }*/
603 break;
604
605 case "Layout":
606 if (is_object($this->media_object) && $this->in_media_object)
607 {
608 $this->media_item->setWidth($a_attribs["Width"]);
609 $this->media_item->setHeight($a_attribs["Height"]);
610 $this->media_item->setHAlign($a_attribs["HorizontalAlign"]);
611 }
612 break;
613
614 case "Parameter":
615 if (is_object($this->media_object) && $this->in_media_object)
616 {
617 $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]);
618 }
619 break;
620
621 case "MapArea":
622 $this->in_map_area = true;
623 $this->map_area = new ilMapArea();
624 $this->map_area->setShape($a_attribs["Shape"]);
625 $this->map_area->setCoords($a_attribs["Coords"]);
626 $this->map_area->setHighlightMode($a_attribs["HighlightMode"]);
627 $this->map_area->setHighlightClass($a_attribs["HighlightClass"]);
628 break;
629
630 case "Glossary":
631 $this->in_glossary = true;
632 if ($this->content_object->getType() != "glo")
633 {
634 $this->glossary_object = new ilObjGlossary();
635 $this->glossary_object->setTitle("");
636 $this->glossary_object->setDescription("");
637 $this->glossary_object->create(true);
638 $this->glossary_object->createReference();
639 $parent = $this->tree->getParentNodeData($this->content_object->getRefId());
640 $this->glossary_object->putInTree($parent["child"]);
641 $this->glossary_object->setPermissions($parent["child"]);
642 $this->glossary_object->notify("new", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$this->glossary_object->getRefId());
643 }
644 $this->current_object = $this->glossary_object;
645 break;
646
647 case "GlossaryItem":
648 $this->glossary_term = new ilGlossaryTerm();
649 $this->glossary_term->setGlossaryId($this->glossary_object->getId());
650 $this->glossary_term->setLanguage($a_attribs["Language"]);
651 $this->glossary_term->setImportId($a_attribs["Id"]);
652 $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"];
653 break;
654
655 case "Definition":
656 $this->in_glossary_definition = true;
657 $this->glossary_definition = new ilGlossaryDefinition();
658 include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
659 $this->page_object = new ilGlossaryDefPage();
660 $this->page_object->setParentId($this->glossary_term->getGlossaryId());
661 $this->glossary_definition->setTermId($this->glossary_term->getId());
662 $this->glossary_definition->assignPageObject($this->page_object);
663 $this->current_object = $this->glossary_definition;
664 $this->glossary_definition->create(true);
665 // see bug #12465, we need to clear xml after creation, since it will be <PageObject></PageObject>
666 // otherwise, and appendXML calls will lead to "<PageObject></PageObject><PageObject>....</PageObject>"
667 $this->page_object->setXMLContent("");
668 break;
669
670 case "FileItem":
671 $this->in_file_item = true;
672 $this->file_item = new ilObjFile();
673 $this->file_item->setTitle("dummy");
674 $this->file_item->setMode("filelist");
675 if (is_object($this->page_object))
676 {
677 $this->page_object->needsImportParsing(true);
678 }
679 break;
680
681 case "Paragraph":
682 if ($a_attribs["Characteristic"] == "Code")
683 {
684 $this->inside_code = true;
685 }
686 break;
687
688 case "Properties":
689 $this->in_properties = true;
690 break;
691
692 case "Property":
693 if ($this->content_object->getType() == "lm"
694 || $this->content_object->getType() == "dbk")
695 {
696 switch($a_attribs["Name"])
697 {
698 case "Layout":
699 $this->content_object->setLayout($a_attribs["Value"]);
700 break;
701
702 case "PageHeader":
703 $this->content_object->setPageHeader($a_attribs["Value"]);
704 break;
705
706 case "TOCMode":
707 $this->content_object->setTOCMode($a_attribs["Value"]);
708 break;
709
710 case "ActiveLMMenu":
711 $this->content_object->setActiveLMMenu(
712 ilUtil::yn2tf($a_attribs["Value"]));
713 break;
714
715 case "ActiveNumbering":
716 $this->content_object->setActiveNumbering(
717 ilUtil::yn2tf($a_attribs["Value"]));
718 break;
719
720 case "ActiveTOC":
721 $this->content_object->setActiveTOC(
722 ilUtil::yn2tf($a_attribs["Value"]));
723 break;
724
725 case "ActivePrintView":
726 $this->content_object->setActivePrintView(
727 ilUtil::yn2tf($a_attribs["Value"]));
728 break;
729
730 case "CleanFrames":
731 $this->content_object->setCleanFrames(
732 ilUtil::yn2tf($a_attribs["Value"]));
733 break;
734
735 case "PublicNotes":
736 $this->content_object->setPublicNotes(
737 ilUtil::yn2tf($a_attribs["Value"]));
738 break;
739
740 case "HistoryUserComments":
741 $this->content_object->setHistoryUserComments(
742 ilUtil::yn2tf($a_attribs["Value"]));
743 break;
744
745 case "Rating":
746 $this->content_object->setRating(
747 ilUtil::yn2tf($a_attribs["Value"]));
748 break;
749
750 case "RatingPages":
751 $this->content_object->setRatingPages(
752 ilUtil::yn2tf($a_attribs["Value"]));
753 break;
754
755 case "HeaderPage":
756 if ($a_attribs["Value"] != "")
757 {
758 if ($this->pg_mapping[$a_attribs["Value"]] > 0)
759 {
760 $this->content_object->setHeaderPage(
761 $this->pg_mapping[$a_attribs["Value"]]);
762 }
763 }
764 break;
765
766 case "FooterPage":
767 if ($a_attribs["Value"] != "")
768 {
769 if ($this->pg_mapping[$a_attribs["Value"]] > 0)
770 {
771 $this->content_object->setFooterPage(
772 $this->pg_mapping[$a_attribs["Value"]]);
773 }
774 }
775 break;
776
777 case "LayoutPerPage":
778 $this->content_object->setLayoutPerPage($a_attribs["Value"]);
779 break;
780
781 case "ProgressIcons":
782 $this->content_object->setProgressIcons($a_attribs["Value"]);
783 break;
784
785 case "StoreTries":
786 $this->content_object->setStoreTries($a_attribs["Value"]);
787 break;
788
789 case "RestrictForwardNavigation":
790 $this->content_object->setRestrictForwardNavigation($a_attribs["Value"]);
791 break;
792
793 case "DisableDefaultFeedback":
794 $this->content_object->setDisableDefaultFeedback($a_attribs["Value"]);
795 break;
796
797 }
798 //echo "<br>+".$a_attribs["Name"]."+";
799 }
800 break;
801
805 case "MetaData":
806 $this->in_meta_data = true;
807//echo "<br>begin meta data section -".$this->current_object->getType()."-";
808 // media obejct meta data handling
809 // is done in the "Identifier" begin tag processing
810 // the rest is done here
811 if(!$this->in_media_object)
812 {
813 if (($this->coType != "tst") and ($this->coType != "qpl"))
814 {
815 // type pg/st
816 if ($this->current_object->getType() == "st" ||
817 $this->current_object->getType() == "pg")
818 {
819 // late creation of page object
820 if ($this->current_object->getType() == "pg")
821 {
822 $this->lm_page_object->create(true);
823 }
824 $this->md = new ilMD($this->content_object->getId() ,
825 $this->current_object->getId(),
826 $this->current_object->getType());
827 }
828 // type gdf
829 else if ($this->current_object->getType() == "gdf")
830 {
831 $this->md = new ilMD($this->glossary_object->getId() ,
832 $this->current_object->getId(),
833 $this->current_object->getType());
834 }
835 // type lm, dbk, glo
836 else
837 {
838 if ($this->processMeta())
839 {
840 $this->md = new ilMD($this->current_object->getId() ,
841 0,
842 $this->current_object->getType());
843 }
844 }
845 }
846 else
847 {
848 // type qpl or tst
849 $this->md = new ilMD($this->content_object->getId() ,
850 0,
851 $this->current_object->getType()
852 );
853 if ($this->md->getGeneral() != false)
854 {
855 $this->metadata_parsing_disabled = true;
856 $this->enableMDParsing(false);
857 }
858 }
859 }
860 break;
861
862 // Identifier
863 case "Identifier":
864
865 // begin-patch optes_lok_export
866 if($this->in_meta_data && $this->current_object instanceof ilStructureObject)
867 {
868 if($this->mapping instanceof ilImportMapping)
869 {
870 $import_id_parsed = ilUtil::parseImportId($a_attribs['Entry']);
871 if($import_id_parsed['type'] == 'st')
872 {
873 $this->mapping->addMapping(
874 'Modules/LearningModule',
875 'lm_tree',
876 $import_id_parsed['id'],
877 $this->current_object->getId()
878 );
879 }
880 }
881 }
882 // end-patch optes_lok_export
883
884 // please note: Meta-Metadata and MetaData are different tags!
885 if (!$this->in_meta_meta_data)
886 {
887 if ($this->in_meta_data && !$this->in_glossary_definition)
888 {
889 if (!$this->in_media_object)
890 {
891 $this->current_object->setImportId($a_attribs["Entry"]);
892 }
893 $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
894 }
895 if ($this->in_file_item)
896 {
897 if ($this->file_item_mapping[$a_attribs["Entry"]] == "")
898 {
899 $this->file_item->create();
900 $this->file_item->setImportId($a_attribs["Entry"]);
901 $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
902 }
903 }
904 if ($this->in_meta_data && $this->in_media_object)
905 {
906//echo "looking for -".$a_attribs["Entry"]."-<br>";
907
908 $mob_id = $this->mob_mapping[$a_attribs["Entry"]];
909
910 // within learning module import, usually a media object
911 // has already been created with a media alias tag
912 if ($mob_id > 0)
913 {
914 $this->media_object = new ilObjMediaObject($mob_id);
915 }
916 else // in glossaries the media objects precede the definitions
917 // so we don't have an object already
918 {
919 $this->media_object = new ilObjMediaObject();
920 $this->media_object->create(true, false);
921 $this->mob_mapping[$a_attribs["Entry"]]
922 = $this->media_object->getId();
923 }
924 $this->media_object->setImportId($a_attribs["Entry"]);
925 $this->md = new ilMD(0 ,
926 $this->media_object->getId(),
927 "mob");
928 $this->emptyMediaMetaCache($a_xml_parser);
929 }
930 }
931 break;
932
933 case "Meta-Metadata":
934 $this->in_meta_meta_data = true;
935 break;
936
937 // Internal Link
938 case "IntLink":
939 if (is_object($this->page_object))
940 {
941 $this->page_object->setContainsIntLink(true);
942 }
943 if ($this->in_map_area)
944 {
945//echo "intlink:maparea:<br>";
946 $this->map_area->setLinkType(IL_INT_LINK);
947 $this->map_area->setTarget($a_attribs["Target"]);
948 $this->map_area->setType($a_attribs["Type"]);
949 $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
950 if (is_object($this->media_object))
951 {
952//echo ":setContainsLink:<br>";
953 $this->media_object->setContainsIntLink(true);
954 }
955 }
956 break;
957
958 // External Link
959 case "ExtLink":
960 if ($this->in_map_area)
961 {
962 $this->map_area->setLinkType(IL_EXT_LINK);
963 $this->map_area->setHref($a_attribs["Href"]);
964 $this->map_area->setExtTitle($a_attribs["Title"]);
965 }
966 break;
967
968 // Question
969 case "Question":
970 $this->cur_qid = $a_attribs["QRef"];
971 $this->page_object->setContainsQuestion(true);
972 break;
973
974 case "Location":
975 $this->loc_type = $a_attribs["Type"];
976 break;
977
978 case "Bibliography":
979 $this->in_bib_item = true;
980//echo "<br>---NEW BIBLIOGRAPHY---<br>";
981 $this->bib_item = new ilBibItem();
982 break;
983
984 }
985 $this->beginElement($a_name);
986
987 // append content to page xml content
988 if(($this->in_page_object || $this->in_glossary_definition)
989 && !$this->in_meta_data && !$this->in_media_object)
990 {
991 if ($a_name == "Definition")
992 {
993 $app_name = "PageObject";
994 $app_attribs = array();
995 }
996 else
997 {
998 $app_name = $a_name;
999 $app_attribs = $a_attribs;
1000 }
1001
1002 // change identifier entry of file items to new local file id
1003 if ($this->in_file_item && $app_name == "Identifier")
1004 {
1005 $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]];
1006 //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
1007 }
1008
1009 $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
1010//echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
1011 }
1012
1013 // append content to bibitem xml content
1014 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
1015 {
1016 $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs));
1017 }
1018
1019 // call meta data handler
1020 if ($this->in_meta_data && $this->processMeta())
1021 {
1022 // cache beginning of meta data within media object tags
1023 // (we need to know the id at the begin of meta elements within
1024 // media objects, after the "Identifier" tag has been processed
1025 // we send the cached data to the meta xml handler)
1026 if ($this->in_media_object && $this->media_meta_start)
1027 {
1028 $this->media_meta_cache[] =
1029 array("type" => "handlerBeginTag", "par1" => $a_name, "par2" => $a_attribs);
1030 }
1031 else
1032 {
1033 if ($a_name == "Identifier")
1034 {
1035 if (!$this->in_media_object)
1036 {
1037 $a_attribs["Entry"] = "il__".$this->current_object->getType().
1038 "_".$this->current_object->getId();
1039 }
1040 else
1041 {
1042 $a_attribs["Entry"] = "il__mob".
1043 "_".$this->media_object->getId();
1044 }
1045 $a_attribs["Catalog"] = "ILIAS";
1046 }
1047
1048 parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
1049 }
1050 }
1051 }
$_GET["client_id"]
const IL_INT_LINK
const IL_EXT_LINK
Question page object.
Class ilBibItem.
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
processMeta()
check whether meta data should be processed
Glossary definition page object.
Class ilGlossaryDefinition.
Class ilGlossaryTerm.
Class ilLMPageObject.
Extension of ilPageObject for learning modules.
enableMDParsing($a_status)
Class ilMapArea.
Class ilMediaItem.
Class ilObjGlossary.
Class ilObjMediaObject.
Class ilStructreObject.
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 yn2tf($a_yn)
convert "y"/"n" to true/false

References $_GET, $content_object, $glossary_object, $lm_page_object, beginElement(), buildTag(), emptyMediaMetaCache(), ilMDSaxParser\enableMDParsing(), IL_EXT_LINK, IL_INT_LINK, ilUtil\parseImportId(), processMeta(), and ilUtil\yn2tf().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilContObjParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

Reimplemented from ilMDSaxParser.

Definition at line 1627 of file class.ilContObjParser.php.

1628 {
1629 // call meta data handler
1630 if ($this->in_meta_data && $this->processMeta())
1631 {
1632 // cache beginning of meta data within media object tags
1633 // (we need to know the id, after that we send the cached data
1634 // to the meta xml handler)
1635 if ($this->in_media_object && $this->media_meta_start)
1636 {
1637 $this->media_meta_cache[] =
1638 array("type" => "handlerCharacterData", "par1" => $a_data);
1639 }
1640 else
1641 {
1642 parent::handlerCharacterData($a_xml_parser,$a_data);
1643 }
1644 }
1645
1646 // the parser converts "&gt;" to ">" and "&lt;" to "<"
1647 // in character data, but we don't want that, because it's the
1648 // way we mask user html in our content, so we convert back...
1649
1650 $a_data = str_replace("<","&lt;",$a_data);
1651 $a_data = str_replace(">","&gt;",$a_data);
1652
1653
1654 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1655 $a_data = preg_replace("/\n/","",$a_data);
1656 if (!$this->inside_code)
1657 {
1658 $a_data = preg_replace("/\t+/","",$a_data);
1659 }
1660
1661 $this->chr_data .= $a_data;
1662
1663 if(!empty($a_data) || $a_data === "0")
1664 {
1665 // append all data to page, if we are within PageObject,
1666 // but not within MetaData or MediaObject
1667 if (($this->in_page_object || $this->in_glossary_definition)
1668 && !$this->in_meta_data && !$this->in_media_object)
1669 {
1670 $this->page_object->appendXMLContent($a_data);
1671 }
1672
1673 if ($this->in_meta_data)
1674 {
1675 //$this->meta_data->appendXMLContent($a_data);
1676//echo "<br>".$a_data;
1677 }
1678
1679 if ($this->in_bib_item )
1680 {
1681 $this->bib_item->appendXMLContent($a_data);
1682 }
1683
1684 switch($this->getCurrentElement())
1685 {
1686
1687 case "IntLink":
1688 case "ExtLink":
1689 if($this->in_map_area)
1690 {
1691 $this->map_area->appendTitle($a_data);
1692 }
1693 break;
1694
1695 }
1696 }
1697
1698 }

References getCurrentElement(), and processMeta().

+ Here is the call graph for this function:

◆ handlerEndTag()

ilContObjParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

Reimplemented from ilMDSaxParser.

Definition at line 1077 of file class.ilContObjParser.php.

1078 {
1079 // call meta data handler
1080 if ($this->in_meta_data && $this->processMeta())
1081 {
1082 // cache beginning of meta data within media object tags
1083 // (we need to know the id, after that we send the cached data
1084 // to the meta xml handler)
1085 if ($this->in_media_object && $this->media_meta_start)
1086 {
1087 $this->media_meta_cache[] =
1088 array("type" => "handlerEndTag", "par1" => $a_name);
1089 }
1090 else
1091 {
1092 parent::handlerEndTag($a_xml_parser,$a_name);
1093 }
1094 }
1095
1096//echo "<b>END TAG: $a_name <br></b>"; flush();
1097 // append content to page xml content
1098 if (($this->in_page_object || $this->in_glossary_definition)
1099 && !$this->in_meta_data && !$this->in_media_object)
1100 {
1101 $app_name = ($a_name == "Definition")
1102 ? "PageObject"
1103 : $a_name;
1104 $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
1105 }
1106
1107 // append content to bibitemxml content
1108 if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object
1109 {
1110 if($a_name == "BibItem")
1111 {
1112 $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name));
1113 }
1114 else
1115 {
1116 $this->bib_item->appendXMLContent($this->buildTag("end", $a_name));
1117 }
1118
1119 }
1120
1121 switch($a_name)
1122 {
1123 case "StructureObject":
1124 //unset($this->meta_data);
1125 unset($this->structure_objects[count($this->structure_objects) - 1]);
1126 break;
1127
1128 case "PageObject":
1129
1130 $this->in_page_object = false;
1131 if (($this->coType != "tst") and ($this->coType != "qpl"))
1132 {
1133 if (!$this->lm_page_object->isAlias())
1134 {
1135 //$this->page_object->createFromXML();
1136 $this->page_object->updateFromXML();
1137 $this->pg_mapping[$this->lm_page_object->getImportId()]
1138 = $this->lm_page_object->getId();
1139
1140 if($this->mapping instanceof ilImportMapping)
1141 {
1142 $import_id_parsed = ilUtil::parseImportId($this->lm_page_object->getImportId());
1143 if($import_id_parsed['type'] == 'pg')
1144 {
1145 $this->mapping->addMapping(
1146 'Modules/LearningModule',
1147 'pg',
1148 $import_id_parsed['id'],
1149 $this->lm_page_object->getId()
1150 );
1151 }
1152
1153 }
1154
1155 // collect pages with internal links
1156 if ($this->page_object->containsIntLink())
1157 {
1158 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1159 }
1160
1161 // collect pages with mobs or files
1162 if ($this->page_object->needsImportParsing())
1163 {
1164 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1165 }
1166
1167 // collect pages with questions
1168 if ($this->page_object->getContainsQuestion())
1169 {
1170 $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId();
1171 }
1172
1173 }
1174 }
1175 else
1176 {
1177 $xml = $this->page_object->getXMLContent();
1178 if ($this->cur_qid != "")
1179 {
1180 $ids = $this->qst_mapping[$this->cur_qid];
1181 if ($ids["pool"] > 0)
1182 {
1183 // question pool question
1184 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1185 $page = new ilAssQuestionPage($ids["pool"]);
1186 $xmlcontent = str_replace($this->cur_qid,
1187 "il__qst_".$ids["pool"], $xml);
1188 $page->setXMLContent($xmlcontent);
1189 $page->updateFromXML();
1190 if( $this->page_object->needsImportParsing() )
1191 {
1192 $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1193 }
1194 unset($page);
1195 }
1196 if ($ids["test"] > 0)
1197 {
1198 // test question
1199 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1200 $page = new ilAssQuestionPage($ids["test"]);
1201 $xmlcontent = str_replace($this->cur_qid,
1202 "il__qst_".$ids["test"], $xml);
1203 $page->setXMLContent($xmlcontent);
1204 $page->updateFromXML();
1205 if( $this->page_object->needsImportParsing() )
1206 {
1207 $this->pages_to_parse["qpl:".$page->getId()] = "qpl:".$page->getId();
1208 }
1209 unset($page);
1210 }
1211 }
1212 }
1213
1214 // if we are within a structure object: put page in tree
1215 $cnt = count($this->structure_objects);
1216//echo "1";
1217 if ($cnt > 0)
1218 {
1219//echo "B-$cnt-<br>";
1220//echo "<br>"; var_dump($this->structure_objects); echo "<br>";
1221 $parent_id = $this->structure_objects[$cnt - 1]->getId();
1222 if ($this->lm_page_object->isAlias())
1223 {
1224//echo "3";
1225 $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
1226//echo "<br>"; var_dump($this->pg_into_tree); echo "<br>";
1227 }
1228 else
1229 {
1230//echo "4";
1231 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
1232 }
1233 }
1234
1235 unset($this->page_object);
1236 unset($this->lm_page_object);
1237 unset ($this->container[count($this->container) - 1]);
1238 break;
1239
1240 case "MediaObject":
1241 $this->in_media_object = false;
1242case "InteractiveImage":
1243
1244//echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
1245 // create media object on first occurence of an Id
1246
1247
1248 if(empty($this->mob_mapping[$this->media_object->getImportId()]))
1249 {
1250//echo "No mapping found --creating media object:title:".$this->media_object->getTitle().":<br>";
1251
1252 // create media object
1253 // media items are saves for mobs outside of
1254 // pages only
1255 $this->media_object->create(true, false);
1256
1257//echo "<br>creating mob ".$this->media_object->getId().":".$this->media_object->getTitle().":";
1258
1259 // collect mobs with internal links
1260 if ($this->media_object->containsIntLink())
1261 {
1262//echo "got int link :".$this->media_object->getId().":<br>";
1263 $this->mobs_with_int_links[] = $this->media_object->getId();
1264 }
1265
1266 $this->mob_mapping[$this->media_object->getImportId()]
1267 = $this->media_object->getId();
1268//echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
1269 }
1270 else
1271 {
1272//echo "Mapping found<br>";
1273 // get the id from mapping
1274 $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
1275
1276 // update "real" (no alias) media object
1277 // (note: we overwrite any data from the media object
1278 // created by an MediaAlias, only the data of the real
1279 // object is stored in db separately; data of the
1280 // MediaAliases are within the page XML
1281 if (!$this->media_object->isAlias())
1282 {
1283 // now the media items are saved within the db
1284 $this->media_object->update();
1285
1286//echo "<br>update media object :".$this->media_object->getId().":";
1287
1288 // collect mobs with internal links
1289 if ($this->media_object->containsIntLink())
1290 {
1291//echo "got int link :".$this->media_object->getId().":<br>";
1292 $this->mobs_with_int_links[] = $this->media_object->getId();
1293 }
1294 }
1295 }
1296
1297 // append media alias to page, if we are in a page
1298 if ($this->in_page_object || $this->in_glossary_definition)
1299 {
1300 if ($a_name != "InteractiveImage")
1301 {
1302 $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
1303//echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
1304 }
1305 }
1306
1307 break;
1308
1309 case "MediaItem":
1310 case "MediaAliasItem":
1311 $this->in_media_item = false;
1312 $this->media_object->addMediaItem($this->media_item);
1313//echo "adding media item -".$this->media_item->getId()."-".$this->media_item->getLocation()."- to object -".$this->media_object->getId()."-";
1314 break;
1315
1316 case "MapArea":
1317 $this->in_map_area = false;
1318 $this->media_item->addMapArea($this->map_area);
1319 break;
1320
1321 case "Properties":
1322 $this->in_properties = false;
1323 if ($this->content_object->getType() == "lm"
1324 || $this->content_object->getType() == "dbk")
1325 {
1326 $this->content_object->update();
1327 }
1328 break;
1329
1330 case "MetaData":
1331 $this->in_meta_data = false;
1332 if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object)
1333 {
1334 // Metadaten eines PageObjects sichern in NestedSet
1335 if (is_object($this->lm_page_object))
1336 {
1337 // update title/description of page object
1338 $this->current_object->MDUpdateListener('General');
1339 ilLMObject::_writeImportId($this->current_object->getId(),
1340 $this->current_object->getImportId());
1341 }
1342 }
1343 else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
1344 strtolower(get_class($this->current_object)) == "ilobjtest") &&
1345 !$this->in_media_object)
1346// !$this->in_media_object && !$this->in_page_object)
1347// changed for imports of ILIAS 2 Tests where PageObjects could have
1348// Metadata sections (Helmut Schottmüller, 2005-12-02)
1349 {
1350 if ($this->metadata_parsing_disabled)
1351 {
1352 $this->enableMDParsing(true);
1353 }
1354 else
1355 {
1356 if ($this->in_page_object)
1357 {
1358 $this->page_object->MDUpdateListener('General');
1359 ilLMObject::_writeImportId($this->page_object->getId(),
1360 $this->page_object->getImportId());
1361 }
1362 else
1363 {
1364 $this->current_object->MDUpdateListener('General');
1365 ilLMObject::_writeImportId($this->current_object->getId(),
1366 $this->current_object->getImportId());
1367 }
1368 }
1369 }
1370 else if(strtolower(get_class($this->current_object)) == "ilstructureobject")
1371 { // save structure object at the end of its meta block
1372 // determine parent
1373 $cnt = count($this->structure_objects);
1374 if ($cnt > 1)
1375 {
1376 $parent_id = $this->structure_objects[$cnt - 2]->getId();
1377 }
1378 else
1379 {
1380 $parent_id = $this->lm_tree->getRootId();
1381 }
1382
1383 // create structure object and put it in tree
1384 //$this->current_object->create(true); // now on top
1385 $this->st_into_tree[] = array ("id" => $this->current_object->getId(),
1386 "parent" => $parent_id);
1387
1388 // update title/description of structure object
1389 $this->current_object->MDUpdateListener('General');
1390 ilLMObject::_writeImportId($this->current_object->getId(),
1391 $this->current_object->getImportId());
1392 }
1393 else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1394 strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
1395 (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary))
1396 {
1397 // todo: saving of md? getting title/descr and
1398 // set it for current object
1399 }
1400 else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object)
1401 {
1402 // now on top
1403 //$this->glossary_definition->create();
1404
1405 $this->page_object->setId($this->glossary_definition->getId());
1406 $this->page_object->updateFromXML();
1407
1408 // todo: saving of md? getting title/descr and
1409 // set it for current object
1410 }
1411
1412
1413 if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1414 strtolower(get_class($this->current_object)) == "ilobjdlbook" ||
1415 strtolower(get_class($this->current_object)) == "ilobjglossary")
1416 {
1417 if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
1418 $this->content_object->getType() != "glo")
1419 {
1420//echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
1421 $this->current_object->setTitle($this->content_object->getTitle()." - ".
1422 $this->lng->txt("glossary"));
1423 }
1424
1425 $this->current_object->MDUpdateListener('General');
1426 /*
1427 if (!$this->in_media_object && $this->processMeta())
1428 {
1429 $this->current_object->update();
1430 }
1431 */
1432 }
1433
1434 if ($this->in_media_object)
1435 {
1436//echo "<br>call media object update listener";
1437 $this->media_object->MDUpdateListener('General');
1438 }
1439
1440 if ($this->in_glossary_definition)
1441 {
1442 $this->glossary_definition->MDUpdateListener('General');
1443 }
1444
1445 break;
1446
1447 case "Meta-Metadata":
1448 $this->in_meta_meta_data = false;
1449 break;
1450
1451 case "FileItem":
1452 $this->in_file_item = false;
1453 // only update new file items
1454 if ($this->file_item->getImportId($a_attribs["Entry"] != ""))
1455 {
1456 $this->file_item->update();
1457 }
1458 break;
1459
1460 case "Bibliography":
1461
1462 $this->in_bib_item = false;
1463
1464 $nested = new ilNestedSetXML();
1465 $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib");
1466 break;
1467
1468 case "Table":
1469 unset ($this->container[count($this->container) - 1]);
1470 break;
1471
1472 case "Glossary":
1473 $this->in_glossary = false;
1474 break;
1475
1476 case "GlossaryTerm":
1477 $term = trim($this->chr_data);
1478 $term = str_replace("&lt;", "<", $term);
1479 $term = str_replace("&gt;", ">", $term);
1480 $this->glossary_term->setTerm($term);
1481 $this->glossary_term->create();
1482 $iia = explode("_", $this->glossary_term->getImportId());
1483 $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1484 break;
1485
1486 case "Paragraph":
1487 $this->inside_code = false;
1488 break;
1489
1490 case "Definition":
1491 $this->in_glossary_definition = false;
1492 $this->page_object->updateFromXML();
1493//echo "&nbsp;&nbsp;after def update, xml:".htmlentities($this->page_object->getXMLContent()).":<br>";
1494//echo "<br>".$this->page_object->getId()."-".$this->page_object->getParentType()."-";
1495 $this->page_object->buildDom();
1496 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
1497 $this->glossary_definition->update();
1498 //$this->pg_mapping[$this->lm_page_object->getImportId()]
1499 // = $this->lm_page_object->getId();
1500 if ($this->page_object->containsIntLink())
1501 {
1502//echo "<br>Definition contains Int Link:".$this->page_object->getId();
1503 $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1504 }
1505 if ($this->page_object->needsImportParsing())
1506 {
1507 $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId();
1508 }
1509 break;
1510
1511 case "Format":
1512 if ($this->in_media_item)
1513 {
1514 $this->media_item->setFormat(trim($this->chr_data));
1515 }
1516 if ($this->in_file_item)
1517 {
1518 $this->file_item->setFileType(trim($this->chr_data));
1519 }
1520 break;
1521
1522 case "Title":
1523 if (!$this->in_media_object)
1524 {
1525 $this->current_object->setTitle(trim($this->chr_data));
1526 //$this->meta_data->setTitle(trim($this->chr_data));
1527 }
1528 else
1529 {
1530 $this->media_object->setTitle(trim($this->chr_data));
1531 //$this->meta_data->setTitle(trim($this->chr_data));
1532 }
1533 break;
1534
1535 case "Language":
1536 /*
1537 if (is_object($this->meta_data))
1538 {
1539 $this->meta_data->setLanguage(trim($this->chr_data));
1540 }*/
1541
1542 if (is_object($this->bib_item))
1543 {
1544 $this->bib_item->setLanguage(trim($this->chr_data));
1545 }
1546 break;
1547
1548 case "Description":
1549 //$this->meta_data->setDescription(trim($this->chr_data));
1550 break;
1551
1552 case "Caption":
1553 if ($this->in_media_object)
1554 {
1555 $this->media_item->setCaption(trim($this->chr_data));
1556 }
1557 break;
1558
1559 case "TextRepresentation":
1560 if ($this->in_media_object)
1561 {
1562 $this->media_item->setTextRepresentation(trim($this->chr_data));
1563 }
1564 break;
1565
1566 // Location
1567 case "Location":
1568 // TODO: adapt for files in "real" subdirectories
1569 if ($this->in_media_item)
1570 {
1571 $this->media_item->setLocationType($this->loc_type);
1572 if ($this->loc_type == "Reference")
1573 {
1574 $this->media_item->setLocation(str_replace("&", "&amp;", trim($this->chr_data)));
1575 }
1576 else
1577 {
1578 $this->media_item->setLocation(trim($this->chr_data));
1579 }
1580 //echo "-".$this->media_item->getLocation()."-";
1581 }
1582 if ($this->in_file_item)
1583 {
1584 // set file name from xml file
1585 $this->file_item->setFileName(trim($this->chr_data));
1586
1587 // special handling for file names with special characters
1588 // (e.g. "&gt;")
1589 if ($this->file_item->getType() == "file" &&
1590 is_int(strpos($this->chr_data, "&")) &&
1591 is_int(strpos($this->chr_data, ";")))
1592 {
1593 $imp_dir = $this->import_dir;
1594 $source_dir = $imp_dir."/".$this->subdir."/objects/".
1595 $this->file_item->getImportId();
1596
1597 // read "physical" file name from directory
1598 if ($dir = opendir($source_dir))
1599 {
1600 while (false !== ($file = readdir($dir)))
1601 {
1602 if ($file != "." && $file != "..")
1603 {
1604 $this->file_item->setFileName($file);
1605 }
1606 }
1607 closedir($dir);
1608 }
1609 }
1610
1611 // set file item title
1612 $this->file_item->setTitle(trim($this->chr_data));
1613 }
1614 break;
1615
1616 }
1617 $this->endElement($a_name);
1618 $this->chr_data = "";
1619 }
print $file
const IL_MODE_ALIAS
_writeImportId($a_id, $a_import_id)
write import id to db (static)
Class NestedSetXML functions for storing XML-Data into nested-set-database-strcture.

References $cnt, $file, ilLMObject\_writeImportId(), buildTag(), ilMDSaxParser\enableMDParsing(), endElement(), IL_MODE_ALIAS, ilUtil\parseImportId(), and processMeta().

+ Here is the call graph for this function:

◆ ilContObjParser()

ilContObjParser::ilContObjParser ( $a_content_object,
  $a_xml_file,
  $a_subdir,
  $a_import_dir = "" 
)

Constructor.

Parameters
object$a_content_objectmust be of type ilObjContentObject ilObjTest or ilObjQuestionPool
string$a_xml_filexml file
string$a_subdirsubdirectory in import directory @access public

Definition at line 90 of file class.ilContObjParser.php.

91 {
92 global $lng, $tree;
93
94 $this->log = ilLoggerFactory::getLogger('lm');
95
96 $this->import_dir = ($a_import_dir != "")
97 ? $a_import_dir
98 : $a_content_object->getImportDirectory();
99
100 parent::ilMDSaxParser($a_xml_file);
101 $this->cnt = array();
102 $this->current_element = array();
103 $this->structure_objects = array();
104 $this->content_object = $a_content_object;
105 //$this->lm_id = $a_lm_id;
106 $this->st_into_tree = array();
107 $this->pg_into_tree = array();
108 $this->pages_to_parse = array();
109 $this->mobs_with_int_links = array();
110 $this->mob_mapping = array();
111 $this->file_item_mapping = array();
112 $this->pg_mapping = array();
113 $this->link_targets = array();
114 $this->subdir = $a_subdir;
115 $this->lng = $lng;
116 $this->tree = $tree;
117 $this->inside_code = false;
118 $this->qst_mapping = array();
119 $this->coType = $this->content_object->getType();
120 $this->metadata_parsing_disabled = false;
121
122 if (($this->coType != "tst") and ($this->coType != "qpl"))
123 {
124 $this->lm_tree = new ilTree($this->content_object->getId());
125 $this->lm_tree->setTreeTablePK("lm_id");
126 $this->lm_tree->setTableNames('lm_tree','lm_data');
127 }
128 //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI
129
130 }
static getLogger($a_component_id)
Get component logger.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...

References $lng, $tree, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ processMeta()

ilContObjParser::processMeta ( )

check whether meta data should be processed

Definition at line 1056 of file class.ilContObjParser.php.

1057 {
1058 // do not process second meta block in (ilias3) glossaries
1059 // which comes right after the "Glossary" tag
1060 if ($this->content_object->getType() == "glo" &&
1061 $this->in_glossary && !$this->in_media_object
1062 && !$this->in_glossary_definition)
1063 {
1064 return false;
1065 }
1066
1067 return true;
1068 }

Referenced by handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ processPagesToParse()

ilContObjParser::processPagesToParse ( )

parse pages that contain files, mobs and/or internal links

Definition at line 228 of file class.ilContObjParser.php.

229 {
230 /*
231 $pg_mapping = array();
232 foreach($this->pg_mapping as $key => $value)
233 {
234 $pg_mapping[$key] = "il__pg_".$value;
235 }*/
236//echo "<br><b>processIntLinks</b>"; flush();
237
238 // outgoin internal links
239 foreach($this->pages_to_parse as $page_id)
240 {
241 $page_arr = explode(":", $page_id);
242//echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
243 switch($page_arr[0])
244 {
245 case "lm":
246 switch ($this->content_object->getType())
247 {
248 case "lm":
249 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
250 $page_obj = new ilLMPage($page_arr[1]);
251 break;
252
253 default:
254 die("Unknown content type ".$this->content_object->getType());
255 }
256
257 break;
258
259 case "gdf":
260 include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
261 $page_obj = new ilGlossaryDefPage($page_arr[1]);
262 break;
263
264 case "qpl":
265 $page_obj = new ilAssQuestionPage($page_arr[1]);
266 break;
267 }
268 $page_obj->buildDom();
269 $page_obj->resolveIntLinks();
270 $page_obj->resolveIIMMediaAliases($this->mob_mapping);
271 if (in_array($this->coType, array("lm", "dbk")))
272 {
273 $page_obj->resolveQuestionReferences($this->qst_mapping);
274 }
275 $page_obj->update(false);
276
277 if ($page_arr[0] == "gdf")
278 {
279 $def = new ilGlossaryDefinition($page_arr[1]);
280 $def->updateShortText();
281 }
282
283 unset($page_obj);
284 }
285
286//echo "<br><b>map area internal links</b>"; flush();
287 // outgoins map area (mob) internal links
288 foreach($this->mobs_with_int_links as $mob_id)
289 {
291 }
292
293//echo "<br><b>incoming interna links</b>"; flush();
294 // incoming internal links
295 $done = array();
296 foreach ($this->link_targets as $link_target)
297 {
298//echo "doin link target:".$link_target.":<br>";
299 $link_arr = explode("_", $link_target);
300 $target_inst = $link_arr[1];
301 $target_type = $link_arr[2];
302 $target_id = $link_arr[3];
303//echo "<br>-".$target_type."-".$target_id."-".$target_inst."-";
305 foreach($sources as $key => $source)
306 {
307//echo "got source:".$key.":<br>";
308 if(in_array($key, $done))
309 {
310 continue;
311 }
312 $type_arr = explode(":", $source["type"]);
313
314 // content object pages
315 if ($type_arr[1] == "pg")
316 {
317 if (ilPageObject::_exists($type_arr[0],$source["id"]))
318 {
319 include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
320 $page_object = ilPageObjectFactory::getInstance($type_arr[0], $source["id"]);
321 $page_object->buildDom();
322 $page_object->resolveIntLinks();
323 $page_object->update();
324 unset($page_object);
325 }
326 }
327
328 // eventually correct links in questions to learning modules
329 if ($type_arr[0] == "qst")
330 {
331 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
332 assQuestion::_resolveIntLinks($source["id"]);
333 }
334 // eventually correct links in survey questions to learning modules
335 if ($type_arr[0] == "sqst")
336 {
337 require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
339 }
340 $done[$key] = $key;
341 }
342 }
343 }
_resolveIntLinks($question_id)
_resolveIntLinks($question_id)
_resolveMapAreaLinks($a_mob_id)
resolve internal links of all media items of a media object
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.
$target_id
Definition: goto.php:88
$target_type
Definition: goto.php:87

References $page_object, $target_id, $target_type, ilPageObject\_exists(), ilInternalLink\_getSourcesOfTarget(), SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), ilMediaItem\_resolveMapAreaLinks(), and ilPageObjectFactory\getInstance().

Referenced by startParsing().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilContObjParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser @access private

Reimplemented from ilMDSaxParser.

Definition at line 138 of file class.ilContObjParser.php.

139 {
140 xml_set_object($a_xml_parser,$this);
141 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
142 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
143 }

◆ setImportMapping()

ilContObjParser::setImportMapping ( ilImportMapping  $mapping = null)

Set import mapping.

Parameters
ilImportMapping$mapping

Definition at line 149 of file class.ilContObjParser.php.

150 {
151 $this->mapping = $mapping;
152 }

◆ setQuestionMapping()

ilContObjParser::setQuestionMapping (   $a_map)

set question import ident to pool/test question id mapping

Definition at line 428 of file class.ilContObjParser.php.

429 {
430 $this->qst_mapping = $a_map;
431 }

◆ startParsing()

ilContObjParser::startParsing ( )

start parser

Reimplemented from ilSaxParser.

Definition at line 158 of file class.ilContObjParser.php.

159 {
160 $this->log->debug("start");
161
162//echo "<b>start parsing</b><br>";
163 parent::startParsing();
164//echo "<b>storeTree</b><br>";
165 $this->storeTree();
166//echo "<b>processPagesToParse</b><br>";
167 $this->processPagesToParse();
168//echo "<b>copyMobFiles</b><br>";
169 $this->copyMobFiles();
170//echo "<b>copyFileItems</b><br>";
171 $this->copyFileItems();
172//echo "<br>END Parsing"; exit;
173 }
storeTree()
insert StructureObjects and PageObjects into tree
processPagesToParse()
parse pages that contain files, mobs and/or internal links
copyMobFiles()
copy multimedia object files from import zip file to mob directory
copyFileItems()
copy files of file items

References copyFileItems(), copyMobFiles(), processPagesToParse(), and storeTree().

+ Here is the call graph for this function:

◆ storeTree()

ilContObjParser::storeTree ( )

insert StructureObjects and PageObjects into tree

Definition at line 179 of file class.ilContObjParser.php.

180 {
181 global $ilLog;
182
183//echo "<b>Storing the tree</b><br>";
184 foreach($this->st_into_tree as $st)
185 {
186//echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>";
187 $this->lm_tree->insertNode($st["id"], $st["parent"]);
188//echo "done<br>";
189//var_dump($this->pg_into_tree[$st["id"]]);
190//echo "<br>";
191 if (is_array($this->pg_into_tree[$st["id"]]))
192 {
193 foreach($this->pg_into_tree[$st["id"]] as $pg)
194 {
195 switch ($pg["type"])
196 {
197 case "pg_alias":
198 if ($this->pg_mapping[$pg["id"]] == "")
199 {
200 $ilLog->write("LM Import: No PageObject for PageAlias ".
201 $pg["id"]." found! (Please update export installation to ILIAS 3.3.0)");
202
203 // Jump two levels up. First level is switch
204 continue 2;
205 }
206 $pg_id = $this->pg_mapping[$pg["id"]];
207 break;
208
209 case "pg":
210 $pg_id = $pg["id"];
211 break;
212 }
213 if (!$this->lm_tree->isInTree($pg_id))
214 {
215 $this->lm_tree->insertNode($pg_id, $st["id"]);
216 }
217 }
218 }
219 }
220//echo "<b>END: storing the tree</b>";
221//exit;
222 }

References $ilLog.

Referenced by startParsing().

+ Here is the caller graph for this function:

Field Documentation

◆ $bib_item

ilContObjParser::$bib_item

Definition at line 67 of file class.ilContObjParser.php.

◆ $cnt

ilContObjParser::$cnt

Definition at line 36 of file class.ilContObjParser.php.

Referenced by handlerEndTag().

◆ $container

ilContObjParser::$container

Definition at line 50 of file class.ilContObjParser.php.

◆ $content_object

ilContObjParser::$content_object

Definition at line 57 of file class.ilContObjParser.php.

Referenced by handlerBeginTag().

◆ $current_element

ilContObjParser::$current_element

Definition at line 37 of file class.ilContObjParser.php.

◆ $current_object

ilContObjParser::$current_object

Definition at line 43 of file class.ilContObjParser.php.

◆ $file_item

ilContObjParser::$file_item

Definition at line 59 of file class.ilContObjParser.php.

◆ $file_item_mapping

ilContObjParser::$file_item_mapping

Definition at line 63 of file class.ilContObjParser.php.

◆ $glossary_object

ilContObjParser::$glossary_object

Definition at line 58 of file class.ilContObjParser.php.

Referenced by handlerBeginTag().

◆ $glossary_term_map

ilContObjParser::$glossary_term_map = array()
protected

Definition at line 74 of file class.ilContObjParser.php.

Referenced by getGlossaryTermMap().

◆ $in_bib_item

ilContObjParser::$in_bib_item

Definition at line 69 of file class.ilContObjParser.php.

◆ $in_file_item

ilContObjParser::$in_file_item

Definition at line 54 of file class.ilContObjParser.php.

◆ $in_glossary

ilContObjParser::$in_glossary

Definition at line 55 of file class.ilContObjParser.php.

◆ $in_map_area

ilContObjParser::$in_map_area

Definition at line 56 of file class.ilContObjParser.php.

◆ $in_media_object

ilContObjParser::$in_media_object

Definition at line 53 of file class.ilContObjParser.php.

◆ $in_meta_data

ilContObjParser::$in_meta_data

Definition at line 52 of file class.ilContObjParser.php.

◆ $in_meta_meta_data

ilContObjParser::$in_meta_meta_data = false

Definition at line 73 of file class.ilContObjParser.php.

◆ $in_page_object

ilContObjParser::$in_page_object

Definition at line 51 of file class.ilContObjParser.php.

◆ $keyword_language

ilContObjParser::$keyword_language

Definition at line 60 of file class.ilContObjParser.php.

◆ $learning_module

ilContObjParser::$learning_module

Definition at line 38 of file class.ilContObjParser.php.

◆ $link_targets

ilContObjParser::$link_targets

Definition at line 70 of file class.ilContObjParser.php.

◆ $lm_page_object

ilContObjParser::$lm_page_object

Definition at line 40 of file class.ilContObjParser.php.

Referenced by handlerBeginTag().

◆ $lm_tree

ilContObjParser::$lm_tree

Definition at line 47 of file class.ilContObjParser.php.

◆ $lng

ilContObjParser::$lng

Definition at line 34 of file class.ilContObjParser.php.

Referenced by ilContObjParser().

◆ $loc_type

ilContObjParser::$loc_type

Definition at line 66 of file class.ilContObjParser.php.

◆ $log

ilContObjParser::$log
protected

Definition at line 79 of file class.ilContObjParser.php.

◆ $map_area

ilContObjParser::$map_area

Definition at line 68 of file class.ilContObjParser.php.

◆ $media_item

ilContObjParser::$media_item

Definition at line 65 of file class.ilContObjParser.php.

◆ $media_object

ilContObjParser::$media_object

Definition at line 42 of file class.ilContObjParser.php.

◆ $meta_data

ilContObjParser::$meta_data

Definition at line 44 of file class.ilContObjParser.php.

◆ $metadata_parsing_disabled

ilContObjParser::$metadata_parsing_disabled

Definition at line 72 of file class.ilContObjParser.php.

◆ $mob_mapping

ilContObjParser::$mob_mapping

Definition at line 62 of file class.ilContObjParser.php.

◆ $page_object

ilContObjParser::$page_object

Definition at line 39 of file class.ilContObjParser.php.

Referenced by processPagesToParse().

◆ $pages_to_parse

ilContObjParser::$pages_to_parse

Definition at line 61 of file class.ilContObjParser.php.

◆ $paragraph

ilContObjParser::$paragraph

Definition at line 45 of file class.ilContObjParser.php.

◆ $pg_into_tree

ilContObjParser::$pg_into_tree

Definition at line 48 of file class.ilContObjParser.php.

◆ $qst_mapping

ilContObjParser::$qst_mapping

Definition at line 71 of file class.ilContObjParser.php.

◆ $st_into_tree

ilContObjParser::$st_into_tree

Definition at line 49 of file class.ilContObjParser.php.

◆ $structure_objects

ilContObjParser::$structure_objects

Definition at line 41 of file class.ilContObjParser.php.

◆ $subdir

ilContObjParser::$subdir

Definition at line 64 of file class.ilContObjParser.php.

◆ $table

ilContObjParser::$table

Definition at line 46 of file class.ilContObjParser.php.

◆ $tree

ilContObjParser::$tree

Definition at line 35 of file class.ilContObjParser.php.

Referenced by ilContObjParser().


The documentation for this class was generated from the following file: