2
0

UserFeed.php 7.5 KB

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