[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * $Horde: framework/XML_WBXML/WBXML/ContentHandler.php,v 1.9.10.7 2006/05/01 12:05:15 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 $this->_output .= $o; 108 } 109 110 function setOpaqueHandler($opaqueHandler) 111 { 112 $this->_opaqueHandler = $opaqueHandler; 113 } 114 115 function removeOpaqueHandler() 116 { 117 unset($this->_opaqueHandler); 118 } 119 120 function createSubHandler() 121 { 122 $name = get_class($this); // clone current class 123 $sh = &new $name(); 124 $sh->setCharset($this->getCharsetStr()); 125 $sh->setVersion($this->getVersion()); 126 return $sh; 127 } 128 129 } 130 131 class XML_WBXML_LifoQueue { 132 133 var $_queue = array(); 134 135 function XML_WBXML_LifoQueue() 136 { 137 } 138 139 function push($obj) 140 { 141 $this->_queue[] = $obj; 142 } 143 144 function pop() 145 { 146 if (count($this->_queue)) { 147 return array_pop($this->_queue); 148 } else { 149 return null; 150 } 151 } 152 153 function top() 154 { 155 if ($count = count($this->_queue)) { 156 return $this->_queue[$count - 1]; 157 } else { 158 return null; 159 } 160 } 161 162 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |