Esempio n. 1
0
 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 {
     $element = parent::getDOM($doc, $majorVersion, $minorVersion);
     if ($this->_totalResults != null) {
         $element->appendChild($this->_totalResults->getDOM($element->ownerDocument));
     }
     if ($this->_startIndex != null) {
         $element->appendChild($this->_startIndex->getDOM($element->ownerDocument));
     }
     if ($this->_itemsPerPage != null) {
         $element->appendChild($this->_itemsPerPage->getDOM($element->ownerDocument));
     }
     // ETags are special. We only support them in protocol >= 2.X.
     // This will be duplicated by the HTTP ETag header.
     if ($majorVersion >= 2) {
         if ($this->_etag != null) {
             $element->setAttributeNS($this->lookupNamespace('gd'), 'gd:etag', $this->_etag->getFieldValue());
         }
     }
     return $element;
 }
 public function testExtensionAttributes()
 {
     $extensionAttributes = $this->openSearchStartIndex->extensionAttributes;
     $extensionAttributes['foo1'] = array('name' => 'foo1', 'value' => 'bar');
     $extensionAttributes['foo2'] = array('name' => 'foo2', 'value' => 'rab');
     $this->openSearchStartIndex->extensionAttributes = $extensionAttributes;
     $this->assertEquals('bar', $this->openSearchStartIndex->extensionAttributes['foo1']['value']);
     $this->assertEquals('rab', $this->openSearchStartIndex->extensionAttributes['foo2']['value']);
     $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML();
     $newOpenSearchStartIndex = new Extension\OpenSearchStartIndex();
     $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml);
     $this->assertEquals('bar', $newOpenSearchStartIndex->extensionAttributes['foo1']['value']);
     $this->assertEquals('rab', $newOpenSearchStartIndex->extensionAttributes['foo2']['value']);
 }
Esempio n. 3
0
 /**
  * Creates individual Entry objects of the appropriate type and
  * stores them in the $_entry array based upon DOM data.
  *
  * @param DOMNode $child The DOMNode to process
  */
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('openSearch') . ':' . 'totalResults':
             $totalResults = new Extension\OpenSearchTotalResults();
             $totalResults->transferFromDOM($child);
             $this->_totalResults = $totalResults;
             break;
         case $this->lookupNamespace('openSearch') . ':' . 'startIndex':
             $startIndex = new Extension\OpenSearchStartIndex();
             $startIndex->transferFromDOM($child);
             $this->_startIndex = $startIndex;
             break;
         case $this->lookupNamespace('openSearch') . ':' . 'itemsPerPage':
             $itemsPerPage = new Extension\OpenSearchItemsPerPage();
             $itemsPerPage->transferFromDOM($child);
             $this->_itemsPerPage = $itemsPerPage;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }