3 // +----------------------------------------------------------------------+
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 // +----------------------------------------------------------------------+
20 // $Id: _parse_propfind.php,v 1.2 2004/01/05 12:33:22 hholzgra Exp $
24 * helper class for parsing PROPFIND request bodies
26 * @package HTTP_WebDAV_Server
27 * @author Hartmut Holzgraefe <hholzgra@php.net>
41 * found properties are collected here
49 * internal tag nesting depth counter
62 function _parse_propfind($path)
65 $this->success
= true
;
67 // property storage array
68 $this->props
= array();
70 // internal tag depth counter
73 // remember if any input was parsed
77 $f_in = fopen($path, "r");
79 $this->success
= false
;
84 $xml_parser = xml_parser_create_ns("UTF-8", " ");
86 // set tag and data handlers
87 xml_set_element_handler($xml_parser,
88 array(&$this, "_startElement"),
89 array(&$this, "_endElement"));
91 // we want a case sensitive parser
92 xml_parser_set_option($xml_parser,
93 XML_OPTION_CASE_FOLDING
, false
);
97 while($this->success
&& !feof($f_in)) {
99 if (is_string($line)) {
101 $this->success
&= xml_parse($xml_parser, $line, false
);
107 $this->success
&= xml_parse($xml_parser, "", true
);
111 xml_parser_free($xml_parser);
113 // close input stream
116 // if no input was parsed it was a request
117 if(!count($this->props
)) $this->props
= "all"; // default
125 * @param resource parser
126 * @param string tag name
127 * @param array tag attributes
129 function _startElement($parser, $name, $attrs)
131 // name space handling
132 if (strstr($name, " ")) {
133 list($ns, $tag) = explode(" ", $name);
135 $this->success
= false
;
141 // special tags at level 1: <allprop> and <propname>
142 if ($this->depth
== 1) {
143 if ($tag == "allprop")
144 $this->props
= "all";
146 if ($tag == "propname")
147 $this->props
= "names";
150 // requested properties are found at level 2
151 if ($this->depth
== 2) {
152 $prop = array("name" => $tag);
154 $prop["xmlns"] = $ns;
155 $this->props
[] = $prop;
158 // increment depth count
167 * @param resource parser
168 * @param string tag name
170 function _endElement($parser, $name)
172 // here we only need to decrement the depth count