ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
_parse_lockinfo Class Reference
+ Collaboration diagram for _parse_lockinfo:

Public Member Functions

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

Data Fields

 $success = false
 
 $locktype = ""
 
 $lockscope = ""
 
 $owner = ""
 
 $collect_owner = false
 

Detailed Description

Definition at line 30 of file _parse_lockinfo.php.

Constructor & Destructor Documentation

◆ __construct()

_parse_lockinfo::__construct (   $path)

constructor

Parameters
stringpath of stream to read public

Definition at line 78 of file _parse_lockinfo.php.

References $path, and array.

79  {
80  // we assume success unless problems occur
81  $this->success = true;
82 
83  // remember if any input was parsed
84  $had_input = false;
85 
86  // open stream
87  $f_in = fopen($path, "r");
88  if (!$f_in) {
89  $this->success = false;
90  return;
91  }
92 
93  // create namespace aware parser
94  $xml_parser = xml_parser_create_ns("UTF-8", " ");
95 
96  // set tag and data handlers
97  xml_set_element_handler(
98  $xml_parser,
99  array(&$this, "_startElement"),
100  array(&$this, "_endElement")
101  );
102  xml_set_character_data_handler(
103  $xml_parser,
104  array(&$this, "_data")
105  );
106 
107  // we want a case sensitive parser
108  xml_parser_set_option(
109  $xml_parser,
110  XML_OPTION_CASE_FOLDING,
111  false
112  );
113 
114  // parse input
115  while ($this->success && !feof($f_in)) {
116  $line = fgets($f_in);
117  if (is_string($line)) {
118  $had_input = true;
119  $this->success &= xml_parse($xml_parser, $line, false);
120  }
121  }
122 
123  // finish parsing
124  if ($had_input) {
125  $this->success &= xml_parse($xml_parser, "", true);
126  }
127 
128  // check if required tags where found
129  $this->success &= !empty($this->locktype);
130  $this->success &= !empty($this->lockscope);
131 
132  // free parser resource
133  xml_parser_free($xml_parser);
134 
135  // close input stream
136  fclose($f_in);
137  }
Create styles array
The data for the language used.

Member Function Documentation

◆ _data()

_parse_lockinfo::_data (   $parser,
  $data 
)

data handler

Parameters
resourceparser
stringdata
Returns
void private

Definition at line 197 of file _parse_lockinfo.php.

References $data.

198  {
199  // only the <owner> tag has data content
200  if ($this->collect_owner) {
201  $this->owner .= $data;
202  }
203  }

◆ _endElement()

_parse_lockinfo::_endElement (   $parser,
  $name 
)

tag end handler

Parameters
resourceparser
stringtag name
Returns
void private

Definition at line 213 of file _parse_lockinfo.php.

References $name, and $tag.

214  {
215  // namespace handling
216  if (strstr($name, " ")) {
217  list($ns, $tag) = explode(" ", $name);
218  } else {
219  $ns = "";
220  $tag = $name;
221  }
222 
223  // <owner> finished?
224  if (($ns == "DAV:") && ($tag == "owner")) {
225  $this->collect_owner = false;
226  }
227 
228  // within <owner> we have to collect everything
229  if ($this->collect_owner) {
230  $ns_short = "";
231  $ns_attr = "";
232  if ($ns) {
233  if ($ns == "DAV:") {
234  $ns_short = "D:";
235  } else {
236  $ns_attr = " xmlns='$ns'";
237  }
238  }
239  $this->owner .= "</$ns_short$tag$ns_attr>";
240  }
241  }
if($format !==null) $name
Definition: metadata.php:146
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ _startElement()

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

tag start handler

Parameters
resourceparser
stringtag name
arraytag attributes
Returns
void private

Definition at line 149 of file _parse_lockinfo.php.

References $name, and $tag.

150  {
151  // namespace handling
152  if (strstr($name, " ")) {
153  list($ns, $tag) = explode(" ", $name);
154  } else {
155  $ns = "";
156  $tag = $name;
157  }
158 
159 
160  if ($this->collect_owner) {
161  // everything within the <owner> tag needs to be collected
162  $ns_short = "";
163  $ns_attr = "";
164  if ($ns) {
165  if ($ns == "DAV:") {
166  $ns_short = "D:";
167  } else {
168  $ns_attr = " xmlns='$ns'";
169  }
170  }
171  $this->owner .= "<$ns_short$tag$ns_attr>";
172  } elseif ($ns == "DAV:") {
173  // parse only the essential tags
174  switch ($tag) {
175  case "write":
176  $this->locktype = $tag;
177  break;
178  case "exclusive":
179  case "shared":
180  $this->lockscope = $tag;
181  break;
182  case "owner":
183  $this->collect_owner = true;
184  break;
185  }
186  }
187  }
if($format !==null) $name
Definition: metadata.php:146
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

Field Documentation

◆ $collect_owner

_parse_lockinfo::$collect_owner = false

Definition at line 70 of file _parse_lockinfo.php.

◆ $lockscope

_parse_lockinfo::$lockscope = ""

Definition at line 54 of file _parse_lockinfo.php.

◆ $locktype

_parse_lockinfo::$locktype = ""

Definition at line 46 of file _parse_lockinfo.php.

◆ $owner

_parse_lockinfo::$owner = ""

Definition at line 62 of file _parse_lockinfo.php.

◆ $success

_parse_lockinfo::$success = false

Definition at line 38 of file _parse_lockinfo.php.


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