Source for file album.php
Documentation is available at album.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 album'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 album
* @param mixed $match Check for most up to date album
* @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 album 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 title of the album
* @return string Album title
return (string)
$this->xml->children()->title;
* Method to get the summary of the album
* @return string Album summary
return (string)
$this->xml->children()->summary;
* Method to get the location of the album
* @return string Album location
return (string)
$this->xml->children('gphoto', true)->location;
* Method to get the access level of the album
* @return string Album access level
return (string)
$this->xml->children('gphoto', true)->access;
* Method to get the time of the album
* @return double Album time
return (double)
$this->xml->children('gphoto', true)->timestamp /
1000;
* Method to set the title of the album
* @param string $title New album title
* @return JGoogleDataPicasaAlbum The object for method chaining
$this->xml->children()->title =
$title;
* Method to set the summary of the album
* @param string $summary New album summary
* @return JGoogleDataPicasaAlbum The object for method chaining
$this->xml->children()->summary =
$summary;
* Method to set the location of the album
* @param string $location New album location
* @return JGoogleDataPicasaAlbum The object for method chaining
$this->xml->children('gphoto', true)->location =
$location;
* Method to set the access level of the album
* @param string $access New album access
* @return JGoogleDataPicasaAlbum The object for method chaining
$this->xml->children('gphoto', true)->access =
$access;
* Method to set the time of the album
* @param int $time New album time
* @return JGoogleDataPicasaAlbum The object for method chaining
$this->xml->children('gphoto', true)->timestamp =
$time *
1000;
* Method to modify a Picasa Album
* @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
* @throws UnexpectedValueException
$jdata =
$this->query($url, null, array('GData-Version' =>
2));
* Method to retrieve a list of Picasa Photos
* @return mixed Data from Google
* @throws UnexpectedValueException
$url =
$this->getLink('http://schemas.google.com/g/2005#feed');
$jdata =
$this->query($url, null, array('GData-Version' =>
2));
$xml =
$this->safeXML($jdata->body);
if (isset
($xml->children()->entry))
foreach ($xml->children()->entry as $item)
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* @param string $file Path of file to upload
* @param string $title Title to give to file (defaults to filename)
* @param string $summary Description of the file
* @return mixed Data from Google
* @throws RuntimeException
public function upload($file, $title =
'', $summary =
'')
if (!($type =
$this->getMIME($file)))
throw
new RuntimeException("Inappropriate file type.");
throw
new RuntimeException("Cannot access file: `$file`");
$xml =
new SimpleXMLElement('<entry></entry>');
$xml->addAttribute('xmlns', 'http://www.w3.org/2005/Atom');
$xml->addChild('title', $title);
$xml->addChild('summary', $summary);
$cat =
$xml->addChild('category', '');
$cat->addAttribute('scheme', 'http://schemas.google.com/g/2005#kind');
$cat->addAttribute('term', 'http://schemas.google.com/photos/2007#photo');
$post =
"Media multipart posting\n";
$post .=
"--END_OF_PART\n";
$post .=
"Content-Type: application/atom+xml\n\n";
$post .=
$xml->asXML() .
"\n";
$post .=
"--END_OF_PART\n";
$post .=
"Content-Type: {$type}\n\n";
$jdata =
$this->query($this->getLink(), $post, array('GData-Version' =>
2, 'Content-Type: multipart/related'), 'post');
* @param string $file Filename
* @return mixed Data from Google
* @throws UnexpectedValueException
return 'video/quicktime';
Documentation generated on Tue, 19 Nov 2013 14:53:40 +0100 by phpDocumentor 1.4.3