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

Legacy Content Object Parser. More...

+ Inheritance diagram for ilQuestionPageParser:
+ Collaboration diagram for ilQuestionPageParser:

Public Member Functions

 __construct (ilObject $a_content_object, string $a_xml_file, string $a_subdir, string $a_import_dir="")
 
 setHandlers ($a_xml_parser)
 
 setImportMapping (ilImportMapping $mapping=null)
 
 startParsing ()
 stores xml data in array 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 (array $a_map)
 set question import ident to pool/test question id mapping More...
 
 beginElement (string $a_name)
 
 endElement (string $a_name)
 
 getCurrentElement ()
 
 getOpenCount (string $a_name)
 
 buildTag (string $type, string $name, array $attr=[])
 
 processMeta ()
 
 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)
 
 getGlossaryTermMap ()
 
- 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

 $tree
 
 $cnt = []
 
 $current_element = []
 
 $learning_module = null
 
 $page_object = null
 
 $lm_page_object = null
 
 $structure_objects = []
 
 $media_object = null
 
 $current_object = null
 
 $lm_tree = null
 
 $pg_into_tree = []
 
 $st_into_tree = []
 
 $container = []
 
 $in_page_object = false
 
 $in_meta_data = false
 
 $in_media_object = false
 
 $in_file_item = false
 
 $in_glossary = false
 
 $in_map_area = false
 
 $content_object = null
 
 $glossary_object = null
 
 $file_item = null
 
 $pages_to_parse = []
 
 $mob_mapping = []
 
 $file_item_mapping = []
 
 $subdir = ""
 
 $media_item = null
 
 $loc_type = ""
 
 $map_area = null
 
 $link_targets = []
 
 $qst_mapping = []
 
 $metadata_parsing_disabled = false
 
 $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

 $in_properties
 
 $in_glossary_definition = false
 
 $media_meta_cache = []
 
 $media_meta_start = false
 
 $pg_mapping = []
 
 $mobs_with_int_links = []
 
 $inside_code = false
 
 $coType = ""
 
 $import_dir = ""
 
 $glossary_term_map = []
 
 $log
 
 $glossary_term = null
 
 $mapping = null
 
 $cur_qid = ""
 
 $glossary_definition = null
 
 $chr_data = ""
 
 $in_media_item = false
 
- 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

Legacy Content Object Parser.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Deprecated:
use COPage dependency to export/import COPages instead

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

Constructor & Destructor Documentation

◆ __construct()

ilQuestionPageParser::__construct ( ilObject  $a_content_object,
string  $a_xml_file,
string  $a_subdir,
string  $a_import_dir = "" 
)

Definition at line 86 of file class.ilQuestionPageParser.php.

91 {
92 global $DIC;
93
94 $this->log = $DIC["ilLog"];
95 $lng = $DIC->language();
96 $tree = $DIC->repositoryTree();
97
98 $this->log = ilLoggerFactory::getLogger('lm');
99
100 $this->import_dir = ($a_import_dir != "")
101 ? $a_import_dir
102 : $a_content_object->getImportDirectory();
103
104 parent::__construct($a_xml_file);
105 $this->cnt = array();
106 $this->current_element = array();
107 $this->structure_objects = array();
108 $this->content_object = $a_content_object;
109 $this->st_into_tree = array();
110 $this->pg_into_tree = array();
111 $this->pages_to_parse = array();
112 $this->mobs_with_int_links = array();
113 $this->mob_mapping = array();
114 $this->file_item_mapping = array();
115 $this->pg_mapping = array();
116 $this->link_targets = array();
117 $this->subdir = $a_subdir;
118 $this->lng = $lng;
119 $this->tree = $tree;
120 $this->inside_code = false;
121 $this->qst_mapping = array();
122 $this->coType = $this->content_object->getType();
123 $this->metadata_parsing_disabled = false;
124
125 if (($this->coType != "tst") && ($this->coType != "qpl")) {
126 $this->lm_tree = new ilLMTree($this->content_object->getId());
127 }
128 }
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ beginElement()

ilQuestionPageParser::beginElement ( string  $a_name)

Definition at line 355 of file class.ilQuestionPageParser.php.

355 : void
356 {
357 if (!isset($this->status["$a_name"])) {
358 $this->cnt[$a_name] = 1;
359 } else {
360 $this->cnt[$a_name]++;
361 }
362 $this->current_element[count($this->current_element)] = $a_name;
363 }

◆ buildTag()

ilQuestionPageParser::buildTag ( string  $type,
string  $name,
array  $attr = [] 
)

Definition at line 384 of file class.ilQuestionPageParser.php.

388 : string {
389 $tag = "<";
390
391 if ($type == "end") {
392 $tag .= "/";
393 }
394
395 $tag .= $name;
396
397 if (is_array($attr)) {
398 foreach ($attr as $k => $v) {
399 $tag .= " " . $k . "=\"$v\"";
400 }
401 }
402
403 $tag .= ">";
404
405 return $tag;
406 }
if($format !==null) $name
Definition: metadata.php:230
$type

◆ copyFileItems()

ilQuestionPageParser::copyFileItems ( )

copy files of file items

Definition at line 323 of file class.ilQuestionPageParser.php.

323 : void
324 {
325 $imp_dir = $this->import_dir;
326 foreach ($this->file_item_mapping as $origin_id => $file_id) {
327 if (empty($origin_id)) {
328 continue;
329 }
330 $obj_dir = $origin_id;
331 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
332
333 $file_obj = new ilObjFile($file_id, false);
334 if (is_dir($source_dir)) {
335 $files = scandir($source_dir, SCANDIR_SORT_DESCENDING);
336 if ($files !== false && $files !== [] && is_file($source_dir . '/' . $files[0])) {
337 $file = fopen($source_dir . '/' . $files[0], 'rb');
338 $file_stream = Streams::ofResource($file);
339 $file_obj->appendStream($file_stream, $files[0]);
340 }
341 }
342 $file_obj->update();
343 }
344 }
Class ilObjFile.

References $import_dir.

Referenced by startParsing().

+ Here is the caller graph for this function:

◆ copyMobFiles()

ilQuestionPageParser::copyMobFiles ( )

copy multimedia object files from import zip file to mob directory

Definition at line 297 of file class.ilQuestionPageParser.php.

297 : void
298 {
299 $imp_dir = $this->import_dir;
300 foreach ($this->mob_mapping as $origin_id => $mob_id) {
301 if (empty($origin_id)) {
302 continue;
303 }
304
305 $obj_dir = $origin_id;
306 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
307 $target_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $mob_id;
308
309 if (is_dir($source_dir)) {
310 ilUtil::makeDir($target_dir);
311
312 if (is_dir($target_dir)) {
313 ilLoggerFactory::getLogger("mob")->debug("s:-$source_dir-,t:-$target_dir-");
314 ilUtil::rCopy(realpath($source_dir), realpath($target_dir));
315 }
316 }
317 }
318 }
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $import_dir, 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()

ilQuestionPageParser::emptyMediaMetaCache (   $a_xml_parser)
Parameters
resource$a_xml_parser

Definition at line 1361 of file class.ilQuestionPageParser.php.

1361 : void
1362 {
1363 foreach ($this->media_meta_cache as $cache_entry) {
1364 switch ($cache_entry["type"]) {
1365 case "handlerBeginTag":
1366 parent::handlerBeginTag(
1367 $a_xml_parser,
1368 $cache_entry["par1"],
1369 $cache_entry["par2"]
1370 );
1371 break;
1372
1373 case "handlerEndTag":
1374 parent::handlerEndTag(
1375 $a_xml_parser,
1376 $cache_entry["par1"]
1377 );
1378 break;
1379
1380 case "handlerCharacterData":
1381 parent::handlerCharacterData(
1382 $a_xml_parser,
1383 $cache_entry["par1"]
1384 );
1385 break;
1386 }
1387 }
1388
1389 $this->media_meta_start = false;
1390 $this->media_meta_cache[] = array();
1391 }

◆ endElement()

ilQuestionPageParser::endElement ( string  $a_name)

Definition at line 365 of file class.ilQuestionPageParser.php.

365 : void
366 {
367 $this->cnt[$a_name]--;
368 unset($this->current_element[count($this->current_element) - 1]);
369 }

◆ getCurrentElement()

ilQuestionPageParser::getCurrentElement ( )

Definition at line 371 of file class.ilQuestionPageParser.php.

371 : string
372 {
373 return ($this->current_element[count($this->current_element) - 1] ?? "");
374 }

◆ getGlossaryTermMap()

ilQuestionPageParser::getGlossaryTermMap ( )
Returns
mixed[]

Definition at line 1396 of file class.ilQuestionPageParser.php.

1396 : array
1397 {
1399 }

◆ getOpenCount()

ilQuestionPageParser::getOpenCount ( string  $a_name)

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

376 : int
377 {
378 if (isset($this->cnt[$a_name])) {
379 return $this->cnt[$a_name];
380 }
381 return 0;
382 }

◆ handlerCharacterData()

ilQuestionPageParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Reimplemented from ilMDSaxParser.

Definition at line 1306 of file class.ilQuestionPageParser.php.

1306 : void
1307 {
1308 // call meta data handler
1309 if ($this->in_meta_data && $this->processMeta()) {
1310 // cache beginning of meta data within media object tags
1311 // (we need to know the id, after that we send the cached data
1312 // to the meta xml handler)
1313 if ($this->in_media_object && $this->media_meta_start) {
1314 $this->media_meta_cache[] =
1315 array("type" => "handlerCharacterData", "par1" => $a_data);
1316 } else {
1317 parent::handlerCharacterData($a_xml_parser, $a_data);
1318 }
1319 }
1320
1321 // the parser converts "&gt;" to ">" and "&lt;" to "<"
1322 // in character data, but we don't want that, because it's the
1323 // way we mask user html in our content, so we convert back...
1324
1325 $a_data = str_replace("<", "&lt;", $a_data);
1326 $a_data = str_replace(">", "&gt;", $a_data);
1327
1328
1329 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1330 $a_data = preg_replace("/\n/", "", $a_data);
1331 if (!$this->inside_code) {
1332 $a_data = preg_replace("/\t+/", "", $a_data);
1333 }
1334
1335 $this->chr_data .= $a_data;
1336
1337 if (!empty($a_data) || $a_data === "0") {
1338 // append all data to page, if we are within PageObject,
1339 // but not within MetaData or MediaObject
1340 if (($this->in_page_object || $this->in_glossary_definition)
1341 && !$this->in_meta_data && !$this->in_media_object) {
1342 $this->page_object->appendXMLContent($a_data);
1343 }
1344
1345 switch ($this->getCurrentElement()) {
1346
1347 case "IntLink":
1348 case "ExtLink":
1349 if ($this->in_map_area) {
1350 $this->map_area->appendTitle($a_data);
1351 }
1352 break;
1353
1354 }
1355 }
1356 }

◆ handlerEndTag()

ilQuestionPageParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Reimplemented from ilMDSaxParser.

Definition at line 892 of file class.ilQuestionPageParser.php.

892 : void
893 {
894 // call meta data handler
895 if ($this->in_meta_data && $this->processMeta()) {
896 // cache beginning of meta data within media object tags
897 // (we need to know the id, after that we send the cached data
898 // to the meta xml handler)
899 if ($this->in_media_object && $this->media_meta_start) {
900 $this->media_meta_cache[] =
901 array("type" => "handlerEndTag", "par1" => $a_name);
902 } else {
903 parent::handlerEndTag($a_xml_parser, $a_name);
904 }
905 }
906
907 // append content to page xml content
908 if (($this->in_page_object || $this->in_glossary_definition)
909 && !$this->in_meta_data && !$this->in_media_object) {
910 $app_name = ($a_name == "Definition")
911 ? "PageObject"
912 : $a_name;
913 $this->page_object->appendXMLContent($this->buildTag("end", $app_name));
914 }
915
916 switch ($a_name) {
917 case "StructureObject":
918 unset($this->structure_objects[count($this->structure_objects) - 1]);
919 break;
920
921 case "PageObject":
922
923 $this->in_page_object = false;
924 if (($this->coType != "tst") && ($this->coType != "qpl")) {
925 //if (!$this->lm_page_object->isAlias()) {
926 $this->page_object->updateFromXML();
927 $this->pg_mapping[$this->lm_page_object->getImportId()]
928 = $this->lm_page_object->getId();
929
930 if ($this->mapping instanceof ilImportMapping) {
931 $import_id_parsed = ilUtil::parseImportId($this->lm_page_object->getImportId());
932 if ($import_id_parsed['type'] == 'pg') {
933 $this->mapping->addMapping(
934 'Modules/LearningModule',
935 'pg',
936 $import_id_parsed['id'],
937 $this->lm_page_object->getId()
938 );
939 }
940 }
941
942 // collect pages with internal links
943 if ($this->page_object->containsIntLink()) {
944 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
945 }
946
947 // collect pages with mobs or files
948 if ($this->page_object->needsImportParsing()) {
949 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
950 }
951
952 // collect pages with questions
953 if ($this->page_object->getContainsQuestion()) {
954 $this->pages_to_parse["lm:" . $this->page_object->getId()] = "lm:" . $this->page_object->getId();
955 }
956 //}
957 } else {
958 $xml = $this->page_object->getXMLContent();
959 if ($this->cur_qid != "") {
960 $ids = $this->qst_mapping[$this->cur_qid] ?? ['pool' => 0, 'test' => 0];
961 if ($ids["pool"] > 0) {
962 // question pool question
963 $page = new ilAssQuestionPage($ids["pool"]);
964 $xmlcontent = str_replace(
965 $this->cur_qid,
966 "il__qst_" . $ids["pool"],
967 $xml
968 );
969 $page->setXMLContent($xmlcontent);
970 $page->updateFromXML();
971 if ($this->page_object->needsImportParsing()) {
972 $this->pages_to_parse["qpl:" . $page->getId()] = "qpl:" . $page->getId();
973 }
974 unset($page);
975 }
976 if ($ids["test"] > 0) {
977 // test question
978 $page = new ilAssQuestionPage($ids["test"]);
979 $xmlcontent = str_replace(
980 $this->cur_qid,
981 "il__qst_" . $ids["test"],
982 $xml
983 );
984 $page->setXMLContent($xmlcontent);
985 $page->updateFromXML();
986 if ($this->page_object->needsImportParsing()) {
987 $this->pages_to_parse["qpl:" . $page->getId()] = "qpl:" . $page->getId();
988 }
989 unset($page);
990 }
991 }
992 }
993
994 // if we are within a structure object: put page in tree
995 $cnt = count($this->structure_objects);
996 if ($cnt > 0) {
997 $parent_id = $this->structure_objects[$cnt - 1]->getId();
998 //if ($this->lm_page_object->isAlias()) {
999 // $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId());
1000 //} else {
1001 $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId());
1002 //}
1003 }
1004
1005 unset($this->page_object);
1006 unset($this->lm_page_object);
1007 unset($this->container[count($this->container) - 1]);
1008 break;
1009
1010 case "MediaObject":
1011 case "InteractiveImage":
1012 if ($a_name == "MediaObject") {
1013 $this->in_media_object = false;
1014 }
1015
1016 if (empty($this->mob_mapping[$this->media_object->getImportId()])) {
1017 // create media object
1018 // media items are saves for mobs outside of
1019 // pages only
1020 $this->media_object->create(true, false);
1021
1022 // collect mobs with internal links
1023 if ($this->media_object->containsIntLink()) {
1024 //echo "got int link :".$this->media_object->getId().":<br>";
1025 $this->mobs_with_int_links[] = $this->media_object->getId();
1026 }
1027
1028 $this->mob_mapping[$this->media_object->getImportId()]
1029 = $this->media_object->getId();
1030 } else {
1031 // get the id from mapping
1032 $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
1033
1034 // update "real" (no alias) media object
1035 // (note: we overwrite any data from the media object
1036 // created by an MediaAlias, only the data of the real
1037 // object is stored in db separately; data of the
1038 // MediaAliases are within the page XML
1039 if (!$this->media_object->isAlias()) {
1040 // now the media items are saved within the db
1041 $this->media_object->update();
1042
1043 //echo "<br>update media object :".$this->media_object->getId().":";
1044
1045 // collect mobs with internal links
1046 if ($this->media_object->containsIntLink()) {
1047 //echo "got int link :".$this->media_object->getId().":<br>";
1048 $this->mobs_with_int_links[] = $this->media_object->getId();
1049 }
1050 }
1051 }
1052
1053 // append media alias to page, if we are in a page
1054 if ($this->in_page_object || $this->in_glossary_definition) {
1055 if ($a_name != "InteractiveImage") {
1056 $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
1057 //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>";
1058 }
1059 }
1060
1061 break;
1062
1063 case "MediaItem":
1064 case "MediaAliasItem":
1065 $this->in_media_item = false;
1066 $this->media_object->addMediaItem($this->media_item);
1067 break;
1068
1069 case "MapArea":
1070 $this->in_map_area = false;
1071 $this->media_item->addMapArea($this->map_area);
1072 break;
1073
1074 case "Properties":
1075 $this->in_properties = false;
1076 if ($this->content_object->getType() == "lm") {
1077 $this->content_object->update();
1078 }
1079 break;
1080
1081 case "MetaData":
1082 $this->in_meta_data = false;
1083 if (strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object) {
1084 // Metadaten eines PageObjects sichern in NestedSet
1085 if (is_object($this->lm_page_object)) {
1086 // update title/description of page object
1087 $this->current_object->MDUpdateListener('General');
1089 $this->current_object->getId(),
1090 $this->current_object->getImportId()
1091 );
1092 }
1093 } elseif ((strtolower(get_class($this->current_object)) == "ilobjquestionpool" ||
1094 strtolower(get_class($this->current_object)) == "ilobjtest") &&
1095 !$this->in_media_object) {
1096 // !$this->in_media_object && !$this->in_page_object)
1097 // changed for imports of ILIAS 2 Tests where PageObjects could have
1098 // Metadata sections (Helmut Schottmüller, 2005-12-02)
1099 if ($this->metadata_parsing_disabled) {
1100 $this->enableMDParsing(true);
1101 } else {
1102 if ($this->in_page_object && !is_null($this->page_object)) {
1103 /*
1104 $this->page_object->MDUpdateListener('General');
1105 ilLMObject::_writeImportId(
1106 $this->page_object->getId(),
1107 $this->page_object->getImportId()
1108 );*/
1109 } else {
1110 $this->current_object->MDUpdateListener('General');
1112 $this->current_object->getId(),
1113 $this->current_object->getImportId()
1114 );
1115 }
1116 }
1117 } elseif (strtolower(get_class($this->current_object)) == "ilstructureobject") { // save structure object at the end of its meta block
1118 // determine parent
1119 $cnt = count($this->structure_objects);
1120 if ($cnt > 1) {
1121 $parent_id = $this->structure_objects[$cnt - 2]->getId();
1122 } else {
1123 $parent_id = $this->lm_tree->getRootId();
1124 }
1125
1126 $this->st_into_tree[] = array("id" => $this->current_object->getId(),
1127 "parent" => $parent_id);
1128
1129 // update title/description of structure object
1130 $this->current_object->MDUpdateListener('General');
1132 $this->current_object->getId(),
1133 $this->current_object->getImportId()
1134 );
1135 } elseif (strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1136 strtolower(get_class($this->current_object)) == "ilobjcontentobject" ||
1137 (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary)) {
1138 // todo: saving of md? getting title/descr and
1139 // set it for current object
1140 } elseif (strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object) {
1141 // now on top
1142 //$this->glossary_definition->create();
1143
1144 $this->page_object->setId($this->glossary_definition->getId());
1145 $this->page_object->updateFromXML();
1146
1147 // todo: saving of md? getting title/descr and
1148 // set it for current object
1149 }
1150
1151
1152 if (strtolower(get_class($this->current_object)) == "ilobjlearningmodule" ||
1153 strtolower(get_class($this->current_object)) == "ilobjglossary") {
1154 if (strtolower(get_class($this->current_object)) == "ilobjglossary" &&
1155 $this->content_object->getType() != "glo") {
1156 //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>";
1157 $this->current_object->setTitle($this->content_object->getTitle() . " - " .
1158 $this->lng->txt("glossary"));
1159 }
1160
1161 $this->current_object->MDUpdateListener('General');
1162 /*
1163 if (!$this->in_media_object && $this->processMeta())
1164 {
1165 $this->current_object->update();
1166 }
1167 */
1168 }
1169
1170 if ($this->in_media_object) {
1171 //echo "<br>call media object update listener";
1172 $this->media_object->MDUpdateListener('General');
1173 }
1174
1175 if ($this->in_glossary_definition) {
1176 $this->glossary_definition->MDUpdateListener('General');
1177 }
1178
1179 break;
1180
1181 case "Meta-Metadata":
1182 $this->in_meta_meta_data = false;
1183 break;
1184
1185 case "FileItem":
1186 $this->in_file_item = false;
1187 // only update new file items
1188 if ($this->file_item->getImportId()) {
1189 $this->file_item->update();
1190 }
1191 break;
1192
1193
1194 case "Table":
1195 unset($this->container[count($this->container) - 1]);
1196 break;
1197
1198 case "Glossary":
1199 $this->in_glossary = false;
1200 break;
1201
1202 case "GlossaryTerm":
1203 $term = trim($this->chr_data);
1204 $term = str_replace("&lt;", "<", $term);
1205 $term = str_replace("&gt;", ">", $term);
1206 $this->glossary_term->setTerm($term);
1207 $this->glossary_term->create();
1208 $iia = explode("_", $this->glossary_term->getImportId());
1209 $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1210 break;
1211
1212 case "Paragraph":
1213 $this->inside_code = false;
1214 break;
1215
1216 case "Definition":
1217 $this->in_glossary_definition = false;
1218 $this->page_object->updateFromXML();
1219 $this->page_object->buildDom();
1220 $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText());
1221 $this->glossary_definition->update();
1222 if ($this->page_object->containsIntLink()) {
1223 $this->pages_to_parse["gdf:" . $this->page_object->getId()] = "gdf:" . $this->page_object->getId();
1224 }
1225 if ($this->page_object->needsImportParsing()) {
1226 $this->pages_to_parse["gdf:" . $this->page_object->getId()] = "gdf:" . $this->page_object->getId();
1227 }
1228 break;
1229
1230 case "Format":
1231 if ($this->in_media_item) {
1232 $this->media_item->setFormat(trim($this->chr_data));
1233 }
1234 break;
1235
1236 case "Title":
1237 if ($this->in_meta_data && !$this->in_media_object) {
1238 $this->current_object->setTitle(trim($this->chr_data));
1239 }
1240 if ($this->in_media_object) {
1241 $this->media_object->setTitle(trim($this->chr_data));
1242 }
1243 break;
1244
1245 case "Description":
1246 case "Language":
1247 break;
1248
1249 case "Caption":
1250 if ($this->in_media_object) {
1251 $this->media_item->setCaption(trim($this->chr_data));
1252 }
1253 break;
1254
1255 case "TextRepresentation":
1256 if ($this->in_media_object) {
1257 $this->media_item->setTextRepresentation(trim($this->chr_data));
1258 }
1259 break;
1260
1261 // Location
1262 case "Location":
1263 // TODO: adapt for files in "real" subdirectories
1264 if ($this->in_media_item) {
1265 $this->media_item->setLocationType($this->loc_type);
1266 if ($this->loc_type == "Reference") {
1267 $this->media_item->setLocation(str_replace("&", "&amp;", trim($this->chr_data)));
1268 } else {
1269 $this->media_item->setLocation(trim($this->chr_data));
1270 }
1271 }
1272 if ($this->in_file_item) {
1273 // set file name from xml file
1274 $this->file_item->setFileName(trim($this->chr_data));
1275
1276 // special handling for file names with special characters
1277 // (e.g. "&gt;")
1278 if ($this->file_item->getType() == "file" &&
1279 is_int(strpos($this->chr_data, "&")) &&
1280 is_int(strpos($this->chr_data, ";"))) {
1281 $imp_dir = $this->import_dir;
1282 $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" .
1283 $this->file_item->getImportId();
1284
1285 // read "physical" file name from directory
1286 if ($dir = opendir($source_dir)) {
1287 while (false !== ($file = readdir($dir))) {
1288 if ($file != "." && $file != "..") {
1289 $this->file_item->setFileName($file);
1290 }
1291 }
1292 closedir($dir);
1293 }
1294 }
1295
1296 // set file item title
1297 $this->file_item->setTitle(trim($this->chr_data));
1298 }
1299 break;
1300
1301 }
1302 $this->endElement($a_name);
1303 $this->chr_data = "";
1304 }
const IL_MODE_ALIAS
Question page object.
static _writeImportId($a_id, $a_import_id)
write import id to db (static)
enableMDParsing($a_status)
buildTag(string $type, string $name, array $attr=[])
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
$xml
Definition: metadata.php:332

References $xml, ilLMObject\_writeImportId(), IL_MODE_ALIAS, and ilUtil\parseImportId().

+ Here is the call graph for this function:

◆ processMeta()

ilQuestionPageParser::processMeta ( )

Definition at line 878 of file class.ilQuestionPageParser.php.

878 : bool
879 {
880 // do not process second meta block in (ilias3) glossaries
881 // which comes right after the "Glossary" tag
882 if ($this->content_object->getType() == "glo" &&
883 $this->in_glossary && !$this->in_media_object
884 && !$this->in_glossary_definition) {
885 return false;
886 }
887
888 return true;
889 }

◆ processPagesToParse()

ilQuestionPageParser::processPagesToParse ( )

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

Definition at line 201 of file class.ilQuestionPageParser.php.

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

ilQuestionPageParser::setHandlers (   $a_xml_parser)
Parameters
resource$a_xml_parser

Reimplemented from ilMDSaxParser.

Definition at line 133 of file class.ilQuestionPageParser.php.

133 : void
134 {
135 xml_set_object($a_xml_parser, $this);
136 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
137 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
138 }

◆ setImportMapping()

ilQuestionPageParser::setImportMapping ( ilImportMapping  $mapping = null)

Definition at line 140 of file class.ilQuestionPageParser.php.

140 : void
141 {
142 $this->mapping = $mapping;
143 }

References $mapping.

◆ setQuestionMapping()

ilQuestionPageParser::setQuestionMapping ( array  $a_map)

set question import ident to pool/test question id mapping

Parameters
mixed[]$a_map

Definition at line 350 of file class.ilQuestionPageParser.php.

350 : void
351 {
352 $this->qst_mapping = $a_map;
353 }

◆ startParsing()

ilQuestionPageParser::startParsing ( )

stores xml data in array

@access private

Exceptions
ilSaxParserExceptionor ILIAS Error

Reimplemented from ilSaxParser.

Definition at line 145 of file class.ilQuestionPageParser.php.

145 : void
146 {
147 $this->log->debug("start");
148
149 //echo "<b>start parsing</b><br>";
150 parent::startParsing();
151 //echo "<b>storeTree</b><br>";
152 $this->storeTree();
153 //echo "<b>processPagesToParse</b><br>";
154 $this->processPagesToParse();
155 //echo "<b>copyMobFiles</b><br>";
156 $this->copyMobFiles();
157 //echo "<b>copyFileItems</b><br>";
158 $this->copyFileItems();
159 //echo "<br>END Parsing"; exit;
160 }
copyFileItems()
copy files of file items
copyMobFiles()
copy multimedia object files from import zip file to mob directory
processPagesToParse()
parse pages that contain files, mobs and/or internal links
storeTree()
insert StructureObjects and PageObjects into tree

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

+ Here is the call graph for this function:

◆ storeTree()

ilQuestionPageParser::storeTree ( )

insert StructureObjects and PageObjects into tree

Definition at line 165 of file class.ilQuestionPageParser.php.

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

References $log.

Referenced by startParsing().

+ Here is the caller graph for this function:

Field Documentation

◆ $chr_data

ilQuestionPageParser::$chr_data = ""
protected

Definition at line 83 of file class.ilQuestionPageParser.php.

◆ $cnt

ilQuestionPageParser::$cnt = []

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

◆ $container

ilQuestionPageParser::$container = []

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

◆ $content_object

ilQuestionPageParser::$content_object = null

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

◆ $coType

ilQuestionPageParser::$coType = ""
protected

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

◆ $cur_qid

ilQuestionPageParser::$cur_qid = ""
protected

Definition at line 81 of file class.ilQuestionPageParser.php.

◆ $current_element

ilQuestionPageParser::$current_element = []

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

◆ $current_object

ilQuestionPageParser::$current_object = null

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

◆ $file_item

ilQuestionPageParser::$file_item = null

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

◆ $file_item_mapping

ilQuestionPageParser::$file_item_mapping = []

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

◆ $glossary_definition

ilQuestionPageParser::$glossary_definition = null
protected

Definition at line 82 of file class.ilQuestionPageParser.php.

◆ $glossary_object

ilQuestionPageParser::$glossary_object = null

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

◆ $glossary_term

ilQuestionPageParser::$glossary_term = null
protected

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

◆ $glossary_term_map

ilQuestionPageParser::$glossary_term_map = []
protected

Definition at line 77 of file class.ilQuestionPageParser.php.

◆ $import_dir

ilQuestionPageParser::$import_dir = ""
protected

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

Referenced by copyFileItems(), and copyMobFiles().

◆ $in_file_item

ilQuestionPageParser::$in_file_item = false

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

◆ $in_glossary

ilQuestionPageParser::$in_glossary = false

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

◆ $in_glossary_definition

ilQuestionPageParser::$in_glossary_definition = false
protected

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

◆ $in_map_area

ilQuestionPageParser::$in_map_area = false

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

◆ $in_media_item

ilQuestionPageParser::$in_media_item = false
protected

Definition at line 84 of file class.ilQuestionPageParser.php.

◆ $in_media_object

ilQuestionPageParser::$in_media_object = false

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

◆ $in_meta_data

ilQuestionPageParser::$in_meta_data = false

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

◆ $in_meta_meta_data

ilQuestionPageParser::$in_meta_meta_data = false

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

◆ $in_page_object

ilQuestionPageParser::$in_page_object = false

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

◆ $in_properties

ilQuestionPageParser::$in_properties
protected

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

◆ $inside_code

ilQuestionPageParser::$inside_code = false
protected

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

◆ $learning_module

ilQuestionPageParser::$learning_module = null

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

◆ $link_targets

ilQuestionPageParser::$link_targets = []

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

◆ $lm_page_object

ilQuestionPageParser::$lm_page_object = null

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

◆ $lm_tree

ilQuestionPageParser::$lm_tree = null

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

◆ $loc_type

ilQuestionPageParser::$loc_type = ""

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

◆ $log

ilQuestionPageParser::$log
protected

Definition at line 78 of file class.ilQuestionPageParser.php.

Referenced by storeTree().

◆ $map_area

ilQuestionPageParser::$map_area = null

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

◆ $mapping

ilQuestionPageParser::$mapping = null
protected

Definition at line 80 of file class.ilQuestionPageParser.php.

Referenced by setImportMapping().

◆ $media_item

ilQuestionPageParser::$media_item = null

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

◆ $media_meta_cache

ilQuestionPageParser::$media_meta_cache = []
protected

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

◆ $media_meta_start

ilQuestionPageParser::$media_meta_start = false
protected

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

◆ $media_object

ilQuestionPageParser::$media_object = null

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

◆ $metadata_parsing_disabled

ilQuestionPageParser::$metadata_parsing_disabled = false

Definition at line 75 of file class.ilQuestionPageParser.php.

◆ $mob_mapping

ilQuestionPageParser::$mob_mapping = []

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

◆ $mobs_with_int_links

ilQuestionPageParser::$mobs_with_int_links = []
protected

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

◆ $page_object

ilQuestionPageParser::$page_object = null

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

Referenced by processPagesToParse().

◆ $pages_to_parse

ilQuestionPageParser::$pages_to_parse = []

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

◆ $pg_into_tree

ilQuestionPageParser::$pg_into_tree = []

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

◆ $pg_mapping

ilQuestionPageParser::$pg_mapping = []
protected

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

◆ $qst_mapping

ilQuestionPageParser::$qst_mapping = []

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

◆ $st_into_tree

ilQuestionPageParser::$st_into_tree = []

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

◆ $structure_objects

ilQuestionPageParser::$structure_objects = []

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

◆ $subdir

ilQuestionPageParser::$subdir = ""

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

◆ $tree

ilQuestionPageParser::$tree

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

Referenced by __construct().


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