ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
_parse_propfind Class Reference
+ Collaboration diagram for _parse_propfind:

Public Member Functions

 _parse_propfind ($path)
 constructor More...
 
 _startElement ($parser, $name, $attrs)
 start tag handler More...
 
 _endElement ($parser, $name)
 end tag handler More...
 

Data Fields

 $success = false
 
 $props = false
 
 $depth = 0
 

Detailed Description

Definition at line 30 of file _parse_propfind.php.

Member Function Documentation

◆ _endElement()

_parse_propfind::_endElement (   $parser,
  $name 
)

end tag handler

@access private

Parameters
resourceparser
stringtag name

Definition at line 170 of file _parse_propfind.php.

171 {
172 // here we only need to decrement the depth count
173 $this->depth--;
174 }

◆ _parse_propfind()

_parse_propfind::_parse_propfind (   $path)

constructor

@access public

Definition at line 62 of file _parse_propfind.php.

63 {
64 // success state flag
65 $this->success = true;
66
67 // property storage array
68 $this->props = array();
69
70 // internal tag depth counter
71 $this->depth = 0;
72
73 // remember if any input was parsed
74 $had_input = false;
75
76 // open input stream
77 $f_in = fopen($path, "r");
78 if (!$f_in) {
79 $this->success = false;
80 return;
81 }
82
83 // create XML parser
84 $xml_parser = xml_parser_create_ns("UTF-8", " ");
85
86 // set tag and data handlers
87 xml_set_element_handler($xml_parser,
88 array(&$this, "_startElement"),
89 array(&$this, "_endElement"));
90
91 // we want a case sensitive parser
92 xml_parser_set_option($xml_parser,
93 XML_OPTION_CASE_FOLDING, false);
94
95
96 // parse input
97 while($this->success && !feof($f_in)) {
98 $line = fgets($f_in);
99 if (is_string($line)) {
100 $had_input = true;
101 $this->success &= xml_parse($xml_parser, $line, false);
102 }
103 }
104
105 // finish parsing
106 if($had_input) {
107 $this->success &= xml_parse($xml_parser, "", true);
108 }
109
110 // free parser
111 xml_parser_free($xml_parser);
112
113 // close input stream
114 fclose($f_in);
115
116 // if no input was parsed it was a request
117 if(!count($this->props)) $this->props = "all"; // default
118 }
$path
Definition: index.php:22

References $path.

◆ _startElement()

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

start tag handler

@access private

Parameters
resourceparser
stringtag name
arraytag attributes

Definition at line 129 of file _parse_propfind.php.

130 {
131 // name space handling
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 // special tags at level 1: <allprop> and <propname>
142 if ($this->depth == 1) {
143 if ($tag == "allprop")
144 $this->props = "all";
145
146 if ($tag == "propname")
147 $this->props = "names";
148 }
149
150 // requested properties are found at level 2
151 if ($this->depth == 2) {
152 $prop = array("name" => $tag);
153 if ($ns)
154 $prop["xmlns"] = $ns;
155 $this->props[] = $prop;
156 }
157
158 // increment depth count
159 $this->depth++;
160 }

Field Documentation

◆ $depth

_parse_propfind::$depth = 0

Definition at line 54 of file _parse_propfind.php.

◆ $props

_parse_propfind::$props = false

Definition at line 46 of file _parse_propfind.php.

◆ $success

_parse_propfind::$success = false

Definition at line 38 of file _parse_propfind.php.


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