2
0

UserEntry.php 11 KB

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