ILIAS  release_8 Revision v8.24
class.ilObjQuestionPoolXMLParser.php
Go to the documentation of this file.
1<?php
25{
26 private \ilObjQuestionPool $poolOBJ;
27
29
32 private bool $descriptionProcessed = false;
33 private string $cdata = "";
34
39 public function __construct(ilObjQuestionPool $poolOBJ, ?string $xmlFile)
40 {
41 $this->poolOBJ = $poolOBJ;
42
43 $this->inSettingsTag = false;
44 $this->inMetaDataTag = false;
45 $this->inMdGeneralTag = false;
46
47 return parent::__construct($xmlFile);
48 }
49
50 public function setHandlers($a_xml_parser): void
51 {
52 xml_set_object($a_xml_parser, $this);
53 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
54 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
55 }
56
57 public function handlerBeginTag($xmlParser, $tagName, $tagAttributes): void
58 {
59 switch ($tagName) {
60 case 'MetaData':
61 $this->inMetaDataTag = true;
62 break;
63
64 case 'General':
65 if ($this->inMetaDataTag) {
66 $this->inMdGeneralTag = true;
67 }
68 break;
69
70 case 'Description':
71 if ($this->inMetaDataTag && $this->inMdGeneralTag) {
72 $this->cdata = '';
73 }
74 break;
75
76 case 'Settings':
77 $this->inSettingsTag = true;
78 break;
79
80 case 'ShowTaxonomies':
81 case 'NavTaxonomy':
82 case 'SkillService':
83 if ($this->inSettingsTag) {
84 $this->cdata = '';
85 }
86 break;
87 }
88 }
89
90 public function handlerEndTag($xmlParser, $tagName): void
91 {
92 switch ($tagName) {
93 case 'MetaData':
94 $this->inMetaDataTag = false;
95 break;
96
97 case 'General':
98 if ($this->inMetaDataTag) {
99 $this->inMdGeneralTag = false;
100 }
101 break;
102
103 case 'Description':
104 if ($this->inMetaDataTag && $this->inMdGeneralTag && !$this->descriptionProcessed) {
105 $this->poolOBJ->setDescription($this->cdata);
106 $this->descriptionProcessed = true;
107 $this->cdata = '';
108 }
109 break;
110
111 case 'Settings':
112 $this->inSettingsTag = false;
113 break;
114
115 case 'ShowTaxonomies':
116 $this->poolOBJ->setShowTaxonomies((bool) $this->cdata);
117 $this->cdata = '';
118 break;
119
120 case 'NavTaxonomy':
121 $this->poolOBJ->setNavTaxonomyId((int) $this->cdata);
122 $this->cdata = '';
123 break;
124
125 case 'SkillService':
126 $this->poolOBJ->setSkillServiceEnabled((bool) $this->cdata);
127 $this->cdata = '';
128 break;
129 }
130 }
131
132 public function handlerCharacterData($xmlParser, $charData): void
133 {
134 if ($charData != "\n") {
135 // Replace multiple tabs with one space
136 $charData = preg_replace("/\t+/", " ", $charData);
137
138 $this->cdata .= $charData;
139 }
140 }
141}
__construct(ilObjQuestionPool $poolOBJ, ?string $xmlFile)
handlerBeginTag($xmlParser, $tagName, $tagAttributes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc