ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilQuestionPageParser Class Reference

Legacy Content Object Parser. More...

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

Public Member Functions

 __construct (private readonly ilObject $content_object, string $xml_file, private readonly string $importdir)
 
 setHandlers ($xml_parser)
 
 setImportMapping (?ilImportMapping $mapping=null)
 
 startParsing ()
 
 storeTree ()
 insert StructureObjects and PageObjects into tree More...
 
 processPagesToParse ()
 parse pages that contain files, mobs and/or internal links 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, string $a_name)
 
 handlerCharacterData ($a_xml_parser, string $a_data)
 
 getGlossaryTermMap ()
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Data Fields

ilTree $tree
 
array $cnt = []
 
array $current_element = []
 
ilObjLearningModule $learning_module = null
 
ilPageObject $page_object = null
 
ilLMPageObject $lm_page_object = null
 
array $structure_objects = []
 
ilObjMediaObject $media_object = null
 
object $current_object = null
 
ilLMTree $lm_tree = null
 
array $pg_into_tree = []
 
array $st_into_tree = []
 
array $container = []
 
bool $in_page_object = false
 
bool $in_media_object = false
 
bool $in_file_item = false
 
bool $in_glossary = false
 
bool $in_map_area = false
 
ilObjGlossary $glossary_object = null
 
ilObjFile $file_item = null
 
array $pages_to_parse = []
 
array $mob_mapping = []
 
array $file_item_mapping = []
 
ilMediaItem $media_item = null
 
string $loc_type = ''
 
ilMapArea $map_area = null
 
array $link_targets = []
 
array $qst_mapping = []
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Protected Attributes

bool $in_properties
 
bool $in_glossary_definition = false
 
array $pg_mapping = []
 
array $mobs_with_int_links = []
 
bool $inside_code = false
 
string $content_type = ''
 
array $glossary_term_map = []
 
ilLogger $log
 
ilGlossaryTerm $glossary_term = null
 
ilImportMapping $mapping = null
 
string $cur_qid = ''
 
string $chr_data = ''
 
bool $in_media_item = false
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Member Functions

 copyFileItems ()
 copy files of file items More...
 
 parseLinkTarget (string $identifier)
 Parse a string the get the elements of a link target Return null if the string is not a link target. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

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 ( private readonly ilObject  $content_object,
string  $xml_file,
private readonly string  $importdir 
)

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

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

81  {
82  global $DIC;
83  $lng = $DIC->language();
84  $tree = $DIC->repositoryTree();
85 
86  $this->log = ilLoggerFactory::getLogger('lm');
87 
89  $this->cnt = [];
90  $this->current_element = [];
91  $this->structure_objects = [];
92  $this->st_into_tree = [];
93  $this->pg_into_tree = [];
94  $this->pages_to_parse = [];
95  $this->mobs_with_int_links = [];
96  $this->mob_mapping = [];
97  $this->file_item_mapping = [];
98  $this->pg_mapping = [];
99  $this->link_targets = [];
100  $this->lng = $lng;
101  $this->tree = $tree;
102  $this->inside_code = false;
103  $this->qst_mapping = [];
104  $this->content_type = $this->content_object->getType();
105 
106  if ($this->content_type !== 'tst' && $this->content_type !== 'qpl') {
107  $this->lm_tree = new ilLMTree($this->content_object->getId());
108  }
109  }
static getLogger(string $a_component_id)
Get component logger.
ilLanguage $lng
global $DIC
Definition: shib_login.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ beginElement()

ilQuestionPageParser::beginElement ( string  $a_name)

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

Referenced by buildTag().

293  : void
294  {
295  if (!isset($this->status['$a_name'])) {
296  $this->cnt[$a_name] = 1;
297  } else {
298  $this->cnt[$a_name]++;
299  }
300  $this->current_element[count($this->current_element)] = $a_name;
301  }
+ Here is the caller graph for this function:

◆ buildTag()

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

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

References $glossary_object, $glossary_term, $lm_page_object, beginElement(), IL_EXT_LINK, IL_INT_LINK, parseLinkTarget(), and ilUtil\yn2tf().

Referenced by handlerEndTag().

326  : string {
327  $tag = '<';
328 
329  if ($type == 'end') {
330  $tag .= '/';
331  }
332 
333  $tag .= $name;
334 
335  if (is_array($attr)) {
336  foreach ($attr as $k => $v) {
337  $tag .= ' ' . $k . "='$v'";
338  }
339  }
340 
341  $tag .= '>';
342 
343  return $tag;
344  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyFileItems()

ilQuestionPageParser::copyFileItems ( )
private

copy files of file items

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

Referenced by startParsing().

262  : void
263  {
264  foreach ($this->file_item_mapping as $origin_id => $file_id) {
265  if (empty($origin_id)) {
266  continue;
267  }
268  $obj_dir = $origin_id;
269  $source_dir = $this->importdir . DIRECTORY_SEPARATOR . 'objects' . DIRECTORY_SEPARATOR . $obj_dir;
270 
271  $file_obj = new ilObjFile($file_id, false);
272  if (is_dir($source_dir)) {
273  $files = scandir($source_dir, SCANDIR_SORT_DESCENDING);
274  if ($files !== false && $files !== [] && is_file($source_dir . '/' . $files[0])) {
275  $file = fopen($source_dir . '/' . $files[0], 'rb');
276  $file_stream = Streams::ofResource($file);
277  $file_obj->appendStream($file_stream, $files[0]);
278  }
279  }
280  $file_obj->update();
281  }
282  }
Class ilObjFile.
+ Here is the caller graph for this function:

◆ endElement()

ilQuestionPageParser::endElement ( string  $a_name)

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

Referenced by handlerEndTag().

303  : void
304  {
305  $this->cnt[$a_name]--;
306  unset($this->current_element[count($this->current_element) - 1]);
307  }
+ Here is the caller graph for this function:

◆ getCurrentElement()

ilQuestionPageParser::getCurrentElement ( )

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

Referenced by handlerCharacterData().

309  : string
310  {
311  return ($this->current_element[count($this->current_element) - 1] ?? '');
312  }
+ Here is the caller graph for this function:

◆ getGlossaryTermMap()

ilQuestionPageParser::getGlossaryTermMap ( )
Returns
mixed[]

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

References $glossary_term_map.

1049  : array
1050  {
1051  return $this->glossary_term_map;
1052  }

◆ getOpenCount()

ilQuestionPageParser::getOpenCount ( string  $a_name)

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

314  : int
315  {
316  if (isset($this->cnt[$a_name])) {
317  return $this->cnt[$a_name];
318  }
319  return 0;
320  }

◆ handlerCharacterData()

ilQuestionPageParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)

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

References getCurrentElement().

Referenced by setHandlers().

1009  : void
1010  {
1011  // the parser converts '&gt;' to '>' and '&lt;' to '<'
1012  // in character data, but we don't want that, because it's the
1013  // way we mask user html in our content, so we convert back...
1014 
1015  $a_data = str_replace('<', '&lt;', $a_data);
1016  $a_data = str_replace('>', '&gt;', $a_data);
1017 
1018 
1019  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
1020  $a_data = preg_replace('/\n/', '', $a_data);
1021  if (!$this->inside_code) {
1022  $a_data = preg_replace('/\t+/', '', $a_data);
1023  }
1024 
1025  $this->chr_data .= $a_data;
1026 
1027  if (!empty($a_data) || $a_data === '0') {
1028  // append all data to page, if we are within PageObject,
1029  // but not within MetaData or MediaObject
1030  if (($this->in_page_object || $this->in_glossary_definition)
1031  && !$this->in_media_object) {
1032  $this->page_object->appendXMLContent($a_data);
1033  }
1034 
1035  switch ($this->getCurrentElement()) {
1036  case 'IntLink':
1037  case 'ExtLink':
1038  if ($this->in_map_area) {
1039  $this->map_area->appendTitle($a_data);
1040  }
1041  break;
1042  }
1043  }
1044  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilQuestionPageParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

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

References $cur_qid, buildTag(), endElement(), IL_MODE_ALIAS, ILIAS\Repository\int(), and ilUtil\parseImportId().

Referenced by setHandlers().

704  : void
705  {
706  // append content to page xml content
707  if (($this->in_page_object || $this->in_glossary_definition)
708  && !$this->in_media_object) {
709  $app_name = ($a_name == 'Definition')
710  ? 'PageObject'
711  : $a_name;
712  $this->page_object->appendXMLContent($this->buildTag('end', $app_name));
713  }
714 
715  switch ($a_name) {
716  case 'StructureObject':
717  unset($this->structure_objects[count($this->structure_objects) - 1]);
718  break;
719 
720  case 'PageObject':
721  $this->in_page_object = false;
722  if ($this->content_type != 'tst' && $this->content_type != 'qpl') {
723  //if (!$this->lm_page_object->isAlias()) {
724  $this->page_object->updateFromXML();
725  $this->pg_mapping[$this->lm_page_object->getImportId()]
726  = $this->lm_page_object->getId();
727 
728  if ($this->mapping instanceof ilImportMapping) {
729  $import_id_parsed = ilUtil::parseImportId($this->lm_page_object->getImportId());
730  if ($import_id_parsed['type'] == 'pg') {
731  $this->mapping->addMapping(
732  'components/ILIAS/LearningModule',
733  'pg',
734  $import_id_parsed['id'],
735  $this->lm_page_object->getId()
736  );
737  }
738  }
739 
740  // collect pages with internal links
741  if ($this->page_object->containsIntLink()) {
742  $this->pages_to_parse['lm:' . $this->page_object->getId()] = 'lm:' . $this->page_object->getId();
743  }
744 
745  // collect pages with mobs or files
746  if ($this->page_object->needsImportParsing()) {
747  $this->pages_to_parse['lm:' . $this->page_object->getId()] = 'lm:' . $this->page_object->getId();
748  }
749 
750  // collect pages with questions
751  if ($this->page_object->getContainsQuestion()) {
752  $this->pages_to_parse['lm:' . $this->page_object->getId()] = 'lm:' . $this->page_object->getId();
753  }
754  //}
755  } else {
756  $xml = $this->page_object->getXMLContent();
757  if ($this->cur_qid != '') {
758  $ids = $this->qst_mapping[$this->cur_qid] ?? ['pool' => 0, 'test' => 0];
759  if ($ids['pool'] > 0) {
760  // question pool question
761  $page = new ilAssQuestionPage($ids['pool']);
762  $xmlcontent = str_replace(
763  $this->cur_qid,
764  'il__qst_' . $ids['pool'],
765  $xml
766  );
767  $page->setXMLContent($xmlcontent);
768  $page->updateFromXML();
769  if ($this->page_object->needsImportParsing()) {
770  $this->pages_to_parse['qpl:' . $page->getId()] = 'qpl:' . $page->getId();
771  }
772  unset($page);
773  }
774  if ($ids['test'] > 0) {
775  // test question
776  $page = new ilAssQuestionPage($ids['test']);
777  $xmlcontent = str_replace(
778  $this->cur_qid,
779  'il__qst_' . $ids['test'],
780  $xml
781  );
782  $page->setXMLContent($xmlcontent);
783  $page->updateFromXML();
784  if ($this->page_object->needsImportParsing()) {
785  $this->pages_to_parse['qpl:' . $page->getId()] = 'qpl:' . $page->getId();
786  }
787  unset($page);
788  }
789  }
790  }
791 
792  // if we are within a structure object: put page in tree
793  $cnt = count($this->structure_objects);
794  if ($cnt > 0) {
795  $parent_id = $this->structure_objects[$cnt - 1]->getId();
796  $this->pg_into_tree[$parent_id][] = ['type' => 'pg', 'id' => $this->lm_page_object->getId()];
797  }
798 
799  unset($this->page_object);
800  unset($this->lm_page_object);
801  unset($this->container[count($this->container) - 1]);
802  break;
803 
804  case 'MediaObject':
805  case 'InteractiveImage':
806  if ($a_name == 'MediaObject') {
807  $this->in_media_object = false;
808  }
809 
810  if (empty($this->mob_mapping[$this->media_object->getImportId()])) {
811  // create media object
812  // media items are saves for mobs outside of
813  // pages only
814  $this->media_object->create(false, false);
815 
816  // collect mobs with internal links
817  if ($this->media_object->containsIntLink()) {
818  $this->mobs_with_int_links[] = $this->media_object->getId();
819  }
820 
821  $this->mob_mapping[$this->media_object->getImportId()]
822  = $this->media_object->getId();
823  } else {
824  // get the id from mapping
825  $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]);
826 
827  // update 'real' (no alias) media object
828  // (note: we overwrite any data from the media object
829  // created by an MediaAlias, only the data of the real
830  // object is stored in db separately; data of the
831  // MediaAliases are within the page XML
832  if (!$this->media_object->isAlias()) {
833  // now the media items are saved within the db
834  $this->media_object->update();
835 
836  // collect mobs with internal links
837  if ($this->media_object->containsIntLink()) {
838  $this->mobs_with_int_links[] = $this->media_object->getId();
839  }
840  }
841  }
842 
843  // append media alias to page, if we are in a page
844  if ($this->in_page_object || $this->in_glossary_definition) {
845  if ($a_name != 'InteractiveImage') {
846  $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS));
847  }
848  }
849 
850  break;
851 
852  case 'MediaAliasItem':
853  $this->in_media_item = false;
854  $this->media_object->addMediaItem($this->media_item);
855  break;
856  case 'MediaItem':
857  $this->in_media_item = false;
858  $import_dir = $this->importdir . DIRECTORY_SEPARATOR . 'objects' . DIRECTORY_SEPARATOR . $this->media_object->getImportId();
859  if (!file_exists($import_dir)
860  || !is_dir($import_dir)) {
861  $this->media_object->addMediaItem($this->media_item);
862  break;
863  }
864 
865  $dir_handle = opendir($import_dir);
866  while (($file = readdir($dir_handle)) !== false) {
867  if ($file !== $this->media_item->getLocation()) {
868  continue;
869  }
870 
871  $this->media_object->addMediaItemFromLocalFile(
872  $this->media_item->getPurpose(),
873  $import_dir . DIRECTORY_SEPARATOR . $file,
874  $file
875  );
876  break;
877  }
878  closedir($dir_handle);
879  break;
880 
881  case 'MapArea':
882  $this->in_map_area = false;
883  $this->media_item->addMapArea($this->map_area);
884  break;
885 
886  case 'Properties':
887  $this->in_properties = false;
888  if ($this->content_object->getType() == 'lm') {
889  $this->content_object->update();
890  }
891  break;
892 
893  case 'FileItem':
894  $this->in_file_item = false;
895  // only update new file items
896  if ($this->file_item->getImportId()) {
897  $this->file_item->update();
898  }
899  break;
900 
901 
902  case 'Table':
903  unset($this->container[count($this->container) - 1]);
904  break;
905 
906  case 'Glossary':
907  $this->in_glossary = false;
908  break;
909 
910  case 'GlossaryTerm':
911  $term = trim($this->chr_data);
912  $term = str_replace('&lt;', '<', $term);
913  $term = str_replace('&gt;', '>', $term);
914  $this->glossary_term->setTerm($term);
915  $this->glossary_term->create();
916  $iia = explode('_', $this->glossary_term->getImportId());
917  $this->glossary_term_map[(int) $iia[count($iia) - 1]] = $this->glossary_term->getId();
918  break;
919 
920  case 'Paragraph':
921  $this->inside_code = false;
922  break;
923 
924  case 'Definition':
925  $this->in_glossary_definition = false;
926  $this->page_object->updateFromXML();
927  $this->page_object->buildDom();
928  $this->glossary_term->setShortText($this->page_object->getFirstParagraphText());
929  $this->glossary_term->update();
930  if ($this->page_object->containsIntLink()) {
931  $this->pages_to_parse['term:' . $this->page_object->getId()] = 'term:' . $this->page_object->getId();
932  }
933  if ($this->page_object->needsImportParsing()) {
934  $this->pages_to_parse['term:' . $this->page_object->getId()] = 'term:' . $this->page_object->getId();
935  }
936  break;
937 
938  case 'Format':
939  if ($this->in_media_item) {
940  $this->media_item->setFormat(trim($this->chr_data));
941  }
942  break;
943 
944  case 'Title':
945  if ($this->in_media_object) {
946  $this->media_object->setTitle(trim($this->chr_data));
947  }
948  break;
949 
950  case 'Description':
951  case 'Language':
952  break;
953 
954  case 'Caption':
955  if ($this->in_media_object) {
956  $this->media_item->setCaption(trim($this->chr_data));
957  }
958  break;
959 
960  case 'TextRepresentation':
961  if ($this->in_media_object) {
962  $this->media_item->setTextRepresentation(trim($this->chr_data));
963  }
964  break;
965 
966  // Location
967  case 'Location':
968  // TODO: adapt for files in 'real' subdirectories
969  if ($this->in_media_item) {
970  $this->media_item->setLocationType($this->loc_type);
971  if ($this->loc_type == 'Reference') {
972  $this->media_item->setLocation(str_replace('&', '&amp;', trim($this->chr_data)));
973  } else {
974  $this->media_item->setLocation(trim($this->chr_data));
975  }
976  }
977  if ($this->in_file_item) {
978  // set file name from xml file
979  $this->file_item->setFileName(trim($this->chr_data));
980 
981  // special handling for file names with special characters
982  // (e.g. '&gt;')
983  if ($this->file_item->getType() == 'file' &&
984  is_int(strpos($this->chr_data, '&')) &&
985  is_int(strpos($this->chr_data, ';'))) {
986  $source_dir = $this->importdir . DIRECTORY_SEPARATOR . 'objects' . DIRECTORY_SEPARATOR .
987  $this->file_item->getImportId();
988 
989  // read 'physical' file name from directory
990  if ($dir = opendir($source_dir)) {
991  while (false !== ($file = readdir($dir))) {
992  if ($file != '.' && $file != '..') {
993  $this->file_item->setFileName($file);
994  }
995  }
996  closedir($dir);
997  }
998  }
999 
1000  // set file item title
1001  $this->file_item->setTitle(trim($this->chr_data));
1002  }
1003  break;
1004  }
1005  $this->endElement($a_name);
1006  $this->chr_data = '';
1007  }
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...
static parseImportId(string $a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( &#39;orig&#39; ...
const IL_MODE_ALIAS
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseLinkTarget()

ilQuestionPageParser::parseLinkTarget ( string  $identifier)
private

Parse a string the get the elements of a link target Return null if the string is not a link target.

Returns
array{target_inst: int, target_type: string, target_id: int}|null

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

References ILIAS\Repository\int(), and null.

Referenced by buildTag(), and processPagesToParse().

1059  : ?array
1060  {
1061  $link_arr = explode('_', $identifier);
1062 
1063  if (count($link_arr) !== 4
1064  || $link_arr[0] !== 'il'
1065  || !is_numeric($link_arr[1])
1066  || !is_numeric($link_arr[3])
1067  ) {
1068  return null;
1069  }
1070 
1071  return [
1072  'target_inst' => (int) $link_arr[1],
1073  'target_type' => (string) $link_arr[2],
1074  'target_id' => (int) $link_arr[3]
1075  ];
1076  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processMeta()

ilQuestionPageParser::processMeta ( )

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

References $in_glossary_definition.

690  : bool
691  {
692  // do not process second meta block in (ilias3) glossaries
693  // which comes right after the 'Glossary' tag
694  if ($this->content_object->getType() == 'glo' &&
695  $this->in_glossary && !$this->in_media_object
697  return false;
698  }
699 
700  return true;
701  }

◆ processPagesToParse()

ilQuestionPageParser::processPagesToParse ( )

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

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

References ilPageObject\_exists(), ilInternalLink\_getSourcesOfTarget(), ilMediaItem\_resolveMapAreaLinks(), ilPageObject\buildDom(), ilPageObjectFactory\getInstance(), assQuestion\instantiateQuestion(), null, parseLinkTarget(), ilPageObject\resolveIntLinks(), and ilPageObject\update().

Referenced by startParsing().

174  : void
175  {
176  // outgoin internal links
177  foreach ($this->pages_to_parse as $page_id) {
178  $page_arr = explode(':', $page_id);
179  $page_obj = null;
180  switch ($page_arr[0]) {
181  case 'lm':
182  switch ($this->content_object->getType()) {
183  case 'lm':
184  $page_obj = new ilLMPage($page_arr[1]);
185  break;
186 
187  default:
188  die('Unknown content type ' . $this->content_object->getType());
189  }
190 
191  break;
192 
193  case 'term':
194  $page_obj = new ilGlossaryDefPage($page_arr[1]);
195  break;
196 
197  case 'qpl':
198  $page_obj = new ilAssQuestionPage($page_arr[1]);
199  break;
200  }
201  $page_obj->buildDom();
202  $page_obj->resolveIntLinks();
203  $page_obj->resolveIIMMediaAliases($this->mob_mapping);
204  if ($this->content_type == 'lm') {
205  $page_obj->resolveQuestionReferences($this->qst_mapping);
206  }
207  $page_obj->update(false);
208 
209  if ($page_arr[0] == 'term') {
210  $term = new ilGlossaryTerm($page_arr[1]);
211  $term->updateShortText();
212  }
213 
214  unset($page_obj);
215  }
216 
217  foreach ($this->mobs_with_int_links as $mob_id) {
219  }
220 
221  $done = [];
222  foreach ($this->link_targets as $link_target) {
223  $parsed = $this->parseLinkTarget((string) $link_target);
224  if (!isset($parsed)) {
225  continue;
226  }
227  //echo "doin link target:".$link_target.":<br>";
229  $parsed['target_type'],
230  $parsed['target_id'],
231  $parsed['target_inst']
232  );
233  foreach ($sources as $key => $source) {
234  if (in_array($key, $done)) {
235  continue;
236  }
237  $type_arr = explode(':', $source['type']);
238 
239  // content object pages
240  if ($type_arr[1] == 'pg') {
241  if (ilPageObject::_exists($type_arr[0], $source['id'])) {
242  $page_object = ilPageObjectFactory::getInstance($type_arr[0], $source['id']);
245  $page_object->update();
246  unset($page_object);
247  }
248  }
249 
250  // eventually correct links in questions to learning modules
251  if ($type_arr[0] === 'qst') {
252  assQuestion::instantiateQuestion($source['id'])->resolveSuggestedSolutionLinks();
253  }
254  $done[$key] = $key;
255  }
256  }
257  }
buildDom(bool $a_force=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseLinkTarget(string $identifier)
Parse a string the get the elements of a link target Return null if the string is not a link target...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static instantiateQuestion(int $question_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
resolveIntLinks(?array $a_link_map=null)
Resolves all internal link targets of the page, if targets are available (after import) ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _resolveMapAreaLinks(int $a_mob_id)
resolve internal links of all media items of a media object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

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

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

References handlerCharacterData(), and handlerEndTag().

114  : void
115  {
116  xml_set_element_handler($xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
117  xml_set_character_data_handler($xml_parser, $this->handlerCharacterData(...));
118  }
handlerEndTag($a_xml_parser, string $a_name)
handlerCharacterData($a_xml_parser, string $a_data)
+ Here is the call graph for this function:

◆ setImportMapping()

ilQuestionPageParser::setImportMapping ( ?ilImportMapping  $mapping = null)

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

References $mapping.

120  : void
121  {
122  $this->mapping = $mapping;
123  }

◆ setQuestionMapping()

ilQuestionPageParser::setQuestionMapping ( array  $a_map)

set question import ident to pool/test question id mapping

Parameters
mixed[]$a_map

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

288  : void
289  {
290  $this->qst_mapping = $a_map;
291  }

◆ startParsing()

ilQuestionPageParser::startParsing ( )

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

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

125  : void
126  {
127  $this->log->debug('start');
128 
129  parent::startParsing();
130  $this->storeTree();
131  $this->processPagesToParse();
132  $this->copyFileItems();
133  }
processPagesToParse()
parse pages that contain files, mobs and/or internal links
copyFileItems()
copy files of file items
storeTree()
insert StructureObjects and PageObjects into tree
+ Here is the call graph for this function:

◆ storeTree()

ilQuestionPageParser::storeTree ( )

insert StructureObjects and PageObjects into tree

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

References $log, and ilLogger\write().

Referenced by startParsing().

138  : void
139  {
140  $ilLog = $this->log;
141 
142  foreach ($this->st_into_tree as $st) {
143  $this->lm_tree->insertNode($st['id'], $st['parent']);
144  if (is_array($this->pg_into_tree[$st['id']])) {
145  foreach ($this->pg_into_tree[$st['id']] as $pg) {
146  $pg_id = 0;
147  switch ($pg['type']) {
148  case 'pg_alias':
149  if ($this->pg_mapping[$pg['id']] == '') {
150  $ilLog->write('LM Import: No PageObject for PageAlias ' .
151  $pg['id'] . ' found! (Please update export installation to ILIAS 3.3.0)');
152 
153  // Jump two levels up. First level is switch
154  continue 2;
155  }
156  $pg_id = $this->pg_mapping[$pg['id']];
157  break;
158 
159  case 'pg':
160  $pg_id = $pg['id'];
161  break;
162  }
163  if (!$this->lm_tree->isInTree($pg_id)) {
164  $this->lm_tree->insertNode($pg_id, $st['id']);
165  }
166  }
167  }
168  }
169  }
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $chr_data

string ilQuestionPageParser::$chr_data = ''
protected

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

◆ $cnt

array ilQuestionPageParser::$cnt = []

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

◆ $container

array ilQuestionPageParser::$container = []

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

◆ $content_type

string ilQuestionPageParser::$content_type = ''
protected

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

◆ $cur_qid

string ilQuestionPageParser::$cur_qid = ''
protected

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

Referenced by handlerEndTag().

◆ $current_element

array ilQuestionPageParser::$current_element = []

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

◆ $current_object

object ilQuestionPageParser::$current_object = null

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

◆ $file_item

ilObjFile ilQuestionPageParser::$file_item = null

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

◆ $file_item_mapping

array ilQuestionPageParser::$file_item_mapping = []

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

◆ $glossary_object

ilObjGlossary ilQuestionPageParser::$glossary_object = null

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

Referenced by buildTag().

◆ $glossary_term

ilGlossaryTerm ilQuestionPageParser::$glossary_term = null
protected

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

Referenced by buildTag().

◆ $glossary_term_map

array ilQuestionPageParser::$glossary_term_map = []
protected

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

Referenced by getGlossaryTermMap().

◆ $in_file_item

bool ilQuestionPageParser::$in_file_item = false

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

◆ $in_glossary

bool ilQuestionPageParser::$in_glossary = false

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

◆ $in_glossary_definition

bool ilQuestionPageParser::$in_glossary_definition = false
protected

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

Referenced by processMeta().

◆ $in_map_area

bool ilQuestionPageParser::$in_map_area = false

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

◆ $in_media_item

bool ilQuestionPageParser::$in_media_item = false
protected

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

◆ $in_media_object

bool ilQuestionPageParser::$in_media_object = false

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

◆ $in_page_object

bool ilQuestionPageParser::$in_page_object = false

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

◆ $in_properties

bool ilQuestionPageParser::$in_properties
protected

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

◆ $inside_code

bool ilQuestionPageParser::$inside_code = false
protected

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

◆ $learning_module

ilObjLearningModule ilQuestionPageParser::$learning_module = null

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

◆ $link_targets

array ilQuestionPageParser::$link_targets = []

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

◆ $lm_page_object

ilLMPageObject ilQuestionPageParser::$lm_page_object = null

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

Referenced by buildTag().

◆ $lm_tree

ilLMTree ilQuestionPageParser::$lm_tree = null

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

◆ $loc_type

string ilQuestionPageParser::$loc_type = ''

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

◆ $log

ilLogger ilQuestionPageParser::$log
protected

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

Referenced by storeTree().

◆ $map_area

ilMapArea ilQuestionPageParser::$map_area = null

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

◆ $mapping

ilImportMapping ilQuestionPageParser::$mapping = null
protected

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

Referenced by setImportMapping().

◆ $media_item

ilMediaItem ilQuestionPageParser::$media_item = null

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

◆ $media_object

ilObjMediaObject ilQuestionPageParser::$media_object = null

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

◆ $mob_mapping

array ilQuestionPageParser::$mob_mapping = []

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

◆ $mobs_with_int_links

array ilQuestionPageParser::$mobs_with_int_links = []
protected

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

◆ $page_object

ilPageObject ilQuestionPageParser::$page_object = null

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

◆ $pages_to_parse

array ilQuestionPageParser::$pages_to_parse = []

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

◆ $pg_into_tree

array ilQuestionPageParser::$pg_into_tree = []

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

◆ $pg_mapping

array ilQuestionPageParser::$pg_mapping = []
protected

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

◆ $qst_mapping

array ilQuestionPageParser::$qst_mapping = []

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

◆ $st_into_tree

array ilQuestionPageParser::$st_into_tree = []

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

◆ $structure_objects

array ilQuestionPageParser::$structure_objects = []

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

◆ $tree

ilTree ilQuestionPageParser::$tree

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

Referenced by __construct().


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