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-2008 Zend Technologies USA Inc. (http://www.zend.com)
20
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* @see Zend_Gdata_App_FeedEntryParent
26
require_once 'Zend/Gdata/App/FeedEntryParent.php';
29
* @see Zend_Gdata_App_Extension_Content
31
require_once 'Zend/Gdata/App/Extension/Content.php';
34
* @see Zend_Gdata_App_Extension_Published
36
require_once 'Zend/Gdata/App/Extension/Published.php';
39
* @see Zend_Gdata_App_Extension_Source
41
require_once 'Zend/Gdata/App/Extension/Source.php';
44
* @see Zend_Gdata_App_Extension_Summary
46
require_once 'Zend/Gdata/App/Extension/Summary.php';
49
* @see Zend_Gdata_App_Extension_Control
51
require_once 'Zend/Gdata/App/Extension/Control.php';
54
* Concrete class for working with Atom entries.
58
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
59
* @license http://framework.zend.com/license/new-bsd New BSD License
61
class Zend_Gdata_App_Entry extends Zend_Gdata_App_FeedEntryParent
65
* Root XML element for Atom entries.
69
protected $_rootElement = 'entry';
72
* Class name for each entry in this feed*
76
protected $_entryClassName = 'Zend_Gdata_App_Entry';
79
* atom:content element
81
* @var Zend_Gdata_App_Extension_Content
83
protected $_content = null;
86
* atom:published element
88
* @var Zend_Gdata_App_Extension_Published
90
protected $_published = null;
95
* @var Zend_Gdata_App_Extension_Source
97
protected $_source = null;
100
* atom:summary element
102
* @var Zend_Gdata_App_Extension_Summary
104
protected $_summary = null;
107
* app:control element
109
* @var Zend_Gdata_App_Extension_Control
111
protected $_control = null;
113
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
115
$element = parent::getDOM($doc, $majorVersion, $minorVersion);
116
if ($this->_content != null) {
117
$element->appendChild($this->_content->getDOM($element->ownerDocument));
119
if ($this->_published != null) {
120
$element->appendChild($this->_published->getDOM($element->ownerDocument));
122
if ($this->_source != null) {
123
$element->appendChild($this->_source->getDOM($element->ownerDocument));
125
if ($this->_summary != null) {
126
$element->appendChild($this->_summary->getDOM($element->ownerDocument));
128
if ($this->_control != null) {
129
$element->appendChild($this->_control->getDOM($element->ownerDocument));
134
protected function takeChildFromDOM($child)
136
$absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
137
switch ($absoluteNodeName) {
138
case $this->lookupNamespace('atom') . ':' . 'content':
139
$content = new Zend_Gdata_App_Extension_Content();
140
$content->transferFromDOM($child);
141
$this->_content = $content;
143
case $this->lookupNamespace('atom') . ':' . 'published':
144
$published = new Zend_Gdata_App_Extension_Published();
145
$published->transferFromDOM($child);
146
$this->_published = $published;
148
case $this->lookupNamespace('atom') . ':' . 'source':
149
$source = new Zend_Gdata_App_Extension_Source();
150
$source->transferFromDOM($child);
151
$this->_source = $source;
153
case $this->lookupNamespace('atom') . ':' . 'summary':
154
$summary = new Zend_Gdata_App_Extension_Summary();
155
$summary->transferFromDOM($child);
156
$this->_summary = $summary;
158
case $this->lookupNamespace('app') . ':' . 'control':
159
$control = new Zend_Gdata_App_Extension_Control();
160
$control->transferFromDOM($child);
161
$this->_control = $control;
164
parent::takeChildFromDOM($child);
170
* Uploads changes in this entry to the server using Zend_Gdata_App
172
* @param string|null $uri The URI to send requests to, or null if $data
174
* @param string|null $className The name of the class that should we
175
* deserializing the server response. If null, then
176
* 'Zend_Gdata_App_Entry' will be used.
177
* @param array $extraHeaders Extra headers to add to the request, as an
178
* array of string-based key/value pairs.
179
* @return Zend_Gdata_App_Entry The updated entry.
180
* @throws Zend_Gdata_App_Exception
182
public function save($uri = null, $className = null, $extraHeaders = array())
184
return $this->getService()->updateEntry($this,
191
* Deletes this entry to the server using the referenced
192
* Zend_Http_Client to do a HTTP DELETE to the edit link stored in this
193
* entry's link collection.
196
* @throws Zend_Gdata_App_Exception
198
public function delete()
200
$this->getService()->delete($this);
204
* Reload the current entry. Returns a new copy of the entry as returned
205
* by the server, or null if no changes exist. This does not
206
* modify the current entry instance.
208
* @param string|null The URI to send requests to, or null if $data
210
* @param string|null The name of the class that should we deserializing
211
* the server response. If null, then 'Zend_Gdata_App_Entry' will
213
* @param array $extraHeaders Extra headers to add to the request, as an
214
* array of string-based key/value pairs.
215
* @return mixed A new instance of the current entry with updated data, or
216
* null if the server reports that no changes have been made.
217
* @throws Zend_Gdata_App_Exception
219
public function reload($uri = null, $className = null, $extraHeaders = array())
222
$editLink = $this->getEditLink();
223
if (is_null($uri) && $editLink != null) {
224
$uri = $editLink->getHref();
227
// Set classname to current class, if not otherwise set
228
if (is_null($className)) {
229
$className = get_class($this);
232
// Append ETag, if present (Gdata v2 and above, only) and doesn't
233
// conflict with existing headers
234
if ($this->_etag != null
235
&& !array_key_exists('If-Match', $extraHeaders)
236
&& !array_key_exists('If-None-Match', $extraHeaders)) {
237
$extraHeaders['If-None-Match'] = $this->_etag;
240
// If an HTTP 304 status (Not Modified)is returned, then we return
244
$result = $this->service->importUrl($uri, $className, $extraHeaders);
245
} catch (Zend_Gdata_App_HttpException $e) {
246
if ($e->getResponse()->getStatus() != '304')
254
* Gets the value of the atom:content element
256
* @return Zend_Gdata_App_Extension_Content
258
public function getContent()
260
return $this->_content;
264
* Sets the value of the atom:content element
266
* @param Zend_Gdata_App_Extension_Content $value
267
* @return Zend_Gdata_App_Entry Provides a fluent interface
269
public function setContent($value)
271
$this->_content = $value;
276
* Sets the value of the atom:published element
277
* This represents the publishing date for an entry
279
* @return Zend_Gdata_App_Extension_Published
281
public function getPublished()
283
return $this->_published;
287
* Sets the value of the atom:published element
288
* This represents the publishing date for an entry
290
* @param Zend_Gdata_App_Extension_Published $value
291
* @return Zend_Gdata_App_Entry Provides a fluent interface
293
public function setPublished($value)
295
$this->_published = $value;
300
* Gets the value of the atom:source element
302
* @return Zend_Gdata_App_Extension_Source
304
public function getSource()
306
return $this->_source;
310
* Sets the value of the atom:source element
312
* @param Zend_Gdata_App_Extension_Source $value
313
* @return Zend_Gdata_App_Entry Provides a fluent interface
315
public function setSource($value)
317
$this->_source = $value;
322
* Gets the value of the atom:summary element
323
* This represents a textual summary of this entry's content
325
* @return Zend_Gdata_App_Extension_Summary
327
public function getSummary()
329
return $this->_summary;
333
* Sets the value of the atom:summary element
334
* This represents a textual summary of this entry's content
336
* @param Zend_Gdata_App_Extension_Summary $value
337
* @return Zend_Gdata_App_Entry Provides a fluent interface
339
public function setSummary($value)
341
$this->_summary = $value;
346
* Gets the value of the app:control element
348
* @return Zend_Gdata_App_Extension_Control
350
public function getControl()
352
return $this->_control;
356
* Sets the value of the app:control element
358
* @param Zend_Gdata_App_Extension_Control $value
359
* @return Zend_Gdata_App_Entry Provides a fluent interface
361
public function setControl($value)
363
$this->_control = $value;