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