ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
_parse_proppatch.php
Go to the documentation of this file.
1 <?php
2 //
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4 |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Hartmut Holzgraefe <hholzgra@php.net> |
17 // | Christian Stocker <chregu@bitflux.ch> |
18 // +----------------------------------------------------------------------+
19 //
20 // $Id: _parse_proppatch.php,v 1.3 2004/01/05 12:41:34 hholzgra Exp $
21 //
22 
31 {
38  public $success;
39 
46  public $props;
47 
54  public $depth;
55 
62  public $mode;
63 
70  public $current;
71 
78  public function __construct($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(
95  $xml_parser,
96  array(&$this, "_startElement"),
97  array(&$this, "_endElement")
98  );
99 
100  xml_set_character_data_handler(
101  $xml_parser,
102  array(&$this, "_data")
103  );
104 
105  xml_parser_set_option(
106  $xml_parser,
107  XML_OPTION_CASE_FOLDING,
108  false
109  );
110 
111  while ($this->success && !feof($f_in)) {
112  $line = fgets($f_in);
113  if (is_string($line)) {
114  $had_input = true;
115  $this->success &= xml_parse($xml_parser, $line, false);
116  }
117  }
118 
119  if ($had_input) {
120  $this->success &= xml_parse($xml_parser, "", true);
121  }
122 
123  xml_parser_free($xml_parser);
124 
125  fclose($f_in);
126  }
127 
137  public function _startElement($parser, $name, $attrs)
138  {
139  if (strstr($name, " ")) {
140  list($ns, $tag) = explode(" ", $name);
141  if ($ns == "") {
142  $this->success = false;
143  }
144  } else {
145  $ns = "";
146  $tag = $name;
147  }
148 
149  if ($this->depth == 1) {
150  $this->mode = $tag;
151  }
152 
153  if ($this->depth == 3) {
154  $prop = array("name" => $tag);
155  $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
156  if ($this->mode == "set") {
157  $this->current["val"] = ""; // default set val
158  }
159  }
160 
161  if ($this->depth >= 4) {
162  $this->current["val"] .= "<$tag";
163  foreach ($attr as $key => $val) {
164  $this->current["val"] .= ' ' . $key . '="' . str_replace('"', '&quot;', $val) . '"';
165  }
166  $this->current["val"] .= ">";
167  }
168 
169 
170 
171  $this->depth++;
172  }
173 
182  public function _endElement($parser, $name)
183  {
184  if (strstr($name, " ")) {
185  list($ns, $tag) = explode(" ", $name);
186  if ($ns == "") {
187  $this->success = false;
188  }
189  } else {
190  $ns = "";
191  $tag = $name;
192  }
193 
194  $this->depth--;
195 
196  if ($this->depth >= 4) {
197  $this->current["val"] .= "</$tag>";
198  }
199 
200  if ($this->depth == 3) {
201  if (isset($this->current)) {
202  $this->props[] = $this->current;
203  unset($this->current);
204  }
205  }
206  }
207 
216  public function _data($parser, $data)
217  {
218  if (isset($this->current)) {
219  $this->current["val"] .= $data;
220  }
221  }
222 }
__construct($path)
constructor
if($format !==null) $name
Definition: metadata.php:146
_endElement($parser, $name)
tag end handler
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
_data($parser, $data)
input data handler
$key
Definition: croninfo.php:18
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
_startElement($parser, $name, $attrs)
tag start handler