UserEntry.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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_Entry
  24. */
  25. require_once 'Zend/Gdata/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Gapps
  28. */
  29. require_once 'Zend/Gdata/Gapps.php';
  30. /**
  31. * @see Zend_Gdata_Photos_Extension_Nickname
  32. */
  33. require_once 'Zend/Gdata/Photos/Extension/Nickname.php';
  34. /**
  35. * @see Zend_Gdata_Photos_Extension_Thumbnail
  36. */
  37. require_once 'Zend/Gdata/Photos/Extension/Thumbnail.php';
  38. /**
  39. * @see Zend_Gdata_Photos_Extension_QuotaCurrent
  40. */
  41. require_once 'Zend/Gdata/Photos/Extension/QuotaCurrent.php';
  42. /**
  43. * @see Zend_Gdata_Photos_Extension_QuotaLimit
  44. */
  45. require_once 'Zend/Gdata/Photos/Extension/QuotaLimit.php';
  46. /**
  47. * @see Zend_Gdata_Photos_Extension_MaxPhotosPerAlbum
  48. */
  49. require_once 'Zend/Gdata/Photos/Extension/MaxPhotosPerAlbum.php';
  50. /**
  51. * @see Zend_Gdata_Photos_Extension_User
  52. */
  53. require_once 'Zend/Gdata/Photos/Extension/User.php';
  54. /**
  55. * @see Zend_Gdata_App_Extension_Category
  56. */
  57. require_once 'Zend/Gdata/App/Extension/Category.php';
  58. /**
  59. * Data model class for a User Entry.
  60. *
  61. * To transfer user entries to and from the servers, including
  62. * creating new entries, refer to the service class,
  63. * Zend_Gdata_Photos.
  64. *
  65. * This class represents <atom:entry> in the Google Data protocol.
  66. *
  67. * @category Zend
  68. * @package Zend_Gdata
  69. * @subpackage Photos
  70. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  71. * @license http://framework.zend.com/license/new-bsd New BSD License
  72. */
  73. class Zend_Gdata_Photos_UserEntry extends Zend_Gdata_Entry
  74. {
  75. protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
  76. /**
  77. * gphoto:nickname element
  78. *
  79. * @var Zend_Gdata_Photos_Extension_Nickname
  80. */
  81. protected $_gphotoNickname = null;
  82. /**
  83. * gphoto:user element
  84. *
  85. * @var Zend_Gdata_Photos_Extension_User
  86. */
  87. protected $_gphotoUser = null;
  88. /**
  89. * gphoto:thumbnail element
  90. *
  91. * @var Zend_Gdata_Photos_Extension_Thumbnail
  92. */
  93. protected $_gphotoThumbnail = null;
  94. /**
  95. * gphoto:quotalimit element
  96. *
  97. * @var Zend_Gdata_Photos_Extension_QuotaLimit
  98. */
  99. protected $_gphotoQuotaLimit = null;
  100. /**
  101. * gphoto:quotacurrent element
  102. *
  103. * @var Zend_Gdata_Photos_Extension_QuotaCurrent
  104. */
  105. protected $_gphotoQuotaCurrent = null;
  106. /**
  107. * gphoto:maxPhotosPerAlbum element
  108. *
  109. * @var Zend_Gdata_Photos_Extension_MaxPhotosPerAlbum
  110. */
  111. protected $_gphotoMaxPhotosPerAlbum = null;
  112. /**
  113. * Create a new instance.
  114. *
  115. * @param DOMElement $element (optional) DOMElement from which this
  116. * object should be constructed.
  117. */
  118. public function __construct($element = null)
  119. {
  120. $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
  121. parent::__construct($element);
  122. $category = new Zend_Gdata_App_Extension_Category(
  123. 'http://schemas.google.com/photos/2007#user',
  124. 'http://schemas.google.com/g/2005#kind');
  125. $this->setCategory(array($category));
  126. }
  127. /**
  128. * Retrieves a DOMElement which corresponds to this element and all
  129. * child properties. This is used to build an entry back into a DOM
  130. * and eventually XML text for application storage/persistence.
  131. *
  132. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  133. * @return DOMElement The DOMElement representing this element and all
  134. * child properties.
  135. */
  136. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  137. {
  138. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  139. if ($this->_gphotoNickname !== null) {
  140. $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
  141. }
  142. if ($this->_gphotoThumbnail !== null) {
  143. $element->appendChild($this->_gphotoThumbnail->getDOM($element->ownerDocument));
  144. }
  145. if ($this->_gphotoUser !== null) {
  146. $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
  147. }
  148. if ($this->_gphotoQuotaCurrent !== null) {
  149. $element->appendChild($this->_gphotoQuotaCurrent->getDOM($element->ownerDocument));
  150. }
  151. if ($this->_gphotoQuotaLimit !== null) {
  152. $element->appendChild($this->_gphotoQuotaLimit->getDOM($element->ownerDocument));
  153. }
  154. if ($this->_gphotoMaxPhotosPerAlbum !== null) {
  155. $element->appendChild($this->_gphotoMaxPhotosPerAlbum->getDOM($element->ownerDocument));
  156. }
  157. return $element;
  158. }
  159. /**
  160. * Creates individual Entry objects of the appropriate type and
  161. * stores them as members of this entry based upon DOM data.
  162. *
  163. * @param DOMNode $child The DOMNode to process
  164. */
  165. protected function takeChildFromDOM($child)
  166. {
  167. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  168. switch ($absoluteNodeName) {
  169. case $this->lookupNamespace('gphoto') . ':' . 'nickname';
  170. $nickname = new Zend_Gdata_Photos_Extension_Nickname();
  171. $nickname->transferFromDOM($child);
  172. $this->_gphotoNickname = $nickname;
  173. break;
  174. case $this->lookupNamespace('gphoto') . ':' . 'thumbnail';
  175. $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
  176. $thumbnail->transferFromDOM($child);
  177. $this->_gphotoThumbnail = $thumbnail;
  178. break;
  179. case $this->lookupNamespace('gphoto') . ':' . 'user';
  180. $user = new Zend_Gdata_Photos_Extension_User();
  181. $user->transferFromDOM($child);
  182. $this->_gphotoUser = $user;
  183. break;
  184. case $this->lookupNamespace('gphoto') . ':' . 'quotacurrent';
  185. $quotaCurrent = new Zend_Gdata_Photos_Extension_QuotaCurrent();
  186. $quotaCurrent->transferFromDOM($child);
  187. $this->_gphotoQuotaCurrent = $quotaCurrent;
  188. break;
  189. case $this->lookupNamespace('gphoto') . ':' . 'quotalimit';
  190. $quotaLimit = new Zend_Gdata_Photos_Extension_QuotaLimit();
  191. $quotaLimit->transferFromDOM($child);
  192. $this->_gphotoQuotaLimit = $quotaLimit;
  193. break;
  194. case $this->lookupNamespace('gphoto') . ':' . 'maxPhotosPerAlbum';
  195. $maxPhotosPerAlbum = new Zend_Gdata_Photos_Extension_MaxPhotosPerAlbum();
  196. $maxPhotosPerAlbum->transferFromDOM($child);
  197. $this->_gphotoMaxPhotosPerAlbum = $maxPhotosPerAlbum;
  198. break;
  199. default:
  200. parent::takeChildFromDOM($child);
  201. break;
  202. }
  203. }
  204. /**
  205. * Get the value for this element's gphoto:nickname attribute.
  206. *
  207. * @see setGphotoNickname
  208. * @return string The requested attribute.
  209. */
  210. public function getGphotoNickname()
  211. {
  212. return $this->_gphotoNickname;
  213. }
  214. /**
  215. * Set the value for this element's gphoto:nickname attribute.
  216. *
  217. * @param string $value The desired value for this attribute.
  218. * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
  219. */
  220. public function setGphotoNickname($value)
  221. {
  222. $this->_gphotoNickname = $value;
  223. return $this;
  224. }
  225. /**
  226. * Get the value for this element's gphoto:thumbnail attribute.
  227. *
  228. * @see setGphotoThumbnail
  229. * @return string The requested attribute.
  230. */
  231. public function getGphotoThumbnail()
  232. {
  233. return $this->_gphotoThumbnail;
  234. }
  235. /**
  236. * Set the value for this element's gphoto:thumbnail attribute.
  237. *
  238. * @param string $value The desired value for this attribute.
  239. * @return Zend_Gdata_Photos_Extension_Thumbnail The element being modified.
  240. */
  241. public function setGphotoThumbnail($value)
  242. {
  243. $this->_gphotoThumbnail = $value;
  244. return $this;
  245. }
  246. /**
  247. * Get the value for this element's gphoto:quotacurrent attribute.
  248. *
  249. * @see setGphotoQuotaCurrent
  250. * @return string The requested attribute.
  251. */
  252. public function getGphotoQuotaCurrent()
  253. {
  254. return $this->_gphotoQuotaCurrent;
  255. }
  256. /**
  257. * Set the value for this element's gphoto:quotacurrent attribute.
  258. *
  259. * @param string $value The desired value for this attribute.
  260. * @return Zend_Gdata_Photos_Extension_QuotaCurrent The element being modified.
  261. */
  262. public function setGphotoQuotaCurrent($value)
  263. {
  264. $this->_gphotoQuotaCurrent = $value;
  265. return $this;
  266. }
  267. /**
  268. * Get the value for this element's gphoto:quotalimit attribute.
  269. *
  270. * @see setGphotoQuotaLimit
  271. * @return string The requested attribute.
  272. */
  273. public function getGphotoQuotaLimit()
  274. {
  275. return $this->_gphotoQuotaLimit;
  276. }
  277. /**
  278. * Set the value for this element's gphoto:quotalimit attribute.
  279. *
  280. * @param string $value The desired value for this attribute.
  281. * @return Zend_Gdata_Photos_Extension_QuotaLimit The element being modified.
  282. */
  283. public function setGphotoQuotaLimit($value)
  284. {
  285. $this->_gphotoQuotaLimit = $value;
  286. return $this;
  287. }
  288. /**
  289. * Get the value for this element's gphoto:maxPhotosPerAlbum attribute.
  290. *
  291. * @see setGphotoMaxPhotosPerAlbum
  292. * @return string The requested attribute.
  293. */
  294. public function getGphotoMaxPhotosPerAlbum()
  295. {
  296. return $this->_gphotoMaxPhotosPerAlbum;
  297. }
  298. /**
  299. * Set the value for this element's gphoto:maxPhotosPerAlbum attribute.
  300. *
  301. * @param string $value The desired value for this attribute.
  302. * @return Zend_Gdata_Photos_Extension_MaxPhotosPerAlbum The element being modified.
  303. */
  304. public function setGphotoMaxPhotosPerAlbum($value)
  305. {
  306. $this->_gphotoMaxPhotosPerAlbum = $value;
  307. return $this;
  308. }
  309. /**
  310. * Get the value for this element's gphoto:user attribute.
  311. *
  312. * @see setGphotoUser
  313. * @return string The requested attribute.
  314. */
  315. public function getGphotoUser()
  316. {
  317. return $this->_gphotoUser;
  318. }
  319. /**
  320. * Set the value for this element's gphoto:user attribute.
  321. *
  322. * @param string $value The desired value for this attribute.
  323. * @return Zend_Gdata_Photos_Extension_User The element being modified.
  324. */
  325. public function setGphotoUser($value)
  326. {
  327. $this->_gphotoUser = $value;
  328. return $this;
  329. }
  330. }