[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/ -> Entry.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_MediaEntry
  31   */
  32  require_once 'Zend/Gdata/App/MediaEntry.php';
  33  
  34  /**
  35   * Represents the Gdata flavor of an Atom entry
  36   *
  37   * @category   Zend
  38   * @package    Zend_Gdata
  39   * @subpackage Gdata
  40   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  41   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  42   */
  43  class Zend_Gdata_Entry extends Zend_Gdata_App_MediaEntry
  44  {
  45  
  46      protected $_entryClassName = 'Zend_Gdata_Entry';
  47  
  48      public function __construct($element = null)
  49      {
  50          $this->registerAllNamespaces(Zend_Gdata::$namespaces);
  51          parent::__construct($element);
  52      }
  53  
  54      public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  55      {
  56          $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  57          // ETags are special. We only support them in protocol >= 2.X.
  58          // This will be duplicated by the HTTP ETag header.
  59          if ($majorVersion >= 2) {
  60              if ($this->_etag != null) {
  61                  $element->setAttributeNS($this->lookupNamespace('gd'),
  62                                           'gd:etag',
  63                                           $this->_etag);
  64              }
  65          }
  66          return $element;
  67      }
  68  
  69      protected function takeChildFromDOM($child)
  70      {
  71          $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  72          switch ($absoluteNodeName) {
  73          case $this->lookupNamespace('atom') . ':' . 'content':
  74              $content = new Zend_Gdata_App_Extension_Content();
  75              $content->transferFromDOM($child);
  76              $this->_content = $content;
  77              break;
  78          case $this->lookupNamespace('atom') . ':' . 'published':
  79              $published = new Zend_Gdata_App_Extension_Published();
  80              $published->transferFromDOM($child);
  81              $this->_published = $published;
  82              break;
  83          case $this->lookupNamespace('atom') . ':' . 'source':
  84              $source = new Zend_Gdata_App_Extension_Source();
  85              $source->transferFromDOM($child);
  86              $this->_source = $source;
  87              break;
  88          case $this->lookupNamespace('atom') . ':' . 'summary':
  89              $summary = new Zend_Gdata_App_Extension_Summary();
  90              $summary->transferFromDOM($child);
  91              $this->_summary = $summary;
  92              break;
  93          case $this->lookupNamespace('app') . ':' . 'control':
  94              $control = new Zend_Gdata_App_Extension_Control();
  95              $control->transferFromDOM($child);
  96              $this->_control = $control;
  97              break;
  98          default:
  99              parent::takeChildFromDOM($child);
 100              break;
 101          }
 102      }
 103  
 104      /**
 105       * Given a DOMNode representing an attribute, tries to map the data into
 106       * instance members.  If no mapping is defined, the name and value are
 107       * stored in an array.
 108       *
 109       * @param DOMNode $attribute The DOMNode attribute needed to be handled
 110       */
 111      protected function takeAttributeFromDOM($attribute)
 112      {
 113          switch ($attribute->localName) {
 114          case 'etag':
 115              // ETags are special, since they can be conveyed by either the
 116              // HTTP ETag header or as an XML attribute.
 117              $etag = $attribute->nodeValue;
 118              if ($this->_etag === null) {
 119                  $this->_etag = $etag;
 120              }
 121              elseif ($this->_etag != $etag) {
 122                  require_once('Zend/Gdata/App/IOException.php');
 123                  throw new Zend_Gdata_App_IOException("ETag mismatch");
 124              }
 125              break;
 126          default:
 127              parent::takeAttributeFromDOM($attribute);
 128              break;
 129          }
 130      }
 131  
 132  }


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