ILIAS  release_8 Revision v8.24
ilObjectXMLParser Class Reference
+ 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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

23 {
25 $this->setXMLContent($a_xml_data);
26 }
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 178 of file class.ilObjectXMLParser.php.

178 : void
179 {
180 $this->object_data[$this->curr_obj][$a_name] = $a_value;
181 }

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

183 : void
184 {
185 $reference['ref_id'] = $a_ref_id;
186 $reference['parent_id'] = $a_parent_id;
187 $reference['time_target'] = $a_time_target;
188
189 if (isset($reference['time_target']['changeable']) && $reference['time_target']['changeable'] &&
190 !isset($reference['time_target']['suggestion_start'], $reference['time_target']['suggestion_end'])) {
191 throw new ilObjectXMLException(
192 'Missing attributes: "starting_time" and "ending_time" required for attribute "changeable"'
193 );
194 }
195
196 $this->object_data[$this->curr_obj]['references'][] = $reference;
197 }
Exception class for ObjectXMLWriter and ObjectXMLParser.

References $curr_obj.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getObjectData()

ilObjectXMLParser::getObjectData ( )

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

28 : array
29 {
30 return $this->object_data;
31 }

References $object_data.

◆ handlerBeginTag()

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

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

47 : void
48 {
49 switch ($a_name) {
50 case 'Objects':
51 $this->curr_obj = -1;
52 break;
53
54 case 'Object':
56
57 $this->addProperty('type', (string) $a_attribs['type']);
58 $this->addProperty(
59 'obj_id',
60 is_numeric($a_attribs['obj_id']) ? (int) $a_attribs["obj_id"] : ilUtil::__extractId(
61 $a_attribs["obj_id"] ?? '',
63 )
64 );
65 $this->addProperty('offline', $a_attribs['offline']);
66 break;
67
68 case 'ImportId':
69 case 'LastUpdate':
70 case 'CreateDate':
71 case 'Owner':
72 case 'Description':
73 case 'Title':
74 break;
75
76 case 'References':
77 $this->time_target = [];
78 $this->ref_id = $a_attribs["ref_id"];
79 $this->parent_id = $a_attribs['parent_id'];
80 break;
81
82 case 'TimeTarget':
83 $this->time_target['timing_type'] = $a_attribs['type'];
84 break;
85
86 case 'Timing':
87 $this->time_target['timing_visibility'] = $a_attribs['visibility'];
88 if (isset($a_attribs['starting_time'])) {
89 $this->time_target['starting_time'] = $a_attribs['starting_time'];
90 }
91 if (isset($a_attribs['ending_time'])) {
92 $this->time_target['ending_time'] = $a_attribs['ending_time'];
93 }
94
95 if ($a_attribs['ending_time'] < $a_attribs['starting_time']) {
96 throw new ilObjectXMLException('Starting time must be earlier than ending time.');
97 }
98 break;
99
100 case 'Suggestion':
101 $this->time_target['changeable'] = $a_attribs['changeable'];
102
103 if (isset($a_attribs['starting_time'])) {
104 $this->time_target['suggestion_start'] = $a_attribs['starting_time'];
105 }
106 if (isset($a_attribs['ending_time'])) {
107 $this->time_target['suggestion_end'] = $a_attribs['ending_time'];
108 }
109 break;
110
111 }
112 }
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.

+ Here is the call 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 163 of file class.ilObjectXMLParser.php.

163 : void
164 {
165 if ($a_data !== "\n") {
166 // Replace multiple tabs with one space
167 $a_data = preg_replace("/\t+/", " ", $a_data);
168
169 $this->cdata .= $a_data;
170 }
171 }

◆ handlerEndTag()

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

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

119 : void
120 {
121 switch ($a_name) {
122 case 'Object':
123 case 'Objects':
124 break;
125
126 case 'Title':
127 $this->addProperty('title', trim($this->cdata));
128 break;
129
130 case 'Description':
131 $this->addProperty('description', trim($this->cdata));
132 break;
133
134 case 'Owner':
135 $this->addProperty('owner', trim($this->cdata));
136 break;
137
138 case 'CreateDate':
139 $this->addProperty('create_date', trim($this->cdata));
140 break;
141
142 case 'LastUpdate':
143 $this->addProperty('last_update', trim($this->cdata));
144 break;
145
146 case 'ImportId':
147 $this->addProperty('import_id', trim($this->cdata));
148 break;
149
150 case 'References':
151 $this->addReference($this->ref_id, $this->parent_id, $this->time_target);
152 break;
153 }
154
155 $this->cdata = '';
156 }
addReference(int $a_ref_id, int $a_parent_id, array $a_time_target)

References addProperty(), and addReference().

+ Here is the call graph for this function:

◆ setHandlers()

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

Reimplemented from ilSaxParser.

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

37 : void
38 {
39 xml_set_object($a_xml_parser, $this);
40 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
41 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
42 }

Field Documentation

◆ $cdata

string ilObjectXMLParser::$cdata = ''
private

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

◆ $curr_obj

int ilObjectXMLParser::$curr_obj = 0
private

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

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

◆ $object_data

array ilObjectXMLParser::$object_data = []

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

Referenced by getObjectData().

◆ $parent_id

int ilObjectXMLParser::$parent_id = 0
private

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

◆ $ref_id

int ilObjectXMLParser::$ref_id = 0
private

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

◆ $time_target

array ilObjectXMLParser::$time_target = []
private

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


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