ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjectXMLParser Class Reference

Object XML Parser. More...

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

Public Member Functions

 __construct ($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
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object 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 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
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). 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...
 
 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

- Static Public Member Functions inherited from PEAR
static & 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...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- 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.

Constructor & Destructor Documentation

◆ __construct()

ilObjectXMLParser::__construct (   $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 public

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

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

54  {
55  parent::__construct('', $throwException);
56  $this->setXMLContent($a_xml_data);
57  }
setXMLContent($a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ __addProperty()

ilObjectXMLParser::__addProperty (   $a_name,
  $a_value 
)

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

Referenced by handlerBeginTag(), and handlerEndTag().

251  {
252  $this->object_data[$this->curr_obj][$a_name] = $a_value;
253  }
+ 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 258 of file class.ilObjectXMLParser.php.

Referenced by handlerEndTag().

259  {
260  $reference['ref_id'] = $a_ref_id;
261  $reference['parent_id'] = $a_parent_id;
262  $reference['time_target'] = $a_time_target;
263 
264  if (isset($reference['time_target']['changeable']) and $reference['time_target']['changeable']) {
265  if (!isset($reference['time_target']['earliest_start']) or !isset($reference['time_target']['latest_end'])) {
266  throw new ilObjectXMLException('Missing attributes: "earliest_start" and "latest_end" required for attribute "changeable"');
267  }
268  if (!isset($reference['time_target']['suggestion_start']) or !isset($reference['time_target']['suggestion_end'])) {
269  throw new ilObjectXMLException('Missing attributes: "starting_time" and "ending_time" required for attribute "changeable"');
270  }
271  if (($reference['time_target']['earliest_start'] < $reference['time_target']['suggestion_start']) or
272  ($reference['time_target']['earliest_start'] > $reference['time_target']['suggestion_end'])) {
273  throw new ilObjectXMLException('Invalid attributes: "earliest_start" must be within "starting_time" and "ending_time"');
274  }
275  if (($reference['time_target']['latest_end'] < $reference['time_target']['suggestion_start']) or
276  ($reference['time_target']['latest_end'] > $reference['time_target']['suggestion_end'])) {
277  throw new ilObjectXMLException('Invalid attributes: "latest_end" must be within "starting_time" and "ending_time"');
278  }
279  }
280 
281  $this->object_data[$this->curr_obj]['references'][] = $reference;
282  }
Exception class for ObjectXMLWriter and ObjectXMLParser.
+ Here is the caller graph for this function:

◆ getObjectData()

ilObjectXMLParser::getObjectData ( )

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

References array.

60  {
61  return $this->object_data ? $this->object_data : array();
62  }
Create styles array
The data for the language used.

◆ 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.

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

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

240  {
241  if ($a_data != "\n") {
242  // Replace multiple tabs with one space
243  $a_data = preg_replace("/\t+/", " ", $a_data);
244 
245  $this->cdata .= $a_data;
246  }
247  }

◆ 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 190 of file class.ilObjectXMLParser.php.

References __addProperty(), and __addReference().

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

◆ parse()

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

parse xml file

private

Exceptions
ilSaxParserException
ilObjectXMLException

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 private

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: