source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Books/VolumeEntry.php@ 44

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