public function endElement($uri, $name) { if ($this->_subParser == null) { $this->_output .= chr(Horde_Xml_Wbxml::GLOBAL_TOKEN_END); } else { $this->_subParser->endElement($uri, $name); $this->_subParserStack--; if ($this->_subParserStack == 0) { $this->_output .= chr(Horde_Xml_Wbxml::GLOBAL_TOKEN_OPAQUE); Horde_Xml_Wbxml::intToMBUInt32($this->_output, strlen($this->_subParser->getOutput())); $this->_output .= $this->_subParser->getOutput(); $this->_subParser = null; } } }
/** * Encoding Multi-byte Integers from Section 5.1 */ public static function intToMBUInt32(&$out, $i) { if ($i > 268435455) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $bytes3 = 128 | Horde_Xml_Wbxml::getBits(3, $i); $bytes4 = 128 | Horde_Xml_Wbxml::getBits(4, $i); $out .= chr($bytes4) . chr($bytes3) . chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 2097151) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $bytes3 = 128 | Horde_Xml_Wbxml::getBits(3, $i); $out .= chr($bytes3) . chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 16383) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $bytes2 = 128 | Horde_Xml_Wbxml::getBits(2, $i); $out .= chr($bytes2) . chr($bytes1) . chr($bytes0); } elseif ($i > 127) { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $bytes1 = 128 | Horde_Xml_Wbxml::getBits(1, $i); $out .= chr($bytes1) . chr($bytes0); } else { $bytes0 = 0 | Horde_Xml_Wbxml::getBits(0, $i); $out .= chr($bytes0); } }
public function getAttributes($input) { $this->startGetAttributes(); $hasMoreAttributes = true; $attrs = array(); $attr = null; $value = null; $token = null; while ($hasMoreAttributes) { $token = $this->getByte($input); switch ($token) { // Attribute specified. case Horde_Xml_Wbxml::GLOBAL_TOKEN_LITERAL: // Section 5.8.4.5 if (isset($attr)) { $attrs[] = array('attribute' => $attr, 'value' => $value); } $attr = $this->getStringTableEntry(Horde_Xml_Wbxml::MBUInt32ToInt($input, $this->_strpos)); break; // Value specified. // Value specified. case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_I_0: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_I_1: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_I_2: // Section 5.8.4.2 $value .= $this->termstr($input); break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_T_0: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_T_1: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_T_2: // Section 5.8.4.2 $value .= $this->getStringTableEntry(Horde_Xml_Wbxml::MBUInt32ToInt($input, $this->_strpos)); break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_0: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_1: case Horde_Xml_Wbxml::GLOBAL_TOKEN_EXT_2: // Section 5.8.4.2 $value .= $input[$this->_strpos++]; break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_ENTITY: // Section 5.8.4.3 $value .= $this->entity(Horde_Xml_Wbxml::MBUInt32ToInt($input, $this->_strpos)); break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_STR_I: // Section 5.8.4.1 $value .= $this->termstr($input); break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_STR_T: // Section 5.8.4.1 $value .= $this->getStringTableEntry(Horde_Xml_Wbxml::MBUInt32ToInt($input, $this->_strpos)); break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_OPAQUE: // Section 5.8.4.6 $size = Horde_Xml_Wbxml::MBUInt32ToInt($input, $this->_strpos); $b = substr($input, $this->_strpos, $this->_strpos + $size); $this->_strpos += $size; $value .= $b; break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_END: // Section 5.8.4.7.1 $hasMoreAttributes = false; if (isset($attr)) { $attrs[] = array('attribute' => $attr, 'value' => $value); } break; case Horde_Xml_Wbxml::GLOBAL_TOKEN_SWITCH_PAGE: // Section 5.8.4.7.2 $codePage = $this->getByte($input); if (!$this->_prevAttributeDTD) { $this->_prevAttributeDTD = $this->_attributeDTD; } $this->switchAttributeCodePage($codePage); break; default: if ($token > 128) { if (isset($attr)) { $attrs[] = array('attribute' => $attr, 'value' => $value); } $attr = $this->_attributeDTD->toAttribute($token); } else { // Value. $value .= $this->_attributeDTD->toAttribute($token); } break; } } if (!$this->_prevAttributeDTD) { $this->_attributeDTD = $this->_prevAttributeDTD; $this->_prevAttributeDTD = false; } $this->stopGetAttributes(); }