source: extensions/Google2Piwigo/include/Zend/Gdata/Books/VolumeEntry.php @ 17475

Last change on this file since 17475 was 17475, checked in by mistic100, 12 years ago

new extension: Google2Piwigo

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-2012 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license    http://framework.zend.com/license/new-bsd     New BSD License
21 * @version    $Id: VolumeEntry.php 24594 2012-01-05 21:27:01Z matthew $
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-2012 Zend Technologies USA Inc. (http://www.zend.com)
106 * @license    http://framework.zend.com/license/new-bsd     New BSD License
107 */
108class Zend_Gdata_Books_VolumeEntry extends Zend_Gdata_Entry
109{
110
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';
115
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;
130
131    /**
132     * Constructor for Zend_Gdata_Books_VolumeEntry which
133     * Describes an entry in a feed of Book Search volumes
134     *
135     * @param DOMElement $element (optional) DOMElement from which this
136     *          object should be constructed.
137     */
138    public function __construct($element = null)
139    {
140        $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
141        parent::__construct($element);
142    }
143
144    /**
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.
149     *
150     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
151     * @return DOMElement The DOMElement representing this element and all
152     * child properties.
153     */
154    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
155    {
156        $element = parent::getDOM($doc);
157        if ($this->_creators !== null) {
158            foreach ($this->_creators as $creators) {
159                $element->appendChild($creators->getDOM(
160                    $element->ownerDocument));
161            }
162        }
163        if ($this->_dates !== null) {
164            foreach ($this->_dates as $dates) {
165                $element->appendChild($dates->getDOM($element->ownerDocument));
166            }
167        }
168        if ($this->_descriptions !== null) {
169            foreach ($this->_descriptions as $descriptions) {
170                $element->appendChild($descriptions->getDOM(
171                    $element->ownerDocument));
172            }
173        }
174        if ($this->_formats !== null) {
175            foreach ($this->_formats as $formats) {
176                $element->appendChild($formats->getDOM(
177                    $element->ownerDocument));
178            }
179        }
180        if ($this->_identifiers !== null) {
181            foreach ($this->_identifiers as $identifiers) {
182                $element->appendChild($identifiers->getDOM(
183                    $element->ownerDocument));
184            }
185        }
186        if ($this->_languages !== null) {
187            foreach ($this->_languages as $languages) {
188                $element->appendChild($languages->getDOM(
189                    $element->ownerDocument));
190            }
191        }
192        if ($this->_publishers !== null) {
193            foreach ($this->_publishers as $publishers) {
194                $element->appendChild($publishers->getDOM(
195                    $element->ownerDocument));
196            }
197        }
198        if ($this->_subjects !== null) {
199            foreach ($this->_subjects as $subjects) {
200                $element->appendChild($subjects->getDOM(
201                    $element->ownerDocument));
202            }
203        }
204        if ($this->_titles !== null) {
205            foreach ($this->_titles as $titles) {
206                $element->appendChild($titles->getDOM($element->ownerDocument));
207            }
208        }
209        if ($this->_comments !== null) {
210            $element->appendChild($this->_comments->getDOM(
211                $element->ownerDocument));
212        }
213        if ($this->_embeddability !== null) {
214            $element->appendChild($this->_embeddability->getDOM(
215                $element->ownerDocument));
216        }
217        if ($this->_rating !== null) {
218            $element->appendChild($this->_rating->getDOM(
219                $element->ownerDocument));
220        }
221        if ($this->_review !== null) {
222            $element->appendChild($this->_review->getDOM(
223                $element->ownerDocument));
224        }
225        if ($this->_viewability !== null) {
226            $element->appendChild($this->_viewability->getDOM(
227                $element->ownerDocument));
228        }
229        return $element;
230    }
231
232    /**
233     * Creates individual objects of the appropriate type and stores
234     * them in this object based upon DOM data.
235     *
236     * @param DOMNode $child The DOMNode to process.
237     */
238    protected function takeChildFromDOM($child)
239    {
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;
315        }
316    }
317
318    /**
319     * Returns the Comments class
320     *
321     * @return Zend_Gdata_Extension_Comments|null The comments
322     */
323    public function getComments()
324    {
325        return $this->_comments;
326    }
327
328    /**
329     * Returns the creators
330     *
331     * @return array The creators
332     */
333    public function getCreators()
334    {
335        return $this->_creators;
336    }
337
338    /**
339     * Returns the dates
340     *
341     * @return array The dates
342     */
343    public function getDates()
344    {
345        return $this->_dates;
346    }
347
348    /**
349     * Returns the descriptions
350     *
351     * @return array The descriptions
352     */
353    public function getDescriptions()
354    {
355        return $this->_descriptions;
356    }
357
358    /**
359     * Returns the embeddability
360     *
361     * @return Zend_Gdata_Books_Extension_Embeddability|null The embeddability
362     */
363    public function getEmbeddability()
364    {
365        return $this->_embeddability;
366    }
367
368    /**
369     * Returns the formats
370     *
371     * @return array The formats
372     */
373    public function getFormats()
374    {
375        return $this->_formats;
376    }
377
378    /**
379     * Returns the identifiers
380     *
381     * @return array The identifiers
382     */
383    public function getIdentifiers()
384    {
385        return $this->_identifiers;
386    }
387
388    /**
389     * Returns the languages
390     *
391     * @return array The languages
392     */
393    public function getLanguages()
394    {
395        return $this->_languages;
396    }
397
398    /**
399     * Returns the publishers
400     *
401     * @return array The publishers
402     */
403    public function getPublishers()
404    {
405        return $this->_publishers;
406    }
407
408    /**
409     * Returns the rating
410     *
411     * @return Zend_Gdata_Extension_Rating|null The rating
412     */
413    public function getRating()
414    {
415        return $this->_rating;
416    }
417
418    /**
419     * Returns the review
420     *
421     * @return Zend_Gdata_Books_Extension_Review|null The review
422     */
423    public function getReview()
424    {
425        return $this->_review;
426    }
427
428    /**
429     * Returns the subjects
430     *
431     * @return array The subjects
432     */
433    public function getSubjects()
434    {
435        return $this->_subjects;
436    }
437
438    /**
439     * Returns the titles
440     *
441     * @return array The titles
442     */
443    public function getTitles()
444    {
445        return $this->_titles;
446    }
447
448    /**
449     * Returns the viewability
450     *
451     * @return Zend_Gdata_Books_Extension_Viewability|null The viewability
452     */
453    public function getViewability()
454    {
455        return $this->_viewability;
456    }
457
458    /**
459     * Sets the Comments class
460     *
461     * @param Zend_Gdata_Extension_Comments|null $comments Comments class
462     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
463     */
464    public function setComments($comments)
465    {
466        $this->_comments = $comments;
467        return $this;
468    }
469
470    /**
471     * Sets the creators
472     *
473     * @param array $creators Creators|null
474     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
475     */
476    public function setCreators($creators)
477    {
478        $this->_creators = $creators;
479        return $this;
480    }
481
482    /**
483     * Sets the dates
484     *
485     * @param array $dates dates
486     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
487     */
488    public function setDates($dates)
489    {
490        $this->_dates = $dates;
491        return $this;
492    }
493
494    /**
495     * Sets the descriptions
496     *
497     * @param array $descriptions descriptions
498     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
499     */
500    public function setDescriptions($descriptions)
501    {
502        $this->_descriptions = $descriptions;
503        return $this;
504    }
505
506    /**
507     * Sets the embeddability
508     *
509     * @param Zend_Gdata_Books_Extension_Embeddability|null $embeddability
510     *        embeddability
511     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
512     */
513    public function setEmbeddability($embeddability)
514    {
515        $this->_embeddability = $embeddability;
516        return $this;
517    }
518
519    /**
520     * Sets the formats
521     *
522     * @param array $formats formats
523     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
524     */
525    public function setFormats($formats)
526    {
527        $this->_formats = $formats;
528        return $this;
529    }
530
531    /**
532     * Sets the identifiers
533     *
534     * @param array $identifiers identifiers
535     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
536     */
537    public function setIdentifiers($identifiers)
538    {
539        $this->_identifiers = $identifiers;
540        return $this;
541    }
542
543    /**
544     * Sets the languages
545     *
546     * @param array $languages languages
547     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
548     */
549    public function setLanguages($languages)
550    {
551        $this->_languages = $languages;
552        return $this;
553    }
554
555    /**
556     * Sets the publishers
557     *
558     * @param array $publishers publishers
559     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
560     */
561    public function setPublishers($publishers)
562    {
563        $this->_publishers = $publishers;
564        return $this;
565    }
566
567    /**
568     * Sets the rating
569     *
570     * @param Zend_Gdata_Extension_Rating|null $rating rating
571     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
572     */
573    public function setRating($rating)
574    {
575        $this->_rating = $rating;
576        return $this;
577    }
578
579    /**
580     * Sets the review
581     *
582     * @param Zend_Gdata_Books_Extension_Review|null $review review
583     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
584     */
585    public function setReview($review)
586    {
587        $this->_review = $review;
588        return $this;
589    }
590
591    /**
592     * Sets the subjects
593     *
594     * @param array $subjects subjects
595     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
596     */
597    public function setSubjects($subjects)
598    {
599        $this->_subjects = $subjects;
600        return $this;
601    }
602
603    /**
604     * Sets the titles
605     *
606     * @param array $titles titles
607     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
608     */
609    public function setTitles($titles)
610    {
611        $this->_titles = $titles;
612        return $this;
613    }
614
615    /**
616     * Sets the viewability
617     *
618     * @param Zend_Gdata_Books_Extension_Viewability|null $viewability
619     *        viewability
620     * @return Zend_Gdata_Books_VolumeEntry Provides a fluent interface
621     */
622    public function setViewability($viewability)
623    {
624        $this->_viewability = $viewability;
625        return $this;
626    }
627
628
629    /**
630     * Gets the volume ID based upon the atom:id value
631     *
632     * @return string The volume ID
633     * @throws Zend_Gdata_App_Exception
634     */
635    public function getVolumeId()
636    {
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);
644        }
645    }
646
647    /**
648     * Gets the thumbnail link
649     *
650     * @return Zend_Gdata_App_Extension_link|null The thumbnail link
651     */
652    public function getThumbnailLink()
653    {
654        return $this->getLink(self::THUMBNAIL_LINK_REL);
655    }
656
657    /**
658     * Gets the preview link
659     *
660     * @return Zend_Gdata_App_Extension_Link|null The preview link
661     */
662    public function getPreviewLink()
663    {
664        return $this->getLink(self::PREVIEW_LINK_REL);
665    }
666
667    /**
668     * Gets the info link
669     *
670     * @return Zend_Gdata_App_Extension_Link|null The info link
671     */
672    public function getInfoLink()
673    {
674        return $this->getLink(self::INFO_LINK_REL);
675    }
676
677    /**
678     * Gets the annotations link
679     *
680     * @return Zend_Gdata_App_Extension_Link|null The annotations link
681     */
682    public function getAnnotationLink()
683    {
684        return $this->getLink(self::ANNOTATION_LINK_REL);
685    }
686
687}
Note: See TracBrowser for help on using the repository browser.