[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/ -> Feed.php (source)

   1  <?php
   2  
   3  /**
   4   * Zend Framework
   5   *
   6   * LICENSE
   7   *
   8   * This source file is subject to the new BSD license that is bundled
   9   * with this package in the file LICENSE.txt.
  10   * It is also available through the world-wide-web at this URL:
  11   * http://framework.zend.com/license/new-bsd
  12   * If you did not receive a copy of the license and are unable to
  13   * obtain it through the world-wide-web, please send an email
  14   * to [email protected] so we can send you a copy immediately.
  15   *
  16   * @category   Zend
  17   * @package    Zend_Gdata
  18   * @subpackage Gdata
  19   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  20   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  21   * @version    $Id$
  22   */
  23  
  24  /**
  25   * @see Zend_Gdata
  26   */
  27  require_once 'Zend/Gdata.php';
  28  
  29  /**
  30   * @see Zend_Gdata_App_Feed
  31   */
  32  require_once 'Zend/Gdata/App/Feed.php';
  33  
  34  /**
  35   * @see Zend_Gdata_Entry
  36   */
  37  require_once 'Zend/Gdata/Entry.php';
  38  
  39  /**
  40   * @see Zend_Gdata_Extension_OpenSearchTotalResults
  41   */
  42  require_once 'Zend/Gdata/Extension/OpenSearchTotalResults.php';
  43  
  44  /**
  45   * @see Zend_Gdata_Extension_OpenSearchStartIndex
  46   */
  47  require_once 'Zend/Gdata/Extension/OpenSearchStartIndex.php';
  48  
  49  /**
  50   * @see Zend_Gdata_Extension_OpenSearchItemsPerPage
  51   */
  52  require_once 'Zend/Gdata/Extension/OpenSearchItemsPerPage.php';
  53  
  54  /**
  55   * The Gdata flavor of an Atom Feed
  56   *
  57   * @category   Zend
  58   * @package    Zend_Gdata
  59   * @subpackage Gdata
  60   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  61   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  62   */
  63  class Zend_Gdata_Feed extends Zend_Gdata_App_Feed
  64  {
  65  
  66      /**
  67       * The classname for individual feed elements.
  68       *
  69       * @var string
  70       */
  71      protected $_entryClassName = 'Zend_Gdata_Entry';
  72  
  73      /**
  74       * The openSearch:totalResults element
  75       *
  76       * @var Zend_Gdata_Extension_OpenSearchTotalResults|null
  77       */
  78      protected $_totalResults = null;
  79  
  80      /**
  81       * The openSearch:startIndex element
  82       *
  83       * @var Zend_Gdata_Extension_OpenSearchStartIndex|null
  84       */
  85      protected $_startIndex = null;
  86  
  87      /**
  88       * The openSearch:itemsPerPage element
  89       *
  90       * @var Zend_Gdata_Extension_OpenSearchItemsPerPage|null
  91       */
  92      protected $_itemsPerPage = null;
  93  
  94      public function __construct($element = null)
  95      {
  96          $this->registerAllNamespaces(Zend_Gdata::$namespaces);
  97          parent::__construct($element);
  98      }
  99  
 100      public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 101      {
 102          $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 103          if ($this->_totalResults != null) {
 104              $element->appendChild($this->_totalResults->getDOM($element->ownerDocument));
 105          }
 106          if ($this->_startIndex != null) {
 107              $element->appendChild($this->_startIndex->getDOM($element->ownerDocument));
 108          }
 109          if ($this->_itemsPerPage != null) {
 110              $element->appendChild($this->_itemsPerPage->getDOM($element->ownerDocument));
 111          }
 112  
 113          // ETags are special. We only support them in protocol >= 2.X.
 114          // This will be duplicated by the HTTP ETag header.
 115          if ($majorVersion >= 2) {
 116              if ($this->_etag != null) {
 117                  $element->setAttributeNS($this->lookupNamespace('gd'),
 118                                           'gd:etag',
 119                                           $this->_etag);
 120              }
 121          }
 122  
 123          return $element;
 124      }
 125  
 126      /**
 127       * Creates individual Entry objects of the appropriate type and
 128       * stores them in the $_entry array based upon DOM data.
 129       *
 130       * @param DOMNode $child The DOMNode to process
 131       */
 132      protected function takeChildFromDOM($child)
 133      {
 134          $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
 135          switch ($absoluteNodeName) {
 136          case $this->lookupNamespace('openSearch') . ':' . 'totalResults':
 137              $totalResults = new Zend_Gdata_Extension_OpenSearchTotalResults();
 138              $totalResults->transferFromDOM($child);
 139              $this->_totalResults = $totalResults;
 140              break;
 141          case $this->lookupNamespace('openSearch') . ':' . 'startIndex':
 142              $startIndex = new Zend_Gdata_Extension_OpenSearchStartIndex();
 143              $startIndex->transferFromDOM($child);
 144              $this->_startIndex = $startIndex;
 145              break;
 146          case $this->lookupNamespace('openSearch') . ':' . 'itemsPerPage':
 147              $itemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage();
 148              $itemsPerPage->transferFromDOM($child);
 149              $this->_itemsPerPage = $itemsPerPage;
 150              break;
 151          default:
 152              parent::takeChildFromDOM($child);
 153              break;
 154          }
 155      }
 156  
 157      /**
 158       * Given a DOMNode representing an attribute, tries to map the data into
 159       * instance members.  If no mapping is defined, the name and value are
 160       * stored in an array.
 161       *
 162       * @param DOMNode $attribute The DOMNode attribute needed to be handled
 163       */
 164      protected function takeAttributeFromDOM($attribute)
 165      {
 166          switch ($attribute->localName) {
 167          case 'etag':
 168              // ETags are special, since they can be conveyed by either the
 169              // HTTP ETag header or as an XML attribute.
 170              $etag = $attribute->nodeValue;
 171              if ($this->_etag === null) {
 172                  $this->_etag = $etag;
 173              }
 174              elseif ($this->_etag != $etag) {
 175                  require_once('Zend/Gdata/App/IOException.php');
 176                  throw new Zend_Gdata_App_IOException("ETag mismatch");
 177              }
 178              break;
 179          default:
 180              parent::takeAttributeFromDOM($attribute);
 181              break;
 182          }
 183      }
 184  
 185      /**
 186       *  Set the value of the totalResults property.
 187       *
 188       * @param Zend_Gdata_Extension_OpenSearchTotalResults|null $value The
 189       *        value of the totalResults property. Use null to unset.
 190       * @return Zend_Gdata_Feed Provides a fluent interface.
 191       */
 192      function setTotalResults($value) {
 193          $this->_totalResults = $value;
 194          return $this;
 195      }
 196  
 197      /**
 198       * Get the value of the totalResults property.
 199       *
 200       * @return Zend_Gdata_Extension_OpenSearchTotalResults|null The value of
 201       *         the totalResults property, or null if unset.
 202       */
 203      function getTotalResults() {
 204          return $this->_totalResults;
 205      }
 206  
 207      /**
 208       * Set the start index property for feed paging.
 209       *
 210       * @param Zend_Gdata_Extension_OpenSearchStartIndex|null $value The value
 211       *        for the startIndex property. Use null to unset.
 212       * @return Zend_Gdata_Feed Provides a fluent interface.
 213       */
 214      function setStartIndex($value) {
 215          $this->_startIndex = $value;
 216          return $this;
 217      }
 218  
 219      /**
 220       * Get the value of the startIndex property.
 221       *
 222       * @return Zend_Gdata_Extension_OpenSearchStartIndex|null The value of the
 223       *         startIndex property, or null if unset.
 224       */
 225      function getStartIndex() {
 226          return $this->_startIndex;
 227      }
 228  
 229      /**
 230       * Set the itemsPerPage property.
 231       *
 232       * @param Zend_Gdata_Extension_OpenSearchItemsPerPage|null $value The
 233       *        value for the itemsPerPage property. Use nul to unset.
 234       * @return Zend_Gdata_Feed Provides a fluent interface.
 235       */
 236      function setItemsPerPage($value) {
 237          $this->_itemsPerPage = $value;
 238          return $this;
 239      }
 240  
 241      /**
 242       * Get the value of the itemsPerPage property.
 243       *
 244       * @return Zend_Gdata_Extension_OpenSearchItemsPerPage|null The value of
 245       *         the itemsPerPage property, or null if unset.
 246       */
 247      function getItemsPerPage() {
 248          return $this->_itemsPerPage;
 249      }
 250  
 251  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1