/zf/library/Zend/Gdata/Books/VolumeEntry.php

http://github.com/eryx/php-framework-benchmark · PHP · 687 lines · 351 code · 57 blank · 279 comment · 17 complexity · 4b1e38076b9a8b16403288ff3afd941e MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Books
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: VolumeEntry.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @see Zend_Gdata_Entry
  24. */
  25. require_once 'Zend/Gdata/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Extension_Comments
  28. */
  29. require_once 'Zend/Gdata/Extension/Comments.php';
  30. /**
  31. * @see Zend_Gdata_DublinCore_Extension_Creator
  32. */
  33. require_once 'Zend/Gdata/DublinCore/Extension/Creator.php';
  34. /**
  35. * @see Zend_Gdata_DublinCore_Extension_Date
  36. */
  37. require_once 'Zend/Gdata/DublinCore/Extension/Date.php';
  38. /**
  39. * @see Zend_Gdata_DublinCore_Extension_Description
  40. */
  41. require_once 'Zend/Gdata/DublinCore/Extension/Description.php';
  42. /**
  43. * @see Zend_Gdata_Books_Extension_Embeddability
  44. */
  45. require_once 'Zend/Gdata/Books/Extension/Embeddability.php';
  46. /**
  47. * @see Zend_Gdata_DublinCore_Extension_Format
  48. */
  49. require_once 'Zend/Gdata/DublinCore/Extension/Format.php';
  50. /**
  51. * @see Zend_Gdata_DublinCore_Extension_Identifier
  52. */
  53. require_once 'Zend/Gdata/DublinCore/Extension/Identifier.php';
  54. /**
  55. * @see Zend_Gdata_DublinCore_Extension_Language
  56. */
  57. require_once 'Zend/Gdata/DublinCore/Extension/Language.php';
  58. /**
  59. * @see Zend_Gdata_DublinCore_Extension_Publisher
  60. */
  61. require_once 'Zend/Gdata/DublinCore/Extension/Publisher.php';
  62. /**
  63. * @see Zend_Gdata_Extension_Rating
  64. */
  65. require_once 'Zend/Gdata/Extension/Rating.php';
  66. /**
  67. * @see Zend_Gdata_Books_Extension_Review
  68. */
  69. require_once 'Zend/Gdata/Books/Extension/Review.php';
  70. /**
  71. * @see Zend_Gdata_DublinCore_Extension_Subject
  72. */
  73. require_once 'Zend/Gdata/DublinCore/Extension/Subject.php';
  74. /**
  75. * @see Zend_Gdata_DublinCore_Extension_Title
  76. */
  77. require_once 'Zend/Gdata/DublinCore/Extension/Title.php';
  78. /**
  79. * @see Zend_Gdata_Books_Extension_Viewability
  80. */
  81. require_once 'Zend/Gdata/Books/Extension/Viewability.php';
  82. /**
  83. * Describes an entry in a feed of Book Search volumes
  84. *
  85. * @category Zend
  86. * @package Zend_Gdata
  87. * @subpackage Books
  88. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  89. * @license http://framework.zend.com/license/new-bsd New BSD License
  90. */
  91. class Zend_Gdata_Books_VolumeEntry extends Zend_Gdata_Entry
  92. {
  93. const THUMBNAIL_LINK_REL = 'http://schemas.google.com/books/2008/thumbnail';
  94. const PREVIEW_LINK_REL = 'http://schemas.google.com/books/2008/preview';
  95. const INFO_LINK_REL = 'http://schemas.google.com/books/2008/info';
  96. const ANNOTATION_LINK_REL = 'http://schemas.google.com/books/2008/annotation';
  97. protected $_comments = null;
  98. protected $_creators = array();
  99. protected $_dates = array();
  100. protected $_descriptions = array();
  101. protected $_embeddability = null;
  102. protected $_formats = array();
  103. protected $_identifiers = array();
  104. protected $_languages = array();
  105. protected $_publishers = array();
  106. protected $_rating = null;
  107. protected $_review = null;
  108. protected $_subjects = array();
  109. protected $_titles = array();
  110. protected $_viewability = null;
  111. /**
  112. * Constructor for Zend_Gdata_Books_VolumeEntry which
  113. * Describes an entry in a feed of Book Search volumes
  114. *
  115. * @param DOMElement $element (optional) DOMElement from which this
  116. * object should be constructed.
  117. */
  118. public function __construct($element = null)
  119. {
  120. $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
  121. parent::__construct($element);
  122. }
  123. /**
  124. * Retrieves DOMElement which corresponds to this element and all
  125. * child properties. This is used to build this object back into a DOM
  126. * and eventually XML text for sending to the server upon updates, or
  127. * for application storage/persistance.
  128. *
  129. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  130. * @return DOMElement The DOMElement representing this element and all
  131. * child properties.
  132. */
  133. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  134. {
  135. $element = parent::getDOM($doc);
  136. if ($this->_creators !== null) {
  137. foreach ($this->_creators as $creators) {
  138. $element->appendChild($creators->getDOM(
  139. $element->ownerDocument));
  140. }
  141. }
  142. if ($this->_dates !== null) {
  143. foreach ($this->_dates as $dates) {
  144. $element->appendChild($dates->getDOM($element->ownerDocument));
  145. }
  146. }
  147. if ($this->_descriptions !== null) {
  148. foreach ($this->_descriptions as $descriptions) {
  149. $element->appendChild($descriptions->getDOM(
  150. $element->ownerDocument));
  151. }
  152. }
  153. if ($this->_formats !== null) {
  154. foreach ($this->_formats as $formats) {
  155. $element->appendChild($formats->getDOM(
  156. $element->ownerDocument));
  157. }
  158. }
  159. if ($this->_identifiers !== null) {
  160. foreach ($this->_identifiers as $identifiers) {
  161. $element->appendChild($identifiers->getDOM(
  162. $element->ownerDocument));
  163. }
  164. }
  165. if ($this->_languages !== null) {
  166. foreach ($this->_languages as $languages) {
  167. $element->appendChild($languages->getDOM(
  168. $element->ownerDocument));
  169. }
  170. }
  171. if ($this->_publishers !== null) {
  172. foreach ($this->_publishers as $publishers) {
  173. $element->appendChild($publishers->getDOM(
  174. $element->ownerDocument));
  175. }
  176. }
  177. if ($this->_subjects !== null) {
  178. foreach ($this->_subjects as $subjects) {
  179. $element->appendChild($subjects->getDOM(
  180. $element->ownerDocument));
  181. }
  182. }
  183. if ($this->_titles !== null) {
  184. foreach ($this->_titles as $titles) {
  185. $element->appendChild($titles->getDOM($element->ownerDocument));
  186. }
  187. }
  188. if ($this->_comments !== null) {
  189. $element->appendChild($this->_comments->getDOM(
  190. $element->ownerDocument));
  191. }
  192. if ($this->_embeddability !== null) {
  193. $element->appendChild($this->_embeddability->getDOM(
  194. $element->ownerDocument));
  195. }
  196. if ($this->_rating !== null) {
  197. $element->appendChild($this->_rating->getDOM(
  198. $element->ownerDocument));
  199. }
  200. if ($this->_review !== null) {
  201. $element->appendChild($this->_review->getDOM(
  202. $element->ownerDocument));
  203. }
  204. if ($this->_viewability !== null) {
  205. $element->appendChild($this->_viewability->getDOM(
  206. $element->ownerDocument));
  207. }
  208. return $element;
  209. }
  210. /**
  211. * Creates individual objects of the appropriate type and stores
  212. * them in this object based upon DOM data.
  213. *
  214. * @param DOMNode $child The DOMNode to process.
  215. */
  216. protected function takeChildFromDOM($child)
  217. {
  218. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  219. switch ($absoluteNodeName) {
  220. case $this->lookupNamespace('dc') . ':' . 'creator':
  221. $creators = new Zend_Gdata_DublinCore_Extension_Creator();
  222. $creators->transferFromDOM($child);
  223. $this->_creators[] = $creators;
  224. break;
  225. case $this->lookupNamespace('dc') . ':' . 'date':
  226. $dates = new Zend_Gdata_DublinCore_Extension_Date();
  227. $dates->transferFromDOM($child);
  228. $this->_dates[] = $dates;
  229. break;
  230. case $this->lookupNamespace('dc') . ':' . 'description':
  231. $descriptions = new Zend_Gdata_DublinCore_Extension_Description();
  232. $descriptions->transferFromDOM($child);
  233. $this->_descriptions[] = $descriptions;
  234. break;
  235. case $this->lookupNamespace('dc') . ':' . 'format':
  236. $formats = new Zend_Gdata_DublinCore_Extension_Format();
  237. $formats->transferFromDOM($child);
  238. $this->_formats[] = $formats;
  239. break;
  240. case $this->lookupNamespace('dc') . ':' . 'identifier':
  241. $identifiers = new Zend_Gdata_DublinCore_Extension_Identifier();
  242. $identifiers->transferFromDOM($child);
  243. $this->_identifiers[] = $identifiers;
  244. break;
  245. case $this->lookupNamespace('dc') . ':' . 'language':
  246. $languages = new Zend_Gdata_DublinCore_Extension_Language();
  247. $languages->transferFromDOM($child);
  248. $this->_languages[] = $languages;
  249. break;
  250. case $this->lookupNamespace('dc') . ':' . 'publisher':
  251. $publishers = new Zend_Gdata_DublinCore_Extension_Publisher();
  252. $publishers->transferFromDOM($child);
  253. $this->_publishers[] = $publishers;
  254. break;
  255. case $this->lookupNamespace('dc') . ':' . 'subject':
  256. $subjects = new Zend_Gdata_DublinCore_Extension_Subject();
  257. $subjects->transferFromDOM($child);
  258. $this->_subjects[] = $subjects;
  259. break;
  260. case $this->lookupNamespace('dc') . ':' . 'title':
  261. $titles = new Zend_Gdata_DublinCore_Extension_Title();
  262. $titles->transferFromDOM($child);
  263. $this->_titles[] = $titles;
  264. break;
  265. case $this->lookupNamespace('gd') . ':' . 'comments':
  266. $comments = new Zend_Gdata_Extension_Comments();
  267. $comments->transferFromDOM($child);
  268. $this->_comments = $comments;
  269. break;
  270. case $this->lookupNamespace('gbs') . ':' . 'embeddability':
  271. $embeddability = new Zend_Gdata_Books_Extension_Embeddability();
  272. $embeddability->transferFromDOM($child);
  273. $this->_embeddability = $embeddability;
  274. break;
  275. case $this->lookupNamespace('gd') . ':' . 'rating':
  276. $rating = new Zend_Gdata_Extension_Rating();
  277. $rating->transferFromDOM($child);
  278. $this->_rating = $rating;
  279. break;
  280. case $this->lookupNamespace('gbs') . ':' . 'review':
  281. $review = new Zend_Gdata_Books_Extension_Review();
  282. $review->transferFromDOM($child);
  283. $this->_review = $review;
  284. break;
  285. case $this->lookupNamespace('gbs') . ':' . 'viewability':
  286. $viewability = new Zend_Gdata_Books_Extension_Viewability();
  287. $viewability->transferFromDOM($child);
  288. $this->_viewability = $viewability;
  289. break;
  290. default:
  291. parent::takeChildFromDOM($child);
  292. break;
  293. }
  294. }
  295. /**
  296. * Returns the Comments class
  297. *
  298. * @return Zend_Gdata_Extension_Comments|null The comments
  299. */
  300. public function getComments()
  301. {
  302. return $this->_comments;
  303. }
  304. /**
  305. * Returns the creators
  306. *
  307. * @return array The creators
  308. */
  309. public function getCreators()
  310. {
  311. return $this->_creators;
  312. }
  313. /**
  314. * Returns the dates
  315. *
  316. * @return array The dates
  317. */
  318. public function getDates()
  319. {
  320. return $this->_dates;
  321. }
  322. /**
  323. * Returns the descriptions
  324. *
  325. * @return array The descriptions
  326. */
  327. public function getDescriptions()
  328. {
  329. return $this->_descriptions;
  330. }
  331. /**
  332. * Returns the embeddability
  333. *
  334. * @return Zend_Gdata_Books_Extension_Embeddability|null The embeddability
  335. */
  336. public function getEmbeddability()
  337. {
  338. return $this->_embeddability;
  339. }
  340. /**
  341. * Returns the formats
  342. *
  343. * @return array The formats
  344. */
  345. public function getFormats()
  346. {
  347. return $this->_formats;
  348. }
  349. /**
  350. * Returns the identifiers
  351. *
  352. * @return array The identifiers
  353. */
  354. public function getIdentifiers()
  355. {
  356. return $this->_identifiers;
  357. }
  358. /**
  359. * Returns the languages
  360. *
  361. * @return array The languages
  362. */
  363. public function getLanguages()
  364. {
  365. return $this->_languages;
  366. }
  367. /**
  368. * Returns the publishers
  369. *
  370. * @return array The publishers
  371. */
  372. public function getPublishers()
  373. {
  374. return $this->_publishers;
  375. }
  376. /**
  377. * Returns the rating
  378. *
  379. * @return Zend_Gdata_Extension_Rating|null The rating
  380. */
  381. public function getRating()
  382. {
  383. return $this->_rating;
  384. }
  385. /**
  386. * Returns the review
  387. *
  388. * @return Zend_Gdata_Books_Extension_Review|null The review
  389. */
  390. public function getReview()
  391. {
  392. return $this->_review;
  393. }
  394. /**
  395. * Returns the subjects
  396. *
  397. * @return array The subjects
  398. */
  399. public function getSubjects()
  400. {
  401. return $this->_subjects;
  402. }
  403. /**
  404. * Returns the titles
  405. *
  406. * @return array The titles
  407. */
  408. public function getTitles()
  409. {
  410. return $this->_titles;
  411. }
  412. /**
  413. * Returns the viewability
  414. *
  415. * @return Zend_Gdata_Books_Extension_Viewability|null The viewability
  416. */
  417. public function getViewability()
  418. {
  419. return $this->_viewability;
  420. }
  421. /**
  422. * Sets the Comments class
  423. *
  424. * @param Zend_Gdata_Extension_Comments|null $comments Comments class
  425. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  426. */
  427. public function setComments($comments)
  428. {
  429. $this->_comments = $comments;
  430. return $this;
  431. }
  432. /**
  433. * Sets the creators
  434. *
  435. * @param array $creators Creators|null
  436. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  437. */
  438. public function setCreators($creators)
  439. {
  440. $this->_creators = $creators;
  441. return $this;
  442. }
  443. /**
  444. * Sets the dates
  445. *
  446. * @param array $dates dates
  447. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  448. */
  449. public function setDates($dates)
  450. {
  451. $this->_dates = $dates;
  452. return $this;
  453. }
  454. /**
  455. * Sets the descriptions
  456. *
  457. * @param array $descriptions descriptions
  458. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  459. */
  460. public function setDescriptions($descriptions)
  461. {
  462. $this->_descriptions = $descriptions;
  463. return $this;
  464. }
  465. /**
  466. * Sets the embeddability
  467. *
  468. * @param Zend_Gdata_Books_Extension_Embeddability|null $embeddability
  469. * embeddability
  470. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  471. */
  472. public function setEmbeddability($embeddability)
  473. {
  474. $this->_embeddability = $embeddability;
  475. return $this;
  476. }
  477. /**
  478. * Sets the formats
  479. *
  480. * @param array $formats formats
  481. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  482. */
  483. public function setFormats($formats)
  484. {
  485. $this->_formats = $formats;
  486. return $this;
  487. }
  488. /**
  489. * Sets the identifiers
  490. *
  491. * @param array $identifiers identifiers
  492. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  493. */
  494. public function setIdentifiers($identifiers)
  495. {
  496. $this->_identifiers = $identifiers;
  497. return $this;
  498. }
  499. /**
  500. * Sets the languages
  501. *
  502. * @param array $languages languages
  503. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  504. */
  505. public function setLanguages($languages)
  506. {
  507. $this->_languages = $languages;
  508. return $this;
  509. }
  510. /**
  511. * Sets the publishers
  512. *
  513. * @param array $publishers publishers
  514. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  515. */
  516. public function setPublishers($publishers)
  517. {
  518. $this->_publishers = $publishers;
  519. return $this;
  520. }
  521. /**
  522. * Sets the rating
  523. *
  524. * @param Zend_Gdata_Extension_Rating|null $rating rating
  525. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  526. */
  527. public function setRating($rating)
  528. {
  529. $this->_rating = $rating;
  530. return $this;
  531. }
  532. /**
  533. * Sets the review
  534. *
  535. * @param Zend_Gdata_Books_Extension_Review|null $review review
  536. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  537. */
  538. public function setReview($review)
  539. {
  540. $this->_review = $review;
  541. return $this;
  542. }
  543. /**
  544. * Sets the subjects
  545. *
  546. * @param array $subjects subjects
  547. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  548. */
  549. public function setSubjects($subjects)
  550. {
  551. $this->_subjects = $subjects;
  552. return $this;
  553. }
  554. /**
  555. * Sets the titles
  556. *
  557. * @param array $titles titles
  558. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  559. */
  560. public function setTitles($titles)
  561. {
  562. $this->_titles = $titles;
  563. return $this;
  564. }
  565. /**
  566. * Sets the viewability
  567. *
  568. * @param Zend_Gdata_Books_Extension_Viewability|null $viewability
  569. * viewability
  570. * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
  571. */
  572. public function setViewability($viewability)
  573. {
  574. $this->_viewability = $viewability;
  575. return $this;
  576. }
  577. /**
  578. * Gets the volume ID based upon the atom:id value
  579. *
  580. * @return string The volume ID
  581. * @throws Zend_Gdata_App_Exception
  582. */
  583. public function getVolumeId()
  584. {
  585. $fullId = $this->getId()->getText();
  586. $position = strrpos($fullId, '/');
  587. if ($position === false) {
  588. require_once 'Zend/Gdata/App/Exception.php';
  589. throw new Zend_Gdata_App_Exception('Slash not found in atom:id');
  590. } else {
  591. return substr($fullId, strrpos($fullId,'/') + 1);
  592. }
  593. }
  594. /**
  595. * Gets the thumbnail link
  596. *
  597. * @return Zend_Gdata_App_Extension_link|null The thumbnail link
  598. */
  599. public function getThumbnailLink()
  600. {
  601. return $this->getLink(self::THUMBNAIL_LINK_REL);
  602. }
  603. /**
  604. * Gets the preview link
  605. *
  606. * @return Zend_Gdata_App_Extension_Link|null The preview link
  607. */
  608. public function getPreviewLink()
  609. {
  610. return $this->getLink(self::PREVIEW_LINK_REL);
  611. }
  612. /**
  613. * Gets the info link
  614. *
  615. * @return Zend_Gdata_App_Extension_Link|null The info link
  616. */
  617. public function getInfoLink()
  618. {
  619. return $this->getLink(self::INFO_LINK_REL);
  620. }
  621. /**
  622. * Gets the annotations link
  623. *
  624. * @return Zend_Gdata_App_Extension_Link|null The annotations link
  625. */
  626. public function getAnnotationLink()
  627. {
  628. return $this->getLink(self::ANNOTATION_LINK_REL);
  629. }
  630. }