ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 __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 ()
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object 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 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 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 31 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 public

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

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

88  {
89  global $DIC;
90 
91  $this->log = $DIC["ilLog"];
92  $lng = $DIC->language();
93  $tree = $DIC->repositoryTree();
94 
95  $this->log = ilLoggerFactory::getLogger('lm');
96 
97  $this->import_dir = ($a_import_dir != "")
98  ? $a_import_dir
99  : $a_content_object->getImportDirectory();
100 
101  parent::__construct($a_xml_file);
102  $this->cnt = array();
103  $this->current_element = array();
104  $this->structure_objects = array();
105  $this->content_object = $a_content_object;
106  //$this->lm_id = $a_lm_id;
107  $this->st_into_tree = array();
108  $this->pg_into_tree = array();
109  $this->pages_to_parse = array();
110  $this->mobs_with_int_links = array();
111  $this->mob_mapping = array();
112  $this->file_item_mapping = array();
113  $this->pg_mapping = array();
114  $this->link_targets = array();
115  $this->subdir = $a_subdir;
116  $this->lng = $lng;
117  $this->tree = $tree;
118  $this->inside_code = false;
119  $this->qst_mapping = array();
120  $this->coType = $this->content_object->getType();
121  $this->metadata_parsing_disabled = false;
122 
123  if (($this->coType != "tst") and ($this->coType != "qpl")) {
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  }
global $DIC
Definition: saml.php:7
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ beginElement()

ilContObjParser::beginElement (   $a_name)

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

Referenced by handlerBeginTag().

411  {
412  if (!isset($this->status["$a_name"])) {
413  $this->cnt[$a_name] == 1;
414  } else {
415  $this->cnt[$a_name]++;
416  }
417  $this->current_element[count($this->current_element)] = $a_name;
418  }
+ 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 460 of file class.ilContObjParser.php.

References $name, $tag, and $type.

Referenced by handlerBeginTag(), and handlerEndTag().

461  {
462  $tag = "<";
463 
464  if ($type == "end") {
465  $tag .= "/";
466  }
467 
468  $tag .= $name;
469 
470  if (is_array($attr)) {
471  foreach ($attr as $k => $v) {
472  $tag .= " " . $k . "=\"$v\"";
473  }
474  }
475 
476  $tag .= ">";
477 
478  return $tag;
479  }
$type
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the caller graph for this function:

◆ copyFileItems()

ilContObjParser::copyFileItems ( )

copy files of file items

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

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

Referenced by startParsing().

370  {
371  $imp_dir = $this->import_dir;
372  foreach ($this->file_item_mapping as $origin_id => $file_id) {
373  if (empty($origin_id)) {
374  continue;
375  }
376  $obj_dir = $origin_id;
377  $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
378 
379  include_once("./Modules/File/classes/class.ilObjFile.php");
380  $file_obj = new ilObjFile($file_id, false);
381  //$target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
382  $target_dir = $file_obj->getDirectory();
383  if (@is_dir($source_dir)) {
384  // make target directory
385  ilUtil::makeDir($target_dir);
386  //@mkdir($target_dir);
387  //@chmod($target_dir, 0755);
388 
389  if (@is_dir($target_dir)) {
390  ilUtil::rCopy(realpath($source_dir), realpath($target_dir));
391  }
392  }
393  $test = $file_obj->determineFilesize();
394  $file_obj->update();
395  }
396  }
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 ...
$test
Definition: Utf8Test.php:84
+ 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 329 of file class.ilContObjParser.php.

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

Referenced by startParsing().

330  {
331  $imp_dir = $this->import_dir;
332  foreach ($this->mob_mapping as $origin_id => $mob_id) {
333  if (empty($origin_id)) {
334  continue;
335  }
336 
337  /*
338  $origin_arr = explode("_", $origin_id);
339  if ($origin_arr[2] == "el") // imagemap
340  {
341  $obj_dir = "imagemap".$origin_arr[3];
342  }
343  else // normal media object
344  {
345  $obj_dir = "mm".$origin_arr[3];
346  }*/
347 
348  $obj_dir = $origin_id;
349  $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
350  $target_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $mob_id;
351 
352  if (@is_dir($source_dir)) {
353  // make target directory
354  ilUtil::makeDir($target_dir);
355  //@mkdir($target_dir);
356  //@chmod($target_dir, 0755);
357 
358  if (@is_dir($target_dir)) {
359  ilLoggerFactory::getLogger("mob")->debug("s:-$source_dir-,t:-$target_dir-");
360  ilUtil::rCopy(realpath($source_dir), realpath($target_dir));
361  }
362  }
363  }
364  }
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 ...
static getLogger($a_component_id)
Get component logger.
static getWebspaceDir($mode="filesystem")
get webspace directory
+ 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 1517 of file class.ilContObjParser.php.

Referenced by handlerBeginTag().

1518  {
1519  foreach ($this->media_meta_cache as $cache_entry) {
1520  switch ($cache_entry["type"]) {
1521  case "handlerBeginTag":
1522  parent::handlerBeginTag(
1523  $a_xml_parser,
1524  $cache_entry["par1"],
1525  $cache_entry["par2"]
1526  );
1527  break;
1528 
1529  case "handlerEndTag":
1530  parent::handlerEndTag(
1531  $a_xml_parser,
1532  $cache_entry["par1"]
1533  );
1534  break;
1535 
1536  case "handlerCharacterData":
1537  parent::handlerCharacterData(
1538  $a_xml_parser,
1539  $cache_entry["par1"]
1540  );
1541  break;
1542  }
1543  }
1544 
1545  $this->media_meta_start = false;
1546  $this->media_meta_cache[] = array();
1547  }
+ Here is the caller graph for this function:

◆ endElement()

ilContObjParser::endElement (   $a_name)

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

Referenced by handlerEndTag().

426  {
427  $this->cnt[$a_name]--;
428  unset($this->current_element[count($this->current_element) - 1]);
429  }
+ Here is the caller graph for this function:

◆ getCurrentElement()

ilContObjParser::getCurrentElement ( )

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

Referenced by handlerCharacterData().

435  {
436  return ($this->current_element[count($this->current_element) - 1]);
437  }
+ Here is the caller graph for this function:

◆ getGlossaryTermMap()

ilContObjParser::getGlossaryTermMap ( )

Get glossary term map (imported ids to new ids)

Parameters

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

References $glossary_term_map.

1556  {
1557  return $this->glossary_term_map;
1558  }

◆ getOpenCount()

ilContObjParser::getOpenCount (   $a_name)

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

445  {
446  if (isset($this->cnt[$a_name])) {
447  return $this->cnt[$a_name];
448  } else {
449  return 0;
450  }
451  }

◆ 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

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

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().

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

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

References getCurrentElement(), and processMeta().

1456  {
1457  // call meta data handler
1458  if ($this->in_meta_data && $this->processMeta()) {
1459  // cache beginning of meta data within media object tags
1460  // (we need to know the id, after that we send the cached data
1461  // to the meta xml handler)
1462  if ($this->in_media_object && $this->media_meta_start) {
1463  $this->media_meta_cache[] =
1464  array("type" => "handlerCharacterData", "par1" => $a_data);
1465  } else {
1466  parent::handlerCharacterData($a_xml_parser, $a_data);
1467  }
1468  }
1469 
1470  // the parser converts "&gt;" to ">" and "&lt;" to "<"
1471  // in character data, but we don't want that, because it's the
1472  // way we mask user html in our content, so we convert back...
1473 
1474  $a_data = str_replace("<", "&lt;", $a_data);
1475  $a_data = str_replace(">", "&gt;", $a_data);
1476 
1477 
1478  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1479  $a_data = preg_replace("/\n/", "", $a_data);
1480  if (!$this->inside_code) {
1481  $a_data = preg_replace("/\t+/", "", $a_data);
1482  }
1483 
1484  $this->chr_data .= $a_data;
1485 
1486  if (!empty($a_data) || $a_data === "0") {
1487  // append all data to page, if we are within PageObject,
1488  // but not within MetaData or MediaObject
1489  if (($this->in_page_object || $this->in_glossary_definition)
1490  && !$this->in_meta_data && !$this->in_media_object) {
1491  $this->page_object->appendXMLContent($a_data);
1492  }
1493 
1494  if ($this->in_meta_data) {
1495  //$this->meta_data->appendXMLContent($a_data);
1496 //echo "<br>".$a_data;
1497  }
1498 
1499  switch ($this->getCurrentElement()) {
1500 
1501  case "IntLink":
1502  case "ExtLink":
1503  if ($this->in_map_area) {
1504  $this->map_area->appendTitle($a_data);
1505  }
1506  break;
1507 
1508  }
1509  }
1510  }
processMeta()
check whether meta data should be processed
+ 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

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

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

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

◆ processMeta()

ilContObjParser::processMeta ( )

check whether meta data should be processed

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

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

975  {
976  // do not process second meta block in (ilias3) glossaries
977  // which comes right after the "Glossary" tag
978  if ($this->content_object->getType() == "glo" &&
979  $this->in_glossary && !$this->in_media_object
980  && !$this->in_glossary_definition) {
981  return false;
982  }
983 
984  return true;
985  }
+ Here is the caller graph for this function:

◆ processPagesToParse()

ilContObjParser::processPagesToParse ( )

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

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

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

Referenced by startParsing().

222  {
223  /*
224  $pg_mapping = array();
225  foreach($this->pg_mapping as $key => $value)
226  {
227  $pg_mapping[$key] = "il__pg_".$value;
228  }*/
229  //echo "<br><b>processIntLinks</b>"; flush();
230 
231  // outgoin internal links
232  foreach ($this->pages_to_parse as $page_id) {
233  $page_arr = explode(":", $page_id);
234  //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
235  switch ($page_arr[0]) {
236  case "lm":
237  switch ($this->content_object->getType()) {
238  case "lm":
239  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
240  $page_obj = new ilLMPage($page_arr[1]);
241  break;
242 
243  default:
244  die("Unknown content type " . $this->content_object->getType());
245  }
246 
247  break;
248 
249  case "gdf":
250  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
251  $page_obj = new ilGlossaryDefPage($page_arr[1]);
252  break;
253 
254  case "qpl":
255  $page_obj = new ilAssQuestionPage($page_arr[1]);
256  break;
257  }
258  $page_obj->buildDom();
259  $page_obj->resolveIntLinks();
260  $page_obj->resolveIIMMediaAliases($this->mob_mapping);
261  if (in_array($this->coType, array("lm"))) {
262  $page_obj->resolveQuestionReferences($this->qst_mapping);
263  }
264  $page_obj->update(false);
265 
266  if ($page_arr[0] == "gdf") {
267  $def = new ilGlossaryDefinition($page_arr[1]);
268  $def->updateShortText();
269  }
270 
271  unset($page_obj);
272  }
273 
274  //echo "<br><b>map area internal links</b>"; flush();
275  // outgoins map area (mob) internal links
276  foreach ($this->mobs_with_int_links as $mob_id) {
278  }
279 
280  //echo "<br><b>incoming interna links</b>"; flush();
281  // incoming internal links
282  $done = array();
283  foreach ($this->link_targets as $link_target) {
284  //echo "doin link target:".$link_target.":<br>";
285  $link_arr = explode("_", $link_target);
286  $target_inst = $link_arr[1];
287  $target_type = $link_arr[2];
288  $target_id = $link_arr[3];
289  //echo "<br>-".$target_type."-".$target_id."-".$target_inst."-";
291  foreach ($sources as $key => $source) {
292  //echo "got source:".$key.":<br>";
293  if (in_array($key, $done)) {
294  continue;
295  }
296  $type_arr = explode(":", $source["type"]);
297 
298  // content object pages
299  if ($type_arr[1] == "pg") {
300  if (ilPageObject::_exists($type_arr[0], $source["id"])) {
301  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
303  $page_object->buildDom();
304  $page_object->resolveIntLinks();
305  $page_object->update();
306  unset($page_object);
307  }
308  }
309 
310  // eventually correct links in questions to learning modules
311  if ($type_arr[0] == "qst") {
312  require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
314  }
315  // eventually correct links in survey questions to learning modules
316  if ($type_arr[0] == "sqst") {
317  require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
319  }
320  $done[$key] = $key;
321  }
322  }
323  }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
$target_type
Definition: goto.php:48
static _resolveIntLinks($question_id)
Question page object.
static _resolveMapAreaLinks($a_mob_id)
resolve internal links of all media items of a media object
$target_id
Definition: goto.php:49
Glossary definition page object.
Class ilGlossaryDefinition.
_resolveIntLinks($question_id)
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
$def
Definition: croninfo.php:21
$source
Definition: linkback.php:22
$key
Definition: croninfo.php:18
Extension of ilPageObject for learning modules.
+ 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 private

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

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

◆ setImportMapping()

ilContObjParser::setImportMapping ( ilImportMapping  $mapping = null)

Set import mapping.

Parameters
ilImportMapping$mapping

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

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

◆ setQuestionMapping()

ilContObjParser::setQuestionMapping (   $a_map)

set question import ident to pool/test question id mapping

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

402  {
403  $this->qst_mapping = $a_map;
404  }

◆ startParsing()

ilContObjParser::startParsing ( )

start parser

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

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

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

◆ storeTree()

ilContObjParser::storeTree ( )

insert StructureObjects and PageObjects into tree

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

References $ilLog, and $log.

Referenced by startParsing().

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

Field Documentation

◆ $cnt

ilContObjParser::$cnt

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

Referenced by handlerEndTag().

◆ $container

ilContObjParser::$container = []

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

◆ $content_object

ilContObjParser::$content_object

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

Referenced by handlerBeginTag().

◆ $current_element

ilContObjParser::$current_element

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

◆ $current_object

ilContObjParser::$current_object

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

◆ $file_item

ilContObjParser::$file_item

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

◆ $file_item_mapping

ilContObjParser::$file_item_mapping

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

◆ $glossary_object

ilContObjParser::$glossary_object

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

Referenced by handlerBeginTag().

◆ $glossary_term_map

ilContObjParser::$glossary_term_map = array()
protected

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

Referenced by getGlossaryTermMap().

◆ $in_file_item

ilContObjParser::$in_file_item

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

◆ $in_glossary

ilContObjParser::$in_glossary

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

◆ $in_map_area

ilContObjParser::$in_map_area

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

◆ $in_media_object

ilContObjParser::$in_media_object

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

◆ $in_meta_data

ilContObjParser::$in_meta_data

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

◆ $in_meta_meta_data

ilContObjParser::$in_meta_meta_data = false

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

◆ $in_page_object

ilContObjParser::$in_page_object

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

◆ $keyword_language

ilContObjParser::$keyword_language

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

◆ $learning_module

ilContObjParser::$learning_module

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

◆ $link_targets

ilContObjParser::$link_targets

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

◆ $lm_page_object

ilContObjParser::$lm_page_object

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

Referenced by handlerBeginTag().

◆ $lm_tree

ilContObjParser::$lm_tree

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

◆ $lng

ilContObjParser::$lng

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

Referenced by __construct().

◆ $loc_type

ilContObjParser::$loc_type

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

◆ $log

ilContObjParser::$log
protected

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

Referenced by storeTree().

◆ $map_area

ilContObjParser::$map_area

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

◆ $media_item

ilContObjParser::$media_item

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

◆ $media_object

ilContObjParser::$media_object

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

◆ $meta_data

ilContObjParser::$meta_data

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

◆ $metadata_parsing_disabled

ilContObjParser::$metadata_parsing_disabled

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

◆ $mob_mapping

ilContObjParser::$mob_mapping

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

◆ $page_object

ilContObjParser::$page_object

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

Referenced by processPagesToParse().

◆ $pages_to_parse

ilContObjParser::$pages_to_parse

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

◆ $paragraph

ilContObjParser::$paragraph

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

◆ $pg_into_tree

ilContObjParser::$pg_into_tree

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

◆ $qst_mapping

ilContObjParser::$qst_mapping

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

◆ $st_into_tree

ilContObjParser::$st_into_tree

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

◆ $structure_objects

ilContObjParser::$structure_objects

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

◆ $subdir

ilContObjParser::$subdir

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

◆ $table

ilContObjParser::$table

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

◆ $tree

ilContObjParser::$tree

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

Referenced by __construct().


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