]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/Photos/PhotoFeed.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / Photos / PhotoFeed.php
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 Photos
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
22  */
23
24 /**
25  * @see Zend_Gdata_Photos
26  */
27 require_once 'Zend/Gdata/Photos.php';
28
29 /**
30  * @see Zend_Gdata_Feed
31  */
32 require_once 'Zend/Gdata/Feed.php';
33
34 /**
35  * @see Zend_Gdata_Photos_PhotoEntry
36  */
37 require_once 'Zend/Gdata/Photos/PhotoEntry.php';
38
39 /**
40  * Data model for a collection of photo entries, usually
41  * provided by the Picasa servers.
42  *
43  * For information on requesting this feed from a server, see the
44  * service class, Zend_Gdata_Photos.
45  *
46  * @category   Zend
47  * @package    Zend_Gdata
48  * @subpackage Photos
49  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
50  * @license    http://framework.zend.com/license/new-bsd     New BSD License
51  */
52 class Zend_Gdata_Photos_PhotoFeed extends Zend_Gdata_Feed
53 {
54
55     /**
56      * gphoto:id element
57      *
58      * @var Zend_Gdata_Photos_Extension_Id
59      */
60     protected $_gphotoId = null;
61
62     /**
63      * gphoto:albumid element
64      *
65      * @var Zend_Gdata_Photos_Extension_AlbumId
66      */
67     protected $_gphotoAlbumId = null;
68
69     /**
70      * gphoto:version element
71      *
72      * @var Zend_Gdata_Photos_Extension_Version
73      */
74     protected $_gphotoVersion = null;
75
76     /**
77      * gphoto:width element
78      *
79      * @var Zend_Gdata_Photos_Extension_Width
80      */
81     protected $_gphotoWidth = null;
82
83     /**
84      * gphoto:height element
85      *
86      * @var Zend_Gdata_Photos_Extension_Height
87      */
88     protected $_gphotoHeight = null;
89
90     /**
91      * gphoto:size element
92      *
93      * @var Zend_Gdata_Photos_Extension_Size
94      */
95     protected $_gphotoSize = null;
96
97     /**
98      * gphoto:client element
99      *
100      * @var Zend_Gdata_Photos_Extension_Client
101      */
102     protected $_gphotoClient = null;
103
104     /**
105      * gphoto:checksum element
106      *
107      * @var Zend_Gdata_Photos_Extension_Checksum
108      */
109     protected $_gphotoChecksum = null;
110
111     /**
112      * gphoto:timestamp element
113      *
114      * @var Zend_Gdata_Photos_Extension_Timestamp
115      */
116     protected $_gphotoTimestamp = null;
117
118     /**
119      * gphoto:commentCount element
120      *
121      * @var Zend_Gdata_Photos_Extension_CommentCount
122      */
123     protected $_gphotoCommentCount = null;
124
125     /**
126      * gphoto:commentingEnabled element
127      *
128      * @var Zend_Gdata_Photos_Extension_CommentingEnabled
129      */
130     protected $_gphotoCommentingEnabled = null;
131
132     /**
133      * media:group element
134      *
135      * @var Zend_Gdata_Media_Extension_MediaGroup
136      */
137     protected $_mediaGroup = null;
138
139     protected $_entryClassName = 'Zend_Gdata_Photos_PhotoEntry';
140     protected $_feedClassName = 'Zend_Gdata_Photos_PhotoFeed';
141
142     protected $_entryKindClassMapping = array(
143         'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
144         'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
145     );
146
147     public function __construct($element = null)
148     {
149         $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
150         parent::__construct($element);
151     }
152
153     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
154     {
155         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
156         if ($this->_gphotoId != null) {
157             $element->appendChild($this->_gphotoId->getDOM($element->ownerDocument));
158         }
159         if ($this->_gphotoVersion != null) {
160             $element->appendChild($this->_gphotoVersion->getDOM($element->ownerDocument));
161         }
162         if ($this->_gphotoWidth != null) {
163             $element->appendChild($this->_gphotoWidth->getDOM($element->ownerDocument));
164         }
165         if ($this->_gphotoHeight != null) {
166             $element->appendChild($this->_gphotoHeight->getDOM($element->ownerDocument));
167         }
168         if ($this->_gphotoSize != null) {
169             $element->appendChild($this->_gphotoSize->getDOM($element->ownerDocument));
170         }
171         if ($this->_gphotoClient != null) {
172             $element->appendChild($this->_gphotoClient->getDOM($element->ownerDocument));
173         }
174         if ($this->_gphotoChecksum != null) {
175             $element->appendChild($this->_gphotoChecksum->getDOM($element->ownerDocument));
176         }
177         if ($this->_gphotoTimestamp != null) {
178             $element->appendChild($this->_gphotoTimestamp->getDOM($element->ownerDocument));
179         }
180         if ($this->_gphotoCommentingEnabled != null) {
181             $element->appendChild($this->_gphotoCommentingEnabled->getDOM($element->ownerDocument));
182         }
183         if ($this->_gphotoCommentCount != null) {
184             $element->appendChild($this->_gphotoCommentCount->getDOM($element->ownerDocument));
185         }
186         if ($this->_mediaGroup != null) {
187             $element->appendChild($this->_mediaGroup->getDOM($element->ownerDocument));
188         }
189
190         return $element;
191     }
192
193     protected function takeChildFromDOM($child)
194     {
195         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
196
197         switch ($absoluteNodeName) {
198             case $this->lookupNamespace('gphoto') . ':' . 'id';
199                 $id = new Zend_Gdata_Photos_Extension_Id();
200                 $id->transferFromDOM($child);
201                 $this->_gphotoId = $id;
202                 break;
203             case $this->lookupNamespace('gphoto') . ':' . 'version';
204                 $version = new Zend_Gdata_Photos_Extension_Version();
205                 $version->transferFromDOM($child);
206                 $this->_gphotoVersion = $version;
207                 break;
208             case $this->lookupNamespace('gphoto') . ':' . 'albumid';
209                 $albumid = new Zend_Gdata_Photos_Extension_AlbumId();
210                 $albumid->transferFromDOM($child);
211                 $this->_gphotoAlbumId = $albumid;
212                 break;
213             case $this->lookupNamespace('gphoto') . ':' . 'width';
214                 $width = new Zend_Gdata_Photos_Extension_Width();
215                 $width->transferFromDOM($child);
216                 $this->_gphotoWidth = $width;
217                 break;
218             case $this->lookupNamespace('gphoto') . ':' . 'height';
219                 $height = new Zend_Gdata_Photos_Extension_Height();
220                 $height->transferFromDOM($child);
221                 $this->_gphotoHeight = $height;
222                 break;
223             case $this->lookupNamespace('gphoto') . ':' . 'size';
224                 $size = new Zend_Gdata_Photos_Extension_Size();
225                 $size->transferFromDOM($child);
226                 $this->_gphotoSize = $size;
227                 break;
228             case $this->lookupNamespace('gphoto') . ':' . 'client';
229                 $client = new Zend_Gdata_Photos_Extension_Client();
230                 $client->transferFromDOM($child);
231                 $this->_gphotoClient = $client;
232                 break;
233             case $this->lookupNamespace('gphoto') . ':' . 'checksum';
234                 $checksum = new Zend_Gdata_Photos_Extension_Checksum();
235                 $checksum->transferFromDOM($child);
236                 $this->_gphotoChecksum = $checksum;
237                 break;
238             case $this->lookupNamespace('gphoto') . ':' . 'timestamp';
239                 $timestamp = new Zend_Gdata_Photos_Extension_Timestamp();
240                 $timestamp->transferFromDOM($child);
241                 $this->_gphotoTimestamp = $timestamp;
242                 break;
243             case $this->lookupNamespace('gphoto') . ':' . 'commentingEnabled';
244                 $commentingEnabled = new Zend_Gdata_Photos_Extension_CommentingEnabled();
245                 $commentingEnabled->transferFromDOM($child);
246                 $this->_gphotoCommentingEnabled = $commentingEnabled;
247                 break;
248             case $this->lookupNamespace('gphoto') . ':' . 'commentCount';
249                 $commentCount = new Zend_Gdata_Photos_Extension_CommentCount();
250                 $commentCount->transferFromDOM($child);
251                 $this->_gphotoCommentCount = $commentCount;
252                 break;
253             case $this->lookupNamespace('media') . ':' . 'group';
254                 $mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
255                 $mediaGroup->transferFromDOM($child);
256                 $this->_mediaGroup = $mediaGroup;
257                 break;
258             case $this->lookupNamespace('atom') . ':' . 'entry':
259                 $entryClassName = $this->_entryClassName;
260                 $tmpEntry = new Zend_Gdata_App_Entry($child);
261                 $categories = $tmpEntry->getCategory();
262                 foreach ($categories as $category) {
263                     if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
264                         $this->_entryKindClassMapping[$category->term] != "") {
265                             $entryClassName = $this->_entryKindClassMapping[$category->term];
266                             break;
267                     } else {
268                         require_once 'Zend/Gdata/App/Exception.php';
269                         throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
270                     }
271                 }
272
273                 $newEntry = new $entryClassName($child);
274                 $newEntry->setHttpClient($this->getHttpClient());
275                 $this->_entry[] = $newEntry;
276                 break;
277             default:
278                 parent::takeChildFromDOM($child);
279                 break;
280         }
281     }
282
283     /**
284      * Get the value for this element's gphoto:id attribute.
285      *
286      * @see setGphotoId
287      * @return string The requested attribute.
288      */
289     public function getGphotoId()
290     {
291         return $this->_gphotoId;
292     }
293
294     /**
295      * Set the value for this element's gphoto:id attribute.
296      *
297      * @param string $value The desired value for this attribute.
298      * @return Zend_Gdata_Photos_Extension_Id The element being modified.
299      */
300     public function setGphotoId($value)
301     {
302         $this->_gphotoId = $value;
303         return $this;
304     }
305
306     /**
307      * Get the value for this element's gphoto:version attribute.
308      *
309      * @see setGphotoVersion
310      * @return string The requested attribute.
311      */
312     public function getGphotoVersion()
313     {
314         return $this->_gphotoVersion;
315     }
316
317     /**
318      * Set the value for this element's gphoto:version attribute.
319      *
320      * @param string $value The desired value for this attribute.
321      * @return Zend_Gdata_Photos_Extension_Version The element being modified.
322      */
323     public function setGphotoVersion($value)
324     {
325         $this->_gphotoVersion = $value;
326         return $this;
327     }
328
329     /**
330      * Get the value for this element's gphoto:albumid attribute.
331      *
332      * @see setGphotoAlbumId
333      * @return string The requested attribute.
334      */
335     public function getGphotoAlbumId()
336     {
337         return $this->_gphotoAlbumId;
338     }
339
340     /**
341      * Set the value for this element's gphoto:albumid attribute.
342      *
343      * @param string $value The desired value for this attribute.
344      * @return Zend_Gdata_Photos_Extension_AlbumId The element being modified.
345      */
346     public function setGphotoAlbumId($value)
347     {
348         $this->_gphotoAlbumId = $value;
349         return $this;
350     }
351
352     /**
353      * Get the value for this element's gphoto:width attribute.
354      *
355      * @see setGphotoWidth
356      * @return string The requested attribute.
357      */
358     public function getGphotoWidth()
359     {
360         return $this->_gphotoWidth;
361     }
362
363     /**
364      * Set the value for this element's gphoto:width attribute.
365      *
366      * @param string $value The desired value for this attribute.
367      * @return Zend_Gdata_Photos_Extension_Width The element being modified.
368      */
369     public function setGphotoWidth($value)
370     {
371         $this->_gphotoWidth = $value;
372         return $this;
373     }
374
375     /**
376      * Get the value for this element's gphoto:height attribute.
377      *
378      * @see setGphotoHeight
379      * @return string The requested attribute.
380      */
381     public function getGphotoHeight()
382     {
383         return $this->_gphotoHeight;
384     }
385
386     /**
387      * Set the value for this element's gphoto:height attribute.
388      *
389      * @param string $value The desired value for this attribute.
390      * @return Zend_Gdata_Photos_Extension_Height The element being modified.
391      */
392     public function setGphotoHeight($value)
393     {
394         $this->_gphotoHeight = $value;
395         return $this;
396     }
397
398     /**
399      * Get the value for this element's gphoto:size attribute.
400      *
401      * @see setGphotoSize
402      * @return string The requested attribute.
403      */
404     public function getGphotoSize()
405     {
406         return $this->_gphotoSize;
407     }
408
409     /**
410      * Set the value for this element's gphoto:size attribute.
411      *
412      * @param string $value The desired value for this attribute.
413      * @return Zend_Gdata_Photos_Extension_Size The element being modified.
414      */
415     public function setGphotoSize($value)
416     {
417         $this->_gphotoSize = $value;
418         return $this;
419     }
420
421     /**
422      * Get the value for this element's gphoto:client attribute.
423      *
424      * @see setGphotoClient
425      * @return string The requested attribute.
426      */
427     public function getGphotoClient()
428     {
429         return $this->_gphotoClient;
430     }
431
432     /**
433      * Set the value for this element's gphoto:client attribute.
434      *
435      * @param string $value The desired value for this attribute.
436      * @return Zend_Gdata_Photos_Extension_Client The element being modified.
437      */
438     public function setGphotoClient($value)
439     {
440         $this->_gphotoClient = $value;
441         return $this;
442     }
443
444     /**
445      * Get the value for this element's gphoto:checksum attribute.
446      *
447      * @see setGphotoChecksum
448      * @return string The requested attribute.
449      */
450     public function getGphotoChecksum()
451     {
452         return $this->_gphotoChecksum;
453     }
454
455     /**
456      * Set the value for this element's gphoto:checksum attribute.
457      *
458      * @param string $value The desired value for this attribute.
459      * @return Zend_Gdata_Photos_Extension_Checksum The element being modified.
460      */
461     public function setGphotoChecksum($value)
462     {
463         $this->_gphotoChecksum = $value;
464         return $this;
465     }
466
467     /**
468      * Get the value for this element's gphoto:timestamp attribute.
469      *
470      * @see setGphotoTimestamp
471      * @return string The requested attribute.
472      */
473     public function getGphotoTimestamp()
474     {
475         return $this->_gphotoTimestamp;
476     }
477
478     /**
479      * Set the value for this element's gphoto:timestamp attribute.
480      *
481      * @param string $value The desired value for this attribute.
482      * @return Zend_Gdata_Photos_Extension_Timestamp The element being modified.
483      */
484     public function setGphotoTimestamp($value)
485     {
486         $this->_gphotoTimestamp = $value;
487         return $this;
488     }
489
490     /**
491      * Get the value for this element's gphoto:commentCount attribute.
492      *
493      * @see setGphotoCommentCount
494      * @return string The requested attribute.
495      */
496     public function getGphotoCommentCount()
497     {
498         return $this->_gphotoCommentCount;
499     }
500
501     /**
502      * Set the value for this element's gphoto:commentCount attribute.
503      *
504      * @param string $value The desired value for this attribute.
505      * @return Zend_Gdata_Photos_Extension_CommentCount The element being modified.
506      */
507     public function setGphotoCommentCount($value)
508     {
509         $this->_gphotoCommentCount = $value;
510         return $this;
511     }
512
513     /**
514      * Get the value for this element's gphoto:commentingEnabled attribute.
515      *
516      * @see setGphotoCommentingEnabled
517      * @return string The requested attribute.
518      */
519     public function getGphotoCommentingEnabled()
520     {
521         return $this->_gphotoCommentingEnabled;
522     }
523
524     /**
525      * Set the value for this element's gphoto:commentingEnabled attribute.
526      *
527      * @param string $value The desired value for this attribute.
528      * @return Zend_Gdata_Photos_Extension_CommentingEnabled The element being modified.
529      */
530     public function setGphotoCommentingEnabled($value)
531     {
532         $this->_gphotoCommentingEnabled = $value;
533         return $this;
534     }
535
536     /**
537      * Get the value for this element's media:group attribute.
538      *
539      * @see setMediaGroup
540      * @return string The requested attribute.
541      */
542     public function getMediaGroup()
543     {
544         return $this->_mediaGroup;
545     }
546
547     /**
548      * Set the value for this element's media:group attribute.
549      *
550      * @param string $value The desired value for this attribute.
551      * @return Zend_Gdata_Media_Extension_MediaGroup The element being modified.
552      */
553     public function setMediaGroup($value)
554     {
555         $this->_mediaGroup = $value;
556         return $this;
557     }
558
559 }