UserFeed.php 7.5 KB

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