ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 @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
 __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 @access public

Reimplemented from ilSaxParser.

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

54 {
55 parent::__construct('', $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:

Member Function Documentation

◆ __addProperty()

ilObjectXMLParser::__addProperty (   $a_name,
  $a_value 
)

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

239 {
240 $this->object_data[$this->curr_obj][$a_name] = $a_value;
241 }

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

247 {
248 $reference['ref_id'] = $a_ref_id;
249 $reference['parent_id'] = $a_parent_id;
250 $reference['time_target'] = $a_time_target;
251
252 if (isset($reference['time_target']['changeable']) and $reference['time_target']['changeable']) {
253 if (!isset($reference['time_target']['suggestion_start']) or !isset($reference['time_target']['suggestion_end'])) {
254 throw new ilObjectXMLException('Missing attributes: "starting_time" and "ending_time" required for attribute "changeable"');
255 }
256 }
257
258 $this->object_data[$this->curr_obj]['references'][] = $reference;
259 }
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 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 $this->__addProperty('offline', $a_attribs['offline']);
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 $this->time_target['starting_time'] = $a_attribs['starting_time'];
147 }
148 if (isset($a_attribs['ending_time'])) {
149 $this->time_target['ending_time'] = $a_attribs['ending_time'];
150 }
151
152 if ($a_attribs['ending_time'] < $a_attribs['starting_time']) {
153 throw new ilObjectXMLException('Starting time must be earlier than ending time.');
154 }
155 break;
156
157 case 'Suggestion':
158 $this->time_target['changeable'] = $a_attribs['changeable'];
159
160
161 if (isset($a_attribs['starting_time'])) {
162 $this->time_target['suggestion_start'] = $a_attribs['starting_time'];
163 }
164 if (isset($a_attribs['ending_time'])) {
165 $this->time_target['suggestion_end'] = $a_attribs['ending_time'];
166 }
167 break;
168
169 }
170 }
__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 227 of file class.ilObjectXMLParser.php.

228 {
229 if ($a_data != "\n") {
230 // Replace multiple tabs with one space
231 $a_data = preg_replace("/\t+/", " ", $a_data);
232
233 $this->cdata .= $a_data;
234 }
235 }

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

179 {
180 switch ($a_name) {
181 case 'Objects':
182 break;
183
184 case 'Object':
185 break;
186
187 case 'Title':
188 $this->__addProperty('title', trim($this->cdata));
189 break;
190
191 case 'Description':
192 $this->__addProperty('description', trim($this->cdata));
193 break;
194
195 case 'Owner':
196 $this->__addProperty('owner', trim($this->cdata));
197 break;
198
199 case 'CreateDate':
200 $this->__addProperty('create_date', trim($this->cdata));
201 break;
202
203 case 'LastUpdate':
204 $this->__addProperty('last_update', trim($this->cdata));
205 break;
206
207 case 'ImportId':
208 $this->__addProperty('import_id', trim($this->cdata));
209 break;
210
211 case 'References':
212 $this->__addReference($this->ref_id, $this->parent_id, $this->time_target);
213 break;
214 }
215
216 $this->cdata = '';
217
218 return;
219 }
__addReference($a_ref_id, $a_parent_id, $a_time_target)

References __addProperty(), and __addReference().

+ 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 }
parse($uri)
Parses a URI and returns its individual components.
Definition: functions.php:181

References Sabre\Uri\parse().

+ Here is the call graph for this function:

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