PhotoFeed.php 17 KB

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