ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjectXMLParser Class Reference

Object XML Parser. More...

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

Public Member Functions

 ilObjectXMLParser ($a_xml_data='', $throwException=false)
 Constructor. More...
 
 getObjectData ()
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 __addProperty ($a_name, $a_value)
 
 __addReference ($a_ref_id, $a_parent_id, $a_time_target)
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $object_data = array()
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Private Attributes

 $ref_id
 
 $parent_id
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Object XML Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

◆ __addProperty()

ilObjectXMLParser::__addProperty (   $a_name,
  $a_value 
)

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

259 {
260 $this->object_data[$this->curr_obj][$a_name] = $a_value;
261 }

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ __addReference()

ilObjectXMLParser::__addReference (   $a_ref_id,
  $a_parent_id,
  $a_time_target 
)
Exceptions
ilObjectXMLException

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

267 {
268 $reference['ref_id'] = $a_ref_id;
269 $reference['parent_id'] = $a_parent_id;
270 $reference['time_target'] = $a_time_target;
271
272 if(isset($reference['time_target']['changeable']) and $reference['time_target']['changeable'])
273 {
274 if(!isset($reference['time_target']['earliest_start']) or !isset($reference['time_target']['latest_end']))
275 {
276 throw new ilObjectXMLException('Missing attributes: "earliest_start" and "latest_end" required for attribute "changeable"');
277 }
278 if(!isset($reference['time_target']['suggestion_start']) or !isset($reference['time_target']['suggestion_end']))
279 {
280 throw new ilObjectXMLException('Missing attributes: "starting_time" and "ending_time" required for attribute "changeable"');
281 }
282 if(($reference['time_target']['earliest_start'] < $reference['time_target']['suggestion_start']) or
283 ($reference['time_target']['earliest_start'] > $reference['time_target']['suggestion_end']))
284 {
285 throw new ilObjectXMLException('Invalid attributes: "earliest_start" must be within "starting_time" and "ending_time"');
286 }
287 if(($reference['time_target']['latest_end'] < $reference['time_target']['suggestion_start']) or
288 ($reference['time_target']['latest_end'] > $reference['time_target']['suggestion_end']))
289 {
290 throw new ilObjectXMLException('Invalid attributes: "latest_end" must be within "starting_time" and "ending_time"');
291 }
292 }
293
294 $this->object_data[$this->curr_obj]['references'][] = $reference;
295 }
Exception class for ObjectXMLWriter and ObjectXMLParser.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getObjectData()

ilObjectXMLParser::getObjectData ( )

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

60 {
61 return $this->object_data ? $this->object_data : array();
62 }

◆ handlerBeginTag()

ilObjectXMLParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

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

101 {
102 switch($a_name)
103 {
104 case 'Objects':
105 $this->curr_obj = -1;
106 break;
107
108 case 'Object':
109 ++$this->curr_obj;
110
111 $this->__addProperty('type',$a_attribs['type']);
112 $this->__addProperty('obj_id',is_numeric($a_attribs['obj_id'])?(int) $a_attribs["obj_id"] : ilUtil::__extractId($a_attribs["obj_id"], IL_INST_ID));
113 break;
114
115 case 'Title':
116 break;
117
118 case 'Description':
119 break;
120
121 case 'Owner':
122 break;
123
124 case 'CreateDate':
125 break;
126
127 case 'LastUpdate':
128 break;
129
130 case 'ImportId':
131 break;
132
133 case 'References':
134 $this->time_target = array();
135 $this->ref_id = $a_attribs["ref_id"];
136 $this->parent_id = $a_attribs['parent_id'];
137 break;
138
139 case 'TimeTarget':
140 $this->time_target['timing_type'] = $a_attribs['type'];
141 break;
142
143 case 'Timing':
144 $this->time_target['timing_visibility'] = $a_attribs['visibility'];
145 if(isset($a_attribs['starting_time']))
146 {
147 $this->time_target['starting_time'] = $a_attribs['starting_time'];
148 }
149 if(isset($a_attribs['ending_time']))
150 {
151 $this->time_target['ending_time'] = $a_attribs['ending_time'];
152 }
153
154 if($a_attribs['ending_time'] < $a_attribs['starting_time'])
155 throw new ilObjectXMLException('Starting time must be earlier than ending time.');
156 break;
157
158 case 'Suggestion':
159 $this->time_target['changeable'] = $a_attribs['changeable'];
160
161
162 if(isset($a_attribs['starting_time']))
163 {
164 $this->time_target['suggestion_start'] = $a_attribs['starting_time'];
165 }
166 if(isset($a_attribs['ending_time']))
167 {
168 $this->time_target['suggestion_end'] = $a_attribs['ending_time'];
169 }
170 if(isset($a_attribs['earliest_start']))
171 {
172 $this->time_target['earliest_start'] = $a_attribs['earliest_start'];
173 }
174 if(isset($a_attribs['latest_end']))
175 {
176 $this->time_target['latest_end'] = $a_attribs['latest_end'];
177 }
178
179 if($a_attribs['latest_end'] < $a_attribs['earliest_start'])
180 throw new ilObjectXMLException('Earliest start time must be earlier than latest ending time.');
181 if($a_attribs['ending_time'] < $a_attribs['starting_time'])
182 throw new ilObjectXMLException('Starting time must be earlier than ending time.');
183 break;
184
185 }
186 }
__addProperty($a_name, $a_value)
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.

References __addProperty(), and ilUtil\__extractId().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilObjectXMLParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

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

245 {
246 if($a_data != "\n")
247 {
248 // Replace multiple tabs with one space
249 $a_data = preg_replace("/\t+/"," ",$a_data);
250
251 $this->cdata .= $a_data;
252 }
253
254
255 }

◆ handlerEndTag()

ilObjectXMLParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

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

195 {
196 switch($a_name)
197 {
198 case 'Objects':
199 break;
200
201 case 'Object':
202 break;
203
204 case 'Title':
205 $this->__addProperty('title',trim($this->cdata));
206 break;
207
208 case 'Description':
209 $this->__addProperty('description',trim($this->cdata));
210 break;
211
212 case 'Owner':
213 $this->__addProperty('owner',trim($this->cdata));
214 break;
215
216 case 'CreateDate':
217 $this->__addProperty('create_date',trim($this->cdata));
218 break;
219
220 case 'LastUpdate':
221 $this->__addProperty('last_update',trim($this->cdata));
222 break;
223
224 case 'ImportId':
225 $this->__addProperty('import_id',trim($this->cdata));
226 break;
227
228 case 'References':
229 $this->__addReference($this->ref_id,$this->parent_id,$this->time_target);
230 break;
231 }
232
233 $this->cdata = '';
234
235 return;
236 }
__addReference($a_ref_id, $a_parent_id, $a_time_target)

References __addProperty(), and __addReference().

+ Here is the call graph for this function:

◆ ilObjectXMLParser()

ilObjectXMLParser::ilObjectXMLParser (   $a_xml_data = '',
  $throwException = false 
)

Constructor.

Parameters
object$a_content_objectmust be of type ilObjContentObject ilObjTest or ilObjQuestionPool
string$a_xml_filexml data
string$a_subdirsubdirectory in import directory @access public

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

54 {
55 parent::ilSaxParser('', $throwException);
56 $this->setXMLContent($a_xml_data);
57 }
setXMLContent($a_xml_content)

References ilSaxParser\$throwException, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

◆ parse()

ilObjectXMLParser::parse (   $a_xml_parser,
  $a_fp = null 
)

parse xml file

@access private

Exceptions
ilSaxParserException
ilObjectXMLException

Reimplemented from ilSaxParser.

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

72 {
73 parent::parse($a_xml_parser,$a_fp);
74 }

◆ setHandlers()

ilObjectXMLParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser @access private

Reimplemented from ilSaxParser.

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

84 {
85 xml_set_object($a_xml_parser,$this);
86 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
87 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
88 }

Field Documentation

◆ $object_data

ilObjectXMLParser::$object_data = array()

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

◆ $parent_id

ilObjectXMLParser::$parent_id
private

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

◆ $ref_id

ilObjectXMLParser::$ref_id
private

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


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