| [ PHPXref.com ] | [ Generated: Sun Jul 20 17:06:29 2008 ] | [ CRM-CTT 3.4.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 // helper class for parsing LOCK request bodies 4 class _parse_lockinfo 5 { 6 var $owner = ""; 7 var $collect_owner = false; 8 9 function _parse_lockinfo($path) 10 { 11 $this->success = true; 12 $had_input = false; 13 14 $xml_parser = xml_parser_create_ns("UTF-8", " "); 15 xml_set_element_handler($xml_parser, 16 array(&$this, "_startElement"), 17 array(&$this, "_endElement")); 18 xml_set_character_data_handler($xml_parser, 19 array(&$this, "_data")); 20 xml_parser_set_option($xml_parser, 21 XML_OPTION_CASE_FOLDING, false); 22 23 $f_in = fopen($path, "r"); 24 while($this->success && !feof($f_in)) { 25 $line = fgets($f_in); 26 if (is_string($line)) { 27 $line = trim($line); 28 if($line == "") continue; 29 $had_input = true; 30 $this->success &= xml_parse($xml_parser, $line, false); 31 } 32 } 33 if($had_input) { 34 $this->success &= xml_parse($xml_parser, "", true); 35 } 36 fclose($f_in); 37 38 xml_parser_free($xml_parser); 39 } 40 41 42 function _startElement($parser, 43 $name, 44 $attrs) { 45 if (strstr($name, " ")) { 46 list($ns, $tag) = explode(" ", $name); 47 } else { 48 $ns = ""; 49 $tag = $name; 50 } 51 52 if ($this->collect_owner) { 53 $ns_short = ""; 54 $ns_attr = ""; 55 if ($ns) { 56 if ($ns == "DAV:") { 57 $ns_short = "D:"; 58 } else { 59 $ns_attr = " xmlns='$ns'"; 60 } 61 } 62 $this->owner .= "<$ns_short$tag$ns_attr>"; 63 } else if ($ns == "DAV:") { 64 switch ($tag) { 65 case "write": 66 $this->locktype = $tag; 67 break; 68 case "exclusive": 69 case "shared": 70 $this->lockscope = $tag; 71 break; 72 case "owner": 73 $this->collect_owner = true; 74 break; 75 } 76 } 77 } 78 79 function _data($parser, 80 $data) { 81 if ($this->collect_owner) { 82 $this->owner .= $data; 83 } 84 } 85 86 function _endElement($parser, $name) { 87 if (strstr($name, " ")) { 88 list($ns, $tag) = explode(" ", $name); 89 } else { 90 $ns = ""; 91 $tag = $name; 92 } 93 if (($ns == "DAV:") && ($tag == "owner")) { 94 $this->collect_owner = false; 95 } 96 if ($this->collect_owner) { 97 $ns_short = ""; 98 $ns_attr = ""; 99 if ($ns) { 100 if ($ns == "DAV:") { 101 $ns_short = "D:"; 102 } else { 103 $ns_attr = " xmlns='$ns'"; 104 } 105 } 106 $this->owner .= "</$ns_short$tag$ns_attr>"; 107 } 108 } 109 } 110 111 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |