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.
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
27 require_once 'Zend/Gdata.php';
30 * @see Zend_Gdata_App_MediaEntry
32 require_once 'Zend/Gdata/App/MediaEntry.php';
35 * Represents the Gdata flavor of an Atom entry
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
43 class Zend_Gdata_Entry extends Zend_Gdata_App_MediaEntry
46 protected $_entryClassName = 'Zend_Gdata_Entry';
48 public function __construct($element = null)
50 $this->registerAllNamespaces(Zend_Gdata::$namespaces);
51 parent::__construct($element);
54 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
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'),
69 protected function takeChildFromDOM($child)
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;
78 case $this->lookupNamespace('atom') . ':' . 'published':
79 $published = new Zend_Gdata_App_Extension_Published();
80 $published->transferFromDOM($child);
81 $this->_published = $published;
83 case $this->lookupNamespace('atom') . ':' . 'source':
84 $source = new Zend_Gdata_App_Extension_Source();
85 $source->transferFromDOM($child);
86 $this->_source = $source;
88 case $this->lookupNamespace('atom') . ':' . 'summary':
89 $summary = new Zend_Gdata_App_Extension_Summary();
90 $summary->transferFromDOM($child);
91 $this->_summary = $summary;
93 case $this->lookupNamespace('app') . ':' . 'control':
94 $control = new Zend_Gdata_App_Extension_Control();
95 $control->transferFromDOM($child);
96 $this->_control = $control;
99 parent::takeChildFromDOM($child);
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.
109 * @param DOMNode $attribute The DOMNode attribute needed to be handled
111 protected function takeAttributeFromDOM($attribute)
113 switch ($attribute->localName) {
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;
121 elseif ($this->_etag != $etag) {
122 require_once('Zend/Gdata/App/IOException.php');
123 throw new Zend_Gdata_App_IOException("ETag mismatch");
127 parent::takeAttributeFromDOM($attribute);