Horde_Xml_Wbxml_Decoder::getAttributes PHP Method

getAttributes() public method

public getAttributes ( $input )
    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();
    }