AlbumFeed.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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_AlbumEntry
  32. */
  33. require_once 'Zend/Gdata/Photos/AlbumEntry.php';
  34. /**
  35. * Data model for a collection of album entries, usually
  36. * provided by the servers.
  37. *
  38. * For information on requesting this feed from a server, see the
  39. * service class, Zend_Gdata_Photos.
  40. *
  41. * @category Zend
  42. * @package Zend_Gdata
  43. * @subpackage Photos
  44. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  45. * @license http://framework.zend.com/license/new-bsd New BSD License
  46. */
  47. class Zend_Gdata_Photos_AlbumFeed extends Zend_Gdata_Feed
  48. {
  49. protected $_entryClassName = 'Zend_Gdata_Photos_AlbumEntry';
  50. protected $_feedClassName = 'Zend_Gdata_Photos_AlbumFeed';
  51. /**
  52. * gphoto:id element
  53. *
  54. * @var Zend_Gdata_Photos_Extension_Id
  55. */
  56. protected $_gphotoId = null;
  57. /**
  58. * gphoto:user element
  59. *
  60. * @var Zend_Gdata_Photos_Extension_User
  61. */
  62. protected $_gphotoUser = null;
  63. /**
  64. * gphoto:access element
  65. *
  66. * @var Zend_Gdata_Photos_Extension_Access
  67. */
  68. protected $_gphotoAccess = null;
  69. /**
  70. * gphoto:location element
  71. *
  72. * @var Zend_Gdata_Photos_Extension_Location
  73. */
  74. protected $_gphotoLocation = null;
  75. /**
  76. * gphoto:nickname element
  77. *
  78. * @var Zend_Gdata_Photos_Extension_Nickname
  79. */
  80. protected $_gphotoNickname = null;
  81. /**
  82. * gphoto:timestamp element
  83. *
  84. * @var Zend_Gdata_Photos_Extension_Timestamp
  85. */
  86. protected $_gphotoTimestamp = null;
  87. /**
  88. * gphoto:name element
  89. *
  90. * @var Zend_Gdata_Photos_Extension_Name
  91. */
  92. protected $_gphotoName = null;
  93. /**
  94. * gphoto:numphotos element
  95. *
  96. * @var Zend_Gdata_Photos_Extension_NumPhotos
  97. */
  98. protected $_gphotoNumPhotos = null;
  99. /**
  100. * gphoto:commentCount element
  101. *
  102. * @var Zend_Gdata_Photos_Extension_CommentCount
  103. */
  104. protected $_gphotoCommentCount = null;
  105. /**
  106. * gphoto:commentingEnabled element
  107. *
  108. * @var Zend_Gdata_Photos_Extension_CommentingEnabled
  109. */
  110. protected $_gphotoCommentingEnabled = null;
  111. protected $_entryKindClassMapping = array(
  112. 'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
  113. 'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
  114. 'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
  115. );
  116. public function __construct($element = null)
  117. {
  118. $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
  119. parent::__construct($element);
  120. }
  121. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  122. {
  123. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  124. if ($this->_gphotoId != null) {
  125. $element->appendChild($this->_gphotoId->getDOM($element->ownerDocument));
  126. }
  127. if ($this->_gphotoUser != null) {
  128. $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
  129. }
  130. if ($this->_gphotoNickname != null) {
  131. $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
  132. }
  133. if ($this->_gphotoName != null) {
  134. $element->appendChild($this->_gphotoName->getDOM($element->ownerDocument));
  135. }
  136. if ($this->_gphotoLocation != null) {
  137. $element->appendChild($this->_gphotoLocation->getDOM($element->ownerDocument));
  138. }
  139. if ($this->_gphotoAccess != null) {
  140. $element->appendChild($this->_gphotoAccess->getDOM($element->ownerDocument));
  141. }
  142. if ($this->_gphotoTimestamp != null) {
  143. $element->appendChild($this->_gphotoTimestamp->getDOM($element->ownerDocument));
  144. }
  145. if ($this->_gphotoNumPhotos != null) {
  146. $element->appendChild($this->_gphotoNumPhotos->getDOM($element->ownerDocument));
  147. }
  148. if ($this->_gphotoCommentingEnabled != null) {
  149. $element->appendChild($this->_gphotoCommentingEnabled->getDOM($element->ownerDocument));
  150. }
  151. if ($this->_gphotoCommentCount != null) {
  152. $element->appendChild($this->_gphotoCommentCount->getDOM($element->ownerDocument));
  153. }
  154. return $element;
  155. }
  156. protected function takeChildFromDOM($child)
  157. {
  158. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  159. switch ($absoluteNodeName) {
  160. case $this->lookupNamespace('gphoto') . ':' . 'id';
  161. $id = new Zend_Gdata_Photos_Extension_Id();
  162. $id->transferFromDOM($child);
  163. $this->_gphotoId = $id;
  164. break;
  165. case $this->lookupNamespace('gphoto') . ':' . 'user';
  166. $user = new Zend_Gdata_Photos_Extension_User();
  167. $user->transferFromDOM($child);
  168. $this->_gphotoUser = $user;
  169. break;
  170. case $this->lookupNamespace('gphoto') . ':' . 'nickname';
  171. $nickname = new Zend_Gdata_Photos_Extension_Nickname();
  172. $nickname->transferFromDOM($child);
  173. $this->_gphotoNickname = $nickname;
  174. break;
  175. case $this->lookupNamespace('gphoto') . ':' . 'name';
  176. $name = new Zend_Gdata_Photos_Extension_Name();
  177. $name->transferFromDOM($child);
  178. $this->_gphotoName = $name;
  179. break;
  180. case $this->lookupNamespace('gphoto') . ':' . 'location';
  181. $location = new Zend_Gdata_Photos_Extension_Location();
  182. $location->transferFromDOM($child);
  183. $this->_gphotoLocation = $location;
  184. break;
  185. case $this->lookupNamespace('gphoto') . ':' . 'access';
  186. $access = new Zend_Gdata_Photos_Extension_Access();
  187. $access->transferFromDOM($child);
  188. $this->_gphotoAccess = $access;
  189. break;
  190. case $this->lookupNamespace('gphoto') . ':' . 'timestamp';
  191. $timestamp = new Zend_Gdata_Photos_Extension_Timestamp();
  192. $timestamp->transferFromDOM($child);
  193. $this->_gphotoTimestamp = $timestamp;
  194. break;
  195. case $this->lookupNamespace('gphoto') . ':' . 'numphotos';
  196. $numphotos = new Zend_Gdata_Photos_Extension_NumPhotos();
  197. $numphotos->transferFromDOM($child);
  198. $this->_gphotoNumPhotos = $numphotos;
  199. break;
  200. case $this->lookupNamespace('gphoto') . ':' . 'commentingEnabled';
  201. $commentingEnabled = new Zend_Gdata_Photos_Extension_CommentingEnabled();
  202. $commentingEnabled->transferFromDOM($child);
  203. $this->_gphotoCommentingEnabled = $commentingEnabled;
  204. break;
  205. case $this->lookupNamespace('gphoto') . ':' . 'commentCount';
  206. $commentCount = new Zend_Gdata_Photos_Extension_CommentCount();
  207. $commentCount->transferFromDOM($child);
  208. $this->_gphotoCommentCount = $commentCount;
  209. break;
  210. case $this->lookupNamespace('atom') . ':' . 'entry':
  211. $entryClassName = $this->_entryClassName;
  212. $tmpEntry = new Zend_Gdata_App_Entry($child);
  213. $categories = $tmpEntry->getCategory();
  214. foreach ($categories as $category) {
  215. if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
  216. $this->_entryKindClassMapping[$category->term] != "") {
  217. $entryClassName = $this->_entryKindClassMapping[$category->term];
  218. break;
  219. } else {
  220. require_once 'Zend/Gdata/App/Exception.php';
  221. throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
  222. }
  223. }
  224. $newEntry = new $entryClassName($child);
  225. $newEntry->setHttpClient($this->getHttpClient());
  226. $this->_entry[] = $newEntry;
  227. break;
  228. default:
  229. parent::takeChildFromDOM($child);
  230. break;
  231. }
  232. }
  233. /**
  234. * Get the value for this element's gphoto:user attribute.
  235. *
  236. * @see setGphotoUser
  237. * @return string The requested attribute.
  238. */
  239. public function getGphotoUser()
  240. {
  241. return $this->_gphotoUser;
  242. }
  243. /**
  244. * Set the value for this element's gphoto:user attribute.
  245. *
  246. * @param string $value The desired value for this attribute.
  247. * @return Zend_Gdata_Photos_Extension_User The element being modified.
  248. */
  249. public function setGphotoUser($value)
  250. {
  251. $this->_gphotoUser = $value;
  252. return $this;
  253. }
  254. /**
  255. * Get the value for this element's gphoto:access attribute.
  256. *
  257. * @see setGphotoAccess
  258. * @return string The requested attribute.
  259. */
  260. public function getGphotoAccess()
  261. {
  262. return $this->_gphotoAccess;
  263. }
  264. /**
  265. * Set the value for this element's gphoto:access attribute.
  266. *
  267. * @param string $value The desired value for this attribute.
  268. * @return Zend_Gdata_Photos_Extension_Access The element being modified.
  269. */
  270. public function setGphotoAccess($value)
  271. {
  272. $this->_gphotoAccess = $value;
  273. return $this;
  274. }
  275. /**
  276. * Get the value for this element's gphoto:location attribute.
  277. *
  278. * @see setGphotoLocation
  279. * @return string The requested attribute.
  280. */
  281. public function getGphotoLocation()
  282. {
  283. return $this->_gphotoLocation;
  284. }
  285. /**
  286. * Set the value for this element's gphoto:location attribute.
  287. *
  288. * @param string $value The desired value for this attribute.
  289. * @return Zend_Gdata_Photos_Extension_Location The element being modified.
  290. */
  291. public function setGphotoLocation($value)
  292. {
  293. $this->_gphotoLocation = $value;
  294. return $this;
  295. }
  296. /**
  297. * Get the value for this element's gphoto:name attribute.
  298. *
  299. * @see setGphotoName
  300. * @return string The requested attribute.
  301. */
  302. public function getGphotoName()
  303. {
  304. return $this->_gphotoName;
  305. }
  306. /**
  307. * Set the value for this element's gphoto:name attribute.
  308. *
  309. * @param string $value The desired value for this attribute.
  310. * @return Zend_Gdata_Photos_Extension_Name The element being modified.
  311. */
  312. public function setGphotoName($value)
  313. {
  314. $this->_gphotoName = $value;
  315. return $this;
  316. }
  317. /**
  318. * Get the value for this element's gphoto:numphotos attribute.
  319. *
  320. * @see setGphotoNumPhotos
  321. * @return string The requested attribute.
  322. */
  323. public function getGphotoNumPhotos()
  324. {
  325. return $this->_gphotoNumPhotos;
  326. }
  327. /**
  328. * Set the value for this element's gphoto:numphotos attribute.
  329. *
  330. * @param string $value The desired value for this attribute.
  331. * @return Zend_Gdata_Photos_Extension_NumPhotos The element being modified.
  332. */
  333. public function setGphotoNumPhotos($value)
  334. {
  335. $this->_gphotoNumPhotos = $value;
  336. return $this;
  337. }
  338. /**
  339. * Get the value for this element's gphoto:commentCount attribute.
  340. *
  341. * @see setGphotoCommentCount
  342. * @return string The requested attribute.
  343. */
  344. public function getGphotoCommentCount()
  345. {
  346. return $this->_gphotoCommentCount;
  347. }
  348. /**
  349. * Set the value for this element's gphoto:commentCount attribute.
  350. *
  351. * @param string $value The desired value for this attribute.
  352. * @return Zend_Gdata_Photos_Extension_CommentCount The element being modified.
  353. */
  354. public function setGphotoCommentCount($value)
  355. {
  356. $this->_gphotoCommentCount = $value;
  357. return $this;
  358. }
  359. /**
  360. * Get the value for this element's gphoto:commentingEnabled attribute.
  361. *
  362. * @see setGphotoCommentingEnabled
  363. * @return string The requested attribute.
  364. */
  365. public function getGphotoCommentingEnabled()
  366. {
  367. return $this->_gphotoCommentingEnabled;
  368. }
  369. /**
  370. * Set the value for this element's gphoto:commentingEnabled attribute.
  371. *
  372. * @param string $value The desired value for this attribute.
  373. * @return Zend_Gdata_Photos_Extension_CommentingEnabled The element being modified.
  374. */
  375. public function setGphotoCommentingEnabled($value)
  376. {
  377. $this->_gphotoCommentingEnabled = $value;
  378. return $this;
  379. }
  380. /**
  381. * Get the value for this element's gphoto:id attribute.
  382. *
  383. * @see setGphotoId
  384. * @return string The requested attribute.
  385. */
  386. public function getGphotoId()
  387. {
  388. return $this->_gphotoId;
  389. }
  390. /**
  391. * Set the value for this element's gphoto:id attribute.
  392. *
  393. * @param string $value The desired value for this attribute.
  394. * @return Zend_Gdata_Photos_Extension_Id The element being modified.
  395. */
  396. public function setGphotoId($value)
  397. {
  398. $this->_gphotoId = $value;
  399. return $this;
  400. }
  401. /**
  402. * Get the value for this element's georss:where attribute.
  403. *
  404. * @see setGeoRssWhere
  405. * @return string The requested attribute.
  406. */
  407. public function getGeoRssWhere()
  408. {
  409. return $this->_geoRssWhere;
  410. }
  411. /**
  412. * Set the value for this element's georss:where attribute.
  413. *
  414. * @param string $value The desired value for this attribute.
  415. * @return Zend_Gdata_Geo_Extension_GeoRssWhere The element being modified.
  416. */
  417. public function setGeoRssWhere($value)
  418. {
  419. $this->_geoRssWhere = $value;
  420. return $this;
  421. }
  422. /**
  423. * Get the value for this element's gphoto:nickname attribute.
  424. *
  425. * @see setGphotoNickname
  426. * @return string The requested attribute.
  427. */
  428. public function getGphotoNickname()
  429. {
  430. return $this->_gphotoNickname;
  431. }
  432. /**
  433. * Set the value for this element's gphoto:nickname attribute.
  434. *
  435. * @param string $value The desired value for this attribute.
  436. * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
  437. */
  438. public function setGphotoNickname($value)
  439. {
  440. $this->_gphotoNickname = $value;
  441. return $this;
  442. }
  443. /**
  444. * Get the value for this element's gphoto:timestamp attribute.
  445. *
  446. * @see setGphotoTimestamp
  447. * @return string The requested attribute.
  448. */
  449. public function getGphotoTimestamp()
  450. {
  451. return $this->_gphotoTimestamp;
  452. }
  453. /**
  454. * Set the value for this element's gphoto:timestamp attribute.
  455. *
  456. * @param string $value The desired value for this attribute.
  457. * @return Zend_Gdata_Photos_Extension_Timestamp The element being modified.
  458. */
  459. public function setGphotoTimestamp($value)
  460. {
  461. $this->_gphotoTimestamp = $value;
  462. return $this;
  463. }
  464. }