Source for file photo.php
Documentation is available at photo.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
* Google Picasa data class for the Joomla Platform.
* @package Joomla.Platform
* @var SimpleXMLElement The photo's XML
* @param SimpleXMLElement $xml XML from Google
* @param JRegistry $options Google options object
* @param JGoogleAuth $auth Google data http client object
public function __construct(SimpleXMLElement $xml, JRegistry $options =
null, JGoogleAuth $auth =
null)
if (isset
($this->auth) &&
!$this->auth->getOption('scope'))
$this->auth->setOption('scope', 'https://picasaweb.google.com/data/');
* Method to delete a Picasa photo
* @param mixed $match Check for most up to date photo
* @return boolean Success or failure.
* @throws UnexpectedValueException
public function delete($match =
'*')
$match =
$this->xml->xpath('./@gd:etag');
$jdata =
$this->query($url, null, array('GData-Version' =>
2, 'If-Match' =>
$match), 'delete');
if (strpos($e->getMessage(), 'Error code 412 received requesting data: Mismatch: etags') ===
0)
throw
new RuntimeException("Etag match failed: `$match`.");
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to get the photo link
* @param string $type Type of link to return
* @return string Link or false on failure
public function getLink($type =
'edit')
$links =
$this->xml->link;
foreach ($links as $link)
if ($link->attributes()->rel ==
$type)
return (string)
$link->attributes()->href;
* Method to get the photo's URL
return (string)
$this->xml->children()->content->attributes()->src;
* Method to get the photo's thumbnails
* @return array An array of thumbnails
foreach ($this->xml->children('media', true)->group->thumbnail as $item)
$url = (string)
$item->attributes()->url;
$width = (int)
$item->attributes()->width;
$height = (int)
$item->attributes()->height;
$thumbs[$width] =
array('url' =>
$url, 'w' =>
$width, 'h' =>
$height);
* Method to get the title of the photo
* @return string Photo title
return (string)
$this->xml->children()->title;
* Method to get the summary of the photo
* @return string Photo description
return (string)
$this->xml->children()->summary;
* Method to get the access level of the photo
* @return string Photo access level
return (string)
$this->xml->children('gphoto', true)->access;
* Method to get the time of the photo
* @return double Photo time
return (double)
$this->xml->children('gphoto', true)->timestamp /
1000;
* Method to get the size of the photo
return (int)
$this->xml->children('gphoto', true)->size;
* Method to get the height of the photo
* @return int Photo height
return (int)
$this->xml->children('gphoto', true)->height;
* Method to get the width of the photo
* @return int Photo width
return (int)
$this->xml->children('gphoto', true)->width;
* Method to set the title of the photo
* @param string $title New photo title
* @return JGoogleDataPicasaPhoto The object for method chaining
$this->xml->children()->title =
$title;
* Method to set the summary of the photo
* @param string $summary New photo description
* @return JGoogleDataPicasaPhoto The object for method chaining
$this->xml->children()->summary =
$summary;
* Method to set the access level of the photo
* @param string $access New photo access level
* @return JGoogleDataPicasaPhoto The object for method chaining
$this->xml->children('gphoto', true)->access =
$access;
* Method to set the time of the photo
* @param int $time New photo time
* @return JGoogleDataPicasaPhoto The object for method chaining
$this->xml->children('gphoto', true)->timestamp =
$time *
1000;
* Method to modify a Picasa Photo
* @param string $match Optional eTag matching parameter
* @return mixed Data from Google.
public function save($match =
'*')
$match =
$this->xml->xpath('./@gd:etag');
$headers =
array('GData-Version' =>
2, 'Content-type' =>
'application/atom+xml', 'If-Match' =>
$match);
$jdata =
$this->query($url, $this->xml->asXML(), $headers, 'put');
if (strpos($e->getMessage(), 'Error code 412 received requesting data: Mismatch: etags') ===
0)
throw
new RuntimeException("Etag match failed: `$match`.");
* @return mixed Data from Google
$jdata =
$this->query($url, null, array('GData-Version' =>
2));
Documentation generated on Tue, 19 Nov 2013 15:10:31 +0100 by phpDocumentor 1.4.3