AlbumFeed.php 16 KB

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