[ZF-10089] Zend_Log
[zend.git] / library / Zend / Gdata / Books / VolumeEntry.php
blob3b911684be852a8aea2756428b9c22c09d3d486d
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
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.
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Books
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
21 * @version $Id$
24 /**
25 * @see Zend_Gdata_Entry
27 require_once 'Zend/Gdata/Entry.php';
29 /**
30 * @see Zend_Gdata_Extension_Comments
32 require_once 'Zend/Gdata/Extension/Comments.php';
34 /**
35 * @see Zend_Gdata_DublinCore_Extension_Creator
37 require_once 'Zend/Gdata/DublinCore/Extension/Creator.php';
39 /**
40 * @see Zend_Gdata_DublinCore_Extension_Date
42 require_once 'Zend/Gdata/DublinCore/Extension/Date.php';
44 /**
45 * @see Zend_Gdata_DublinCore_Extension_Description
47 require_once 'Zend/Gdata/DublinCore/Extension/Description.php';
49 /**
50 * @see Zend_Gdata_Books_Extension_Embeddability
52 require_once 'Zend/Gdata/Books/Extension/Embeddability.php';
54 /**
55 * @see Zend_Gdata_DublinCore_Extension_Format
57 require_once 'Zend/Gdata/DublinCore/Extension/Format.php';
59 /**
60 * @see Zend_Gdata_DublinCore_Extension_Identifier
62 require_once 'Zend/Gdata/DublinCore/Extension/Identifier.php';
64 /**
65 * @see Zend_Gdata_DublinCore_Extension_Language
67 require_once 'Zend/Gdata/DublinCore/Extension/Language.php';
69 /**
70 * @see Zend_Gdata_DublinCore_Extension_Publisher
72 require_once 'Zend/Gdata/DublinCore/Extension/Publisher.php';
74 /**
75 * @see Zend_Gdata_Extension_Rating
77 require_once 'Zend/Gdata/Extension/Rating.php';
79 /**
80 * @see Zend_Gdata_Books_Extension_Review
82 require_once 'Zend/Gdata/Books/Extension/Review.php';
84 /**
85 * @see Zend_Gdata_DublinCore_Extension_Subject
87 require_once 'Zend/Gdata/DublinCore/Extension/Subject.php';
89 /**
90 * @see Zend_Gdata_DublinCore_Extension_Title
92 require_once 'Zend/Gdata/DublinCore/Extension/Title.php';
94 /**
95 * @see Zend_Gdata_Books_Extension_Viewability
97 require_once 'Zend/Gdata/Books/Extension/Viewability.php';
99 /**
100 * Describes an entry in a feed of Book Search volumes
102 * @category Zend
103 * @package Zend_Gdata
104 * @subpackage Books
105 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
106 * @license http://framework.zend.com/license/new-bsd New BSD License
108 class Zend_Gdata_Books_VolumeEntry extends Zend_Gdata_Entry
111 const THUMBNAIL_LINK_REL = 'http://schemas.google.com/books/2008/thumbnail';
112 const PREVIEW_LINK_REL = 'http://schemas.google.com/books/2008/preview';
113 const INFO_LINK_REL = 'http://schemas.google.com/books/2008/info';
114 const ANNOTATION_LINK_REL = 'http://schemas.google.com/books/2008/annotation';
116 protected $_comments = null;
117 protected $_creators = array();
118 protected $_dates = array();
119 protected $_descriptions = array();
120 protected $_embeddability = null;
121 protected $_formats = array();
122 protected $_identifiers = array();
123 protected $_languages = array();
124 protected $_publishers = array();
125 protected $_rating = null;
126 protected $_review = null;
127 protected $_subjects = array();
128 protected $_titles = array();
129 protected $_viewability = null;
132 * Constructor for Zend_Gdata_Books_VolumeEntry which
133 * Describes an entry in a feed of Book Search volumes
135 * @param DOMElement $element (optional) DOMElement from which this
136 * object should be constructed.
138 public function __construct($element = null)
140 $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
141 parent::__construct($element);
145 * Retrieves DOMElement which corresponds to this element and all
146 * child properties. This is used to build this object back into a DOM
147 * and eventually XML text for sending to the server upon updates, or
148 * for application storage/persistance.
150 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
151 * @return DOMElement The DOMElement representing this element and all
152 * child properties.
154 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
156 $element = parent::getDOM($doc);
157 if ($this->_creators !== null) {
158 foreach ($this->_creators as $creators) {
159 $element->appendChild($creators->getDOM(
160 $element->ownerDocument));
163 if ($this->_dates !== null) {
164 foreach ($this->_dates as $dates) {
165 $element->appendChild($dates->getDOM($element->ownerDocument));
168 if ($this->_descriptions !== null) {
169 foreach ($this->_descriptions as $descriptions) {
170 $element->appendChild($descriptions->getDOM(
171 $element->ownerDocument));
174 if ($this->_formats !== null) {
175 foreach ($this->_formats as $formats) {
176 $element->appendChild($formats->getDOM(
177 $element->ownerDocument));
180 if ($this->_identifiers !== null) {
181 foreach ($this->_identifiers as $identifiers) {
182 $element->appendChild($identifiers->getDOM(
183 $element->ownerDocument));
186 if ($this->_languages !== null) {
187 foreach ($this->_languages as $languages) {
188 $element->appendChild($languages->getDOM(
189 $element->ownerDocument));
192 if ($this->_publishers !== null) {
193 foreach ($this->_publishers as $publishers) {
194 $element->appendChild($publishers->getDOM(
195 $element->ownerDocument));
198 if ($this->_subjects !== null) {
199 foreach ($this->_subjects as $subjects) {
200 $element->appendChild($subjects->getDOM(
201 $element->ownerDocument));
204 if ($this->_titles !== null) {
205 foreach ($this->_titles as $titles) {
206 $element->appendChild($titles->getDOM($element->ownerDocument));
209 if ($this->_comments !== null) {
210 $element->appendChild($this->_comments->getDOM(
211 $element->ownerDocument));
213 if ($this->_embeddability !== null) {
214 $element->appendChild($this->_embeddability->getDOM(
215 $element->ownerDocument));
217 if ($this->_rating !== null) {
218 $element->appendChild($this->_rating->getDOM(
219 $element->ownerDocument));
221 if ($this->_review !== null) {
222 $element->appendChild($this->_review->getDOM(
223 $element->ownerDocument));
225 if ($this->_viewability !== null) {
226 $element->appendChild($this->_viewability->getDOM(
227 $element->ownerDocument));
229 return $element;
233 * Creates individual objects of the appropriate type and stores
234 * them in this object based upon DOM data.
236 * @param DOMNode $child The DOMNode to process.
238 protected function takeChildFromDOM($child)
240 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
241 switch ($absoluteNodeName) {
242 case $this->lookupNamespace('dc') . ':' . 'creator':
243 $creators = new Zend_Gdata_DublinCore_Extension_Creator();
244 $creators->transferFromDOM($child);
245 $this->_creators[] = $creators;
246 break;
247 case $this->lookupNamespace('dc') . ':' . 'date':
248 $dates = new Zend_Gdata_DublinCore_Extension_Date();
249 $dates->transferFromDOM($child);
250 $this->_dates[] = $dates;
251 break;
252 case $this->lookupNamespace('dc') . ':' . 'description':
253 $descriptions = new Zend_Gdata_DublinCore_Extension_Description();
254 $descriptions->transferFromDOM($child);
255 $this->_descriptions[] = $descriptions;
256 break;
257 case $this->lookupNamespace('dc') . ':' . 'format':
258 $formats = new Zend_Gdata_DublinCore_Extension_Format();
259 $formats->transferFromDOM($child);
260 $this->_formats[] = $formats;
261 break;
262 case $this->lookupNamespace('dc') . ':' . 'identifier':
263 $identifiers = new Zend_Gdata_DublinCore_Extension_Identifier();
264 $identifiers->transferFromDOM($child);
265 $this->_identifiers[] = $identifiers;
266 break;
267 case $this->lookupNamespace('dc') . ':' . 'language':
268 $languages = new Zend_Gdata_DublinCore_Extension_Language();
269 $languages->transferFromDOM($child);
270 $this->_languages[] = $languages;
271 break;
272 case $this->lookupNamespace('dc') . ':' . 'publisher':
273 $publishers = new Zend_Gdata_DublinCore_Extension_Publisher();
274 $publishers->transferFromDOM($child);
275 $this->_publishers[] = $publishers;
276 break;
277 case $this->lookupNamespace('dc') . ':' . 'subject':
278 $subjects = new Zend_Gdata_DublinCore_Extension_Subject();
279 $subjects->transferFromDOM($child);
280 $this->_subjects[] = $subjects;
281 break;
282 case $this->lookupNamespace('dc') . ':' . 'title':
283 $titles = new Zend_Gdata_DublinCore_Extension_Title();
284 $titles->transferFromDOM($child);
285 $this->_titles[] = $titles;
286 break;
287 case $this->lookupNamespace('gd') . ':' . 'comments':
288 $comments = new Zend_Gdata_Extension_Comments();
289 $comments->transferFromDOM($child);
290 $this->_comments = $comments;
291 break;
292 case $this->lookupNamespace('gbs') . ':' . 'embeddability':
293 $embeddability = new Zend_Gdata_Books_Extension_Embeddability();
294 $embeddability->transferFromDOM($child);
295 $this->_embeddability = $embeddability;
296 break;
297 case $this->lookupNamespace('gd') . ':' . 'rating':
298 $rating = new Zend_Gdata_Extension_Rating();
299 $rating->transferFromDOM($child);
300 $this->_rating = $rating;
301 break;
302 case $this->lookupNamespace('gbs') . ':' . 'review':
303 $review = new Zend_Gdata_Books_Extension_Review();
304 $review->transferFromDOM($child);
305 $this->_review = $review;
306 break;
307 case $this->lookupNamespace('gbs') . ':' . 'viewability':
308 $viewability = new Zend_Gdata_Books_Extension_Viewability();
309 $viewability->transferFromDOM($child);
310 $this->_viewability = $viewability;
311 break;
312 default:
313 parent::takeChildFromDOM($child);
314 break;
319 * Returns the Comments class
321 * @return Zend_Gdata_Extension_Comments|null The comments
323 public function getComments()
325 return $this->_comments;
329 * Returns the creators
331 * @return array The creators
333 public function getCreators()
335 return $this->_creators;
339 * Returns the dates
341 * @return array The dates
343 public function getDates()
345 return $this->_dates;
349 * Returns the descriptions
351 * @return array The descriptions
353 public function getDescriptions()
355 return $this->_descriptions;
359 * Returns the embeddability
361 * @return Zend_Gdata_Books_Extension_Embeddability|null The embeddability
363 public function getEmbeddability()
365 return $this->_embeddability;
369 * Returns the formats
371 * @return array The formats
373 public function getFormats()
375 return $this->_formats;
379 * Returns the identifiers
381 * @return array The identifiers
383 public function getIdentifiers()
385 return $this->_identifiers;
389 * Returns the languages
391 * @return array The languages
393 public function getLanguages()
395 return $this->_languages;
399 * Returns the publishers
401 * @return array The publishers
403 public function getPublishers()
405 return $this->_publishers;
409 * Returns the rating
411 * @return Zend_Gdata_Extension_Rating|null The rating
413 public function getRating()
415 return $this->_rating;
419 * Returns the review
421 * @return Zend_Gdata_Books_Extension_Review|null The review
423 public function getReview()
425 return $this->_review;
429 * Returns the subjects
431 * @return array The subjects
433 public function getSubjects()
435 return $this->_subjects;
439 * Returns the titles
441 * @return array The titles
443 public function getTitles()
445 return $this->_titles;
449 * Returns the viewability
451 * @return Zend_Gdata_Books_Extension_Viewability|null The viewability
453 public function getViewability()
455 return $this->_viewability;
459 * Sets the Comments class
461 * @param Zend_Gdata_Extension_Comments|null $comments Comments class
462 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
464 public function setComments($comments)
466 $this->_comments = $comments;
467 return $this;
471 * Sets the creators
473 * @param array $creators Creators|null
474 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
476 public function setCreators($creators)
478 $this->_creators = $creators;
479 return $this;
483 * Sets the dates
485 * @param array $dates dates
486 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
488 public function setDates($dates)
490 $this->_dates = $dates;
491 return $this;
495 * Sets the descriptions
497 * @param array $descriptions descriptions
498 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
500 public function setDescriptions($descriptions)
502 $this->_descriptions = $descriptions;
503 return $this;
507 * Sets the embeddability
509 * @param Zend_Gdata_Books_Extension_Embeddability|null $embeddability
510 * embeddability
511 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
513 public function setEmbeddability($embeddability)
515 $this->_embeddability = $embeddability;
516 return $this;
520 * Sets the formats
522 * @param array $formats formats
523 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
525 public function setFormats($formats)
527 $this->_formats = $formats;
528 return $this;
532 * Sets the identifiers
534 * @param array $identifiers identifiers
535 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
537 public function setIdentifiers($identifiers)
539 $this->_identifiers = $identifiers;
540 return $this;
544 * Sets the languages
546 * @param array $languages languages
547 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
549 public function setLanguages($languages)
551 $this->_languages = $languages;
552 return $this;
556 * Sets the publishers
558 * @param array $publishers publishers
559 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
561 public function setPublishers($publishers)
563 $this->_publishers = $publishers;
564 return $this;
568 * Sets the rating
570 * @param Zend_Gdata_Extension_Rating|null $rating rating
571 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
573 public function setRating($rating)
575 $this->_rating = $rating;
576 return $this;
580 * Sets the review
582 * @param Zend_Gdata_Books_Extension_Review|null $review review
583 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
585 public function setReview($review)
587 $this->_review = $review;
588 return $this;
592 * Sets the subjects
594 * @param array $subjects subjects
595 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
597 public function setSubjects($subjects)
599 $this->_subjects = $subjects;
600 return $this;
604 * Sets the titles
606 * @param array $titles titles
607 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
609 public function setTitles($titles)
611 $this->_titles = $titles;
612 return $this;
616 * Sets the viewability
618 * @param Zend_Gdata_Books_Extension_Viewability|null $viewability
619 * viewability
620 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
622 public function setViewability($viewability)
624 $this->_viewability = $viewability;
625 return $this;
630 * Gets the volume ID based upon the atom:id value
632 * @return string The volume ID
633 * @throws Zend_Gdata_App_Exception
635 public function getVolumeId()
637 $fullId = $this->getId()->getText();
638 $position = strrpos($fullId, '/');
639 if ($position === false) {
640 require_once 'Zend/Gdata/App/Exception.php';
641 throw new Zend_Gdata_App_Exception('Slash not found in atom:id');
642 } else {
643 return substr($fullId, strrpos($fullId,'/') + 1);
648 * Gets the thumbnail link
650 * @return Zend_Gdata_App_Extension_link|null The thumbnail link
652 public function getThumbnailLink()
654 return $this->getLink(self::THUMBNAIL_LINK_REL);
658 * Gets the preview link
660 * @return Zend_Gdata_App_Extension_Link|null The preview link
662 public function getPreviewLink()
664 return $this->getLink(self::PREVIEW_LINK_REL);
668 * Gets the info link
670 * @return Zend_Gdata_App_Extension_Link|null The info link
672 public function getInfoLink()
674 return $this->getLink(self::INFO_LINK_REL);
678 * Gets the annotations link
680 * @return Zend_Gdata_App_Extension_Link|null The annotations link
682 public function getAnnotationLink()
684 return $this->getLink(self::ANNOTATION_LINK_REL);