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.
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
25 * @see Zend_Gdata_Photos
27 require_once 'Zend/Gdata/Photos.php';
30 * @see Zend_Gdata_Feed
32 require_once 'Zend/Gdata/Feed.php';
35 * @see Zend_Gdata_Photos_UserEntry
37 require_once 'Zend/Gdata/Photos/UserEntry.php';
40 * @see Zend_Gdata_Photos_AlbumEntry
42 require_once 'Zend/Gdata/Photos/AlbumEntry.php';
45 * @see Zend_Gdata_Photos_PhotoEntry
47 require_once 'Zend/Gdata/Photos/PhotoEntry.php';
50 * @see Zend_Gdata_Photos_TagEntry
52 require_once 'Zend/Gdata/Photos/TagEntry.php';
55 * @see Zend_Gdata_Photos_CommentEntry
57 require_once 'Zend/Gdata/Photos/CommentEntry.php';
60 * Data model for a collection of entries for a specific user, usually
61 * provided by the servers.
63 * For information on requesting this feed from a server, see the
64 * service class, Zend_Gdata_Photos.
69 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
70 * @license http://framework.zend.com/license/new-bsd New BSD License
72 class Zend_Gdata_Photos_UserFeed extends Zend_Gdata_Feed
78 * @var Zend_Gdata_Photos_Extension_User
80 protected $_gphotoUser = null;
83 * gphoto:thumbnail element
85 * @var Zend_Gdata_Photos_Extension_Thumbnail
87 protected $_gphotoThumbnail = null;
90 * gphoto:nickname element
92 * @var Zend_Gdata_Photos_Extension_Nickname
94 protected $_gphotoNickname = null;
96 protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
97 protected $_feedClassName = 'Zend_Gdata_Photos_UserFeed';
99 protected $_entryKindClassMapping = array(
100 'http://schemas.google.com/photos/2007#album' => 'Zend_Gdata_Photos_AlbumEntry',
101 'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
102 'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
103 'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
106 public function __construct($element = null)
108 $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
109 parent::__construct($element);
113 * Creates individual Entry objects of the appropriate type and
114 * stores them in the $_entry array based upon DOM data.
116 * @param DOMNode $child The DOMNode to process
118 protected function takeChildFromDOM($child)
120 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
121 switch ($absoluteNodeName) {
122 case $this->lookupNamespace('gphoto') . ':' . 'user';
123 $user = new Zend_Gdata_Photos_Extension_User();
124 $user->transferFromDOM($child);
125 $this->_gphotoUser = $user;
127 case $this->lookupNamespace('gphoto') . ':' . 'nickname';
128 $nickname = new Zend_Gdata_Photos_Extension_Nickname();
129 $nickname->transferFromDOM($child);
130 $this->_gphotoNickname = $nickname;
132 case $this->lookupNamespace('gphoto') . ':' . 'thumbnail';
133 $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
134 $thumbnail->transferFromDOM($child);
135 $this->_gphotoThumbnail = $thumbnail;
137 case $this->lookupNamespace('atom') . ':' . 'entry':
138 $entryClassName = $this->_entryClassName;
139 $tmpEntry = new Zend_Gdata_App_Entry($child);
140 $categories = $tmpEntry->getCategory();
141 foreach ($categories as $category) {
142 if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
143 $this->_entryKindClassMapping[$category->term] != "") {
144 $entryClassName = $this->_entryKindClassMapping[$category->term];
147 require_once 'Zend/Gdata/App/Exception.php';
148 throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
152 $newEntry = new $entryClassName($child);
153 $newEntry->setHttpClient($this->getHttpClient());
154 $this->_entry[] = $newEntry;
157 parent::takeChildFromDOM($child);
162 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
164 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
165 if ($this->_gphotoUser != null) {
166 $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
168 if ($this->_gphotoNickname != null) {
169 $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
171 if ($this->_gphotoThumbnail != null) {
172 $element->appendChild($this->_gphotoThumbnail->getDOM($element->ownerDocument));
179 * Get the value for this element's gphoto:user attribute.
182 * @return string The requested attribute.
184 public function getGphotoUser()
186 return $this->_gphotoUser;
190 * Set the value for this element's gphoto:user attribute.
192 * @param string $value The desired value for this attribute.
193 * @return Zend_Gdata_Photos_Extension_User The element being modified.
195 public function setGphotoUser($value)
197 $this->_gphotoUser = $value;
202 * Get the value for this element's gphoto:nickname attribute.
204 * @see setGphotoNickname
205 * @return string The requested attribute.
207 public function getGphotoNickname()
209 return $this->_gphotoNickname;
213 * Set the value for this element's gphoto:nickname attribute.
215 * @param string $value The desired value for this attribute.
216 * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
218 public function setGphotoNickname($value)
220 $this->_gphotoNickname = $value;
225 * Get the value for this element's gphoto:thumbnail attribute.
227 * @see setGphotoThumbnail
228 * @return string The requested attribute.
230 public function getGphotoThumbnail()
232 return $this->_gphotoThumbnail;
236 * Set the value for this element's gphoto:thumbnail attribute.
238 * @param string $value The desired value for this attribute.
239 * @return Zend_Gdata_Photos_Extension_Thumbnail The element being modified.
241 public function setGphotoThumbnail($value)
243 $this->_gphotoThumbnail = $value;