1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
|
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Gdata
* @subpackage App
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Gdata_App_FeedEntryParent
*/
require_once 'Zend/Gdata/App/FeedEntryParent.php';
/**
* @see Zend_Gdata_App_Extension_Content
*/
require_once 'Zend/Gdata/App/Extension/Content.php';
/**
* @see Zend_Gdata_App_Extension_Edited
*/
require_once 'Zend/Gdata/App/Extension/Edited.php';
/**
* @see Zend_Gdata_App_Extension_Published
*/
require_once 'Zend/Gdata/App/Extension/Published.php';
/**
* @see Zend_Gdata_App_Extension_Source
*/
require_once 'Zend/Gdata/App/Extension/Source.php';
/**
* @see Zend_Gdata_App_Extension_Summary
*/
require_once 'Zend/Gdata/App/Extension/Summary.php';
/**
* @see Zend_Gdata_App_Extension_Control
*/
require_once 'Zend/Gdata/App/Extension/Control.php';
/**
* Concrete class for working with Atom entries.
*
* @category Zend
* @package Zend_Gdata
* @subpackage App
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Gdata_App_Entry extends Zend_Gdata_App_FeedEntryParent
{
/**
* Root XML element for Atom entries.
*
* @var string
*/
protected $_rootElement = 'entry';
/**
* Class name for each entry in this feed*
*
* @var string
*/
protected $_entryClassName = 'Zend_Gdata_App_Entry';
/**
* atom:content element
*
* @var Zend_Gdata_App_Extension_Content
*/
protected $_content = null;
/**
* atom:published element
*
* @var Zend_Gdata_App_Extension_Published
*/
protected $_published = null;
/**
* atom:source element
*
* @var Zend_Gdata_App_Extension_Source
*/
protected $_source = null;
/**
* atom:summary element
*
* @var Zend_Gdata_App_Extension_Summary
*/
protected $_summary = null;
/**
* app:control element
*
* @var Zend_Gdata_App_Extension_Control
*/
protected $_control = null;
/**
* app:edited element
*
* @var Zend_Gdata_App_Extension_Edited
*/
protected $_edited = null;
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
{
$element = parent::getDOM($doc, $majorVersion, $minorVersion);
if ($this->_content != null) {
$element->appendChild($this->_content->getDOM($element->ownerDocument));
}
if ($this->_published != null) {
$element->appendChild($this->_published->getDOM($element->ownerDocument));
}
if ($this->_source != null) {
$element->appendChild($this->_source->getDOM($element->ownerDocument));
}
if ($this->_summary != null) {
$element->appendChild($this->_summary->getDOM($element->ownerDocument));
}
if ($this->_control != null) {
$element->appendChild($this->_control->getDOM($element->ownerDocument));
}
if ($this->_edited != null) {
$element->appendChild($this->_edited->getDOM($element->ownerDocument));
}
return $element;
}
protected function takeChildFromDOM($child)
{
$absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
switch ($absoluteNodeName) {
case $this->lookupNamespace('atom') . ':' . 'content':
$content = new Zend_Gdata_App_Extension_Content();
$content->transferFromDOM($child);
$this->_content = $content;
break;
case $this->lookupNamespace('atom') . ':' . 'published':
$published = new Zend_Gdata_App_Extension_Published();
$published->transferFromDOM($child);
$this->_published = $published;
break;
case $this->lookupNamespace('atom') . ':' . 'source':
$source = new Zend_Gdata_App_Extension_Source();
$source->transferFromDOM($child);
$this->_source = $source;
break;
case $this->lookupNamespace('atom') . ':' . 'summary':
$summary = new Zend_Gdata_App_Extension_Summary();
$summary->transferFromDOM($child);
$this->_summary = $summary;
break;
case $this->lookupNamespace('app') . ':' . 'control':
$control = new Zend_Gdata_App_Extension_Control();
$control->transferFromDOM($child);
$this->_control = $control;
break;
case $this->lookupNamespace('app') . ':' . 'edited':
$edited = new Zend_Gdata_App_Extension_Edited();
$edited->transferFromDOM($child);
$this->_edited = $edited;
break;
default:
parent::takeChildFromDOM($child);
break;
}
}
/**
* Uploads changes in this entry to the server using Zend_Gdata_App
*
* @param string|null $uri The URI to send requests to, or null if $data
* contains the URI.
* @param string|null $className The name of the class that should we
* deserializing the server response. If null, then
* 'Zend_Gdata_App_Entry' will be used.
* @param array $extraHeaders Extra headers to add to the request, as an
* array of string-based key/value pairs.
* @return Zend_Gdata_App_Entry The updated entry.
* @throws Zend_Gdata_App_Exception
*/
public function save($uri = null, $className = null, $extraHeaders = array())
{
return $this->getService()->updateEntry($this,
$uri,
$className,
$extraHeaders);
}
/**
* Deletes this entry to the server using the referenced
* Zend_Http_Client to do a HTTP DELETE to the edit link stored in this
* entry's link collection.
*
* @return void
* @throws Zend_Gdata_App_Exception
*/
public function delete()
{
$this->getService()->delete($this);
}
/**
* Reload the current entry. Returns a new copy of the entry as returned
* by the server, or null if no changes exist. This does not
* modify the current entry instance.
*
* @param string|null The URI to send requests to, or null if $data
* contains the URI.
* @param string|null The name of the class that should we deserializing
* the server response. If null, then 'Zend_Gdata_App_Entry' will
* be used.
* @param array $extraHeaders Extra headers to add to the request, as an
* array of string-based key/value pairs.
* @return mixed A new instance of the current entry with updated data, or
* null if the server reports that no changes have been made.
* @throws Zend_Gdata_App_Exception
*/
public function reload($uri = null, $className = null, $extraHeaders = array())
{
// Get URI
$editLink = $this->getEditLink();
if (($uri === null) && $editLink != null) {
$uri = $editLink->getHref();
}
// Set classname to current class, if not otherwise set
if ($className === null) {
$className = get_class($this);
}
// Append ETag, if present (Gdata v2 and above, only) and doesn't
// conflict with existing headers
if ($this->_etag != null
&& !array_key_exists('If-Match', $extraHeaders)
&& !array_key_exists('If-None-Match', $extraHeaders)) {
$extraHeaders['If-None-Match'] = $this->_etag;
}
// If an HTTP 304 status (Not Modified)is returned, then we return
// null.
$result = null;
try {
$result = $this->service->importUrl($uri, $className, $extraHeaders);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getResponse()->getStatus() != '304')
throw $e;
}
return $result;
}
/**
* Gets the value of the atom:content element
*
* @return Zend_Gdata_App_Extension_Content
*/
public function getContent()
{
return $this->_content;
}
/**
* Sets the value of the atom:content element
*
* @param Zend_Gdata_App_Extension_Content $value
* @return Zend_Gdata_App_Entry Provides a fluent interface
*/
public function setContent($value)
{
$this->_content = $value;
return $this;
}
/**
* Sets the value of the atom:published element
* This represents the publishing date for an entry
*
* @return Zend_Gdata_App_Extension_Published
*/
public function getPublished()
{
return $this->_published;
}
/**
* Sets the value of the atom:published element
* This represents the publishing date for an entry
*
* @param Zend_Gdata_App_Extension_Published $value
* @return Zend_Gdata_App_Entry Provides a fluent interface
*/
public function setPublished($value)
{
$this->_published = $value;
return $this;
}
/**
* Gets the value of the atom:source element
*
* @return Zend_Gdata_App_Extension_Source
*/
public function getSource()
{
return $this->_source;
}
/**
* Sets the value of the atom:source element
*
* @param Zend_Gdata_App_Extension_Source $value
* @return Zend_Gdata_App_Entry Provides a fluent interface
*/
public function setSource($value)
{
$this->_source = $value;
return $this;
}
/**
* Gets the value of the atom:summary element
* This represents a textual summary of this entry's content
*
* @return Zend_Gdata_App_Extension_Summary
*/
public function getSummary()
{
return $this->_summary;
}
/**
* Sets the value of the atom:summary element
* This represents a textual summary of this entry's content
*
* @param Zend_Gdata_App_Extension_Summary $value
* @return Zend_Gdata_App_Entry Provides a fluent interface
*/
public function setSummary($value)
{
$this->_summary = $value;
return $this;
}
/**
* Gets the value of the app:control element
*
* @return Zend_Gdata_App_Extension_Control
*/
public function getControl()
{
return $this->_control;
}
/**
* Sets the value of the app:control element
*
* @param Zend_Gdata_App_Extension_Control $value
* @return Zend_Gdata_App_Entry Provides a fluent interface
*/
public function setControl($value)
{
$this->_control = $value;
return $this;
}
}
|