ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
_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($xml_parser,
98  array(&$this, "_startElement"),
99  array(&$this, "_endElement"));
100  xml_set_character_data_handler($xml_parser,
101  array(&$this, "_data"));
102 
103  // we want a case sensitive parser
104  xml_parser_set_option($xml_parser,
105  XML_OPTION_CASE_FOLDING, false);
106 
107  // parse input
108  while($this->success && !feof($f_in)) {
109  $line = fgets($f_in);
110  if (is_string($line)) {
111  $had_input = true;
112  $this->success &= xml_parse($xml_parser, $line, false);
113  }
114  }
115 
116  // finish parsing
117  if($had_input) {
118  $this->success &= xml_parse($xml_parser, "", true);
119  }
120 
121  // check if required tags where found
122  $this->success &= !empty($this->locktype);
123  $this->success &= !empty($this->lockscope);
124 
125  // free parser resource
126  xml_parser_free($xml_parser);
127 
128  // close input stream
129  fclose($f_in);
130  }
$path
Definition: aliased.php:25
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 190 of file _parse_lockinfo.php.

References $data.

191  {
192  // only the <owner> tag has data content
193  if ($this->collect_owner) {
194  $this->owner .= $data;
195  }
196  }

◆ _endElement()

_parse_lockinfo::_endElement (   $parser,
  $name 
)

tag end handler

Parameters
resourceparser
stringtag name
Returns
void private

Definition at line 206 of file _parse_lockinfo.php.

207  {
208  // namespace handling
209  if (strstr($name, " ")) {
210  list($ns, $tag) = explode(" ", $name);
211  } else {
212  $ns = "";
213  $tag = $name;
214  }
215 
216  // <owner> finished?
217  if (($ns == "DAV:") && ($tag == "owner")) {
218  $this->collect_owner = false;
219  }
220 
221  // within <owner> we have to collect everything
222  if ($this->collect_owner) {
223  $ns_short = "";
224  $ns_attr = "";
225  if ($ns) {
226  if ($ns == "DAV:") {
227  $ns_short = "D:";
228  } else {
229  $ns_attr = " xmlns='$ns'";
230  }
231  }
232  $this->owner .= "</$ns_short$tag$ns_attr>";
233  }
234  }

◆ _startElement()

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

tag start handler

Parameters
resourceparser
stringtag name
arraytag attributes
Returns
void private

Definition at line 142 of file _parse_lockinfo.php.

143  {
144  // namespace handling
145  if (strstr($name, " ")) {
146  list($ns, $tag) = explode(" ", $name);
147  } else {
148  $ns = "";
149  $tag = $name;
150  }
151 
152 
153  if ($this->collect_owner) {
154  // everything within the <owner> tag needs to be collected
155  $ns_short = "";
156  $ns_attr = "";
157  if ($ns) {
158  if ($ns == "DAV:") {
159  $ns_short = "D:";
160  } else {
161  $ns_attr = " xmlns='$ns'";
162  }
163  }
164  $this->owner .= "<$ns_short$tag$ns_attr>";
165  } else if ($ns == "DAV:") {
166  // parse only the essential tags
167  switch ($tag) {
168  case "write":
169  $this->locktype = $tag;
170  break;
171  case "exclusive":
172  case "shared":
173  $this->lockscope = $tag;
174  break;
175  case "owner":
176  $this->collect_owner = true;
177  break;
178  }
179  }
180  }

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: