ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjectXMLParser Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjectXMLParser:
+ Collaboration diagram for ilObjectXMLParser:

Public Member Functions

 __construct (string $a_xml_data='', ?bool $throw_exception=false)
 
 getObjectData ()
 
 setHandlers ($a_xml_parser)
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag ($a_xml_parser, string $a_name)
 
 handlerCharacterData ($a_xml_parser, string $a_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)
 

Data Fields

array $object_data = []
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Private Member Functions

 addProperty (string $a_name, $a_value)
 
 addReference (int $a_ref_id, int $a_parent_id, array $a_time_target)
 

Private Attributes

int $ref_id = 0
 
int $parent_id = 0
 
int $curr_obj = 0
 
array $time_target = []
 
string $cdata = ''
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilObjectXMLParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectXMLParser::__construct ( string  $a_xml_data = '',
?bool  $throw_exception = false 
)

Definition at line 29 of file class.ilObjectXMLParser.php.

30 {
32 $this->setXMLContent($a_xml_data);
33 }
setXMLContent(string $a_xml_content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilSaxParser\$throw_exception, ILIAS\GlobalScreen\Provider\__construct(), and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ addProperty()

ilObjectXMLParser::addProperty ( string  $a_name,
  $a_value 
)
private
Parameters
string$a_name
string  |  int$a_value
Returns
void

Definition at line 196 of file class.ilObjectXMLParser.php.

196 : void
197 {
198 $this->object_data[$this->curr_obj][$a_name] = $a_value;
199 }

References $curr_obj.

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ addReference()

ilObjectXMLParser::addReference ( int  $a_ref_id,
int  $a_parent_id,
array  $a_time_target 
)
private

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

201 : void
202 {
203 $reference['ref_id'] = $a_ref_id;
204 $reference['parent_id'] = $a_parent_id;
205 $reference['time_target'] = $a_time_target;
206
207 if (isset($reference['time_target']['changeable']) && $reference['time_target']['changeable'] &&
208 !isset($reference['time_target']['suggestion_start'], $reference['time_target']['suggestion_end'])) {
209 throw new ilObjectXMLException(
210 'Missing attributes: "starting_time" and "ending_time" required for attribute "changeable"'
211 );
212 }
213
214 $this->object_data[$this->curr_obj]['references'][] = $reference;
215 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $curr_obj.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getObjectData()

ilObjectXMLParser::getObjectData ( )

Definition at line 35 of file class.ilObjectXMLParser.php.

35 : array
36 {
37 return $this->object_data;
38 }

References $object_data.

◆ handlerBeginTag()

ilObjectXMLParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
XMLParser | resource$a_xml_parser

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

53 : void
54 {
55 switch ($a_name) {
56 case 'Objects':
57 $this->curr_obj = -1;
58 break;
59
60 case 'Object':
62
63 $this->addProperty('type', (string) $a_attribs['type']);
64 if (array_key_exists('obj_id', $a_attribs)) {
65 $this->addProperty(
66 'obj_id',
67 is_numeric($a_attribs['obj_id']) ? (int) $a_attribs["obj_id"] : ilUtil::__extractId(
68 $a_attribs["obj_id"] ?? '',
70 )
71 );
72 }
73 if (isset($a_attribs['offline'])) {
74 $this->addProperty('offline', $a_attribs['offline']);
75 }
76
77
78
79 break;
80
81 case 'ImportId':
82 case 'LastUpdate':
83 case 'CreateDate':
84 case 'Owner':
85 case 'Description':
86 case 'Title':
87 break;
88
89 case 'References':
90 $this->time_target = [];
91 $this->ref_id = $a_attribs["ref_id"] ?? 0;
92 $this->parent_id = $a_attribs['parent_id'] ?? 0;
93 break;
94
95 case 'TimeTarget':
96 $this->time_target['timing_type'] = $a_attribs['type'];
97 break;
98
99 case 'Timing':
100 if (isset($a_attribs['visibility'])) {
101 $this->time_target['timing_visibility'] = $a_attribs['visibility'];
102 }
103 if (isset($a_attribs['starting_time'])) {
104 $this->time_target['starting_time'] = $a_attribs['starting_time'];
105 }
106 if (isset($a_attribs['ending_time'])) {
107 $this->time_target['ending_time'] = $a_attribs['ending_time'];
108 }
109 if (isset($a_attribs['ending_time']) && isset($a_attribs['starting_time'])) {
110 // Validate timing if both times are present
111 if ($a_attribs['ending_time'] < $a_attribs['starting_time']) {
112 throw new ilObjectXMLException('Starting time must be earlier than ending time.');
113 }
114 }
115 break;
116
117 case 'Suggestion':
118 $this->time_target['changeable'] = $a_attribs['changeable'] ?? false;
119
120 if (isset($a_attribs['starting_time'])) {
121 $this->time_target['suggestion_start'] = $a_attribs['starting_time'];
122 }
123 if (isset($a_attribs['ending_time'])) {
124 $this->time_target['suggestion_end'] = $a_attribs['ending_time'];
125 }
126 break;
127 }
128 }
addProperty(string $a_name, $a_value)
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
const IL_INST_ID
Definition: constants.php:40

References $curr_obj, ilUtil\__extractId(), addProperty(), and IL_INST_ID.

Referenced by setHandlers().

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

◆ handlerCharacterData()

ilObjectXMLParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_data
Returns
void

Definition at line 181 of file class.ilObjectXMLParser.php.

181 : void
182 {
183 if ($a_data !== "\n") {
184 // Replace multiple tabs with one space
185 $a_data = preg_replace("/\t+/", " ", $a_data);
186
187 $this->cdata .= $a_data;
188 }
189 }

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerEndTag()

ilObjectXMLParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_name
Returns
void

Definition at line 135 of file class.ilObjectXMLParser.php.

135 : void
136 {
137 switch ($a_name) {
138 case 'Object':
139 case 'Objects':
140 break;
141
142 case 'Title':
143 $this->addProperty('title', trim($this->cdata));
144 break;
145
146 case 'Description':
147 $this->addProperty('description', trim($this->cdata));
148 break;
149
150 case 'Owner':
151 $this->addProperty('owner', trim($this->cdata));
152 break;
153
154 case 'CreateDate':
155 $this->addProperty('create_date', trim($this->cdata));
156 break;
157
158 case 'LastUpdate':
159 $this->addProperty('last_update', trim($this->cdata));
160 break;
161
162 case 'ImportId':
163 $this->addProperty('import_id', trim($this->cdata));
164 break;
165
166 case 'References':
167 if ($this->ref_id !== 0 && $this->parent_id !== 0) {
168 $this->addReference($this->ref_id, $this->parent_id, $this->time_target);
169 }
170 break;
171 }
172
173 $this->cdata = '';
174 }
addReference(int $a_ref_id, int $a_parent_id, array $a_time_target)

References addProperty(), and addReference().

Referenced by setHandlers().

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

◆ setHandlers()

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

Reimplemented from ilSaxParser.

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

44 : void
45 {
46 xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
47 xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
48 }
handlerCharacterData($a_xml_parser, string $a_data)
handlerEndTag($a_xml_parser, string $a_name)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

+ Here is the call graph for this function:

Field Documentation

◆ $cdata

string ilObjectXMLParser::$cdata = ''
private

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

◆ $curr_obj

int ilObjectXMLParser::$curr_obj = 0
private

Definition at line 25 of file class.ilObjectXMLParser.php.

Referenced by addProperty(), addReference(), and handlerBeginTag().

◆ $object_data

array ilObjectXMLParser::$object_data = []

Definition at line 21 of file class.ilObjectXMLParser.php.

Referenced by getObjectData().

◆ $parent_id

int ilObjectXMLParser::$parent_id = 0
private

Definition at line 24 of file class.ilObjectXMLParser.php.

◆ $ref_id

int ilObjectXMLParser::$ref_id = 0
private

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

◆ $time_target

array ilObjectXMLParser::$time_target = []
private

Definition at line 26 of file class.ilObjectXMLParser.php.


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