ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLearningSequenceXMLParser Class Reference
+ Inheritance diagram for ilLearningSequenceXMLParser:
+ Collaboration diagram for ilLearningSequenceXMLParser:

Public Member Functions

 __construct (protected ilObjLearningSequence $obj, string $xml)
 
 start ()
 
 setHandlers ($a_xml_parser)
 
 handleBeginTag ( $parser, string $name, array $attributes)
 
 handleEndTag ($parser, string $name)
 
 handleCharacterData ($parser, $data)
 
- 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)
 

Protected Attributes

array $object
 
array $ls_item_data
 
array $settings
 
array $lp_settings
 
int $counter
 
string $actual_name
 
string $cdata = ''
 
string $current_container_setting = ''
 
bool $in_item_conditions = false
 
array $current_condition = null
 
array $current_table = null
 
array $current_row = null
 
string $current_col_name = ''
 
bool $in_col = false
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Detailed Description

Definition at line 23 of file class.ilLearningSequenceXMLParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningSequenceXMLParser::__construct ( protected ilObjLearningSequence  $obj,
string  $xml 
)

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

60 {
62
63 $this->setXMLContent($xml);
64
65 $this->object = [];
66 $this->ls_item_data = [];
67 $this->settings = [];
68 $this->lp_settings = [];
69 $this->lp_settings["lp_item_ref_ids"] = [];
70 $this->counter = 0;
71 }
setXMLContent(string $a_xml_content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\settings(), and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ handleBeginTag()

ilLearningSequenceXMLParser::handleBeginTag (   $parser,
string  $name,
array  $attributes 
)

Definition at line 94 of file class.ilLearningSequenceXMLParser.php.

98 : void {
99 $this->actual_name = $name;
100
101 switch ($name) {
102 case Writer::TAG_LSO:
103 $this->object["ref_id"] = $attributes["ref_id"];
104 $this->settings["members_gallery"] = $attributes['members_gallery'];
105 $this->settings["mode"] = $attributes['mode'];
106 $this->settings["start_ref_id"] = $attributes['start_ref_id'];
107 $this->settings["end_ref_id"] = $attributes['end_ref_id'];
108 break;
109 case Writer::TAG_LPSETTING:
110 $this->lp_settings["lp_type"] = $attributes['type'];
111 $this->lp_settings["lp_mode"] = $attributes['mode'];
112 $this->lp_settings["lp_item_ref_ids"] = [];
113 break;
114
115 case Writer::TAG_LSITEM:
116 $this->counter = (int) $attributes["ref_id"];
117 $this->ls_item_data[$this->counter]["ref_id"] = $attributes["ref_id"];
118 if (isset($attributes["position"])) {
119 $this->ls_item_data[$this->counter]["position"] = $attributes["position"];
120 }
121 break;
122
123 case Writer::TAG_CONDITION:
124 $this->ls_item_data[$this->counter]["condition_type"] = $attributes["type"];
125 $this->ls_item_data[$this->counter]["condition_value"] = '';
126 break;
127
128 case Writer::TAG_ITEM_CONDITIONS:
129 $this->in_item_conditions = true;
130 if (!isset($this->ls_item_data[$this->counter]["conditions"])) {
131 $this->ls_item_data[$this->counter]["conditions"] = [];
132 }
133 break;
134
135 case Writer::TAG_ITEM_CONDITION:
136 if ($this->in_item_conditions) {
137 $this->current_condition = [
138 'type' => $attributes['type'] ?? '',
139 'subtype' => $attributes['subtype'] ?? null,
140 'data' => [],
141 ];
142 }
143 break;
144
145 case 'Table':
146 if ($this->current_condition !== null) {
147 $this->current_table = [
148 'table' => $attributes['name'] ?? '',
149 'fields' => [],
150 'rows' => [],
151 ];
152 }
153 break;
154
155 case 'Field':
156 if ($this->current_table !== null) {
157 $field_name = $attributes['name'] ?? '';
158 $meta = $attributes;
159 unset($meta['name']);
160 $this->current_table['fields'][$field_name] = $meta;
161 }
162 break;
163
164 case 'Row':
165 if ($this->current_table !== null) {
166 $this->current_row = [];
167 }
168 break;
169
170 case 'Col':
171 if ($this->current_row !== null) {
172 $this->current_col_name = $attributes['name'] ?? '';
173 $this->in_col = true;
174 }
175 break;
176
177 case Writer::TAG_CONTAINERSETTING:
178 $this->current_container_setting = $attributes['id'];
179 break;
180
181 default:
182 break;
183 }
184 }

References $counter, ILIAS\Repository\int(), and ILIAS\Repository\settings().

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleCharacterData()

ilLearningSequenceXMLParser::handleCharacterData (   $parser,
  $data 
)

Definition at line 253 of file class.ilLearningSequenceXMLParser.php.

253 : void
254 {
255 $this->cdata .= ($data ?? "");
256 }
$data
Definition: storeScorm.php:45

References $data.

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handleEndTag()

ilLearningSequenceXMLParser::handleEndTag (   $parser,
string  $name 
)

Definition at line 186 of file class.ilLearningSequenceXMLParser.php.

186 : void
187 {
188 $this->cdata = trim($this->cdata);
189
190 switch ($name) {
191 case Writer::TAG_LPREFID:
192 $this->lp_settings["lp_item_ref_ids"][] = trim($this->cdata);
193 break;
194
195 case Writer::TAG_CONTAINERSETTING:
196 if ($this->current_container_setting) {
198 $this->obj->getId(),
199 $this->current_container_setting,
200 trim($this->cdata)
201 );
202 }
203 break;
204
205 case Writer::TAG_TITLE:
206 $this->obj->setTitle(trim($this->cdata));
207 break;
208
209 case Writer::TAG_DESCRIPTION:
210 $this->obj->setDescription(trim($this->cdata));
211 break;
212
213 case 'Col':
214 if ($this->current_row !== null && $this->in_col) {
215 $this->current_row[$this->current_col_name] = $this->cdata;
216 }
217 $this->in_col = false;
218 $this->current_col_name = '';
219 break;
220
221 case 'Row':
222 if ($this->current_table !== null && $this->current_row !== null) {
223 $this->current_table['rows'][] = $this->current_row;
224 }
225 $this->current_row = null;
226 break;
227
228 case 'Table':
229 if ($this->current_condition !== null && $this->current_table !== null) {
230 $this->current_condition['data'][] = $this->current_table;
231 }
232 $this->current_table = null;
233 break;
234
235 case Writer::TAG_ITEM_CONDITION:
236 if ($this->in_item_conditions && $this->current_condition !== null) {
237 $this->ls_item_data[$this->counter]["conditions"][] = $this->current_condition;
238 }
239 $this->current_condition = null;
240 break;
241
242 case Writer::TAG_ITEM_CONDITIONS:
243 $this->in_item_conditions = false;
244 break;
245
246 default:
247 break;
248 }
249
250 $this->cdata = '';
251 }
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)

References ilContainer\_writeContainerSetting().

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilLearningSequenceXMLParser::setHandlers (   $a_xml_parser)
Parameters
XMLParser | resource$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

Definition at line 88 of file class.ilLearningSequenceXMLParser.php.

88 : void
89 {
90 xml_set_element_handler($a_xml_parser, $this->handleBeginTag(...), $this->handleEndTag(...));
91 xml_set_character_data_handler($a_xml_parser, $this->handleCharacterData(...));
92 }
handleBeginTag( $parser, string $name, array $attributes)

References handleBeginTag(), handleCharacterData(), and handleEndTag().

+ Here is the call graph for this function:

◆ start()

ilLearningSequenceXMLParser::start ( )
Returns
array<string, mixed>

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

76 : array
77 {
78 $this->startParsing();
79 $ret = [];
80 $ret["object"] = $this->object;
81 $ret["item_data"] = $this->ls_item_data;
82 $ret["settings"] = $this->settings;
83 $ret["lp_settings"] = $this->lp_settings;
84
85 return $ret;
86 }
startParsing()
stores xml data in array

References $lp_settings, $ls_item_data, $object, $settings, and ilSaxParser\startParsing().

+ Here is the call graph for this function:

Field Documentation

◆ $actual_name

string ilLearningSequenceXMLParser::$actual_name
protected

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

◆ $cdata

string ilLearningSequenceXMLParser::$cdata = ''
protected

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

◆ $counter

int ilLearningSequenceXMLParser::$counter
protected

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

Referenced by handleBeginTag().

◆ $current_col_name

string ilLearningSequenceXMLParser::$current_col_name = ''
protected

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

◆ $current_condition

array ilLearningSequenceXMLParser::$current_condition = null
protected

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

◆ $current_container_setting

string ilLearningSequenceXMLParser::$current_container_setting = ''
protected

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

◆ $current_row

array ilLearningSequenceXMLParser::$current_row = null
protected

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

◆ $current_table

array ilLearningSequenceXMLParser::$current_table = null
protected

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

◆ $in_col

bool ilLearningSequenceXMLParser::$in_col = false
protected

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

◆ $in_item_conditions

bool ilLearningSequenceXMLParser::$in_item_conditions = false
protected

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

◆ $lp_settings

array ilLearningSequenceXMLParser::$lp_settings
protected

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

Referenced by start().

◆ $ls_item_data

array ilLearningSequenceXMLParser::$ls_item_data
protected

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

Referenced by start().

◆ $object

array ilLearningSequenceXMLParser::$object
protected

Definition at line 28 of file class.ilLearningSequenceXMLParser.php.

Referenced by start().

◆ $settings

array ilLearningSequenceXMLParser::$settings
protected

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

Referenced by start().


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