ILIAS  release_7 Revision v7.30-3-g800a261c036
ilContObjParser Class Reference

Content Object Parser. More...

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

Public Member Functions

 __construct (&$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
 __construct ($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 ()
 
 __construct ($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
 __construct ($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
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). 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...
 
 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
 
 $map_area
 
 $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
 
- Protected Attributes inherited from ilMDSaxParser
 $meta_log
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & 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...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- Protected Member Functions inherited from ilMDSaxParser
 trimAndStripAttribs (array $attribs)
 
 trimAndStrip (string $input)
 
- 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 13 of file class.ilContObjParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilContObjParser::__construct ( $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 69 of file class.ilContObjParser.php.

70 {
71 global $DIC;
72
73 $this->log = $DIC["ilLog"];
74 $lng = $DIC->language();
75 $tree = $DIC->repositoryTree();
76
77 $this->log = ilLoggerFactory::getLogger('lm');
78
79 $this->import_dir = ($a_import_dir != "")
80 ? $a_import_dir
81 : $a_content_object->getImportDirectory();
82
83 parent::__construct($a_xml_file);
84 $this->cnt = array();
85 $this->current_element = array();
86 $this->structure_objects = array();
87 $this->content_object = $a_content_object;
88 //$this->lm_id = $a_lm_id;
89 $this->st_into_tree = array();
90 $this->pg_into_tree = array();
91 $this->pages_to_parse = array();
92 $this->mobs_with_int_links = array();
93 $this->mob_mapping = array();
94 $this->file_item_mapping = array();
95 $this->pg_mapping = array();
96 $this->link_targets = array();
97 $this->subdir = $a_subdir;
98 $this->lng = $lng;
99 $this->tree = $tree;
100 $this->inside_code = false;
101 $this->qst_mapping = array();
102 $this->coType = $this->content_object->getType();
103 $this->metadata_parsing_disabled = false;
104
105 if (($this->coType != "tst") and ($this->coType != "qpl")) {
106 $this->lm_tree = new ilTree($this->content_object->getId());
107 $this->lm_tree->setTreeTablePK("lm_id");
108 $this->lm_tree->setTableNames('lm_tree', 'lm_data');
109 }
110 //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI
111 }
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...
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, $lng, $tree, ILIAS\GlobalScreen\Provider\__construct(), and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

Member Function Documentation

◆ beginElement()

ilContObjParser::beginElement (   $a_name)

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

386 {
387 if (!isset($this->status["$a_name"])) {
388 $this->cnt[$a_name] == 1;
389 } else {
390 $this->cnt[$a_name]++;
391 }
392 $this->current_element[count($this->current_element)] = $a_name;
393 }

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 435 of file class.ilContObjParser.php.

436 {
437 $tag = "<";
438
439 if ($type == "end") {
440 $tag .= "/";
441 }
442
443 $tag .= $name;
444
445 if (is_array($attr)) {
446 foreach ($attr as $k => $v) {
447 $tag .= " " . $k . "=\"$v\"";
448 }
449 }
450
451 $tag .= ">";
452
453 return $tag;
454 }
if($format !==null) $name
Definition: metadata.php:230
$type

References $name, and $type.

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ copyFileItems()

ilContObjParser::copyFileItems ( )

copy files of file items

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

347 {
348 $imp_dir = $this->import_dir;
349 foreach ($this->file_item_mapping as $origin_id => $file_id) {
350 if (empty($origin_id)) {
351 continue;
352 }
353 $obj_dir = $origin_id;
354 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
355
356 $file_obj = new ilObjFile($file_id, false);
357 //$target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
358 $target_dir = $file_obj->getDirectory($file_obj->getVersion());
359 if (@is_dir($source_dir)) {
360 // make target directory
361 ilUtil::makeDir($target_dir);
362 //@mkdir($target_dir);
363 //@chmod($target_dir, 0755);
364
365 if (@is_dir($target_dir)) {
366 ilUtil::rCopy(realpath($source_dir), realpath($target_dir));
367 }
368 }
369 $file_obj->update();
370 }
371 }
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 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 306 of file class.ilContObjParser.php.

307 {
308 $imp_dir = $this->import_dir;
309 foreach ($this->mob_mapping as $origin_id => $mob_id) {
310 if (empty($origin_id)) {
311 continue;
312 }
313
314 /*
315 $origin_arr = explode("_", $origin_id);
316 if ($origin_arr[2] == "el") // imagemap
317 {
318 $obj_dir = "imagemap".$origin_arr[3];
319 }
320 else // normal media object
321 {
322 $obj_dir = "mm".$origin_arr[3];
323 }*/
324
325 $obj_dir = $origin_id;
326 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
327 $target_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $mob_id;
328
329 if (@is_dir($source_dir)) {
330 // make target directory
331 ilUtil::makeDir($target_dir);
332 //@mkdir($target_dir);
333 //@chmod($target_dir, 0755);
334
335 if (@is_dir($target_dir)) {
336 ilLoggerFactory::getLogger("mob")->debug("s:-$source_dir-,t:-$target_dir-");
337 ilUtil::rCopy(realpath($source_dir), realpath($target_dir));
338 }
339 }
340 }
341 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References ilLoggerFactory\getLogger(), 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 1487 of file class.ilContObjParser.php.

1488 {
1489 foreach ($this->media_meta_cache as $cache_entry) {
1490 switch ($cache_entry["type"]) {
1491 case "handlerBeginTag":
1492 parent::handlerBeginTag(
1493 $a_xml_parser,
1494 $cache_entry["par1"],
1495 $cache_entry["par2"]
1496 );
1497 break;
1498
1499 case "handlerEndTag":
1500 parent::handlerEndTag(
1501 $a_xml_parser,
1502 $cache_entry["par1"]
1503 );
1504 break;
1505
1506 case "handlerCharacterData":
1507 parent::handlerCharacterData(
1508 $a_xml_parser,
1509 $cache_entry["par1"]
1510 );
1511 break;
1512 }
1513 }
1514
1515 $this->media_meta_start = false;
1516 $this->media_meta_cache[] = array();
1517 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ endElement()

ilContObjParser::endElement (   $a_name)

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

401 {
402 $this->cnt[$a_name]--;
403 unset($this->current_element[count($this->current_element) - 1]);
404 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getCurrentElement()

ilContObjParser::getCurrentElement ( )

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

410 {
411 return ($this->current_element[count($this->current_element) - 1]);
412 }

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 1525 of file class.ilContObjParser.php.

1526 {
1528 }

References $glossary_term_map.

◆ getOpenCount()

ilContObjParser::getOpenCount (   $a_name)

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

420 {
421 if (isset($this->cnt[$a_name])) {
422 return $this->cnt[$a_name];
423 } else {
424 return 0;
425 }
426 }

◆ 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 463 of file class.ilContObjParser.php.

464 {
465 //echo "<b>BEGIN TAG: $a_name <br></b>"; flush();
466 switch ($a_name) {
467 case "ContentObject":
468 $this->current_object = $this->content_object;
469//echo "<br>Parser:CObjType:".$a_attribs["Type"];
470 if ($a_attribs["Type"] == "Glossary") {
471 $this->glossary_object = $this->content_object;
472 }
473 break;
474
475 case "StructureObject":
476//echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>";
477 $this->structure_objects[count($this->structure_objects)]
478 = new ilStructureObject($this->content_object);
479 $this->current_object = $this->structure_objects[count($this->structure_objects) - 1];
480 $this->current_object->setLMId($this->content_object->getId());
481 // new meta data handling: we create the structure
482 // object already here, this should also create a
483 // md entry
484 $this->current_object->create(true);
485 break;
486
487 case "PageObject":
488 $this->in_page_object = true;
489 $this->cur_qid = "";
490 if (($this->coType != "tst") and ($this->coType != "qpl")) {
491 $this->lm_page_object = new ilLMPageObject($this->content_object);
492 $this->page_object = new ilLMPage();
493 $this->lm_page_object->setLMId($this->content_object->getId());
494 $this->lm_page_object->assignPageObject($this->page_object);
495 $this->current_object = $this->lm_page_object;
496 } else {
497 $this->page_object = new ilAssQuestionPage();
498 }
499 break;
500
501 case "PageAlias":
502 if (($this->coType != "tst") and ($this->coType != "qpl")) {
503 $this->lm_page_object->setAlias(true);
504 $this->lm_page_object->setOriginID($a_attribs["OriginId"]);
505 }
506 break;
507
508 case "MediaObject":
509 $this->in_media_object = true;
510 // no break
511 case "InteractiveImage":
512
513 $this->media_meta_start = true;
514 $this->media_meta_cache = array();
515 $this->media_object = new ilObjMediaObject();
516 break;
517
518 case "MediaAlias":
519//echo "<br>---NEW MEDIAALIAS---<br>";
520 $this->media_object->setAlias(true);
521 $this->media_object->setImportId($a_attribs["OriginId"]);
522 if (is_object($this->page_object)) {
523 $this->page_object->needsImportParsing(true);
524 }
525 break;
526
527 case "MediaItem":
528 case "MediaAliasItem":
529 $this->in_media_item = true;
530 $this->media_item = new ilMediaItem();
531 $this->media_item->setPurpose($a_attribs["Purpose"]);
532 /*if ($a_name == "MediaItem")
533 {
534 $this->media_item->setHighlightMode($a_attribs["MapHighlightMode"]);
535 $this->media_item->setHighlightClass($a_attribs["MapHighlightClass"]);
536 }*/
537 break;
538
539 case "Layout":
540 if (is_object($this->media_object) && $this->in_media_object) {
541 $this->media_item->setWidth($a_attribs["Width"]);
542 $this->media_item->setHeight($a_attribs["Height"]);
543 $this->media_item->setHAlign($a_attribs["HorizontalAlign"]);
544 }
545 break;
546
547 case "Parameter":
548 if (is_object($this->media_object) && $this->in_media_object) {
549 $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]);
550 }
551 break;
552
553 case "MapArea":
554 $this->in_map_area = true;
555 $this->map_area = new ilMapArea();
556 $this->map_area->setShape($a_attribs["Shape"]);
557 $this->map_area->setCoords($a_attribs["Coords"]);
558 $this->map_area->setHighlightMode($a_attribs["HighlightMode"]);
559 $this->map_area->setHighlightClass($a_attribs["HighlightClass"]);
560 break;
561
562 case "Glossary":
563 $this->in_glossary = true;
564 if ($this->content_object->getType() != "glo") {
565 $this->glossary_object = new ilObjGlossary();
566 $this->glossary_object->setTitle("");
567 $this->glossary_object->setDescription("");
568 $this->glossary_object->create(true);
569 $this->glossary_object->createReference();
570 $parent = $this->tree->getParentNodeData($this->content_object->getRefId());
571 $this->glossary_object->putInTree($parent["child"]);
572 $this->glossary_object->setPermissions($parent["child"]);
573 }
574 $this->current_object = $this->glossary_object;
575 break;
576
577 case "GlossaryItem":
578 $this->glossary_term = new ilGlossaryTerm();
579 $this->glossary_term->setGlossaryId($this->glossary_object->getId());
580 $this->glossary_term->setLanguage($a_attribs["Language"]);
581 $this->glossary_term->setImportId($a_attribs["Id"]);
582 $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"];
583 break;
584
585 case "Definition":
586 $this->in_glossary_definition = true;
587 $this->glossary_definition = new ilGlossaryDefinition();
588 $this->page_object = new ilGlossaryDefPage();
589 $this->page_object->setParentId($this->glossary_term->getGlossaryId());
590 $this->glossary_definition->setTermId($this->glossary_term->getId());
591 $this->glossary_definition->assignPageObject($this->page_object);
592 $this->current_object = $this->glossary_definition;
593 $this->glossary_definition->create(true);
594 // see bug #12465, we need to clear xml after creation, since it will be <PageObject></PageObject>
595 // otherwise, and appendXML calls will lead to "<PageObject></PageObject><PageObject>....</PageObject>"
596 $this->page_object->setXMLContent("");
597 break;
598
599 case "FileItem":
600 $this->in_file_item = true;
601 $this->file_item = new ilObjFile();
602 $this->file_item->setTitle("dummy");
603 $this->file_item->setMode("filelist");
604 if (is_object($this->page_object)) {
605 $this->page_object->needsImportParsing(true);
606 }
607 break;
608
609 case "Paragraph":
610 if ($a_attribs["Characteristic"] == "Code") {
611 $this->inside_code = true;
612 }
613 break;
614
615 case "Properties":
616 $this->in_properties = true;
617 break;
618
619 case "Property":
620 if ($this->content_object->getType() == "lm") {
621 switch ($a_attribs["Name"]) {
622 case "Layout":
623 $this->content_object->setLayout($a_attribs["Value"]);
624 break;
625
626 case "PageHeader":
627 $this->content_object->setPageHeader($a_attribs["Value"]);
628 break;
629
630 case "TOCMode":
631 $this->content_object->setTOCMode($a_attribs["Value"]);
632 break;
633
634 case "ActiveLMMenu":
635 $this->content_object->setActiveLMMenu(
636 ilUtil::yn2tf($a_attribs["Value"])
637 );
638 break;
639
640 case "ActiveNumbering":
641 $this->content_object->setActiveNumbering(
642 ilUtil::yn2tf($a_attribs["Value"])
643 );
644 break;
645
646 case "ActiveTOC":
647 $this->content_object->setActiveTOC(
648 ilUtil::yn2tf($a_attribs["Value"])
649 );
650 break;
651
652 case "ActivePrintView":
653 $this->content_object->setActivePrintView(
654 ilUtil::yn2tf($a_attribs["Value"])
655 );
656 break;
657
658 case "CleanFrames":
659 $this->content_object->setCleanFrames(
660 ilUtil::yn2tf($a_attribs["Value"])
661 );
662 break;
663
664 case "PublicNotes":
665 $this->content_object->setPublicNotes(
666 ilUtil::yn2tf($a_attribs["Value"])
667 );
668 break;
669
670 case "HistoryUserComments":
671 $this->content_object->setHistoryUserComments(
672 ilUtil::yn2tf($a_attribs["Value"])
673 );
674 break;
675
676 case "Rating":
677 $this->content_object->setRating(
678 ilUtil::yn2tf($a_attribs["Value"])
679 );
680 break;
681
682 case "RatingPages":
683 $this->content_object->setRatingPages(
684 ilUtil::yn2tf($a_attribs["Value"])
685 );
686 break;
687
688 case "HeaderPage":
689 if ($a_attribs["Value"] != "") {
690 if ($this->pg_mapping[$a_attribs["Value"]] > 0) {
691 $this->content_object->setHeaderPage(
692 $this->pg_mapping[$a_attribs["Value"]]
693 );
694 }
695 }
696 break;
697
698 case "FooterPage":
699 if ($a_attribs["Value"] != "") {
700 if ($this->pg_mapping[$a_attribs["Value"]] > 0) {
701 $this->content_object->setFooterPage(
702 $this->pg_mapping[$a_attribs["Value"]]
703 );
704 }
705 }
706 break;
707
708 case "LayoutPerPage":
709 $this->content_object->setLayoutPerPage($a_attribs["Value"]);
710 break;
711
712 case "ProgressIcons":
713 $this->content_object->setProgressIcons($a_attribs["Value"]);
714 break;
715
716 case "StoreTries":
717 $this->content_object->setStoreTries($a_attribs["Value"]);
718 break;
719
720 case "RestrictForwardNavigation":
721 $this->content_object->setRestrictForwardNavigation($a_attribs["Value"]);
722 break;
723
724 case "DisableDefaultFeedback":
725 $this->content_object->setDisableDefaultFeedback($a_attribs["Value"]);
726 break;
727
728 }
729 //echo "<br>+".$a_attribs["Name"]."+";
730 }
731 break;
732
736 case "MetaData":
737 $this->in_meta_data = true;
738//echo "<br>begin meta data section -".$this->current_object->getType()."-";
739 // media obejct meta data handling
740 // is done in the "Identifier" begin tag processing
741 // the rest is done here
742 if (!$this->in_media_object) {
743 if (($this->coType != "tst") and ($this->coType != "qpl")) {
744 // type pg/st
745 if ($this->current_object->getType() == "st" ||
746 $this->current_object->getType() == "pg") {
747 // late creation of page object
748 if ($this->current_object->getType() == "pg") {
749 $this->lm_page_object->create(true);
750 }
751 $this->md = new ilMD(
752 $this->content_object->getId(),
753 $this->current_object->getId(),
754 $this->current_object->getType()
755 );
756 }
757 // type gdf
758 elseif ($this->current_object->getType() == "gdf") {
759 $this->md = new ilMD(
760 $this->glossary_object->getId(),
761 $this->current_object->getId(),
762 $this->current_object->getType()
763 );
764 }
765 // type lm, dbk, glo
766 else {
767 if ($this->processMeta()) {
768 $this->md = new ilMD(
769 $this->current_object->getId(),
770 0,
771 $this->current_object->getType()
772 );
773 }
774 }
775 } else {
776 // type qpl or tst
777 $this->md = new ilMD(
778 $this->content_object->getId(),
779 0,
780 $this->current_object->getType()
781 );
782 if ($this->md->getGeneral() != false) {
783 $this->metadata_parsing_disabled = true;
784 $this->enableMDParsing(false);
785 }
786 }
787 }
788 break;
789
790 // Identifier
791 case "Identifier":
792
793 // begin-patch optes_lok_export
794 if ($this->in_meta_data && $this->current_object instanceof ilStructureObject) {
795 if ($this->mapping instanceof ilImportMapping) {
796 $import_id_parsed = ilUtil::parseImportId($a_attribs['Entry']);
797 if ($import_id_parsed['type'] == 'st') {
798 $this->mapping->addMapping(
799 'Modules/LearningModule',
800 'lm_tree',
801 $import_id_parsed['id'],
802 $this->current_object->getId()
803 );
804 }
805 }
806 }
807 // end-patch optes_lok_export
808
809 // please note: Meta-Metadata and MetaData are different tags!
810 if (!$this->in_meta_meta_data) {
811 if ($this->in_meta_data && !$this->in_glossary_definition) {
812 if (!$this->in_media_object) {
813 $this->current_object->setImportId($a_attribs["Entry"]);
814 }
815 $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"];
816 }
817 if ($this->in_file_item) {
818 if ($this->file_item_mapping[$a_attribs["Entry"]] == "") {
819 $this->file_item->create();
820 $this->file_item->setImportId($a_attribs["Entry"]);
821 $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId();
822 }
823 }
824 if ($this->in_meta_data && $this->in_media_object) {
825 //echo "looking for -".$a_attribs["Entry"]."-<br>";
826
827 $mob_id = $this->mob_mapping[$a_attribs["Entry"]];
828
829 // within learning module import, usually a media object
830 // has already been created with a media alias tag
831 if ($mob_id > 0) {
832 $this->media_object = new ilObjMediaObject($mob_id);
833 } else { // in glossaries the media objects precede the definitions
834 // so we don't have an object already
835 $this->media_object = new ilObjMediaObject();
836 $this->media_object->create(true, false);
837 $this->mob_mapping[$a_attribs["Entry"]]
838 = $this->media_object->getId();
839 }
840 $this->media_object->setImportId($a_attribs["Entry"]);
841 $this->md = new ilMD(
842 0,
843 $this->media_object->getId(),
844 "mob"
845 );
846 $this->emptyMediaMetaCache($a_xml_parser);
847 }
848 }
849 break;
850
851 case "Meta-Metadata":
852 $this->in_meta_meta_data = true;
853 break;
854
855 // Internal Link
856 case "IntLink":
857 if (is_object($this->page_object)) {
858 $this->page_object->setContainsIntLink(true);
859 }
860 if ($this->in_map_area) {
861 //echo "intlink:maparea:<br>";
862 $this->map_area->setLinkType(IL_INT_LINK);
863 $this->map_area->setTarget($a_attribs["Target"]);
864 $this->map_area->setType($a_attribs["Type"]);
865 $this->map_area->setTargetFrame($a_attribs["TargetFrame"]);
866 if (is_object($this->media_object)) {
867 //echo ":setContainsLink:<br>";
868 $this->media_object->setContainsIntLink(true);
869 }
870 }
871 break;
872
873 // External Link
874 case "ExtLink":
875 if ($this->in_map_area) {
876 $this->map_area->setLinkType(IL_EXT_LINK);
877 $this->map_area->setHref($a_attribs["Href"]);
878 $this->map_area->setExtTitle($a_attribs["Title"]);
879 }
880 break;
881
882 // Question
883 case "Question":
884 $this->cur_qid = $a_attribs["QRef"];
885 $this->page_object->setContainsQuestion(true);
886 break;
887
888 case "Location":
889 $this->loc_type = $a_attribs["Type"];
890 break;
891
892 }
893 $this->beginElement($a_name);
894
895 // append content to page xml content
896 if (($this->in_page_object || $this->in_glossary_definition)
897 && !$this->in_meta_data && !$this->in_media_object) {
898 if ($a_name == "Definition") {
899 $app_name = "PageObject";
900 $app_attribs = array();
901 } else {
902 $app_name = $a_name;
903 $app_attribs = $a_attribs;
904 }
905
906 // change identifier entry of file items to new local file id
907 if ($this->in_file_item && $app_name == "Identifier") {
908 $app_attribs["Entry"] = "il__file_" . $this->file_item_mapping[$a_attribs["Entry"]];
909 //$app_attribs["Entry"] = "il__file_".$this->file_item->getId();
910 }
911
912 $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs));
913 //echo "&nbsp;&nbsp;after append, xml:".$this->page_object->getXMLContent().":<br>";
914 }
915
916
917 // call meta data handler
918 if ($this->in_meta_data && $this->processMeta()) {
919 // cache beginning of meta data within media object tags
920 // (we need to know the id at the begin of meta elements within
921 // media objects, after the "Identifier" tag has been processed
922 // we send the cached data to the meta xml handler)
923 if ($this->in_media_object && $this->media_meta_start) {
924 $this->media_meta_cache[] =
925 array("type" => "handlerBeginTag", "par1" => $a_name, "par2" => $a_attribs);
926 } else {
927 if ($a_name == "Identifier") {
928 if (!$this->in_media_object) {
929 $a_attribs["Entry"] = "il__" . $this->current_object->getType() .
930 "_" . $this->current_object->getId();
931 } else {
932 $a_attribs["Entry"] = "il__mob" .
933 "_" . $this->media_object->getId();
934 }
935 $a_attribs["Catalog"] = "ILIAS";
936 }
937
938 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
939 }
940 }
941 }
const IL_INT_LINK
const IL_EXT_LINK
Question page object.
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 ilLMPageObject.
Extension of ilPageObject for learning modules.
enableMDParsing($a_status)
Class ilMapArea.
Class ilMediaItem Media Item, component of a media object (file or reference)
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 $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 1425 of file class.ilContObjParser.php.

1426 {
1427 // call meta data handler
1428 if ($this->in_meta_data && $this->processMeta()) {
1429 // cache beginning of meta data within media object tags
1430 // (we need to know the id, after that we send the cached data
1431 // to the meta xml handler)
1432 if ($this->in_media_object && $this->media_meta_start) {
1433 $this->media_meta_cache[] =
1434 array("type" => "handlerCharacterData", "par1" => $a_data);
1435 } else {
1436 parent::handlerCharacterData($a_xml_parser, $a_data);
1437 }
1438 }
1439
1440 // the parser converts "&gt;" to ">" and "&lt;" to "<"
1441 // in character data, but we don't want that, because it's the
1442 // way we mask user html in our content, so we convert back...
1443
1444 $a_data = str_replace("<", "&lt;", $a_data);
1445 $a_data = str_replace(">", "&gt;", $a_data);
1446
1447
1448 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1449 $a_data = preg_replace("/\n/", "", $a_data);
1450 if (!$this->inside_code) {
1451 $a_data = preg_replace("/\t+/", "", $a_data);
1452 }
1453
1454 $this->chr_data .= $a_data;
1455
1456 if (!empty($a_data) || $a_data === "0") {
1457 // append all data to page, if we are within PageObject,
1458 // but not within MetaData or MediaObject
1459 if (($this->in_page_object || $this->in_glossary_definition)
1460 && !$this->in_meta_data && !$this->in_media_object) {
1461 $this->page_object->appendXMLContent($a_data);
1462 }
1463
1464 if ($this->in_meta_data) {
1465 //$this->meta_data->appendXMLContent($a_data);
1466//echo "<br>".$a_data;
1467 }
1468
1469 switch ($this->getCurrentElement()) {
1470
1471 case "IntLink":
1472 case "ExtLink":
1473 if ($this->in_map_area) {
1474 $this->map_area->appendTitle($a_data);
1475 }
1476 break;
1477
1478 }
1479 }
1480 }

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 966 of file class.ilContObjParser.php.

967 {
968 // call meta data handler
969 if ($this->in_meta_data && $this->processMeta()) {
970 // cache beginning of meta data within media object tags
971 // (we need to know the id, after that we send the cached data
972 // to the meta xml handler)
973 if ($this->in_media_object && $this->media_meta_start) {
974 $this->media_meta_cache[] =
975 array("type" => "handlerEndTag", "par1" => $a_name);
976 } else {
977 parent::handlerEndTag($a_xml_parser, $a_name);
978 }
979 }
980
981 //echo "<b>END TAG: $a_name <br></b>"; flush();
982 // append content to page xml content
983 if (($this->in_page_object || $this->in_glossary_definition)
984 && !$this->in_meta_data && !$this->in_media_object) {
985 $app_name = ($a_name == "Definition")
986 ? "PageObject"
987 : $a_name;
988 $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
989 }
990
991 switch ($a_name) {
992 case "StructureObject":
993 //unset($this->meta_data);
994 unset($this->structure_objects[count($this->structure_objects) - 1]);
995 break;
996
997 case "PageObject":
998
999 $this->in_page_object = false;
1000 if (($this->coType != "tst") and ($this->coType != "qpl")) {
1001 if (!$this->lm_page_object->isAlias()) {
1002 //$this->page_object->createFromXML();
1003 $this->page_object->updateFromXML();
1004 $this->pg_mapping[$this->lm_page_object->getImportId()]
1005 = $this->lm_page_object->getId();
1006
1007 if ($this->mapping instanceof ilImportMapping) {
1008 $import_id_parsed = ilUtil::parseImportId($this->lm_page_object->getImportId());
1009 if ($import_id_parsed['type'] == 'pg') {
1010 $this->mapping->addMapping(
1011 'Modules/LearningModule',
1012 'pg',
1013 $import_id_parsed['id'],
1014 $this->lm_page_object->getId()
1015 );
1016 }
1017 }
1018
1019 // collect pages with internal links
1020 if ($this->page_object->containsIntLink()) {
1021 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
1022 }
1023
1024 // collect pages with mobs or files
1025 if ($this->page_object->needsImportParsing()) {
1026 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
1027 }
1028
1029 // collect pages with questions
1030 if ($this->page_object->getContainsQuestion()) {
1031 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
1032 }
1033 }
1034 } else {
1035 $xml = $this->page_object->getXMLContent();
1036 if ($this->cur_qid != "") {
1037 $ids = $this->qst_mapping[$this->cur_qid];
1038 if ($ids["pool"] > 0) {
1039 // question pool question
1040 $page = new ilAssQuestionPage($ids["pool"]);
1041 $xmlcontent = str_replace(
1042 $this->cur_qid,
1043 "il__qst_" . $ids["pool"],
1044 $xml
1045 );
1046 $page->setXMLContent($xmlcontent);
1047 $page->updateFromXML();
1048 if ($this->page_object->needsImportParsing()) {
1049 $this->pages_to_parse["qpl:" . $page->getId()] = "qpl:" . $page->getId();
1050 }
1051 unset($page);
1052 }
1053 if ($ids["test"] > 0) {
1054 // test question
1055 $page = new ilAssQuestionPage($ids["test"]);
1056 $xmlcontent = str_replace(
1057 $this->cur_qid,
1058 "il__qst_" . $ids["test"],
1059 $xml
1060 );
1061 $page->setXMLContent($xmlcontent);
1062 $page->updateFromXML();
1063 if ($this->page_object->needsImportParsing()) {
1064 $this->pages_to_parse["qpl:" . $page->getId()] = "qpl:" . $page->getId();
1065 }
1066 unset($page);
1067 }
1068 }
1069 }
1070
1071 // if we are within a structure object: put page in tree
1072 $cnt = count($this->structure_objects);
1073//echo "1";
1074 if ($cnt > 0) {
1075 //echo "B-$cnt-<br>";
1076 //echo "<br>"; var_dump($this->structure_objects); echo "<br>";
1077 $parent_id = $this->structure_objects[$cnt - 1]->getId();
1078 if ($this->lm_page_object->isAlias()) {
1079 //echo "3";
1080 $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
1081 //echo "<br>"; var_dump($this->pg_into_tree); echo "<br>";
1082 } else {
1083 //echo "4";
1084 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
1085 }
1086 }
1087
1088 unset($this->page_object);
1089 unset($this->lm_page_object);
1090 unset($this->container[count($this->container) - 1]);
1091 break;
1092
1093 case "MediaObject":
1094 $this->in_media_object = false;
1095 // no break
1096case "InteractiveImage":
1097
1098//echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>";
1099 // create media object on first occurence of an Id
1100
1101
1102 if (empty($this->mob_mapping[$this->media_object->getImportId()])) {
1103 //echo "No mapping found --creating media object:title:".$this->media_object->getTitle().":<br>";
1104
1105 // create media object
1106 // media items are saves for mobs outside of
1107 // pages only
1108 $this->media_object->create(true, false);
1109
1110 //echo "<br>creating mob ".$this->media_object->getId().":".$this->media_object->getTitle().":";
1111
1112 // collect mobs with internal links
1113 if ($this->media_object->containsIntLink()) {
1114 //echo "got int link :".$this->media_object->getId().":<br>";
1115 $this->mobs_with_int_links[] = $this->media_object->getId();
1116 }
1117
1118 $this->mob_mapping[$this->media_object->getImportId()]
1119 = $this->media_object->getId();
1120 //echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>";
1121 } else {
1122 //echo "Mapping found<br>";
1123 // get the id from mapping
1124 $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
1125
1126 // update "real" (no alias) media object
1127 // (note: we overwrite any data from the media object
1128 // created by an MediaAlias, only the data of the real
1129 // object is stored in db separately; data of the
1130 // MediaAliases are within the page XML
1131 if (!$this->media_object->isAlias()) {
1132 // now the media items are saved within the db
1133 $this->media_object->update();
1134
1135 //echo "<br>update media object :".$this->media_object->getId().":";
1136
1137 // collect mobs with internal links
1138 if ($this->media_object->containsIntLink()) {
1139 //echo "got int link :".$this->media_object->getId().":<br>";
1140 $this->mobs_with_int_links[] = $this->media_object->getId();
1141 }
1142 }
1143 }
1144
1145 // append media alias to page, if we are in a page
1146 if ($this->in_page_object || $this->in_glossary_definition) {
1147 if ($a_name != "InteractiveImage") {
1148 $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
1149 //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
1150 }
1151 }
1152
1153 break;
1154
1155 case "MediaItem":
1156 case "MediaAliasItem":
1157 $this->in_media_item = false;
1158 $this->media_object->addMediaItem($this->media_item);
1159//echo "adding media item -".$this->media_item->getId()."-".$this->media_item->getLocation()."- to object -".$this->media_object->getId()."-";
1160 break;
1161
1162 case "MapArea":
1163 $this->in_map_area = false;
1164 $this->media_item->addMapArea($this->map_area);
1165 break;
1166
1167 case "Properties":
1168 $this->in_properties = false;
1169 if ($this->content_object->getType() == "lm") {
1170 $this->content_object->update();
1171 }
1172 break;
1173
1174 case "MetaData":
1175 $this->in_meta_data = false;
1176 if (strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object) {
1177 // Metadaten eines PageObjects sichern in NestedSet
1178 if (is_object($this->lm_page_object)) {
1179 // update title/description of page object
1180 $this->current_object->MDUpdateListener('General');
1182 $this->current_object->getId(),
1183 $this->current_object->getImportId()
1184 );
1185 }
1186 } elseif ((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
1187 strtolower(get_class($this->current_object)) == "ilobjtest") &&
1188 !$this->in_media_object) {
1189 // !$this->in_media_object && !$this->in_page_object)
1190 // changed for imports of ILIAS 2 Tests where PageObjects could have
1191 // Metadata sections (Helmut Schottmüller, 2005-12-02)
1192 if ($this->metadata_parsing_disabled) {
1193 $this->enableMDParsing(true);
1194 } else {
1195 if ($this->in_page_object) {
1196 $this->page_object->MDUpdateListener('General');
1198 $this->page_object->getId(),
1199 $this->page_object->getImportId()
1200 );
1201 } else {
1202 $this->current_object->MDUpdateListener('General');
1204 $this->current_object->getId(),
1205 $this->current_object->getImportId()
1206 );
1207 }
1208 }
1209 } elseif (strtolower(get_class($this->current_object)) == "ilstructureobject") { // save structure object at the end of its meta block
1210 // determine parent
1211 $cnt = count($this->structure_objects);
1212 if ($cnt > 1) {
1213 $parent_id = $this->structure_objects[$cnt - 2]->getId();
1214 } else {
1215 $parent_id = $this->lm_tree->getRootId();
1216 }
1217
1218 // create structure object and put it in tree
1219 //$this->current_object->create(true); // now on top
1220 $this->st_into_tree[] = array("id" => $this->current_object->getId(),
1221 "parent" => $parent_id);
1222
1223 // update title/description of structure object
1224 $this->current_object->MDUpdateListener('General');
1226 $this->current_object->getId(),
1227 $this->current_object->getImportId()
1228 );
1229 } elseif (strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1230 strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
1231 (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary)) {
1232 // todo: saving of md? getting title/descr and
1233 // set it for current object
1234 } elseif (strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object) {
1235 // now on top
1236 //$this->glossary_definition->create();
1237
1238 $this->page_object->setId($this->glossary_definition->getId());
1239 $this->page_object->updateFromXML();
1240
1241 // todo: saving of md? getting title/descr and
1242 // set it for current object
1243 }
1244
1245
1246 if (strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1247 strtolower(get_class($this->current_object)) == "ilobjglossary") {
1248 if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
1249 $this->content_object->getType() != "glo") {
1250 //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
1251 $this->current_object->setTitle($this->content_object->getTitle() . " - " .
1252 $this->lng->txt("glossary"));
1253 }
1254
1255 $this->current_object->MDUpdateListener('General');
1256 /*
1257 if (!$this->in_media_object && $this->processMeta())
1258 {
1259 $this->current_object->update();
1260 }
1261 */
1262 }
1263
1264 if ($this->in_media_object) {
1265 //echo "<br>call media object update listener";
1266 $this->media_object->MDUpdateListener('General');
1267 }
1268
1269 if ($this->in_glossary_definition) {
1270 $this->glossary_definition->MDUpdateListener('General');
1271 }
1272
1273 break;
1274
1275 case "Meta-Metadata":
1276 $this->in_meta_meta_data = false;
1277 break;
1278
1279 case "FileItem":
1280 $this->in_file_item = false;
1281 // only update new file items
1282 if ($this->file_item->getImportId($a_attribs["Entry"] != "")) {
1283 $this->file_item->update();
1284 }
1285 break;
1286
1287
1288 case "Table":
1289 unset($this->container[count($this->container) - 1]);
1290 break;
1291
1292 case "Glossary":
1293 $this->in_glossary = false;
1294 break;
1295
1296 case "GlossaryTerm":
1297 $term = trim($this->chr_data);
1298 $term = str_replace("&lt;", "<", $term);
1299 $term = str_replace("&gt;", ">", $term);
1300 $this->glossary_term->setTerm($term);
1301 $this->glossary_term->create();
1302 $iia = explode("_", $this->glossary_term->getImportId());
1303 $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1304 break;
1305
1306 case "Paragraph":
1307 $this->inside_code = false;
1308 break;
1309
1310 case "Definition":
1311 $this->in_glossary_definition = false;
1312 $this->page_object->updateFromXML();
1313//echo "&nbsp;&nbsp;after def update, xml:".htmlentities($this->page_object->getXMLContent()).":<br>";
1314//echo "<br>".$this->page_object->getId()."-".$this->page_object->getParentType()."-";
1315 $this->page_object->buildDom();
1316 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
1317 $this->glossary_definition->update();
1318 //$this->pg_mapping[$this->lm_page_object->getImportId()]
1319 // = $this->lm_page_object->getId();
1320 if ($this->page_object->containsIntLink()) {
1321 //echo "<br>Definition contains Int Link:".$this->page_object->getId();
1322 $this->pages_to_parse["gdf:" . $this->page_object->getId()] = "gdf:" . $this->page_object->getId();
1323 }
1324 if ($this->page_object->needsImportParsing()) {
1325 $this->pages_to_parse["gdf:" . $this->page_object->getId()] = "gdf:" . $this->page_object->getId();
1326 }
1327 break;
1328
1329 case "Format":
1330 if ($this->in_media_item) {
1331 $this->media_item->setFormat(trim($this->chr_data));
1332 }
1333 if ($this->in_file_item) {
1334 $this->file_item->setFileType(trim($this->chr_data));
1335 }
1336 break;
1337
1338 case "Title":
1339 if (!$this->in_media_object) {
1340 $this->current_object->setTitle(trim($this->chr_data));
1341 //$this->meta_data->setTitle(trim($this->chr_data));
1342 } else {
1343 $this->media_object->setTitle(trim($this->chr_data));
1344 //$this->meta_data->setTitle(trim($this->chr_data));
1345 }
1346 break;
1347
1348 case "Language":
1349 /*
1350 if (is_object($this->meta_data))
1351 {
1352 $this->meta_data->setLanguage(trim($this->chr_data));
1353 }*/
1354
1355 break;
1356
1357 case "Description":
1358 //$this->meta_data->setDescription(trim($this->chr_data));
1359 break;
1360
1361 case "Caption":
1362 if ($this->in_media_object) {
1363 $this->media_item->setCaption(trim($this->chr_data));
1364 }
1365 break;
1366
1367 case "TextRepresentation":
1368 if ($this->in_media_object) {
1369 $this->media_item->setTextRepresentation(trim($this->chr_data));
1370 }
1371 break;
1372
1373 // Location
1374 case "Location":
1375 // TODO: adapt for files in "real" subdirectories
1376 if ($this->in_media_item) {
1377 $this->media_item->setLocationType($this->loc_type);
1378 if ($this->loc_type == "Reference") {
1379 $this->media_item->setLocation(str_replace("&", "&amp;", trim($this->chr_data)));
1380 } else {
1381 $this->media_item->setLocation(trim($this->chr_data));
1382 }
1383 //echo "-".$this->media_item->getLocation()."-";
1384 }
1385 if ($this->in_file_item) {
1386 // set file name from xml file
1387 $this->file_item->setFileName(trim($this->chr_data));
1388
1389 // special handling for file names with special characters
1390 // (e.g. "&gt;")
1391 if ($this->file_item->getType() == "file" &&
1392 is_int(strpos($this->chr_data, "&")) &&
1393 is_int(strpos($this->chr_data, ";"))) {
1394 $imp_dir = $this->import_dir;
1395 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" .
1396 $this->file_item->getImportId();
1397
1398 // read "physical" file name from directory
1399 if ($dir = opendir($source_dir)) {
1400 while (false !== ($file = readdir($dir))) {
1401 if ($file != "." && $file != "..") {
1402 $this->file_item->setFileName($file);
1403 }
1404 }
1405 closedir($dir);
1406 }
1407 }
1408
1409 // set file item title
1410 $this->file_item->setTitle(trim($this->chr_data));
1411 }
1412 break;
1413
1414 }
1415 $this->endElement($a_name);
1416 $this->chr_data = "";
1417 }
const IL_MODE_ALIAS
static _writeImportId($a_id, $a_import_id)
write import id to db (static)
$xml
Definition: metadata.php:332

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

+ Here is the call graph for this function:

◆ processMeta()

ilContObjParser::processMeta ( )

check whether meta data should be processed

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

947 {
948 // do not process second meta block in (ilias3) glossaries
949 // which comes right after the "Glossary" tag
950 if ($this->content_object->getType() == "glo" &&
951 $this->in_glossary && !$this->in_media_object
952 && !$this->in_glossary_definition) {
953 return false;
954 }
955
956 return true;
957 }

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 203 of file class.ilContObjParser.php.

204 {
205 /*
206 $pg_mapping = array();
207 foreach($this->pg_mapping as $key => $value)
208 {
209 $pg_mapping[$key] = "il__pg_".$value;
210 }*/
211 //echo "<br><b>processIntLinks</b>"; flush();
212
213 // outgoin internal links
214 foreach ($this->pages_to_parse as $page_id) {
215 $page_arr = explode(":", $page_id);
216 //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
217 switch ($page_arr[0]) {
218 case "lm":
219 switch ($this->content_object->getType()) {
220 case "lm":
221 $page_obj = new ilLMPage($page_arr[1]);
222 break;
223
224 default:
225 die("Unknown content type " . $this->content_object->getType());
226 }
227
228 break;
229
230 case "gdf":
231 $page_obj = new ilGlossaryDefPage($page_arr[1]);
232 break;
233
234 case "qpl":
235 $page_obj = new ilAssQuestionPage($page_arr[1]);
236 break;
237 }
238 $page_obj->buildDom();
239 $page_obj->resolveIntLinks();
240 $page_obj->resolveIIMMediaAliases($this->mob_mapping);
241 if (in_array($this->coType, array("lm"))) {
242 $page_obj->resolveQuestionReferences($this->qst_mapping);
243 }
244 $page_obj->update(false);
245
246 if ($page_arr[0] == "gdf") {
247 $def = new ilGlossaryDefinition($page_arr[1]);
248 $def->updateShortText();
249 }
250
251 unset($page_obj);
252 }
253
254 //echo "<br><b>map area internal links</b>"; flush();
255 // outgoins map area (mob) internal links
256 foreach ($this->mobs_with_int_links as $mob_id) {
258 }
259
260 //echo "<br><b>incoming interna links</b>"; flush();
261 // incoming internal links
262 $done = array();
263 foreach ($this->link_targets as $link_target) {
264 //echo "doin link target:".$link_target.":<br>";
265 $link_arr = explode("_", $link_target);
266 $target_inst = $link_arr[1];
267 $target_type = $link_arr[2];
268 $target_id = $link_arr[3];
269 //echo "<br>-".$target_type."-".$target_id."-".$target_inst."-";
271 foreach ($sources as $key => $source) {
272 //echo "got source:".$key.":<br>";
273 if (in_array($key, $done)) {
274 continue;
275 }
276 $type_arr = explode(":", $source["type"]);
277
278 // content object pages
279 if ($type_arr[1] == "pg") {
280 if (ilPageObject::_exists($type_arr[0], $source["id"])) {
282 $page_object->buildDom();
283 $page_object->resolveIntLinks();
284 $page_object->update();
285 unset($page_object);
286 }
287 }
288
289 // eventually correct links in questions to learning modules
290 if ($type_arr[0] == "qst") {
292 }
293 // eventually correct links in survey questions to learning modules
294 if ($type_arr[0] == "sqst") {
296 }
297 $done[$key] = $key;
298 }
299 }
300 }
static _resolveIntLinks($question_id)
_resolveIntLinks($question_id)
static _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:51
$target_type
Definition: goto.php:50
$source
Definition: metadata.php:76

References $page_object, $source, $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 119 of file class.ilContObjParser.php.

120 {
121 xml_set_object($a_xml_parser, $this);
122 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
123 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
124 }

◆ setImportMapping()

ilContObjParser::setImportMapping ( ilImportMapping  $mapping = null)

Set import mapping.

Parameters
ilImportMapping$mapping

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

131 {
132 $this->mapping = $mapping;
133 }

◆ setQuestionMapping()

ilContObjParser::setQuestionMapping (   $a_map)

set question import ident to pool/test question id mapping

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

377 {
378 $this->qst_mapping = $a_map;
379 }

◆ startParsing()

ilContObjParser::startParsing ( )

start parser

Reimplemented from ilSaxParser.

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

140 {
141 $this->log->debug("start");
142
143 //echo "<b>start parsing</b><br>";
144 parent::startParsing();
145 //echo "<b>storeTree</b><br>";
146 $this->storeTree();
147 //echo "<b>processPagesToParse</b><br>";
148 $this->processPagesToParse();
149 //echo "<b>copyMobFiles</b><br>";
150 $this->copyMobFiles();
151 //echo "<b>copyFileItems</b><br>";
152 $this->copyFileItems();
153 //echo "<br>END Parsing"; exit;
154 }
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 160 of file class.ilContObjParser.php.

161 {
162 $ilLog = $this->log;
163
164 //echo "<b>Storing the tree</b><br>";
165 foreach ($this->st_into_tree as $st) {
166 //echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>";
167 $this->lm_tree->insertNode($st["id"], $st["parent"]);
168 //echo "done<br>";
169 //var_dump($this->pg_into_tree[$st["id"]]);
170 //echo "<br>";
171 if (is_array($this->pg_into_tree[$st["id"]])) {
172 foreach ($this->pg_into_tree[$st["id"]] as $pg) {
173 switch ($pg["type"]) {
174 case "pg_alias":
175 if ($this->pg_mapping[$pg["id"]] == "") {
176 $ilLog->write("LM Import: No PageObject for PageAlias " .
177 $pg["id"] . " found! (Please update export installation to ILIAS 3.3.0)");
178
179 // Jump two levels up. First level is switch
180 continue 2;
181 }
182 $pg_id = $this->pg_mapping[$pg["id"]];
183 break;
184
185 case "pg":
186 $pg_id = $pg["id"];
187 break;
188 }
189 if (!$this->lm_tree->isInTree($pg_id)) {
190 $this->lm_tree->insertNode($pg_id, $st["id"]);
191 }
192 }
193 }
194 }
195 //echo "<b>END: storing the tree</b>";
196//exit;
197 }

References $log.

Referenced by startParsing().

+ Here is the caller graph for this function:

Field Documentation

◆ $cnt

ilContObjParser::$cnt

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

Referenced by handlerEndTag().

◆ $container

ilContObjParser::$container = []

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

◆ $content_object

ilContObjParser::$content_object

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

Referenced by handlerBeginTag().

◆ $current_element

ilContObjParser::$current_element

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

◆ $current_object

ilContObjParser::$current_object

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

◆ $file_item

ilContObjParser::$file_item

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

◆ $file_item_mapping

ilContObjParser::$file_item_mapping

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

◆ $glossary_object

ilContObjParser::$glossary_object

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

Referenced by handlerBeginTag().

◆ $glossary_term_map

ilContObjParser::$glossary_term_map = array()
protected

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

Referenced by getGlossaryTermMap().

◆ $in_file_item

ilContObjParser::$in_file_item

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

◆ $in_glossary

ilContObjParser::$in_glossary

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

◆ $in_map_area

ilContObjParser::$in_map_area

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

◆ $in_media_object

ilContObjParser::$in_media_object

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

◆ $in_meta_data

ilContObjParser::$in_meta_data

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

◆ $in_meta_meta_data

ilContObjParser::$in_meta_meta_data = false

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

◆ $in_page_object

ilContObjParser::$in_page_object

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

◆ $keyword_language

ilContObjParser::$keyword_language

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

◆ $learning_module

ilContObjParser::$learning_module

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

◆ $link_targets

ilContObjParser::$link_targets

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

◆ $lm_page_object

ilContObjParser::$lm_page_object

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

Referenced by handlerBeginTag().

◆ $lm_tree

ilContObjParser::$lm_tree

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

◆ $lng

ilContObjParser::$lng

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

Referenced by __construct().

◆ $loc_type

ilContObjParser::$loc_type

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

◆ $log

ilContObjParser::$log
protected

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

Referenced by storeTree().

◆ $map_area

ilContObjParser::$map_area

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

◆ $media_item

ilContObjParser::$media_item

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

◆ $media_object

ilContObjParser::$media_object

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

◆ $meta_data

ilContObjParser::$meta_data

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

◆ $metadata_parsing_disabled

ilContObjParser::$metadata_parsing_disabled

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

◆ $mob_mapping

ilContObjParser::$mob_mapping

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

◆ $page_object

ilContObjParser::$page_object

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

Referenced by processPagesToParse().

◆ $pages_to_parse

ilContObjParser::$pages_to_parse

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

◆ $paragraph

ilContObjParser::$paragraph

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

◆ $pg_into_tree

ilContObjParser::$pg_into_tree

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

◆ $qst_mapping

ilContObjParser::$qst_mapping

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

◆ $st_into_tree

ilContObjParser::$st_into_tree

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

◆ $structure_objects

ilContObjParser::$structure_objects

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

◆ $subdir

ilContObjParser::$subdir

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

◆ $table

ilContObjParser::$table

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

◆ $tree

ilContObjParser::$tree

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

Referenced by __construct().


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