[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /** 3 * $Horde: framework/XML_WBXML/WBXML/ContentHandler.php,v 1.15 2006/01/01 21:10:25 jan Exp $ 4 * 5 * Copyright 2003-2006 Anthony Mills <amills@pyramid6.com> 6 * 7 * See the enclosed file COPYING for license information (LGPL). If you did 8 * not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 9 * 10 * From Binary XML Content Format Specification Version 1.3, 25 July 2001 11 * found at http://www.wapforum.org 12 * 13 * @package XML_WBXML 14 */ 15 class XML_WBXML_ContentHandler { 16 17 var $_currentUri; 18 var $_output = ''; 19 20 var $_opaqueHandler; 21 22 /** 23 * Charset. 24 */ 25 var $_charset = 'UTF-8'; 26 27 /** 28 * WBXML Version. 29 * 1, 2, or 3 supported 30 */ 31 var $_wbxmlVersion = 2; 32 33 function XML_WBXML_ContentHandler() 34 { 35 $this->_currentUri = &new XML_WBXML_LifoQueue(); 36 } 37 38 function raiseError($error) 39 { 40 include_once 'PEAR.php'; 41 return PEAR::raiseError($error); 42 } 43 44 function getCharsetStr() 45 { 46 return $this->_charset; 47 } 48 49 function setCharset($cs) 50 { 51 $this->_charset = $cs; 52 } 53 54 function getVersion() 55 { 56 return $this->_wbxmlVersion; 57 } 58 59 function setVersion($v) 60 { 61 $this->_wbxmlVersion = 2; 62 } 63 64 function getOutput() 65 { 66 return $this->_output; 67 } 68 69 function getOutputSize() 70 { 71 return strlen($this->_output); 72 } 73 74 function startElement($uri, $element, $attrs) 75 { 76 $this->_output .= '<' . $element; 77 78 $currentUri = $this->_currentUri->top(); 79 80 if (((!$currentUri) || ($currentUri != $uri)) && $uri) { 81 $this->_output .= ' xmlns="' . $uri . '"'; 82 } 83 84 $this->_currentUri->push($uri); 85 86 foreach ($attrs as $attr) { 87 $this->_output .= ' ' . $attr['attribute'] . '="' . $attr['value'] . '"'; 88 } 89 90 $this->_output .= '>'; 91 } 92 93 function endElement($uri, $element) 94 { 95 $this->_output .= '</' . $element . '>'; 96 97 $this->_currentUri->pop(); 98 } 99 100 function characters($str) 101 { 102 $this->_output .= $str; 103 } 104 105 function opaque($o) 106 { 107 // I can check the first chanracter and see if it is WBXML. 108 if (ord($o[0]) < 10) { 109 // Should decode this, I really need a call back function. 110 } else { 111 $this->_output .= $o; 112 } 113 } 114 115 function setOpaqueHandler($opaqueHandler) 116 { 117 $this->_opaqueHandler = $opaqueHandler; 118 } 119 120 function removeOpaqueHandler() 121 { 122 unset($this->_opaqueHandler); 123 } 124 125 } 126 127 class XML_WBXML_LifoQueue { 128 129 var $_queue = array(); 130 131 function XML_WBXML_LifoQueue() 132 { 133 } 134 135 function push($obj) 136 { 137 $this->_queue[] = $obj; 138 } 139 140 function pop() 141 { 142 if (count($this->_queue)) { 143 return array_pop($this->_queue); 144 } else { 145 return null; 146 } 147 } 148 149 function top() 150 { 151 if ($count = count($this->_queue)) { 152 return $this->_queue[$count - 1]; 153 } else { 154 return null; 155 } 156 } 157 158 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |