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

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 7.5 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 Photos
19 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23/**
24 * @see Zend_Gdata_Photos
25 */
26require_once 'Zend/Gdata/Photos.php';
27
28/**
29 * @see Zend_Gdata_Feed
30 */
31require_once 'Zend/Gdata/Feed.php';
32
33/**
34 * @see Zend_Gdata_Photos_UserEntry
35 */
36require_once 'Zend/Gdata/Photos/UserEntry.php';
37
38/**
39 * @see Zend_Gdata_Photos_AlbumEntry
40 */
41require_once 'Zend/Gdata/Photos/AlbumEntry.php';
42
43/**
44 * @see Zend_Gdata_Photos_PhotoEntry
45 */
46require_once 'Zend/Gdata/Photos/PhotoEntry.php';
47
48/**
49 * @see Zend_Gdata_Photos_TagEntry
50 */
51require_once 'Zend/Gdata/Photos/TagEntry.php';
52
53/**
54 * @see Zend_Gdata_Photos_CommentEntry
55 */
56require_once 'Zend/Gdata/Photos/CommentEntry.php';
57
58/**
59 * Data model for a collection of entries for a specific user, usually
60 * provided by the servers.
61 *
62 * For information on requesting this feed from a server, see the
63 * service class, Zend_Gdata_Photos.
64 *
65 * @category Zend
66 * @package Zend_Gdata
67 * @subpackage Photos
68 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
69 * @license http://framework.zend.com/license/new-bsd New BSD License
70 */
71class Zend_Gdata_Photos_UserFeed extends Zend_Gdata_Feed
72{
73
74 /**
75 * gphoto:user element
76 *
77 * @var Zend_Gdata_Photos_Extension_User
78 */
79 protected $_gphotoUser = null;
80
81 /**
82 * gphoto:thumbnail element
83 *
84 * @var Zend_Gdata_Photos_Extension_Thumbnail
85 */
86 protected $_gphotoThumbnail = null;
87
88 /**
89 * gphoto:nickname element
90 *
91 * @var Zend_Gdata_Photos_Extension_Nickname
92 */
93 protected $_gphotoNickname = null;
94
95 protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
96 protected $_feedClassName = 'Zend_Gdata_Photos_UserFeed';
97
98 protected $_entryKindClassMapping = array(
99 'http://schemas.google.com/photos/2007#album' => 'Zend_Gdata_Photos_AlbumEntry',
100 'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
101 'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
102 'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
103 );
104
105 public function __construct($element = null)
106 {
107 $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
108 parent::__construct($element);
109 }
110
111 /**
112 * Creates individual Entry objects of the appropriate type and
113 * stores them in the $_entry array based upon DOM data.
114 *
115 * @param DOMNode $child The DOMNode to process
116 */
117 protected function takeChildFromDOM($child)
118 {
119 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
120 switch ($absoluteNodeName) {
121 case $this->lookupNamespace('gphoto') . ':' . 'user';
122 $user = new Zend_Gdata_Photos_Extension_User();
123 $user->transferFromDOM($child);
124 $this->_gphotoUser = $user;
125 break;
126 case $this->lookupNamespace('gphoto') . ':' . 'nickname';
127 $nickname = new Zend_Gdata_Photos_Extension_Nickname();
128 $nickname->transferFromDOM($child);
129 $this->_gphotoNickname = $nickname;
130 break;
131 case $this->lookupNamespace('gphoto') . ':' . 'thumbnail';
132 $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
133 $thumbnail->transferFromDOM($child);
134 $this->_gphotoThumbnail = $thumbnail;
135 break;
136 case $this->lookupNamespace('atom') . ':' . 'entry':
137 $entryClassName = $this->_entryClassName;
138 $tmpEntry = new Zend_Gdata_App_Entry($child);
139 $categories = $tmpEntry->getCategory();
140 foreach ($categories as $category) {
141 if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
142 $this->_entryKindClassMapping[$category->term] != "") {
143 $entryClassName = $this->_entryKindClassMapping[$category->term];
144 break;
145 } else {
146 require_once 'Zend/Gdata/App/Exception.php';
147 throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
148 }
149 }
150
151 $newEntry = new $entryClassName($child);
152 $newEntry->setHttpClient($this->getHttpClient());
153 $this->_entry[] = $newEntry;
154 break;
155 default:
156 parent::takeChildFromDOM($child);
157 break;
158 }
159 }
160
161 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
162 {
163 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
164 if ($this->_gphotoUser != null) {
165 $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
166 }
167 if ($this->_gphotoNickname != null) {
168 $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
169 }
170 if ($this->_gphotoThumbnail != null) {
171 $element->appendChild($this->_gphotoThumbnail->getDOM($element->ownerDocument));
172 }
173
174 return $element;
175 }
176
177 /**
178 * Get the value for this element's gphoto:user attribute.
179 *
180 * @see setGphotoUser
181 * @return string The requested attribute.
182 */
183 public function getGphotoUser()
184 {
185 return $this->_gphotoUser;
186 }
187
188 /**
189 * Set the value for this element's gphoto:user attribute.
190 *
191 * @param string $value The desired value for this attribute.
192 * @return Zend_Gdata_Photos_Extension_User The element being modified.
193 */
194 public function setGphotoUser($value)
195 {
196 $this->_gphotoUser = $value;
197 return $this;
198 }
199
200 /**
201 * Get the value for this element's gphoto:nickname attribute.
202 *
203 * @see setGphotoNickname
204 * @return string The requested attribute.
205 */
206 public function getGphotoNickname()
207 {
208 return $this->_gphotoNickname;
209 }
210
211 /**
212 * Set the value for this element's gphoto:nickname attribute.
213 *
214 * @param string $value The desired value for this attribute.
215 * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
216 */
217 public function setGphotoNickname($value)
218 {
219 $this->_gphotoNickname = $value;
220 return $this;
221 }
222
223 /**
224 * Get the value for this element's gphoto:thumbnail attribute.
225 *
226 * @see setGphotoThumbnail
227 * @return string The requested attribute.
228 */
229 public function getGphotoThumbnail()
230 {
231 return $this->_gphotoThumbnail;
232 }
233
234 /**
235 * Set the value for this element's gphoto:thumbnail attribute.
236 *
237 * @param string $value The desired value for this attribute.
238 * @return Zend_Gdata_Photos_Extension_Thumbnail The element being modified.
239 */
240 public function setGphotoThumbnail($value)
241 {
242 $this->_gphotoThumbnail = $value;
243 return $this;
244 }
245
246}
Note: See TracBrowser for help on using the repository browser.