File indexing completed on 2025-05-04 05:32:34
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Books 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * @see Zend_Gdata_Entry 0026 */ 0027 // require_once 'Zend/Gdata/Entry.php'; 0028 0029 /** 0030 * @see Zend_Gdata_Extension_Comments 0031 */ 0032 // require_once 'Zend/Gdata/Extension/Comments.php'; 0033 0034 /** 0035 * @see Zend_Gdata_DublinCore_Extension_Creator 0036 */ 0037 // require_once 'Zend/Gdata/DublinCore/Extension/Creator.php'; 0038 0039 /** 0040 * @see Zend_Gdata_DublinCore_Extension_Date 0041 */ 0042 // require_once 'Zend/Gdata/DublinCore/Extension/Date.php'; 0043 0044 /** 0045 * @see Zend_Gdata_DublinCore_Extension_Description 0046 */ 0047 // require_once 'Zend/Gdata/DublinCore/Extension/Description.php'; 0048 0049 /** 0050 * @see Zend_Gdata_Books_Extension_Embeddability 0051 */ 0052 // require_once 'Zend/Gdata/Books/Extension/Embeddability.php'; 0053 0054 /** 0055 * @see Zend_Gdata_DublinCore_Extension_Format 0056 */ 0057 // require_once 'Zend/Gdata/DublinCore/Extension/Format.php'; 0058 0059 /** 0060 * @see Zend_Gdata_DublinCore_Extension_Identifier 0061 */ 0062 // require_once 'Zend/Gdata/DublinCore/Extension/Identifier.php'; 0063 0064 /** 0065 * @see Zend_Gdata_DublinCore_Extension_Language 0066 */ 0067 // require_once 'Zend/Gdata/DublinCore/Extension/Language.php'; 0068 0069 /** 0070 * @see Zend_Gdata_DublinCore_Extension_Publisher 0071 */ 0072 // require_once 'Zend/Gdata/DublinCore/Extension/Publisher.php'; 0073 0074 /** 0075 * @see Zend_Gdata_Extension_Rating 0076 */ 0077 // require_once 'Zend/Gdata/Extension/Rating.php'; 0078 0079 /** 0080 * @see Zend_Gdata_Books_Extension_Review 0081 */ 0082 // require_once 'Zend/Gdata/Books/Extension/Review.php'; 0083 0084 /** 0085 * @see Zend_Gdata_DublinCore_Extension_Subject 0086 */ 0087 // require_once 'Zend/Gdata/DublinCore/Extension/Subject.php'; 0088 0089 /** 0090 * @see Zend_Gdata_DublinCore_Extension_Title 0091 */ 0092 // require_once 'Zend/Gdata/DublinCore/Extension/Title.php'; 0093 0094 /** 0095 * @see Zend_Gdata_Books_Extension_Viewability 0096 */ 0097 // require_once 'Zend/Gdata/Books/Extension/Viewability.php'; 0098 0099 /** 0100 * Describes an entry in a feed of Book Search volumes 0101 * 0102 * @category Zend 0103 * @package Zend_Gdata 0104 * @subpackage Books 0105 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0106 * @license http://framework.zend.com/license/new-bsd New BSD License 0107 */ 0108 class Zend_Gdata_Books_VolumeEntry extends Zend_Gdata_Entry 0109 { 0110 0111 const THUMBNAIL_LINK_REL = 'http://schemas.google.com/books/2008/thumbnail'; 0112 const PREVIEW_LINK_REL = 'http://schemas.google.com/books/2008/preview'; 0113 const INFO_LINK_REL = 'http://schemas.google.com/books/2008/info'; 0114 const ANNOTATION_LINK_REL = 'http://schemas.google.com/books/2008/annotation'; 0115 0116 protected $_comments = null; 0117 protected $_creators = array(); 0118 protected $_dates = array(); 0119 protected $_descriptions = array(); 0120 protected $_embeddability = null; 0121 protected $_formats = array(); 0122 protected $_identifiers = array(); 0123 protected $_languages = array(); 0124 protected $_publishers = array(); 0125 protected $_rating = null; 0126 protected $_review = null; 0127 protected $_subjects = array(); 0128 protected $_titles = array(); 0129 protected $_viewability = null; 0130 0131 /** 0132 * Constructor for Zend_Gdata_Books_VolumeEntry which 0133 * Describes an entry in a feed of Book Search volumes 0134 * 0135 * @param DOMElement $element (optional) DOMElement from which this 0136 * object should be constructed. 0137 */ 0138 public function __construct($element = null) 0139 { 0140 $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces); 0141 parent::__construct($element); 0142 } 0143 0144 /** 0145 * Retrieves DOMElement which corresponds to this element and all 0146 * child properties. This is used to build this object back into a DOM 0147 * and eventually XML text for sending to the server upon updates, or 0148 * for application storage/persistance. 0149 * 0150 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0151 * @return DOMElement The DOMElement representing this element and all 0152 * child properties. 0153 */ 0154 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0155 { 0156 $element = parent::getDOM($doc); 0157 if ($this->_creators !== null) { 0158 foreach ($this->_creators as $creators) { 0159 $element->appendChild($creators->getDOM( 0160 $element->ownerDocument)); 0161 } 0162 } 0163 if ($this->_dates !== null) { 0164 foreach ($this->_dates as $dates) { 0165 $element->appendChild($dates->getDOM($element->ownerDocument)); 0166 } 0167 } 0168 if ($this->_descriptions !== null) { 0169 foreach ($this->_descriptions as $descriptions) { 0170 $element->appendChild($descriptions->getDOM( 0171 $element->ownerDocument)); 0172 } 0173 } 0174 if ($this->_formats !== null) { 0175 foreach ($this->_formats as $formats) { 0176 $element->appendChild($formats->getDOM( 0177 $element->ownerDocument)); 0178 } 0179 } 0180 if ($this->_identifiers !== null) { 0181 foreach ($this->_identifiers as $identifiers) { 0182 $element->appendChild($identifiers->getDOM( 0183 $element->ownerDocument)); 0184 } 0185 } 0186 if ($this->_languages !== null) { 0187 foreach ($this->_languages as $languages) { 0188 $element->appendChild($languages->getDOM( 0189 $element->ownerDocument)); 0190 } 0191 } 0192 if ($this->_publishers !== null) { 0193 foreach ($this->_publishers as $publishers) { 0194 $element->appendChild($publishers->getDOM( 0195 $element->ownerDocument)); 0196 } 0197 } 0198 if ($this->_subjects !== null) { 0199 foreach ($this->_subjects as $subjects) { 0200 $element->appendChild($subjects->getDOM( 0201 $element->ownerDocument)); 0202 } 0203 } 0204 if ($this->_titles !== null) { 0205 foreach ($this->_titles as $titles) { 0206 $element->appendChild($titles->getDOM($element->ownerDocument)); 0207 } 0208 } 0209 if ($this->_comments !== null) { 0210 $element->appendChild($this->_comments->getDOM( 0211 $element->ownerDocument)); 0212 } 0213 if ($this->_embeddability !== null) { 0214 $element->appendChild($this->_embeddability->getDOM( 0215 $element->ownerDocument)); 0216 } 0217 if ($this->_rating !== null) { 0218 $element->appendChild($this->_rating->getDOM( 0219 $element->ownerDocument)); 0220 } 0221 if ($this->_review !== null) { 0222 $element->appendChild($this->_review->getDOM( 0223 $element->ownerDocument)); 0224 } 0225 if ($this->_viewability !== null) { 0226 $element->appendChild($this->_viewability->getDOM( 0227 $element->ownerDocument)); 0228 } 0229 return $element; 0230 } 0231 0232 /** 0233 * Creates individual objects of the appropriate type and stores 0234 * them in this object based upon DOM data. 0235 * 0236 * @param DOMNode $child The DOMNode to process. 0237 */ 0238 protected function takeChildFromDOM($child) 0239 { 0240 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; 0241 switch ($absoluteNodeName) { 0242 case $this->lookupNamespace('dc') . ':' . 'creator': 0243 $creators = new Zend_Gdata_DublinCore_Extension_Creator(); 0244 $creators->transferFromDOM($child); 0245 $this->_creators[] = $creators; 0246 break; 0247 case $this->lookupNamespace('dc') . ':' . 'date': 0248 $dates = new Zend_Gdata_DublinCore_Extension_Date(); 0249 $dates->transferFromDOM($child); 0250 $this->_dates[] = $dates; 0251 break; 0252 case $this->lookupNamespace('dc') . ':' . 'description': 0253 $descriptions = new Zend_Gdata_DublinCore_Extension_Description(); 0254 $descriptions->transferFromDOM($child); 0255 $this->_descriptions[] = $descriptions; 0256 break; 0257 case $this->lookupNamespace('dc') . ':' . 'format': 0258 $formats = new Zend_Gdata_DublinCore_Extension_Format(); 0259 $formats->transferFromDOM($child); 0260 $this->_formats[] = $formats; 0261 break; 0262 case $this->lookupNamespace('dc') . ':' . 'identifier': 0263 $identifiers = new Zend_Gdata_DublinCore_Extension_Identifier(); 0264 $identifiers->transferFromDOM($child); 0265 $this->_identifiers[] = $identifiers; 0266 break; 0267 case $this->lookupNamespace('dc') . ':' . 'language': 0268 $languages = new Zend_Gdata_DublinCore_Extension_Language(); 0269 $languages->transferFromDOM($child); 0270 $this->_languages[] = $languages; 0271 break; 0272 case $this->lookupNamespace('dc') . ':' . 'publisher': 0273 $publishers = new Zend_Gdata_DublinCore_Extension_Publisher(); 0274 $publishers->transferFromDOM($child); 0275 $this->_publishers[] = $publishers; 0276 break; 0277 case $this->lookupNamespace('dc') . ':' . 'subject': 0278 $subjects = new Zend_Gdata_DublinCore_Extension_Subject(); 0279 $subjects->transferFromDOM($child); 0280 $this->_subjects[] = $subjects; 0281 break; 0282 case $this->lookupNamespace('dc') . ':' . 'title': 0283 $titles = new Zend_Gdata_DublinCore_Extension_Title(); 0284 $titles->transferFromDOM($child); 0285 $this->_titles[] = $titles; 0286 break; 0287 case $this->lookupNamespace('gd') . ':' . 'comments': 0288 $comments = new Zend_Gdata_Extension_Comments(); 0289 $comments->transferFromDOM($child); 0290 $this->_comments = $comments; 0291 break; 0292 case $this->lookupNamespace('gbs') . ':' . 'embeddability': 0293 $embeddability = new Zend_Gdata_Books_Extension_Embeddability(); 0294 $embeddability->transferFromDOM($child); 0295 $this->_embeddability = $embeddability; 0296 break; 0297 case $this->lookupNamespace('gd') . ':' . 'rating': 0298 $rating = new Zend_Gdata_Extension_Rating(); 0299 $rating->transferFromDOM($child); 0300 $this->_rating = $rating; 0301 break; 0302 case $this->lookupNamespace('gbs') . ':' . 'review': 0303 $review = new Zend_Gdata_Books_Extension_Review(); 0304 $review->transferFromDOM($child); 0305 $this->_review = $review; 0306 break; 0307 case $this->lookupNamespace('gbs') . ':' . 'viewability': 0308 $viewability = new Zend_Gdata_Books_Extension_Viewability(); 0309 $viewability->transferFromDOM($child); 0310 $this->_viewability = $viewability; 0311 break; 0312 default: 0313 parent::takeChildFromDOM($child); 0314 break; 0315 } 0316 } 0317 0318 /** 0319 * Returns the Comments class 0320 * 0321 * @return Zend_Gdata_Extension_Comments|null The comments 0322 */ 0323 public function getComments() 0324 { 0325 return $this->_comments; 0326 } 0327 0328 /** 0329 * Returns the creators 0330 * 0331 * @return array The creators 0332 */ 0333 public function getCreators() 0334 { 0335 return $this->_creators; 0336 } 0337 0338 /** 0339 * Returns the dates 0340 * 0341 * @return array The dates 0342 */ 0343 public function getDates() 0344 { 0345 return $this->_dates; 0346 } 0347 0348 /** 0349 * Returns the descriptions 0350 * 0351 * @return array The descriptions 0352 */ 0353 public function getDescriptions() 0354 { 0355 return $this->_descriptions; 0356 } 0357 0358 /** 0359 * Returns the embeddability 0360 * 0361 * @return Zend_Gdata_Books_Extension_Embeddability|null The embeddability 0362 */ 0363 public function getEmbeddability() 0364 { 0365 return $this->_embeddability; 0366 } 0367 0368 /** 0369 * Returns the formats 0370 * 0371 * @return array The formats 0372 */ 0373 public function getFormats() 0374 { 0375 return $this->_formats; 0376 } 0377 0378 /** 0379 * Returns the identifiers 0380 * 0381 * @return array The identifiers 0382 */ 0383 public function getIdentifiers() 0384 { 0385 return $this->_identifiers; 0386 } 0387 0388 /** 0389 * Returns the languages 0390 * 0391 * @return array The languages 0392 */ 0393 public function getLanguages() 0394 { 0395 return $this->_languages; 0396 } 0397 0398 /** 0399 * Returns the publishers 0400 * 0401 * @return array The publishers 0402 */ 0403 public function getPublishers() 0404 { 0405 return $this->_publishers; 0406 } 0407 0408 /** 0409 * Returns the rating 0410 * 0411 * @return Zend_Gdata_Extension_Rating|null The rating 0412 */ 0413 public function getRating() 0414 { 0415 return $this->_rating; 0416 } 0417 0418 /** 0419 * Returns the review 0420 * 0421 * @return Zend_Gdata_Books_Extension_Review|null The review 0422 */ 0423 public function getReview() 0424 { 0425 return $this->_review; 0426 } 0427 0428 /** 0429 * Returns the subjects 0430 * 0431 * @return array The subjects 0432 */ 0433 public function getSubjects() 0434 { 0435 return $this->_subjects; 0436 } 0437 0438 /** 0439 * Returns the titles 0440 * 0441 * @return array The titles 0442 */ 0443 public function getTitles() 0444 { 0445 return $this->_titles; 0446 } 0447 0448 /** 0449 * Returns the viewability 0450 * 0451 * @return Zend_Gdata_Books_Extension_Viewability|null The viewability 0452 */ 0453 public function getViewability() 0454 { 0455 return $this->_viewability; 0456 } 0457 0458 /** 0459 * Sets the Comments class 0460 * 0461 * @param Zend_Gdata_Extension_Comments|null $comments Comments class 0462 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0463 */ 0464 public function setComments($comments) 0465 { 0466 $this->_comments = $comments; 0467 return $this; 0468 } 0469 0470 /** 0471 * Sets the creators 0472 * 0473 * @param array $creators Creators|null 0474 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0475 */ 0476 public function setCreators($creators) 0477 { 0478 $this->_creators = $creators; 0479 return $this; 0480 } 0481 0482 /** 0483 * Sets the dates 0484 * 0485 * @param array $dates dates 0486 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0487 */ 0488 public function setDates($dates) 0489 { 0490 $this->_dates = $dates; 0491 return $this; 0492 } 0493 0494 /** 0495 * Sets the descriptions 0496 * 0497 * @param array $descriptions descriptions 0498 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0499 */ 0500 public function setDescriptions($descriptions) 0501 { 0502 $this->_descriptions = $descriptions; 0503 return $this; 0504 } 0505 0506 /** 0507 * Sets the embeddability 0508 * 0509 * @param Zend_Gdata_Books_Extension_Embeddability|null $embeddability 0510 * embeddability 0511 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0512 */ 0513 public function setEmbeddability($embeddability) 0514 { 0515 $this->_embeddability = $embeddability; 0516 return $this; 0517 } 0518 0519 /** 0520 * Sets the formats 0521 * 0522 * @param array $formats formats 0523 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0524 */ 0525 public function setFormats($formats) 0526 { 0527 $this->_formats = $formats; 0528 return $this; 0529 } 0530 0531 /** 0532 * Sets the identifiers 0533 * 0534 * @param array $identifiers identifiers 0535 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0536 */ 0537 public function setIdentifiers($identifiers) 0538 { 0539 $this->_identifiers = $identifiers; 0540 return $this; 0541 } 0542 0543 /** 0544 * Sets the languages 0545 * 0546 * @param array $languages languages 0547 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0548 */ 0549 public function setLanguages($languages) 0550 { 0551 $this->_languages = $languages; 0552 return $this; 0553 } 0554 0555 /** 0556 * Sets the publishers 0557 * 0558 * @param array $publishers publishers 0559 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0560 */ 0561 public function setPublishers($publishers) 0562 { 0563 $this->_publishers = $publishers; 0564 return $this; 0565 } 0566 0567 /** 0568 * Sets the rating 0569 * 0570 * @param Zend_Gdata_Extension_Rating|null $rating rating 0571 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0572 */ 0573 public function setRating($rating) 0574 { 0575 $this->_rating = $rating; 0576 return $this; 0577 } 0578 0579 /** 0580 * Sets the review 0581 * 0582 * @param Zend_Gdata_Books_Extension_Review|null $review review 0583 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0584 */ 0585 public function setReview($review) 0586 { 0587 $this->_review = $review; 0588 return $this; 0589 } 0590 0591 /** 0592 * Sets the subjects 0593 * 0594 * @param array $subjects subjects 0595 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0596 */ 0597 public function setSubjects($subjects) 0598 { 0599 $this->_subjects = $subjects; 0600 return $this; 0601 } 0602 0603 /** 0604 * Sets the titles 0605 * 0606 * @param array $titles titles 0607 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0608 */ 0609 public function setTitles($titles) 0610 { 0611 $this->_titles = $titles; 0612 return $this; 0613 } 0614 0615 /** 0616 * Sets the viewability 0617 * 0618 * @param Zend_Gdata_Books_Extension_Viewability|null $viewability 0619 * viewability 0620 * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface 0621 */ 0622 public function setViewability($viewability) 0623 { 0624 $this->_viewability = $viewability; 0625 return $this; 0626 } 0627 0628 0629 /** 0630 * Gets the volume ID based upon the atom:id value 0631 * 0632 * @return string The volume ID 0633 * @throws Zend_Gdata_App_Exception 0634 */ 0635 public function getVolumeId() 0636 { 0637 $fullId = $this->getId()->getText(); 0638 $position = strrpos($fullId, '/'); 0639 if ($position === false) { 0640 // require_once 'Zend/Gdata/App/Exception.php'; 0641 throw new Zend_Gdata_App_Exception('Slash not found in atom:id'); 0642 } else { 0643 return substr($fullId, strrpos($fullId,'/') + 1); 0644 } 0645 } 0646 0647 /** 0648 * Gets the thumbnail link 0649 * 0650 * @return Zend_Gdata_App_Extension_link|null The thumbnail link 0651 */ 0652 public function getThumbnailLink() 0653 { 0654 return $this->getLink(self::THUMBNAIL_LINK_REL); 0655 } 0656 0657 /** 0658 * Gets the preview link 0659 * 0660 * @return Zend_Gdata_App_Extension_Link|null The preview link 0661 */ 0662 public function getPreviewLink() 0663 { 0664 return $this->getLink(self::PREVIEW_LINK_REL); 0665 } 0666 0667 /** 0668 * Gets the info link 0669 * 0670 * @return Zend_Gdata_App_Extension_Link|null The info link 0671 */ 0672 public function getInfoLink() 0673 { 0674 return $this->getLink(self::INFO_LINK_REL); 0675 } 0676 0677 /** 0678 * Gets the annotations link 0679 * 0680 * @return Zend_Gdata_App_Extension_Link|null The annotations link 0681 */ 0682 public function getAnnotationLink() 0683 { 0684 return $this->getLink(self::ANNOTATION_LINK_REL); 0685 } 0686 0687 }