1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Zend Framework
|
---|
5 | *
|
---|
6 | * LICENSE
|
---|
7 | *
|
---|
8 | * This source file is subject to the new BSD license that is bundled
|
---|
9 | * with this package in the file LICENSE.txt.
|
---|
10 | * It is also available through the world-wide-web at this URL:
|
---|
11 | * http://framework.zend.com/license/new-bsd
|
---|
12 | * If you did not receive a copy of the license and are unable to
|
---|
13 | * obtain it through the world-wide-web, please send an email
|
---|
14 | * to license@zend.com so we can send you a copy immediately.
|
---|
15 | *
|
---|
16 | * @category Zend
|
---|
17 | * @package Zend_Gdata
|
---|
18 | * @subpackage Photos
|
---|
19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * @see Zend_Gdata_Photos_UserFeed
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Photos/UserFeed.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @see Zend_Gdata_Photos_AlbumFeed
|
---|
35 | */
|
---|
36 | require_once 'Zend/Gdata/Photos/AlbumFeed.php';
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @see Zend_Gdata_Photos_PhotoFeed
|
---|
40 | */
|
---|
41 | require_once 'Zend/Gdata/Photos/PhotoFeed.php';
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Service class for interacting with the Google Photos Data API.
|
---|
45 | *
|
---|
46 | * Like other service classes in this module, this class provides access via
|
---|
47 | * an HTTP client to Google servers for working with entries and feeds.
|
---|
48 | *
|
---|
49 | * @link http://code.google.com/apis/picasaweb/gdata.html
|
---|
50 | *
|
---|
51 | * @category Zend
|
---|
52 | * @package Zend_Gdata
|
---|
53 | * @subpackage Photos
|
---|
54 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
55 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
56 | */
|
---|
57 | class Zend_Gdata_Photos extends Zend_Gdata
|
---|
58 | {
|
---|
59 |
|
---|
60 | const PICASA_BASE_URI = 'http://picasaweb.google.com/data';
|
---|
61 | const PICASA_BASE_FEED_URI = 'http://picasaweb.google.com/data/feed';
|
---|
62 | const AUTH_SERVICE_NAME = 'lh2';
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Default projection when interacting with the Picasa server.
|
---|
66 | */
|
---|
67 | const DEFAULT_PROJECTION = 'api';
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * The default visibility to filter events by.
|
---|
71 | */
|
---|
72 | const DEFAULT_VISIBILITY = 'all';
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * The default user to retrieve feeds for.
|
---|
76 | */
|
---|
77 | const DEFAULT_USER = 'default';
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Path to the user feed on the Picasa server.
|
---|
81 | */
|
---|
82 | const USER_PATH = 'user';
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Path to album feeds on the Picasa server.
|
---|
86 | */
|
---|
87 | const ALBUM_PATH = 'albumid';
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Path to photo feeds on the Picasa server.
|
---|
91 | */
|
---|
92 | const PHOTO_PATH = 'photoid';
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * The path to the community search feed on the Picasa server.
|
---|
96 | */
|
---|
97 | const COMMUNITY_SEARCH_PATH = 'all';
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * The path to use for finding links to feeds within entries
|
---|
101 | */
|
---|
102 | const FEED_LINK_PATH = 'http://schemas.google.com/g/2005#feed';
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * The path to use for the determining type of an entry
|
---|
106 | */
|
---|
107 | const KIND_PATH = 'http://schemas.google.com/g/2005#kind';
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Namespaces used for Zend_Gdata_Photos
|
---|
111 | *
|
---|
112 | * @var array
|
---|
113 | */
|
---|
114 | public static $namespaces = array(
|
---|
115 | array('gphoto', 'http://schemas.google.com/photos/2007', 1, 0),
|
---|
116 | array('photo', 'http://www.pheed.com/pheed/', 1, 0),
|
---|
117 | array('exif', 'http://schemas.google.com/photos/exif/2007', 1, 0),
|
---|
118 | array('georss', 'http://www.georss.org/georss', 1, 0),
|
---|
119 | array('gml', 'http://www.opengis.net/gml', 1, 0),
|
---|
120 | array('media', 'http://search.yahoo.com/mrss/', 1, 0)
|
---|
121 | );
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Create Zend_Gdata_Photos object
|
---|
125 | *
|
---|
126 | * @param Zend_Http_Client $client (optional) The HTTP client to use when
|
---|
127 | * when communicating with the servers.
|
---|
128 | * @param string $applicationId The identity of the app in the form of Company-AppName-Version
|
---|
129 | */
|
---|
130 | public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
|
---|
131 | {
|
---|
132 | $this->registerPackage('Zend_Gdata_Photos');
|
---|
133 | $this->registerPackage('Zend_Gdata_Photos_Extension');
|
---|
134 | parent::__construct($client, $applicationId);
|
---|
135 | $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
|
---|
136 | }
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * Retrieve a UserFeed containing AlbumEntries, PhotoEntries and
|
---|
140 | * TagEntries associated with a given user.
|
---|
141 | *
|
---|
142 | * @param string $userName The userName of interest
|
---|
143 | * @param mixed $location (optional) The location for the feed, as a URL
|
---|
144 | * or Query. If not provided, a default URL will be used instead.
|
---|
145 | * @return Zend_Gdata_Photos_UserFeed
|
---|
146 | * @throws Zend_Gdata_App_Exception
|
---|
147 | * @throws Zend_Gdata_App_HttpException
|
---|
148 | */
|
---|
149 | public function getUserFeed($userName = null, $location = null)
|
---|
150 | {
|
---|
151 | if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
152 | $location->setType('feed');
|
---|
153 | if ($userName !== null) {
|
---|
154 | $location->setUser($userName);
|
---|
155 | }
|
---|
156 | $uri = $location->getQueryUrl();
|
---|
157 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
158 | if ($userName !== null) {
|
---|
159 | $location->setUser($userName);
|
---|
160 | }
|
---|
161 | $uri = $location->getQueryUrl();
|
---|
162 | } else if ($location !== null) {
|
---|
163 | $uri = $location;
|
---|
164 | } else if ($userName !== null) {
|
---|
165 | $uri = self::PICASA_BASE_FEED_URI . '/' .
|
---|
166 | self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
|
---|
167 | $userName;
|
---|
168 | } else {
|
---|
169 | $uri = self::PICASA_BASE_FEED_URI . '/' .
|
---|
170 | self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
|
---|
171 | self::DEFAULT_USER;
|
---|
172 | }
|
---|
173 |
|
---|
174 | return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed');
|
---|
175 | }
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Retreive AlbumFeed object containing multiple PhotoEntry or TagEntry
|
---|
179 | * objects.
|
---|
180 | *
|
---|
181 | * @param mixed $location (optional) The location for the feed, as a URL or Query.
|
---|
182 | * @return Zend_Gdata_Photos_AlbumFeed
|
---|
183 | * @throws Zend_Gdata_App_Exception
|
---|
184 | * @throws Zend_Gdata_App_HttpException
|
---|
185 | */
|
---|
186 | public function getAlbumFeed($location = null)
|
---|
187 | {
|
---|
188 | if ($location === null) {
|
---|
189 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
190 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
191 | 'Location must not be null');
|
---|
192 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
193 | $location->setType('feed');
|
---|
194 | $uri = $location->getQueryUrl();
|
---|
195 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
196 | $uri = $location->getQueryUrl();
|
---|
197 | } else {
|
---|
198 | $uri = $location;
|
---|
199 | }
|
---|
200 | return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed');
|
---|
201 | }
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Retreive PhotoFeed object containing comments and tags associated
|
---|
205 | * with a given photo.
|
---|
206 | *
|
---|
207 | * @param mixed $location (optional) The location for the feed, as a URL
|
---|
208 | * or Query. If not specified, the community search feed will
|
---|
209 | * be returned instead.
|
---|
210 | * @return Zend_Gdata_Photos_PhotoFeed
|
---|
211 | * @throws Zend_Gdata_App_Exception
|
---|
212 | * @throws Zend_Gdata_App_HttpException
|
---|
213 | */
|
---|
214 | public function getPhotoFeed($location = null)
|
---|
215 | {
|
---|
216 | if ($location === null) {
|
---|
217 | $uri = self::PICASA_BASE_FEED_URI . '/' .
|
---|
218 | self::DEFAULT_PROJECTION . '/' .
|
---|
219 | self::COMMUNITY_SEARCH_PATH;
|
---|
220 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
221 | $location->setType('feed');
|
---|
222 | $uri = $location->getQueryUrl();
|
---|
223 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
224 | $uri = $location->getQueryUrl();
|
---|
225 | } else {
|
---|
226 | $uri = $location;
|
---|
227 | }
|
---|
228 | return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed');
|
---|
229 | }
|
---|
230 |
|
---|
231 | /**
|
---|
232 | * Retreive a single UserEntry object.
|
---|
233 | *
|
---|
234 | * @param mixed $location The location for the feed, as a URL or Query.
|
---|
235 | * @return Zend_Gdata_Photos_UserEntry
|
---|
236 | * @throws Zend_Gdata_App_Exception
|
---|
237 | * @throws Zend_Gdata_App_HttpException
|
---|
238 | */
|
---|
239 | public function getUserEntry($location)
|
---|
240 | {
|
---|
241 | if ($location === null) {
|
---|
242 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
243 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
244 | 'Location must not be null');
|
---|
245 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
246 | $location->setType('entry');
|
---|
247 | $uri = $location->getQueryUrl();
|
---|
248 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
249 | $uri = $location->getQueryUrl();
|
---|
250 | } else {
|
---|
251 | $uri = $location;
|
---|
252 | }
|
---|
253 | return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry');
|
---|
254 | }
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Retreive a single AlbumEntry object.
|
---|
258 | *
|
---|
259 | * @param mixed $location The location for the feed, as a URL or Query.
|
---|
260 | * @return Zend_Gdata_Photos_AlbumEntry
|
---|
261 | * @throws Zend_Gdata_App_Exception
|
---|
262 | * @throws Zend_Gdata_App_HttpException
|
---|
263 | */
|
---|
264 | public function getAlbumEntry($location)
|
---|
265 | {
|
---|
266 | if ($location === null) {
|
---|
267 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
268 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
269 | 'Location must not be null');
|
---|
270 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
271 | $location->setType('entry');
|
---|
272 | $uri = $location->getQueryUrl();
|
---|
273 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
274 | $uri = $location->getQueryUrl();
|
---|
275 | } else {
|
---|
276 | $uri = $location;
|
---|
277 | }
|
---|
278 | return parent::getEntry($uri, 'Zend_Gdata_Photos_AlbumEntry');
|
---|
279 | }
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * Retreive a single PhotoEntry object.
|
---|
283 | *
|
---|
284 | * @param mixed $location The location for the feed, as a URL or Query.
|
---|
285 | * @return Zend_Gdata_Photos_PhotoEntry
|
---|
286 | * @throws Zend_Gdata_App_Exception
|
---|
287 | * @throws Zend_Gdata_App_HttpException
|
---|
288 | */
|
---|
289 | public function getPhotoEntry($location)
|
---|
290 | {
|
---|
291 | if ($location === null) {
|
---|
292 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
293 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
294 | 'Location must not be null');
|
---|
295 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
296 | $location->setType('entry');
|
---|
297 | $uri = $location->getQueryUrl();
|
---|
298 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
299 | $uri = $location->getQueryUrl();
|
---|
300 | } else {
|
---|
301 | $uri = $location;
|
---|
302 | }
|
---|
303 | return parent::getEntry($uri, 'Zend_Gdata_Photos_PhotoEntry');
|
---|
304 | }
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Retreive a single TagEntry object.
|
---|
308 | *
|
---|
309 | * @param mixed $location The location for the feed, as a URL or Query.
|
---|
310 | * @return Zend_Gdata_Photos_TagEntry
|
---|
311 | * @throws Zend_Gdata_App_Exception
|
---|
312 | * @throws Zend_Gdata_App_HttpException
|
---|
313 | */
|
---|
314 | public function getTagEntry($location)
|
---|
315 | {
|
---|
316 | if ($location === null) {
|
---|
317 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
318 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
319 | 'Location must not be null');
|
---|
320 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
321 | $location->setType('entry');
|
---|
322 | $uri = $location->getQueryUrl();
|
---|
323 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
324 | $uri = $location->getQueryUrl();
|
---|
325 | } else {
|
---|
326 | $uri = $location;
|
---|
327 | }
|
---|
328 | return parent::getEntry($uri, 'Zend_Gdata_Photos_TagEntry');
|
---|
329 | }
|
---|
330 |
|
---|
331 | /**
|
---|
332 | * Retreive a single CommentEntry object.
|
---|
333 | *
|
---|
334 | * @param mixed $location The location for the feed, as a URL or Query.
|
---|
335 | * @return Zend_Gdata_Photos_CommentEntry
|
---|
336 | * @throws Zend_Gdata_App_Exception
|
---|
337 | * @throws Zend_Gdata_App_HttpException
|
---|
338 | */
|
---|
339 | public function getCommentEntry($location)
|
---|
340 | {
|
---|
341 | if ($location === null) {
|
---|
342 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
343 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
344 | 'Location must not be null');
|
---|
345 | } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
|
---|
346 | $location->setType('entry');
|
---|
347 | $uri = $location->getQueryUrl();
|
---|
348 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
349 | $uri = $location->getQueryUrl();
|
---|
350 | } else {
|
---|
351 | $uri = $location;
|
---|
352 | }
|
---|
353 | return parent::getEntry($uri, 'Zend_Gdata_Photos_CommentEntry');
|
---|
354 | }
|
---|
355 |
|
---|
356 | /**
|
---|
357 | * Create a new album from a AlbumEntry.
|
---|
358 | *
|
---|
359 | * @param Zend_Gdata_Photos_AlbumEntry $album The album entry to
|
---|
360 | * insert.
|
---|
361 | * @param string $url (optional) The URI that the album should be
|
---|
362 | * uploaded to. If null, the default album creation URI for
|
---|
363 | * this domain will be used.
|
---|
364 | * @return Zend_Gdata_Photos_AlbumEntry The inserted album entry as
|
---|
365 | * returned by the server.
|
---|
366 | * @throws Zend_Gdata_App_Exception
|
---|
367 | * @throws Zend_Gdata_App_HttpException
|
---|
368 | */
|
---|
369 | public function insertAlbumEntry($album, $uri = null)
|
---|
370 | {
|
---|
371 | if ($uri === null) {
|
---|
372 | $uri = self::PICASA_BASE_FEED_URI . '/' .
|
---|
373 | self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .
|
---|
374 | self::DEFAULT_USER;
|
---|
375 | }
|
---|
376 | $newEntry = $this->insertEntry($album, $uri, 'Zend_Gdata_Photos_AlbumEntry');
|
---|
377 | return $newEntry;
|
---|
378 | }
|
---|
379 |
|
---|
380 | /**
|
---|
381 | * Create a new photo from a PhotoEntry.
|
---|
382 | *
|
---|
383 | * @param Zend_Gdata_Photos_PhotoEntry $photo The photo to insert.
|
---|
384 | * @param string $url The URI that the photo should be uploaded
|
---|
385 | * to. Alternatively, an AlbumEntry can be provided and the
|
---|
386 | * photo will be added to that album.
|
---|
387 | * @return Zend_Gdata_Photos_PhotoEntry The inserted photo entry
|
---|
388 | * as returned by the server.
|
---|
389 | * @throws Zend_Gdata_App_Exception
|
---|
390 | * @throws Zend_Gdata_App_HttpException
|
---|
391 | */
|
---|
392 | public function insertPhotoEntry($photo, $uri = null)
|
---|
393 | {
|
---|
394 | if ($uri instanceof Zend_Gdata_Photos_AlbumEntry) {
|
---|
395 | $uri = $uri->getLink(self::FEED_LINK_PATH)->href;
|
---|
396 | }
|
---|
397 | if ($uri === null) {
|
---|
398 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
399 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
400 | 'URI must not be null');
|
---|
401 | }
|
---|
402 | $newEntry = $this->insertEntry($photo, $uri, 'Zend_Gdata_Photos_PhotoEntry');
|
---|
403 | return $newEntry;
|
---|
404 | }
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * Create a new tag from a TagEntry.
|
---|
408 | *
|
---|
409 | * @param Zend_Gdata_Photos_TagEntry $tag The tag entry to insert.
|
---|
410 | * @param string $url The URI where the tag should be
|
---|
411 | * uploaded to. Alternatively, a PhotoEntry can be provided and
|
---|
412 | * the tag will be added to that photo.
|
---|
413 | * @return Zend_Gdata_Photos_TagEntry The inserted tag entry as returned
|
---|
414 | * by the server.
|
---|
415 | * @throws Zend_Gdata_App_Exception
|
---|
416 | * @throws Zend_Gdata_App_HttpException
|
---|
417 | */
|
---|
418 | public function insertTagEntry($tag, $uri = null)
|
---|
419 | {
|
---|
420 | if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
|
---|
421 | $uri = $uri->getLink(self::FEED_LINK_PATH)->href;
|
---|
422 | }
|
---|
423 | if ($uri === null) {
|
---|
424 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
425 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
426 | 'URI must not be null');
|
---|
427 | }
|
---|
428 | $newEntry = $this->insertEntry($tag, $uri, 'Zend_Gdata_Photos_TagEntry');
|
---|
429 | return $newEntry;
|
---|
430 | }
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * Create a new comment from a CommentEntry.
|
---|
434 | *
|
---|
435 | * @param Zend_Gdata_Photos_CommentEntry $comment The comment entry to
|
---|
436 | * insert.
|
---|
437 | * @param string $url The URI where the comment should be uploaded to.
|
---|
438 | * Alternatively, a PhotoEntry can be provided and
|
---|
439 | * the comment will be added to that photo.
|
---|
440 | * @return Zend_Gdata_Photos_CommentEntry The inserted comment entry
|
---|
441 | * as returned by the server.
|
---|
442 | * @throws Zend_Gdata_App_Exception
|
---|
443 | * @throws Zend_Gdata_App_HttpException
|
---|
444 | */
|
---|
445 | public function insertCommentEntry($comment, $uri = null)
|
---|
446 | {
|
---|
447 | if ($uri instanceof Zend_Gdata_Photos_PhotoEntry) {
|
---|
448 | $uri = $uri->getLink(self::FEED_LINK_PATH)->href;
|
---|
449 | }
|
---|
450 | if ($uri === null) {
|
---|
451 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
452 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
453 | 'URI must not be null');
|
---|
454 | }
|
---|
455 | $newEntry = $this->insertEntry($comment, $uri, 'Zend_Gdata_Photos_CommentEntry');
|
---|
456 | return $newEntry;
|
---|
457 | }
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Delete an AlbumEntry.
|
---|
461 | *
|
---|
462 | * @param Zend_Gdata_Photos_AlbumEntry $album The album entry to
|
---|
463 | * delete.
|
---|
464 | * @param boolean $catch Whether to catch an exception when
|
---|
465 | * modified and re-delete or throw
|
---|
466 | * @return void.
|
---|
467 | * @throws Zend_Gdata_App_Exception
|
---|
468 | * @throws Zend_Gdata_App_HttpException
|
---|
469 | */
|
---|
470 | public function deleteAlbumEntry($album, $catch)
|
---|
471 | {
|
---|
472 | if ($catch) {
|
---|
473 | try {
|
---|
474 | $this->delete($album);
|
---|
475 | } catch (Zend_Gdata_App_HttpException $e) {
|
---|
476 | if ($e->getResponse()->getStatus() === 409) {
|
---|
477 | $entry = new Zend_Gdata_Photos_AlbumEntry($e->getResponse()->getBody());
|
---|
478 | $this->delete($entry->getLink('edit')->href);
|
---|
479 | } else {
|
---|
480 | throw $e;
|
---|
481 | }
|
---|
482 | }
|
---|
483 | } else {
|
---|
484 | $this->delete($album);
|
---|
485 | }
|
---|
486 | }
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Delete a PhotoEntry.
|
---|
490 | *
|
---|
491 | * @param Zend_Gdata_Photos_PhotoEntry $photo The photo entry to
|
---|
492 | * delete.
|
---|
493 | * @param boolean $catch Whether to catch an exception when
|
---|
494 | * modified and re-delete or throw
|
---|
495 | * @return void.
|
---|
496 | * @throws Zend_Gdata_App_Exception
|
---|
497 | * @throws Zend_Gdata_App_HttpException
|
---|
498 | */
|
---|
499 | public function deletePhotoEntry($photo, $catch)
|
---|
500 | {
|
---|
501 | if ($catch) {
|
---|
502 | try {
|
---|
503 | $this->delete($photo);
|
---|
504 | } catch (Zend_Gdata_App_HttpException $e) {
|
---|
505 | if ($e->getResponse()->getStatus() === 409) {
|
---|
506 | $entry = new Zend_Gdata_Photos_PhotoEntry($e->getResponse()->getBody());
|
---|
507 | $this->delete($entry->getLink('edit')->href);
|
---|
508 | } else {
|
---|
509 | throw $e;
|
---|
510 | }
|
---|
511 | }
|
---|
512 | } else {
|
---|
513 | $this->delete($photo);
|
---|
514 | }
|
---|
515 | }
|
---|
516 |
|
---|
517 | /**
|
---|
518 | * Delete a CommentEntry.
|
---|
519 | *
|
---|
520 | * @param Zend_Gdata_Photos_CommentEntry $comment The comment entry to
|
---|
521 | * delete.
|
---|
522 | * @param boolean $catch Whether to catch an exception when
|
---|
523 | * modified and re-delete or throw
|
---|
524 | * @return void.
|
---|
525 | * @throws Zend_Gdata_App_Exception
|
---|
526 | * @throws Zend_Gdata_App_HttpException
|
---|
527 | */
|
---|
528 | public function deleteCommentEntry($comment, $catch)
|
---|
529 | {
|
---|
530 | if ($catch) {
|
---|
531 | try {
|
---|
532 | $this->delete($comment);
|
---|
533 | } catch (Zend_Gdata_App_HttpException $e) {
|
---|
534 | if ($e->getResponse()->getStatus() === 409) {
|
---|
535 | $entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody());
|
---|
536 | $this->delete($entry->getLink('edit')->href);
|
---|
537 | } else {
|
---|
538 | throw $e;
|
---|
539 | }
|
---|
540 | }
|
---|
541 | } else {
|
---|
542 | $this->delete($comment);
|
---|
543 | }
|
---|
544 | }
|
---|
545 |
|
---|
546 | /**
|
---|
547 | * Delete a TagEntry.
|
---|
548 | *
|
---|
549 | * @param Zend_Gdata_Photos_TagEntry $tag The tag entry to
|
---|
550 | * delete.
|
---|
551 | * @param boolean $catch Whether to catch an exception when
|
---|
552 | * modified and re-delete or throw
|
---|
553 | * @return void.
|
---|
554 | * @throws Zend_Gdata_App_Exception
|
---|
555 | * @throws Zend_Gdata_App_HttpException
|
---|
556 | */
|
---|
557 | public function deleteTagEntry($tag, $catch)
|
---|
558 | {
|
---|
559 | if ($catch) {
|
---|
560 | try {
|
---|
561 | $this->delete($tag);
|
---|
562 | } catch (Zend_Gdata_App_HttpException $e) {
|
---|
563 | if ($e->getResponse()->getStatus() === 409) {
|
---|
564 | $entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody());
|
---|
565 | $this->delete($entry->getLink('edit')->href);
|
---|
566 | } else {
|
---|
567 | throw $e;
|
---|
568 | }
|
---|
569 | }
|
---|
570 | } else {
|
---|
571 | $this->delete($tag);
|
---|
572 | }
|
---|
573 | }
|
---|
574 |
|
---|
575 | }
|
---|