File indexing completed on 2024-05-12 06:02:40

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Gdata
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata
0026  */
0027 // require_once 'Zend/Gdata.php';
0028 
0029 /**
0030  * @see Zend_Gdata_App_MediaEntry
0031  */
0032 // require_once 'Zend/Gdata/App/MediaEntry.php';
0033 
0034 /**
0035  * Represents the Gdata flavor of an Atom entry
0036  *
0037  * @category   Zend
0038  * @package    Zend_Gdata
0039  * @subpackage Gdata
0040  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0041  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0042  */
0043 class Zend_Gdata_Entry extends Zend_Gdata_App_MediaEntry
0044 {
0045 
0046     protected $_entryClassName = 'Zend_Gdata_Entry';
0047 
0048     public function __construct($element = null)
0049     {
0050         $this->registerAllNamespaces(Zend_Gdata::$namespaces);
0051         parent::__construct($element);
0052     }
0053 
0054     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0055     {
0056         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0057         // ETags are special. We only support them in protocol >= 2.X.
0058         // This will be duplicated by the HTTP ETag header.
0059         if ($majorVersion >= 2) {
0060             if ($this->_etag != null) {
0061                 $element->setAttributeNS($this->lookupNamespace('gd'),
0062                                          'gd:etag',
0063                                          $this->_etag);
0064             }
0065         }
0066         return $element;
0067     }
0068 
0069     protected function takeChildFromDOM($child)
0070     {
0071         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
0072         switch ($absoluteNodeName) {
0073         case $this->lookupNamespace('atom') . ':' . 'content':
0074             $content = new Zend_Gdata_App_Extension_Content();
0075             $content->transferFromDOM($child);
0076             $this->_content = $content;
0077             break;
0078         case $this->lookupNamespace('atom') . ':' . 'published':
0079             $published = new Zend_Gdata_App_Extension_Published();
0080             $published->transferFromDOM($child);
0081             $this->_published = $published;
0082             break;
0083         case $this->lookupNamespace('atom') . ':' . 'source':
0084             $source = new Zend_Gdata_App_Extension_Source();
0085             $source->transferFromDOM($child);
0086             $this->_source = $source;
0087             break;
0088         case $this->lookupNamespace('atom') . ':' . 'summary':
0089             $summary = new Zend_Gdata_App_Extension_Summary();
0090             $summary->transferFromDOM($child);
0091             $this->_summary = $summary;
0092             break;
0093         case $this->lookupNamespace('app') . ':' . 'control':
0094             $control = new Zend_Gdata_App_Extension_Control();
0095             $control->transferFromDOM($child);
0096             $this->_control = $control;
0097             break;
0098         default:
0099             parent::takeChildFromDOM($child);
0100             break;
0101         }
0102     }
0103 
0104     /**
0105      * Given a DOMNode representing an attribute, tries to map the data into
0106      * instance members.  If no mapping is defined, the name and value are
0107      * stored in an array.
0108      *
0109      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0110      */
0111     protected function takeAttributeFromDOM($attribute)
0112     {
0113         switch ($attribute->localName) {
0114         case 'etag':
0115             // ETags are special, since they can be conveyed by either the
0116             // HTTP ETag header or as an XML attribute.
0117             $etag = $attribute->nodeValue;
0118             if ($this->_etag === null) {
0119                 $this->_etag = $etag;
0120             }
0121             elseif ($this->_etag != $etag) {
0122                 // require_once('Zend/Gdata/App/IOException.php');
0123                 throw new Zend_Gdata_App_IOException("ETag mismatch");
0124             }
0125             break;
0126         default:
0127             parent::takeAttributeFromDOM($attribute);
0128             break;
0129         }
0130     }
0131 
0132 }