Horde_ActiveSync_Wbxml_Encoder::endTag PHP Method

endTag() public method

Output the end tag
public endTag ( )
    public function endTag()
    {
        $stackelem = array_pop($this->_stack);
        if ($stackelem['sent']) {
            $this->_endTag();
            if (count($this->_stack) == 0 && $this->multipart) {
                $this->_stream->rewind();
                $len = $this->_stream->length();
                $totalCount = count($this->_parts) + 1;
                $header = pack('i', $totalCount);
                $offset = $totalCount * 2 * 4 + 4;
                $header .= pack('ii', $offset, $len);
                $offset += $len;
                // start/length of parts
                foreach ($this->_parts as $bp) {
                    if (is_resource($bp)) {
                        rewind($bp);
                        $stat = fstat($bp);
                        $len = $stat['size'];
                    } else {
                        $len = strlen(bin2hex($bp)) / 2;
                    }
                    $header .= pack('ii', $offset, $len);
                    $offset += $len;
                }
                // Output
                $this->_tempStream->add($header);
                $this->_stream->rewind();
                $this->_tempStream->add($this->_stream);
                foreach ($this->_parts as $bp) {
                    if (is_resource($bp)) {
                        rewind($bp);
                        $this->_tempStream->add($bp);
                        fclose($bp);
                    } else {
                        $this->_tempStream->add($bp);
                    }
                }
                $this->_stream->close();
                $this->_stream = $this->_tempStream;
            }
        }
    }

Usage Example

Example #1
0
 /**
  * Send WBXML to indicate provisioning is required.
  *
  * @param string $requestType  The type of request we are handling.
  * @param integer $status      The reason we need to provision.
  */
 protected function _requireProvisionWbxml($requestType, $status)
 {
     $this->_encoder->startWBXML();
     $this->_encoder->startTag($requestType);
     $this->_encoder->startTag(Horde_ActiveSync::SYNC_STATUS);
     $this->_encoder->content($status);
     $this->_encoder->endTag();
     $this->_encoder->endTag();
 }
All Usage Examples Of Horde_ActiveSync_Wbxml_Encoder::endTag