PhotoFeed.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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_PhotoEntry
  31. */
  32. require_once 'Zend/Gdata/Photos/PhotoEntry.php';
  33. /**
  34. * Data model for a collection of photo entries, usually
  35. * provided by the Picasa 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_PhotoFeed extends Zend_Gdata_Feed
  47. {
  48. /**
  49. * gphoto:id element
  50. *
  51. * @var Zend_Gdata_Photos_Extension_Id
  52. */
  53. protected $_gphotoId = null;
  54. /**
  55. * gphoto:albumid element
  56. *
  57. * @var Zend_Gdata_Photos_Extension_AlbumId
  58. */
  59. protected $_gphotoAlbumId = null;
  60. /**
  61. * gphoto:version element
  62. *
  63. * @var Zend_Gdata_Photos_Extension_Version
  64. */
  65. protected $_gphotoVersion = null;
  66. /**
  67. * gphoto:width element
  68. *
  69. * @var Zend_Gdata_Photos_Extension_Width
  70. */
  71. protected $_gphotoWidth = null;
  72. /**
  73. * gphoto:height element
  74. *
  75. * @var Zend_Gdata_Photos_Extension_Height
  76. */
  77. protected $_gphotoHeight = null;
  78. /**
  79. * gphoto:size element
  80. *
  81. * @var Zend_Gdata_Photos_Extension_Size
  82. */
  83. protected $_gphotoSize = null;
  84. /**
  85. * gphoto:client element
  86. *
  87. * @var Zend_Gdata_Photos_Extension_Client
  88. */
  89. protected $_gphotoClient = null;
  90. /**
  91. * gphoto:checksum element
  92. *
  93. * @var Zend_Gdata_Photos_Extension_Checksum
  94. */
  95. protected $_gphotoChecksum = null;
  96. /**
  97. * gphoto:timestamp element
  98. *
  99. * @var Zend_Gdata_Photos_Extension_Timestamp
  100. */
  101. protected $_gphotoTimestamp = null;
  102. /**
  103. * gphoto:commentCount element
  104. *
  105. * @var Zend_Gdata_Photos_Extension_CommentCount
  106. */
  107. protected $_gphotoCommentCount = null;
  108. /**
  109. * gphoto:commentingEnabled element
  110. *
  111. * @var Zend_Gdata_Photos_Extension_CommentingEnabled
  112. */
  113. protected $_gphotoCommentingEnabled = null;
  114. /**
  115. * media:group element
  116. *
  117. * @var Zend_Gdata_Media_Extension_MediaGroup
  118. */
  119. protected $_mediaGroup = null;
  120. protected $_entryClassName = 'Zend_Gdata_Photos_PhotoEntry';
  121. protected $_feedClassName = 'Zend_Gdata_Photos_PhotoFeed';
  122. protected $_entryKindClassMapping = array(
  123. 'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
  124. 'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
  125. );
  126. public function __construct($element = null)
  127. {
  128. $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
  129. parent::__construct($element);
  130. }
  131. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  132. {
  133. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  134. if ($this->_gphotoId != null) {
  135. $element->appendChild($this->_gphotoId->getDOM($element->ownerDocument));
  136. }
  137. if ($this->_gphotoVersion != null) {
  138. $element->appendChild($this->_gphotoVersion->getDOM($element->ownerDocument));
  139. }
  140. if ($this->_gphotoWidth != null) {
  141. $element->appendChild($this->_gphotoWidth->getDOM($element->ownerDocument));
  142. }
  143. if ($this->_gphotoHeight != null) {
  144. $element->appendChild($this->_gphotoHeight->getDOM($element->ownerDocument));
  145. }
  146. if ($this->_gphotoSize != null) {
  147. $element->appendChild($this->_gphotoSize->getDOM($element->ownerDocument));
  148. }
  149. if ($this->_gphotoClient != null) {
  150. $element->appendChild($this->_gphotoClient->getDOM($element->ownerDocument));
  151. }
  152. if ($this->_gphotoChecksum != null) {
  153. $element->appendChild($this->_gphotoChecksum->getDOM($element->ownerDocument));
  154. }
  155. if ($this->_gphotoTimestamp != null) {
  156. $element->appendChild($this->_gphotoTimestamp->getDOM($element->ownerDocument));
  157. }
  158. if ($this->_gphotoCommentingEnabled != null) {
  159. $element->appendChild($this->_gphotoCommentingEnabled->getDOM($element->ownerDocument));
  160. }
  161. if ($this->_gphotoCommentCount != null) {
  162. $element->appendChild($this->_gphotoCommentCount->getDOM($element->ownerDocument));
  163. }
  164. if ($this->_mediaGroup != null) {
  165. $element->appendChild($this->_mediaGroup->getDOM($element->ownerDocument));
  166. }
  167. return $element;
  168. }
  169. protected function takeChildFromDOM($child)
  170. {
  171. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  172. switch ($absoluteNodeName) {
  173. case $this->lookupNamespace('gphoto') . ':' . 'id';
  174. $id = new Zend_Gdata_Photos_Extension_Id();
  175. $id->transferFromDOM($child);
  176. $this->_gphotoId = $id;
  177. break;
  178. case $this->lookupNamespace('gphoto') . ':' . 'version';
  179. $version = new Zend_Gdata_Photos_Extension_Version();
  180. $version->transferFromDOM($child);
  181. $this->_gphotoVersion = $version;
  182. break;
  183. case $this->lookupNamespace('gphoto') . ':' . 'albumid';
  184. $albumid = new Zend_Gdata_Photos_Extension_AlbumId();
  185. $albumid->transferFromDOM($child);
  186. $this->_gphotoAlbumId = $albumid;
  187. break;
  188. case $this->lookupNamespace('gphoto') . ':' . 'width';
  189. $width = new Zend_Gdata_Photos_Extension_Width();
  190. $width->transferFromDOM($child);
  191. $this->_gphotoWidth = $width;
  192. break;
  193. case $this->lookupNamespace('gphoto') . ':' . 'height';
  194. $height = new Zend_Gdata_Photos_Extension_Height();
  195. $height->transferFromDOM($child);
  196. $this->_gphotoHeight = $height;
  197. break;
  198. case $this->lookupNamespace('gphoto') . ':' . 'size';
  199. $size = new Zend_Gdata_Photos_Extension_Size();
  200. $size->transferFromDOM($child);
  201. $this->_gphotoSize = $size;
  202. break;
  203. case $this->lookupNamespace('gphoto') . ':' . 'client';
  204. $client = new Zend_Gdata_Photos_Extension_Client();
  205. $client->transferFromDOM($child);
  206. $this->_gphotoClient = $client;
  207. break;
  208. case $this->lookupNamespace('gphoto') . ':' . 'checksum';
  209. $checksum = new Zend_Gdata_Photos_Extension_Checksum();
  210. $checksum->transferFromDOM($child);
  211. $this->_gphotoChecksum = $checksum;
  212. break;
  213. case $this->lookupNamespace('gphoto') . ':' . 'timestamp';
  214. $timestamp = new Zend_Gdata_Photos_Extension_Timestamp();
  215. $timestamp->transferFromDOM($child);
  216. $this->_gphotoTimestamp = $timestamp;
  217. break;
  218. case $this->lookupNamespace('gphoto') . ':' . 'commentingEnabled';
  219. $commentingEnabled = new Zend_Gdata_Photos_Extension_CommentingEnabled();
  220. $commentingEnabled->transferFromDOM($child);
  221. $this->_gphotoCommentingEnabled = $commentingEnabled;
  222. break;
  223. case $this->lookupNamespace('gphoto') . ':' . 'commentCount';
  224. $commentCount = new Zend_Gdata_Photos_Extension_CommentCount();
  225. $commentCount->transferFromDOM($child);
  226. $this->_gphotoCommentCount = $commentCount;
  227. break;
  228. case $this->lookupNamespace('media') . ':' . 'group';
  229. $mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
  230. $mediaGroup->transferFromDOM($child);
  231. $this->_mediaGroup = $mediaGroup;
  232. break;
  233. case $this->lookupNamespace('atom') . ':' . 'entry':
  234. $entryClassName = $this->_entryClassName;
  235. $tmpEntry = new Zend_Gdata_App_Entry($child);
  236. $categories = $tmpEntry->getCategory();
  237. foreach ($categories as $category) {
  238. if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
  239. $this->_entryKindClassMapping[$category->term] != "") {
  240. $entryClassName = $this->_entryKindClassMapping[$category->term];
  241. break;
  242. } else {
  243. require_once 'Zend/Gdata/App/Exception.php';
  244. throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
  245. }
  246. }
  247. $newEntry = new $entryClassName($child);
  248. $newEntry->setHttpClient($this->getHttpClient());
  249. $this->_entry[] = $newEntry;
  250. break;
  251. default:
  252. parent::takeChildFromDOM($child);
  253. break;
  254. }
  255. }
  256. /**
  257. * Get the value for this element's gphoto:id attribute.
  258. *
  259. * @see setGphotoId
  260. * @return string The requested attribute.
  261. */
  262. public function getGphotoId()
  263. {
  264. return $this->_gphotoId;
  265. }
  266. /**
  267. * Set the value for this element's gphoto:id attribute.
  268. *
  269. * @param string $value The desired value for this attribute.
  270. * @return Zend_Gdata_Photos_Extension_Id The element being modified.
  271. */
  272. public function setGphotoId($value)
  273. {
  274. $this->_gphotoId = $value;
  275. return $this;
  276. }
  277. /**
  278. * Get the value for this element's gphoto:version attribute.
  279. *
  280. * @see setGphotoVersion
  281. * @return string The requested attribute.
  282. */
  283. public function getGphotoVersion()
  284. {
  285. return $this->_gphotoVersion;
  286. }
  287. /**
  288. * Set the value for this element's gphoto:version attribute.
  289. *
  290. * @param string $value The desired value for this attribute.
  291. * @return Zend_Gdata_Photos_Extension_Version The element being modified.
  292. */
  293. public function setGphotoVersion($value)
  294. {
  295. $this->_gphotoVersion = $value;
  296. return $this;
  297. }
  298. /**
  299. * Get the value for this element's gphoto:albumid attribute.
  300. *
  301. * @see setGphotoAlbumId
  302. * @return string The requested attribute.
  303. */
  304. public function getGphotoAlbumId()
  305. {
  306. return $this->_gphotoAlbumId;
  307. }
  308. /**
  309. * Set the value for this element's gphoto:albumid attribute.
  310. *
  311. * @param string $value The desired value for this attribute.
  312. * @return Zend_Gdata_Photos_Extension_AlbumId The element being modified.
  313. */
  314. public function setGphotoAlbumId($value)
  315. {
  316. $this->_gphotoAlbumId = $value;
  317. return $this;
  318. }
  319. /**
  320. * Get the value for this element's gphoto:width attribute.
  321. *
  322. * @see setGphotoWidth
  323. * @return string The requested attribute.
  324. */
  325. public function getGphotoWidth()
  326. {
  327. return $this->_gphotoWidth;
  328. }
  329. /**
  330. * Set the value for this element's gphoto:width attribute.
  331. *
  332. * @param string $value The desired value for this attribute.
  333. * @return Zend_Gdata_Photos_Extension_Width The element being modified.
  334. */
  335. public function setGphotoWidth($value)
  336. {
  337. $this->_gphotoWidth = $value;
  338. return $this;
  339. }
  340. /**
  341. * Get the value for this element's gphoto:height attribute.
  342. *
  343. * @see setGphotoHeight
  344. * @return string The requested attribute.
  345. */
  346. public function getGphotoHeight()
  347. {
  348. return $this->_gphotoHeight;
  349. }
  350. /**
  351. * Set the value for this element's gphoto:height attribute.
  352. *
  353. * @param string $value The desired value for this attribute.
  354. * @return Zend_Gdata_Photos_Extension_Height The element being modified.
  355. */
  356. public function setGphotoHeight($value)
  357. {
  358. $this->_gphotoHeight = $value;
  359. return $this;
  360. }
  361. /**
  362. * Get the value for this element's gphoto:size attribute.
  363. *
  364. * @see setGphotoSize
  365. * @return string The requested attribute.
  366. */
  367. public function getGphotoSize()
  368. {
  369. return $this->_gphotoSize;
  370. }
  371. /**
  372. * Set the value for this element's gphoto:size attribute.
  373. *
  374. * @param string $value The desired value for this attribute.
  375. * @return Zend_Gdata_Photos_Extension_Size The element being modified.
  376. */
  377. public function setGphotoSize($value)
  378. {
  379. $this->_gphotoSize = $value;
  380. return $this;
  381. }
  382. /**
  383. * Get the value for this element's gphoto:client attribute.
  384. *
  385. * @see setGphotoClient
  386. * @return string The requested attribute.
  387. */
  388. public function getGphotoClient()
  389. {
  390. return $this->_gphotoClient;
  391. }
  392. /**
  393. * Set the value for this element's gphoto:client attribute.
  394. *
  395. * @param string $value The desired value for this attribute.
  396. * @return Zend_Gdata_Photos_Extension_Client The element being modified.
  397. */
  398. public function setGphotoClient($value)
  399. {
  400. $this->_gphotoClient = $value;
  401. return $this;
  402. }
  403. /**
  404. * Get the value for this element's gphoto:checksum attribute.
  405. *
  406. * @see setGphotoChecksum
  407. * @return string The requested attribute.
  408. */
  409. public function getGphotoChecksum()
  410. {
  411. return $this->_gphotoChecksum;
  412. }
  413. /**
  414. * Set the value for this element's gphoto:checksum attribute.
  415. *
  416. * @param string $value The desired value for this attribute.
  417. * @return Zend_Gdata_Photos_Extension_Checksum The element being modified.
  418. */
  419. public function setGphotoChecksum($value)
  420. {
  421. $this->_gphotoChecksum = $value;
  422. return $this;
  423. }
  424. /**
  425. * Get the value for this element's gphoto:timestamp attribute.
  426. *
  427. * @see setGphotoTimestamp
  428. * @return string The requested attribute.
  429. */
  430. public function getGphotoTimestamp()
  431. {
  432. return $this->_gphotoTimestamp;
  433. }
  434. /**
  435. * Set the value for this element's gphoto:timestamp attribute.
  436. *
  437. * @param string $value The desired value for this attribute.
  438. * @return Zend_Gdata_Photos_Extension_Timestamp The element being modified.
  439. */
  440. public function setGphotoTimestamp($value)
  441. {
  442. $this->_gphotoTimestamp = $value;
  443. return $this;
  444. }
  445. /**
  446. * Get the value for this element's gphoto:commentCount attribute.
  447. *
  448. * @see setGphotoCommentCount
  449. * @return string The requested attribute.
  450. */
  451. public function getGphotoCommentCount()
  452. {
  453. return $this->_gphotoCommentCount;
  454. }
  455. /**
  456. * Set the value for this element's gphoto:commentCount attribute.
  457. *
  458. * @param string $value The desired value for this attribute.
  459. * @return Zend_Gdata_Photos_Extension_CommentCount The element being modified.
  460. */
  461. public function setGphotoCommentCount($value)
  462. {
  463. $this->_gphotoCommentCount = $value;
  464. return $this;
  465. }
  466. /**
  467. * Get the value for this element's gphoto:commentingEnabled attribute.
  468. *
  469. * @see setGphotoCommentingEnabled
  470. * @return string The requested attribute.
  471. */
  472. public function getGphotoCommentingEnabled()
  473. {
  474. return $this->_gphotoCommentingEnabled;
  475. }
  476. /**
  477. * Set the value for this element's gphoto:commentingEnabled attribute.
  478. *
  479. * @param string $value The desired value for this attribute.
  480. * @return Zend_Gdata_Photos_Extension_CommentingEnabled The element being modified.
  481. */
  482. public function setGphotoCommentingEnabled($value)
  483. {
  484. $this->_gphotoCommentingEnabled = $value;
  485. return $this;
  486. }
  487. /**
  488. * Get the value for this element's media:group attribute.
  489. *
  490. * @see setMediaGroup
  491. * @return string The requested attribute.
  492. */
  493. public function getMediaGroup()
  494. {
  495. return $this->_mediaGroup;
  496. }
  497. /**
  498. * Set the value for this element's media:group attribute.
  499. *
  500. * @param string $value The desired value for this attribute.
  501. * @return Zend_Gdata_Media_Extension_MediaGroup The element being modified.
  502. */
  503. public function setMediaGroup($value)
  504. {
  505. $this->_mediaGroup = $value;
  506. return $this;
  507. }
  508. }