83 private readonly
ilObject $content_object,
85 private readonly
string $importdir
88 $lng = $DIC->language();
89 $tree = $DIC->repositoryTree();
95 $this->current_element = [];
96 $this->structure_objects = [];
97 $this->st_into_tree = [];
98 $this->pg_into_tree = [];
99 $this->pages_to_parse = [];
100 $this->mobs_with_int_links = [];
101 $this->mob_mapping = [];
102 $this->file_item_mapping = [];
103 $this->pg_mapping = [];
104 $this->link_targets = [];
107 $this->inside_code =
false;
108 $this->qst_mapping = [];
109 $this->content_type = $this->content_object->getType();
110 $this->metadata_parsing_disabled =
false;
112 if ($this->content_type !==
'tst' && $this->content_type !==
'qpl') {
113 $this->lm_tree =
new ilLMTree($this->content_object->getId());
122 xml_set_object($xml_parser, $this);
123 xml_set_element_handler($xml_parser,
'handlerBeginTag',
'handlerEndTag');
124 xml_set_character_data_handler($xml_parser,
'handlerCharacterData');
134 $this->log->debug(
'start');
136 parent::startParsing();
149 foreach ($this->st_into_tree as $st) {
150 $this->lm_tree->insertNode($st[
'id'], $st[
'parent']);
151 if (is_array($this->pg_into_tree[$st[
'id']])) {
152 foreach ($this->pg_into_tree[$st[
'id']] as $pg) {
154 switch ($pg[
'type']) {
156 if ($this->pg_mapping[$pg[
'id']] ==
'') {
157 $ilLog->
write(
'LM Import: No PageObject for PageAlias ' .
158 $pg[
'id'] .
' found! (Please update export installation to ILIAS 3.3.0)');
163 $pg_id = $this->pg_mapping[$pg[
'id']];
170 if (!$this->lm_tree->isInTree($pg_id)) {
171 $this->lm_tree->insertNode($pg_id, $st[
'id']);
184 foreach ($this->pages_to_parse as $page_id) {
185 $page_arr = explode(
':', $page_id);
187 switch ($page_arr[0]) {
189 switch ($this->content_object->getType()) {
191 $page_obj =
new ilLMPage($page_arr[1]);
195 die(
'Unknown content type ' . $this->content_object->getType());
208 $page_obj->buildDom();
209 $page_obj->resolveIntLinks();
210 $page_obj->resolveIIMMediaAliases($this->mob_mapping);
211 if ($this->content_type ==
'lm') {
212 $page_obj->resolveQuestionReferences($this->qst_mapping);
214 $page_obj->update(
false);
216 if ($page_arr[0] ==
'term') {
218 $term->updateShortText();
224 foreach ($this->mobs_with_int_links as $mob_id) {
229 foreach ($this->link_targets as $link_target) {
231 if (!isset($parsed)) {
236 $parsed[
'target_type'],
237 $parsed[
'target_id'],
238 $parsed[
'target_inst']
240 foreach ($sources as $key => $source) {
241 if (in_array($key, $done)) {
244 $type_arr = explode(
':', $source[
'type']);
247 if ($type_arr[1] ==
'pg') {
258 if ($type_arr[0] ===
'qst') {
271 foreach ($this->file_item_mapping as $origin_id => $file_id) {
272 if (empty($origin_id)) {
275 $obj_dir = $origin_id;
276 $source_dir = $this->importdir . DIRECTORY_SEPARATOR .
'objects' . DIRECTORY_SEPARATOR . $obj_dir;
278 $file_obj =
new ilObjFile($file_id,
false);
279 if (is_dir($source_dir)) {
280 $files = scandir($source_dir, SCANDIR_SORT_DESCENDING);
281 if ($files !==
false && $files !== [] && is_file($source_dir .
'/' . $files[0])) {
282 $file = fopen($source_dir .
'/' . $files[0],
'rb');
283 $file_stream = Streams::ofResource($file);
284 $file_obj->appendStream($file_stream, $files[0]);
297 $this->qst_mapping = $a_map;
302 if (!isset($this->status[
'$a_name'])) {
303 $this->cnt[$a_name] = 1;
305 $this->cnt[$a_name]++;
307 $this->current_element[count($this->current_element)] = $a_name;
312 $this->cnt[$a_name]--;
313 unset($this->current_element[count($this->current_element) - 1]);
318 return ($this->current_element[count($this->current_element) - 1] ??
'');
323 if (isset($this->cnt[$a_name])) {
324 return $this->cnt[$a_name];
336 if ($type ==
'end') {
342 if (is_array($attr)) {
343 foreach ($attr as $k => $v) {
344 $tag .=
' ' . $k .
"='$v'";
353 public function handlerBeginTag($a_xml_parser,
string $a_name, array $a_attribs):
void 356 case 'ContentObject':
357 $this->current_object = $this->content_object;
358 if ($a_attribs[
'Type'] ==
'Glossary') {
359 $this->glossary_object = $this->content_object;
363 case 'StructureObject':
365 $lm = $this->content_object;
366 $this->structure_objects[count($this->structure_objects)]
368 $this->current_object = $this->structure_objects[count($this->structure_objects) - 1];
369 $this->current_object->setLMId($this->content_object->getId());
373 $this->current_object->create(
true);
377 $this->in_page_object =
true;
379 if ($this->content_type !==
'tst' && $this->content_type !==
'qpl') {
381 $lm = $this->content_object;
383 $this->page_object =
new ilLMPage();
384 $this->lm_page_object->setLMId($this->content_object->getId());
385 $this->lm_page_object->assignPageObject($this->page_object);
396 case 'InteractiveImage':
397 if ($a_name ==
'MediaObject') {
398 $this->in_media_object =
true;
400 $this->media_meta_start =
true;
401 $this->media_meta_cache = [];
403 $this->media_object->create(
true,
false);
407 $this->media_object->setAlias(
true);
408 $this->media_object->setImportId($a_attribs[
'OriginId']);
409 $this->mob_mapping[$this->media_object->getImportId()] = $this->media_object->getId();
410 if (is_object($this->page_object)) {
411 $this->page_object->needsImportParsing(
true);
416 case 'MediaAliasItem':
417 $this->in_media_item =
true;
419 $this->media_item->setPurpose($a_attribs[
'Purpose']);
423 if (is_object($this->media_object) && $this->in_media_object) {
424 $this->media_item->setWidth($a_attribs[
'Width'] ??
'');
425 $this->media_item->setHeight($a_attribs[
'Height'] ??
'');
426 $this->media_item->setHAlign($a_attribs[
'HorizontalAlign'] ??
'');
431 if (is_object($this->media_object) && $this->in_media_object) {
432 $this->media_item->setParameter($a_attribs[
'Name'], $a_attribs[
'Value']);
437 $this->in_map_area =
true;
439 $this->map_area->setShape($a_attribs[
'Shape']);
440 $this->map_area->setCoords($a_attribs[
'Coords']);
441 $this->map_area->setHighlightMode($a_attribs[
'HighlightMode']);
442 $this->map_area->setHighlightClass($a_attribs[
'HighlightClass']);
446 $this->in_glossary =
true;
447 if ($this->content_object->getType() !=
'glo') {
449 $this->glossary_object->setTitle(
'');
450 $this->glossary_object->setDescription(
'');
451 $this->glossary_object->create(
true);
452 $this->glossary_object->createReference();
453 $parent = $this->tree->getParentNodeData($this->content_object->getRefId());
454 $this->glossary_object->putInTree($parent[
'child']);
455 $this->glossary_object->setPermissions($parent[
'child']);
462 $this->glossary_term->setGlossaryId($this->glossary_object->getId());
463 $this->glossary_term->setLanguage($a_attribs[
'Language']);
464 $this->glossary_term->setImportId($a_attribs[
'Id']);
466 if (isset($parsed)) {
467 $this->link_targets[$a_attribs[
"Id"]] = $a_attribs[
'Id'];
472 $this->in_glossary_definition =
true;
474 $this->page_object->setParentId($this->glossary_term->getGlossaryId());
475 $this->glossary_term->assignPageObject($this->page_object);
479 $this->page_object->setXMLContent(
'');
483 $this->in_file_item =
true;
485 $this->file_item->setTitle(
'dummy');
486 $this->file_item->setMode(
'filelist');
487 if (is_object($this->page_object)) {
488 $this->page_object->needsImportParsing(
true);
493 if ($a_attribs[
'Characteristic'] ==
'Code') {
494 $this->inside_code =
true;
499 $this->in_properties =
true;
503 if ($this->content_object->getType() ==
'lm') {
504 switch ($a_attribs[
'Name']) {
506 $this->content_object->setLayout($a_attribs[
'Value']);
510 $this->content_object->setPageHeader($a_attribs[
'Value']);
514 $this->content_object->setTOCMode($a_attribs[
'Value']);
518 $this->content_object->setActiveLMMenu(
523 case 'ActiveNumbering':
524 $this->content_object->setActiveNumbering(
530 $this->content_object->setActiveTOC(
535 case 'ActivePrintView':
536 $this->content_object->setActivePrintView(
542 $this->content_object->setCleanFrames(
548 $this->content_object->setPublicNotes(
553 case 'HistoryUserComments':
554 $this->content_object->setHistoryUserComments(
560 $this->content_object->setRating(
566 $this->content_object->setRatingPages(
572 if ($a_attribs[
'Value'] !=
'') {
573 if ($this->pg_mapping[$a_attribs[
'Value']] > 0) {
574 $this->content_object->setHeaderPage(
575 $this->pg_mapping[$a_attribs[
'Value']]
582 if ($a_attribs[
'Value'] !=
'') {
583 if ($this->pg_mapping[$a_attribs[
'Value']] > 0) {
584 $this->content_object->setFooterPage(
585 $this->pg_mapping[$a_attribs[
'Value']]
591 case 'LayoutPerPage':
592 $this->content_object->setLayoutPerPage($a_attribs[
'Value']);
595 case 'ProgressIcons':
596 $this->content_object->setProgressIcons($a_attribs[
'Value']);
600 $this->content_object->setStoreTries($a_attribs[
'Value']);
603 case 'RestrictForwardNavigation':
604 $this->content_object->setRestrictForwardNavigation($a_attribs[
'Value']);
607 case 'DisableDefaultFeedback':
608 $this->content_object->setDisableDefaultFeedback($a_attribs[
'Value']);
618 $this->in_meta_data =
true;
622 if (!$this->in_media_object) {
623 if ($this->content_type !=
'tst' && $this->content_type !=
'qpl') {
625 if ($this->current_object->getType() ==
'st' 626 || $this->current_object->getType() ==
'pg') {
628 if ($this->current_object->getType() ==
'pg') {
629 $this->lm_page_object->create(
true);
631 $this->md =
new ilMD(
632 $this->content_object->getId(),
633 $this->current_object->getId(),
634 $this->current_object->getType()
638 elseif ($this->current_object->getType() ==
'term') {
639 $this->md =
new ilMD(
640 $this->glossary_object->getId(),
641 $this->current_object->getId(),
642 $this->current_object->getType()
648 $this->md =
new ilMD(
649 $this->current_object->getId(),
651 $this->current_object->getType()
657 $this->md =
new ilMD(
658 $this->content_object->getId(),
660 $this->current_object->getType()
662 if ($this->md->getGeneral() !=
false) {
663 $this->metadata_parsing_disabled =
true;
676 if ($import_id_parsed[
'type'] ==
'st') {
677 $this->mapping->addMapping(
678 'components/ILIAS/LearningModule',
680 $import_id_parsed[
'id'],
681 $this->current_object->getId()
689 if (!$this->in_meta_meta_data) {
690 if ($this->in_meta_data && !$this->in_glossary_definition) {
691 if (!$this->in_media_object) {
692 $this->current_object->setImportId($a_attribs[
'Entry']);
697 if (isset($parsed)) {
698 $this->link_targets[$a_attribs[
'Entry']] = $a_attribs[
'Entry'];
701 if ($this->in_file_item) {
702 if (!isset($this->file_item_mapping[$a_attribs[
'Entry']])
703 || $this->file_item_mapping[$a_attribs[
'Entry']] ===
'') {
704 $this->file_item->create();
705 $this->file_item->setImportId($a_attribs[
'Entry']);
706 $this->file_item_mapping[$a_attribs[
'Entry']] = $this->file_item->getId();
709 if ($this->in_meta_data && $this->in_media_object) {
710 $mob_id = $this->mob_mapping[$a_attribs[
'Entry']];
719 $this->media_object->create(
true,
false);
720 $this->mob_mapping[$a_attribs[
'Entry']]
721 = $this->media_object->getId();
723 $this->media_object->setImportId($a_attribs[
'Entry']);
724 $this->md =
new ilMD(
726 $this->media_object->getId(),
734 case 'Meta-Metadata':
735 $this->in_meta_meta_data =
true;
740 if (is_object($this->page_object)) {
741 $this->page_object->setContainsIntLink(
true);
743 if ($this->in_map_area) {
745 $this->map_area->setTarget($a_attribs[
'Target']);
746 $this->map_area->setType($a_attribs[
'Type']);
747 $this->map_area->setTargetFrame($a_attribs[
'TargetFrame']);
748 if (is_object($this->media_object)) {
749 $this->media_object->setContainsIntLink(
true);
756 if ($this->in_map_area) {
758 $this->map_area->setHref($a_attribs[
'Href']);
759 $this->map_area->setExtTitle($a_attribs[
'Title']);
765 $this->cur_qid = $a_attribs[
'QRef'];
766 $this->page_object->setContainsQuestion(
true);
770 $this->loc_type = $a_attribs[
'Type'];
776 if (($this->in_page_object || $this->in_glossary_definition)
777 && !$this->in_meta_data && !$this->in_media_object) {
778 if ($a_name ==
'Definition') {
779 $app_name =
'PageObject';
783 $app_attribs = $a_attribs;
787 if ($this->in_file_item && $app_name ==
'Identifier') {
788 $app_attribs[
'Entry'] =
'il__file_' . $this->file_item_mapping[$a_attribs[
'Entry']];
791 $this->page_object->appendXMLContent($this->
buildTag(
'start', $app_name, $app_attribs));
801 if ($this->in_media_object && $this->media_meta_start) {
802 $this->media_meta_cache[] =
803 [
'type' =>
'handlerBeginTag',
'par1' => $a_name,
'par2' => $a_attribs];
805 if ($a_name ==
'Identifier') {
806 if (!$this->in_media_object) {
807 $a_attribs[
'Entry'] =
'il__' . $this->current_object->getType() .
808 '_' . $this->current_object->getId();
810 $a_attribs[
'Entry'] =
'il__mob' .
811 '_' . $this->media_object->getId();
813 $a_attribs[
'Catalog'] =
'ILIAS';
816 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
825 if ($this->content_object->getType() ==
'glo' &&
826 $this->in_glossary && !$this->in_media_object
842 if ($this->in_media_object && $this->media_meta_start) {
843 $this->media_meta_cache[] =
844 [
'type' =>
'handlerEndTag',
'par1' => $a_name];
846 parent::handlerEndTag($a_xml_parser, $a_name);
851 if (($this->in_page_object || $this->in_glossary_definition)
852 && !$this->in_meta_data && !$this->in_media_object) {
853 $app_name = ($a_name ==
'Definition')
856 $this->page_object->appendXMLContent($this->
buildTag(
'end', $app_name));
860 case 'StructureObject':
861 unset($this->structure_objects[count($this->structure_objects) - 1]);
865 $this->in_page_object =
false;
866 if ($this->content_type !=
'tst' && $this->content_type !=
'qpl') {
868 $this->page_object->updateFromXML();
869 $this->pg_mapping[$this->lm_page_object->getImportId()]
870 = $this->lm_page_object->getId();
874 if ($import_id_parsed[
'type'] ==
'pg') {
875 $this->mapping->addMapping(
876 'components/ILIAS/LearningModule',
878 $import_id_parsed[
'id'],
879 $this->lm_page_object->getId()
885 if ($this->page_object->containsIntLink()) {
886 $this->pages_to_parse[
'lm:' . $this->page_object->getId()] =
'lm:' . $this->page_object->getId();
890 if ($this->page_object->needsImportParsing()) {
891 $this->pages_to_parse[
'lm:' . $this->page_object->getId()] =
'lm:' . $this->page_object->getId();
895 if ($this->page_object->getContainsQuestion()) {
896 $this->pages_to_parse[
'lm:' . $this->page_object->getId()] =
'lm:' . $this->page_object->getId();
900 $xml = $this->page_object->getXMLContent();
901 if ($this->cur_qid !=
'') {
902 $ids = $this->qst_mapping[
$this->cur_qid] ?? [
'pool' => 0,
'test' => 0];
903 if ($ids[
'pool'] > 0) {
906 $xmlcontent = str_replace(
908 'il__qst_' . $ids[
'pool'],
911 $page->setXMLContent($xmlcontent);
912 $page->updateFromXML();
913 if ($this->page_object->needsImportParsing()) {
914 $this->pages_to_parse[
'qpl:' . $page->getId()] =
'qpl:' . $page->getId();
918 if ($ids[
'test'] > 0) {
921 $xmlcontent = str_replace(
923 'il__qst_' . $ids[
'test'],
926 $page->setXMLContent($xmlcontent);
927 $page->updateFromXML();
928 if ($this->page_object->needsImportParsing()) {
929 $this->pages_to_parse[
'qpl:' . $page->getId()] =
'qpl:' . $page->getId();
937 $cnt = count($this->structure_objects);
939 $parent_id = $this->structure_objects[$cnt - 1]->getId();
940 $this->pg_into_tree[$parent_id][] = [
'type' =>
'pg',
'id' => $this->lm_page_object->getId()];
943 unset($this->page_object);
944 unset($this->lm_page_object);
945 unset($this->container[count($this->container) - 1]);
949 case 'InteractiveImage':
950 if ($a_name ==
'MediaObject') {
951 $this->in_media_object =
false;
954 if (empty($this->mob_mapping[$this->media_object->getImportId()])) {
958 $this->media_object->create(
true,
false);
961 if ($this->media_object->containsIntLink()) {
962 $this->mobs_with_int_links[] = $this->media_object->getId();
965 $this->mob_mapping[$this->media_object->getImportId()]
966 = $this->media_object->getId();
969 $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
976 if (!$this->media_object->isAlias()) {
978 $this->media_object->update();
981 if ($this->media_object->containsIntLink()) {
982 $this->mobs_with_int_links[] = $this->media_object->getId();
988 if ($this->in_page_object || $this->in_glossary_definition) {
989 if ($a_name !=
'InteractiveImage') {
990 $this->page_object->appendXMLContent($this->media_object->getXML(
IL_MODE_ALIAS));
996 case 'MediaAliasItem':
997 $this->in_media_item =
false;
998 $this->media_object->addMediaItem($this->media_item);
1001 $this->in_media_item =
false;
1002 $import_dir = $this->importdir . DIRECTORY_SEPARATOR .
'objects' . DIRECTORY_SEPARATOR . $this->media_object->getImportId();
1003 if (!file_exists($import_dir)
1004 || !is_dir($import_dir)) {
1005 $this->media_object->addMediaItem($this->media_item);
1009 $dir_handle = opendir($import_dir);
1010 while (($file = readdir($dir_handle)) !==
false) {
1011 if ($file !== $this->media_item->getLocation()) {
1015 $this->media_object->addMediaItemFromLocalFile(
1016 $this->media_item->getPurpose(),
1017 $import_dir . DIRECTORY_SEPARATOR . $file,
1022 closedir($dir_handle);
1026 $this->in_map_area =
false;
1027 $this->media_item->addMapArea($this->map_area);
1031 $this->in_properties =
false;
1032 if ($this->content_object->getType() ==
'lm') {
1033 $this->content_object->update();
1038 $this->in_meta_data =
false;
1039 if (strtolower(get_class($this->current_object)) ==
'illmpageobject' && !$this->in_media_object) {
1041 if (is_object($this->lm_page_object)) {
1043 $this->current_object->MDUpdateListener(
'General');
1045 $this->current_object->getId(),
1046 $this->current_object->getImportId()
1049 } elseif ((strtolower(get_class($this->current_object)) ==
'ilobjquestionpool' ||
1050 strtolower(get_class($this->current_object)) ==
'ilobjtest') &&
1051 !$this->in_media_object) {
1055 if ($this->metadata_parsing_disabled) {
1058 if ($this->in_page_object && !is_null($this->page_object)) {
1066 $this->current_object->MDUpdateListener(
'General');
1068 $this->current_object->getId(),
1069 $this->current_object->getImportId()
1073 } elseif (strtolower(get_class($this->current_object)) ==
'ilstructureobject') {
1075 $cnt = count($this->structure_objects);
1077 $parent_id = $this->structure_objects[$cnt - 2]->getId();
1079 $parent_id = $this->lm_tree->getRootId();
1082 $this->st_into_tree[] = [
'id' => $this->current_object->getId(),
1083 'parent' => $parent_id];
1086 $this->current_object->MDUpdateListener(
'General');
1088 $this->current_object->getId(),
1089 $this->current_object->getImportId()
1091 } elseif (strtolower(get_class($this->current_object)) ==
'ilobjlearningmodule' ||
1092 strtolower(get_class($this->current_object)) ==
'ilobjcontentobject' ||
1093 (strtolower(get_class($this->current_object)) ==
'ilobjglossary' && $this->in_glossary)) {
1096 } elseif (strtolower(get_class($this->current_object)) ==
'ilglossaryterm' && !$this->in_media_object) {
1099 $this->page_object->setId($this->glossary_term->getId());
1100 $this->page_object->updateFromXML();
1107 if (strtolower(get_class($this->current_object)) ==
'ilobjlearningmodule' ||
1108 strtolower(get_class($this->current_object)) ==
'ilobjglossary') {
1109 if (strtolower(get_class($this->current_object)) ==
'ilobjglossary' &&
1110 $this->content_object->getType() !=
'glo') {
1111 $this->current_object->setTitle($this->content_object->getTitle() .
' - ' .
1112 $this->
lng->txt(
'glossary'));
1115 $this->current_object->MDUpdateListener(
'General');
1118 if ($this->in_media_object) {
1119 $this->media_object->MDUpdateListener(
'General');
1124 case 'Meta-Metadata':
1125 $this->in_meta_meta_data =
false;
1129 $this->in_file_item =
false;
1131 if ($this->file_item->getImportId()) {
1132 $this->file_item->update();
1138 unset($this->container[count($this->container) - 1]);
1142 $this->in_glossary =
false;
1145 case 'GlossaryTerm':
1146 $term = trim($this->chr_data);
1147 $term = str_replace(
'<',
'<', $term);
1148 $term = str_replace(
'>',
'>', $term);
1149 $this->glossary_term->setTerm($term);
1150 $this->glossary_term->create();
1151 $iia = explode(
'_', $this->glossary_term->getImportId());
1152 $this->glossary_term_map[(
int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
1156 $this->inside_code =
false;
1160 $this->in_glossary_definition =
false;
1161 $this->page_object->updateFromXML();
1162 $this->page_object->buildDom();
1163 $this->glossary_term->setShortText($this->page_object->getFirstParagraphText());
1164 $this->glossary_term->update();
1165 if ($this->page_object->containsIntLink()) {
1166 $this->pages_to_parse[
'term:' . $this->page_object->getId()] =
'term:' . $this->page_object->getId();
1168 if ($this->page_object->needsImportParsing()) {
1169 $this->pages_to_parse[
'term:' . $this->page_object->getId()] =
'term:' . $this->page_object->getId();
1174 if ($this->in_media_item) {
1175 $this->media_item->setFormat(trim($this->chr_data));
1180 if ($this->in_meta_data && !$this->in_media_object) {
1181 $this->current_object->setTitle(trim($this->chr_data));
1183 if ($this->in_media_object) {
1184 $this->media_object->setTitle(trim($this->chr_data));
1193 if ($this->in_media_object) {
1194 $this->media_item->setCaption(trim($this->chr_data));
1198 case 'TextRepresentation':
1199 if ($this->in_media_object) {
1200 $this->media_item->setTextRepresentation(trim($this->chr_data));
1207 if ($this->in_media_item) {
1208 $this->media_item->setLocationType($this->loc_type);
1209 if ($this->loc_type ==
'Reference') {
1210 $this->media_item->setLocation(str_replace(
'&',
'&', trim($this->chr_data)));
1212 $this->media_item->setLocation(trim($this->chr_data));
1215 if ($this->in_file_item) {
1217 $this->file_item->setFileName(trim($this->chr_data));
1221 if ($this->file_item->getType() ==
'file' &&
1222 is_int(strpos($this->chr_data,
'&')) &&
1223 is_int(strpos($this->chr_data,
';'))) {
1224 $source_dir = $this->importdir . DIRECTORY_SEPARATOR .
'objects' . DIRECTORY_SEPARATOR .
1225 $this->file_item->getImportId();
1228 if ($dir = opendir($source_dir)) {
1229 while (
false !== ($file = readdir($dir))) {
1230 if ($file !=
'.' && $file !=
'..') {
1231 $this->file_item->setFileName($file);
1239 $this->file_item->setTitle(trim($this->chr_data));
1244 $this->chr_data =
'';
1250 if ($this->in_meta_data && $this->
processMeta()) {
1254 if ($this->in_media_object && $this->media_meta_start) {
1255 $this->media_meta_cache[] =
1256 [
'type' =>
'handlerCharacterData',
'par1' => $a_data];
1258 parent::handlerCharacterData($a_xml_parser, $a_data);
1266 $a_data = str_replace(
'<',
'<', $a_data);
1267 $a_data = str_replace(
'>',
'>', $a_data);
1271 $a_data = preg_replace(
'/\n/',
'', $a_data);
1272 if (!$this->inside_code) {
1273 $a_data = preg_replace(
'/\t+/',
'', $a_data);
1276 $this->chr_data .= $a_data;
1278 if (!empty($a_data) || $a_data ===
'0') {
1281 if (($this->in_page_object || $this->in_glossary_definition)
1282 && !$this->in_meta_data && !$this->in_media_object) {
1283 $this->page_object->appendXMLContent($a_data);
1289 if ($this->in_map_area) {
1290 $this->map_area->appendTitle($a_data);
1302 foreach ($this->media_meta_cache as $cache_entry) {
1303 switch ($cache_entry[
'type']) {
1304 case 'handlerBeginTag':
1305 parent::handlerBeginTag(
1307 $cache_entry[
'par1'],
1308 $cache_entry[
'par2']
1312 case 'handlerEndTag':
1313 parent::handlerEndTag(
1315 $cache_entry[
'par1']
1319 case 'handlerCharacterData':
1320 parent::handlerCharacterData(
1322 $cache_entry[
'par1']
1328 $this->media_meta_start =
false;
1329 $this->media_meta_cache[] = [];
1347 $link_arr = explode(
'_', $identifier);
1349 if (count($link_arr) !== 4
1350 || $link_arr[0] !==
'il' 1351 || !is_numeric($link_arr[1])
1352 || !is_numeric($link_arr[3])
1358 'target_inst' => (
int) $link_arr[1],
1359 'target_type' => (
string) $link_arr[2],
1360 'target_id' => (
int) $link_arr[3]
processPagesToParse()
parse pages that contain files, mobs and/or internal links
enableMDParsing(bool $a_status)
getOpenCount(string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildDom(bool $a_force=false)
static getLogger(string $a_component_id)
Get component logger.
static _getSourcesOfTarget(string $a_target_type, int $a_target_id, int $a_target_inst)
get all sources of a link target
buildTag(string $type, string $name, array $attr=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handlerEndTag($a_xml_parser, string $a_name)
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
resolveIntLinks(array $a_link_map=null)
Resolves all internal link targets of the page, if targets are available (after import) ...
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
ilGlossaryTerm $glossary_term
endElement(string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setImportMapping(ilImportMapping $mapping=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
bool $metadata_parsing_disabled
ilPageObject $page_object
bool $in_glossary_definition
parseLinkTarget(string $identifier)
Parse a string the get the elements of a link target Return null if the string is not a link target...
static instantiateQuestion(int $question_id)
setQuestionMapping(array $a_map)
set question import ident to pool/test question id mapping
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handlerCharacterData($a_xml_parser, string $a_data)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
Legacy Content Object Parser.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static parseImportId(string $a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
static _writeImportId(int $a_id, string $a_import_id)
ilObjLearningModule $learning_module
copyFileItems()
copy files of file items
emptyMediaMetaCache($a_xml_parser)
array $mobs_with_int_links
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
ilLMPageObject $lm_page_object
static yn2tf(string $a_yn)
ilObjGlossary $glossary_object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private readonly ilObject $content_object, string $xml_file, private readonly string $importdir)
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
beginElement(string $a_name)
ilObjMediaObject $media_object
storeTree()
insert StructureObjects and PageObjects into tree