ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
_parse_proppatch Class Reference
+ Collaboration diagram for _parse_proppatch:

Public Member Functions

 _parse_proppatch ($path)
 constructor More...
 
 _startElement ($parser, $name, $attrs)
 tag start handler More...
 
 _endElement ($parser, $name)
 tag end handler More...
 
 _data ($parser, $data)
 input data handler More...
 

Data Fields

 $success
 
 $props
 
 $depth
 
 $mode
 
 $current
 

Detailed Description

Definition at line 30 of file _parse_proppatch.php.

Member Function Documentation

◆ _data()

_parse_proppatch::_data (   $parser,
  $data 
)

input data handler

Parameters
resourceparser
stringdata
Returns
void private

Definition at line 207 of file _parse_proppatch.php.

References $data.

207  {
208  if (isset($this->current)) {
209  $this->current["val"] .= $data;
210  }
211  }

◆ _endElement()

_parse_proppatch::_endElement (   $parser,
  $name 
)

tag end handler

Parameters
resourceparser
stringtag name
Returns
void private

Definition at line 174 of file _parse_proppatch.php.

References $current.

175  {
176  if (strstr($name, " ")) {
177  list($ns, $tag) = explode(" ", $name);
178  if ($ns == "")
179  $this->success = false;
180  } else {
181  $ns = "";
182  $tag = $name;
183  }
184 
185  $this->depth--;
186 
187  if ($this->depth >= 4) {
188  $this->current["val"] .= "</$tag>";
189  }
190 
191  if ($this->depth == 3) {
192  if (isset($this->current)) {
193  $this->props[] = $this->current;
194  unset($this->current);
195  }
196  }
197  }

◆ _parse_proppatch()

_parse_proppatch::_parse_proppatch (   $path)

constructor

Parameters
stringpath of input stream public

Definition at line 78 of file _parse_proppatch.php.

References $path.

79  {
80  $this->success = true;
81 
82  $this->depth = 0;
83  $this->props = array();
84  $had_input = false;
85 
86  $f_in = fopen($path, "r");
87  if (!$f_in) {
88  $this->success = false;
89  return;
90  }
91 
92  $xml_parser = xml_parser_create_ns("UTF-8", " ");
93 
94  xml_set_element_handler($xml_parser,
95  array(&$this, "_startElement"),
96  array(&$this, "_endElement"));
97 
98  xml_set_character_data_handler($xml_parser,
99  array(&$this, "_data"));
100 
101  xml_parser_set_option($xml_parser,
102  XML_OPTION_CASE_FOLDING, false);
103 
104  while($this->success && !feof($f_in)) {
105  $line = fgets($f_in);
106  if (is_string($line)) {
107  $had_input = true;
108  $this->success &= xml_parse($xml_parser, $line, false);
109  }
110  }
111 
112  if($had_input) {
113  $this->success &= xml_parse($xml_parser, "", true);
114  }
115 
116  xml_parser_free($xml_parser);
117 
118  fclose($f_in);
119  }
$path
Definition: index.php:22

◆ _startElement()

_parse_proppatch::_startElement (   $parser,
  $name,
  $attrs 
)

tag start handler

Parameters
resourceparser
stringtag name
arraytag attributes
Returns
void private

Definition at line 130 of file _parse_proppatch.php.

131  {
132  if (strstr($name, " ")) {
133  list($ns, $tag) = explode(" ", $name);
134  if ($ns == "")
135  $this->success = false;
136  } else {
137  $ns = "";
138  $tag = $name;
139  }
140 
141  if ($this->depth == 1) {
142  $this->mode = $tag;
143  }
144 
145  if ($this->depth == 3) {
146  $prop = array("name" => $tag);
147  $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
148  if ($this->mode == "set") {
149  $this->current["val"] = ""; // default set val
150  }
151  }
152 
153  if ($this->depth >= 4) {
154  $this->current["val"] .= "<$tag";
155  foreach ($attr as $key => $val) {
156  $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
157  }
158  $this->current["val"] .= ">";
159  }
160 
161 
162 
163  $this->depth++;
164  }

Field Documentation

◆ $current

_parse_proppatch::$current

Definition at line 70 of file _parse_proppatch.php.

Referenced by _endElement().

◆ $depth

_parse_proppatch::$depth

Definition at line 54 of file _parse_proppatch.php.

◆ $mode

_parse_proppatch::$mode

Definition at line 62 of file _parse_proppatch.php.

◆ $props

_parse_proppatch::$props

Definition at line 46 of file _parse_proppatch.php.

◆ $success

_parse_proppatch::$success

Definition at line 38 of file _parse_proppatch.php.


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