Exemple #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->openSearchItemsPerPage->extensionAttributes;
     $extensionAttributes['foo1'] = array('name' => 'foo1', 'value' => 'bar');
     $extensionAttributes['foo2'] = array('name' => 'foo2', 'value' => 'rab');
     $this->openSearchItemsPerPage->extensionAttributes = $extensionAttributes;
     $this->assertEquals('bar', $this->openSearchItemsPerPage->extensionAttributes['foo1']['value']);
     $this->assertEquals('rab', $this->openSearchItemsPerPage->extensionAttributes['foo2']['value']);
     $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML();
     $newOpenSearchItemsPerPage = new Extension\OpenSearchItemsPerPage();
     $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml);
     $this->assertEquals('bar', $newOpenSearchItemsPerPage->extensionAttributes['foo1']['value']);
     $this->assertEquals('rab', $newOpenSearchItemsPerPage->extensionAttributes['foo2']['value']);
 }
Exemple #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;
     }
 }