Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renaming spree.

  • Loading branch information...
commit 198bc6f95329338c6b08a580c7957dd49e7f35e1 1 parent 5d41dae
@aaronschmitz aaronschmitz authored LouisLandry committed
Showing with 1,727 additions and 300 deletions.
  1. +6 −6 libraries/joomla/google/auth.php
  2. +14 −14 libraries/joomla/google/auth/oauth2.php
  3. +9 −9 libraries/joomla/google/data.php
  4. +13 −13 libraries/joomla/google/data/adsense.php
  5. +36 −36 libraries/joomla/google/data/calendar.php
  6. +4 −4 libraries/joomla/google/data/picasa.php
  7. +11 −12 libraries/joomla/google/data/picasa/album.php
  8. +9 −9 libraries/joomla/google/data/picasa/photo.php
  9. +95 −0 libraries/joomla/google/data/plus.php
  10. +194 −0 libraries/joomla/google/data/plus/activities.php
  11. +133 −0 libraries/joomla/google/data/plus/comments.php
  12. +171 −0 libraries/joomla/google/data/plus/people.php
  13. +3 −50 libraries/joomla/google/embed.php
  14. +14 −14 libraries/joomla/google/embed/analytics.php
  15. +6 −6 libraries/joomla/google/embed/maps.php
  16. +8 −5 libraries/joomla/google/google.php
  17. +25 −18 libraries/joomla/{oauth/v2client.php → oauth2/client.php}
  18. +21 −20 tests/suites/unit/joomla/google/JGoogleAuthOauth2Test.php
  19. +11 −6 tests/suites/unit/joomla/google/JGoogleDataAdsenseTest.php
  20. +11 −6 tests/suites/unit/joomla/google/JGoogleDataCalendarTest.php
  21. +14 −9 tests/suites/unit/joomla/google/JGoogleDataPicasaAlbumTest.php
  22. +12 −7 tests/suites/unit/joomla/google/JGoogleDataPicasaPhotoTest.php
  23. +11 −6 tests/suites/unit/joomla/google/JGoogleDataPicasaTest.php
  24. +245 −0 tests/suites/unit/joomla/google/JGoogleDataPlusActivitiesTest.php
  25. +203 −0 tests/suites/unit/joomla/google/JGoogleDataPlusCommentsTest.php
  26. +242 −0 tests/suites/unit/joomla/google/JGoogleDataPlusPeopleTest.php
  27. +152 −0 tests/suites/unit/joomla/google/JGoogleDataPlusTest.php
  28. +2 −2 tests/suites/unit/joomla/google/JGoogleEmbedAnalyticsTest.php
  29. +3 −3 tests/suites/unit/joomla/google/JGoogleEmbedMapsTest.php
  30. +13 −4 tests/suites/unit/joomla/google/JGoogleTest.php
  31. +36 −41 tests/suites/unit/joomla/{oauth/JOauthV2clientTest.php → oauth2/JOauth2ClientTest.php}
View
12 libraries/joomla/google/auth.php
@@ -14,33 +14,33 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
abstract class JGoogleAuth
{
/**
* @var JRegistry Options for the Google authentication object.
- * @since 12.2
+ * @since 12.3
*/
protected $options;
/**
* Abstract method to authenticate to Google
*
- * @return bool True on success.
+ * @return boolean True on success.
*
* @since 12.2
*/
- abstract public function auth();
+ abstract public function authenticate();
/**
* Verify if the client has been authenticated
*
- * @return bool Is authenticated
+ * @return boolean Is authenticated
*
* @since 12.2
*/
- abstract public function isAuth();
+ abstract public function isAuthenticated();
/**
* Abstract method to retrieve data from Google
View
28 libraries/joomla/google/auth/oauth2.php
@@ -15,53 +15,53 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleAuthOauth2 extends JGoogleAuth
{
/**
- * @var JOauthV2client OAuth client for the Google authentication object.
- * @since 12.2
+ * @var JOAuth2Client OAuth client for the Google authentication object.
+ * @since 12.3
*/
protected $client;
/**
* Constructor.
*
- * @param JRegistry $options JGoogleAuth options object.
- * @param JOauthV2client $client OAuth client for Google authentication.
+ * @param JRegistry $options JGoogleAuth options object.
+ * @param JOAuth2Client $client OAuth client for Google authentication.
*
* @since 12.2
*/
- public function __construct(JRegistry $options = null, JOauthV2client $client = null)
+ public function __construct(JRegistry $options = null, JOAuth2Client $client = null)
{
$this->options = isset($options) ? $options : new JRegistry;
- $this->client = isset($client) ? $client : new JOauthV2client($this->options);
+ $this->client = isset($client) ? $client : new JOAuth2Client($this->options);
}
/**
* Method to authenticate to Google
*
- * @return bool True on success.
+ * @return boolean True on success.
*
* @since 12.2
*/
- public function auth()
+ public function authenticate()
{
$this->googlize();
- return $this->client->auth();
+ return $this->client->authenticate();
}
/**
* Verify if the client has been authenticated
*
- * @return bool Is authenticated
+ * @return boolean Is authenticated
*
* @since 12.2
*/
- public function isAuth()
+ public function isAuthenticated()
{
- return $this->client->isAuth();
+ return $this->client->isAuthenticated();
}
/**
@@ -85,7 +85,7 @@ public function query($url, $data = null, $headers = null, $method = 'get')
/**
* Method to fill in Google-specific OAuth settings
*
- * @return JOauthV2client Google-configured Oauth2 client.
+ * @return JOAuth2Client Google-configured Oauth2 client.
*
* @since 12.2
*/
View
18 libraries/joomla/google/data.php
@@ -14,19 +14,19 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
abstract class JGoogleData
{
/**
* @var JRegistry Options for the Google data object.
- * @since 12.2
+ * @since 12.3
*/
protected $options;
/**
* @var JGoogleAuth Authentication client for the Google data object.
- * @since 12.2
+ * @since 12.3
*/
protected $auth;
@@ -47,25 +47,25 @@ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
/**
* Method to authenticate to Google
*
- * @return bool True on success.
+ * @return boolean True on success.
*
* @since 12.2
*/
- public function auth()
+ public function authenticate()
{
- return $this->auth->auth();
+ return $this->auth->authenticate();
}
/**
* Check authentication
*
- * @return bool True if authenticated.
+ * @return boolean True if authenticated.
*
* @since 12.2
*/
- public function authenticated()
+ public function isAuthenticated()
{
- return $this->auth->isAuth();
+ return $this->auth->isAuthenticated();
}
/**
View
26 libraries/joomla/google/data/adsense.php
@@ -14,7 +14,7 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataAdsense extends JGoogleData
{
@@ -39,8 +39,8 @@ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
/**
* Method to get an Adsense account's settings from Google
*
- * @param string $accountID ID of account to get
- * @param bool $subaccounts Include list of subaccounts
+ * @param string $accountID ID of account to get
+ * @param boolean $subaccounts Include list of subaccounts
*
* @return mixed Data from Google
*
@@ -48,7 +48,7 @@ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
*/
public function getAccount($accountID, $subaccounts = true)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . ($subaccounts ? '?tree=true' : '');
$jdata = $this->query($url);
@@ -80,7 +80,7 @@ public function getAccount($accountID, $subaccounts = true)
*/
public function listAccounts($options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -107,7 +107,7 @@ public function listAccounts($options = array(), $maxpages = 1)
*/
public function listClients($accountID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -133,7 +133,7 @@ public function listClients($accountID, $options = array(), $maxpages = 1)
*/
public function getUnit($accountID, $adclientID, $adunitID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID);
$url .= '/adclients/' . urlencode($adclientID) . '/adunits/' . urlencode($adunitID);
@@ -169,7 +169,7 @@ public function getUnit($accountID, $adclientID, $adunitID)
*/
public function listUnitChannels($accountID, $adclientID, $adunitID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -196,7 +196,7 @@ public function listUnitChannels($accountID, $adclientID, $adunitID, $options =
*/
public function getChannel($accountID, $adclientID, $channelID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . '/adclients/';
$url .= urlencode($adclientID) . '/customchannels/' . urlencode($channelID);
@@ -231,7 +231,7 @@ public function getChannel($accountID, $adclientID, $channelID)
*/
public function listChannels($accountID, $adclientID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -261,7 +261,7 @@ public function listChannels($accountID, $adclientID, $options = array(), $maxpa
*/
public function listChannelUnits($accountID, $adclientID, $channelID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -290,7 +290,7 @@ public function listChannelUnits($accountID, $adclientID, $channelID, $options =
*/
public function listUrlChannels($accountID, $adclientID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -320,7 +320,7 @@ public function listUrlChannels($accountID, $adclientID, $options = array(), $ma
*/
public function generateReport($accountID, $start, $end = false, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
if (is_int($start))
{
View
72 libraries/joomla/google/data/calendar.php
@@ -14,7 +14,7 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataCalendar extends JGoogleData
{
@@ -41,14 +41,14 @@ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
*
* @param string $calendarID ID of calendar to delete
*
- * @return bool Success or failure
+ * @return boolean Success or failure
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function removeCalendar($calendarID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$jdata = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode($calendarID), null, null, 'delete');
if ($jdata->body != '')
@@ -75,7 +75,7 @@ public function removeCalendar($calendarID)
*/
public function getCalendar($calendarID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$jdata = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode($calendarID));
if ($data = json_decode($jdata->body, true))
@@ -106,7 +106,7 @@ public function getCalendar($calendarID)
*/
public function addCalendar($calendarID, $options = array())
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$options['id'] = $calendarID;
$url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList';
@@ -139,7 +139,7 @@ public function addCalendar($calendarID, $options = array())
*/
public function listCalendars($options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -165,7 +165,7 @@ public function listCalendars($options = array(), $maxpages = 1)
*/
public function editCalendarSettings($calendarID, $options)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode($calendarID);
$jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'put');
@@ -189,14 +189,14 @@ public function editCalendarSettings($calendarID, $options)
*
* @param string $calendarID ID of calendar to clear
*
- * @return bool Success or failure
+ * @return boolean Success or failure
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function clearCalendar($calendarID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$data = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/' . urlencode($calendarID) . '/clear', null, null, 'post');
if ($data->body != '')
@@ -216,14 +216,14 @@ public function clearCalendar($calendarID)
*
* @param string $calendarID ID of calendar to delete.
*
- * @return bool Success or failure
+ * @return boolean Success or failure
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function deleteCalendar($calendarID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$data = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/' . urlencode($calendarID), null, null, 'delete');
if ($data->body != '')
@@ -251,7 +251,7 @@ public function deleteCalendar($calendarID)
*/
public function createCalendar($title, $options = array())
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$options['summary'] = $title;
$url = 'https://www.googleapis.com/calendar/v3/calendars';
@@ -284,7 +284,7 @@ public function createCalendar($title, $options = array())
*/
public function editCalendar($calendarID, $options)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/users/me/calendars/' . urlencode($calendarID);
$jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'put');
@@ -311,14 +311,14 @@ public function editCalendar($calendarID, $options)
* @param string $calendarID ID of calendar to delete from
* @param string $eventID ID of event to delete.
*
- * @return bool Success or failure.
+ * @return boolean Success or failure.
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function deleteEvent($calendarID, $eventID)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/users/me/calendars/' . urlencode($calendarID) . '/events/' . urlencode($eventID);
$data = $this->query($url, null, null, 'delete');
@@ -348,7 +348,7 @@ public function deleteEvent($calendarID, $eventID)
*/
public function getEvent($calendarID, $eventID, $options = array())
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList/';
$url .= urlencode($calendarID) . '/events/' . urlencode($eventID) . '?' . http_build_query($options);
@@ -371,13 +371,13 @@ public function getEvent($calendarID, $eventID, $options = array())
/**
* Method to create a Google Calendar event
*
- * @param string $calendarID ID of calendar
- * @param mixed $start Event start time
- * @param mixed $end Event end time
- * @param array $options New event settings
- * @param mixed $timezone Timezone for event
- * @param bool $allday Treat event as an all-day event
- * @param bool $notify Notify participants
+ * @param string $calendarID ID of calendar
+ * @param mixed $start Event start time
+ * @param mixed $end Event end time
+ * @param array $options New event settings
+ * @param mixed $timezone Timezone for event
+ * @param boolean $allday Treat event as an all-day event
+ * @param boolean $notify Notify participants
*
* @return mixed Data from Google.
*
@@ -387,7 +387,7 @@ public function getEvent($calendarID, $eventID, $options = array())
*/
public function createEvent($calendarID, $start, $end = false, $options = array(), $timezone = false, $allday = false, $notify = false)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
if (!$start)
{
@@ -492,7 +492,7 @@ public function createEvent($calendarID, $start, $end = false, $options = array(
*/
public function listRecurrences($calendarID, $eventID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -520,7 +520,7 @@ public function listRecurrences($calendarID, $eventID, $options = array(), $maxp
*/
public function listEvents($calendarID, $options = array(), $maxpages = 1)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null;
unset($options['nextPageToken']);
@@ -536,10 +536,10 @@ public function listEvents($calendarID, $options = array(), $maxpages = 1)
/**
* Method to move an event from one calendar to another
*
- * @param string $calendarID Calendar ID
- * @param string $eventID ID of the event to change
- * @param string $destID Calendar ID
- * @param bool $notify Notify participants of changes
+ * @param string $calendarID Calendar ID
+ * @param string $eventID ID of the event to change
+ * @param string $destID Calendar ID
+ * @param boolean $notify Notify participants of changes
*
* @return mixed Data from Google.
*
@@ -548,7 +548,7 @@ public function listEvents($calendarID, $options = array(), $maxpages = 1)
*/
public function moveEvent($calendarID, $eventID, $destID, $notify = false)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/calendars/' . urlencode($calendarID) . '/events/' . urlencode($eventID) . '/move';
$url .= '?destination=' . $destID . ($notify ? '&sendNotifications=true' : '');
@@ -571,10 +571,10 @@ public function moveEvent($calendarID, $eventID, $destID, $notify = false)
/**
* Method to edit a Google Calendar event
*
- * @param string $calendarID Calendar ID
- * @param string $eventID ID of the event to change
- * @param array $options Event settings
- * @param bool $notify Notify participants of changes
+ * @param string $calendarID Calendar ID
+ * @param string $eventID ID of the event to change
+ * @param array $options Event settings
+ * @param boolean $notify Notify participants of changes
*
* @return mixed Data from Google.
*
@@ -583,7 +583,7 @@ public function moveEvent($calendarID, $eventID, $destID, $notify = false)
*/
public function editEvent($calendarID, $eventID, $options, $notify = false)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://www.googleapis.com/calendar/v3/calendars/';
$url .= urlencode($calendarID) . '/events/' . urlencode($eventID) . ($notify ? '?sendNotifications=true' : '');
View
8 libraries/joomla/google/data/picasa.php
@@ -14,7 +14,7 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataPicasa extends JGoogleData
{
@@ -48,7 +48,7 @@ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
*/
public function listAlbums($userID = 'default')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = 'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID);
$jdata = $this->query($url, null, array('GData-Version' => 2));
@@ -90,7 +90,7 @@ public function listAlbums($userID = 'default')
*/
public function createAlbum($userID = 'default', $title = '', $access = 'private', $summary = '', $location = '', $time = false, $keywords = array())
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$time = $time ? $time : time();
$title = $title != '' ? $title : date('F j, Y');
@@ -131,7 +131,7 @@ public function createAlbum($userID = 'default', $title = '', $access = 'private
*/
public function getAlbum($url)
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$jdata = $this->query($url, null, array('GData-Version' => 2));
$xml = $this->safeXML($jdata->body);
View
23 libraries/joomla/google/data/picasa/album.php
@@ -14,13 +14,13 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataPicasaAlbum extends JGoogleData
{
/**
* @var SimpleXMLElement The album's XML
- * @since 12.2
+ * @since 12.3
*/
protected $xml;
@@ -50,14 +50,14 @@ public function __construct(SimpleXMLElement $xml, JRegistry $options = null, JG
*
* @param mixed $match Check for most up to date album
*
- * @return bool Success or failure.
+ * @return boolean Success or failure.
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function delete($match = '*')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
@@ -165,14 +165,13 @@ public function getAccess()
/**
* Method to get the time of the album
*
- * @return int Album time
+ * @return double Album time
*
* @since 12.2
*/
public function getTime()
{
- return (int) $this->xml->children('gphoto', true)->timestamp;
- return $this;
+ return (double) $this->xml->children('gphoto', true)->timestamp / 1000;
}
/**
@@ -246,7 +245,7 @@ public function setAccess($access)
*/
public function setTime($time)
{
- $this->xml->children('gphoto', true)->timestamp = $time;
+ $this->xml->children('gphoto', true)->timestamp = $time * 1000;
return $this;
}
@@ -261,7 +260,7 @@ public function setTime($time)
*/
public function save($match = '*')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
@@ -303,7 +302,7 @@ public function save($match = '*')
*/
public function refresh()
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version' => 2));
@@ -326,7 +325,7 @@ public function refresh()
*/
public function listPhotos()
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink('http://schemas.google.com/g/2005#feed');
$jdata = $this->query($url, null, array('GData-Version' => 2));
@@ -365,7 +364,7 @@ public function listPhotos()
*/
public function upload($file, $title = '', $summary = '')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$title = $title != '' ? $title : JFile::getName($file);
if (!($type = $this->getMIME($file)))
View
18 libraries/joomla/google/data/picasa/photo.php
@@ -14,13 +14,13 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataPicasaPhoto extends JGoogleData
{
/**
* @var SimpleXMLElement The photo's XML
- * @since 12.2
+ * @since 12.3
*/
protected $xml;
@@ -50,14 +50,14 @@ public function __construct(SimpleXMLElement $xml, JRegistry $options = null, JG
*
* @param mixed $match Check for most up to date photo
*
- * @return bool Success or failure.
+ * @return boolean Success or failure.
*
* @since 12.2
* @throws UnexpectedValueException
*/
public function delete($match = '*')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
@@ -185,13 +185,13 @@ public function getAccess()
/**
* Method to get the time of the photo
*
- * @return int Photo time
+ * @return double Photo time
*
* @since 12.2
*/
public function getTime()
{
- return (int) $this->xml->children('gphoto', true)->timestamp;
+ return (double) $this->xml->children('gphoto', true)->timestamp / 1000;
}
/**
@@ -286,7 +286,7 @@ public function setAccess($access)
*/
public function setTime($time)
{
- $this->xml->children('gphoto', true)->timestamp = $time;
+ $this->xml->children('gphoto', true)->timestamp = $time * 1000;
return $this;
}
@@ -301,7 +301,7 @@ public function setTime($time)
*/
public function save($match = '*')
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
if ($match === true)
@@ -342,7 +342,7 @@ public function save($match = '*')
*/
public function refresh()
{
- if ($this->authenticated())
+ if ($this->isAuthenticated())
{
$url = $this->getLink();
$jdata = $this->query($url, null, array('GData-Version' => 2));
View
95 libraries/joomla/google/data/plus.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Google
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die;
+
+/**
+ * Google+ data class for the Joomla Platform.
+ *
+ * @package Joomla.Platform
+ * @subpackage Google
+ * @since 1234
+ */
+class JGoogleDataPlus extends JGoogleData
+{
+ /**
+ * @var JGoogleDataPlusPeople Google+ API object for people.
+ * @since 12.3
+ */
+ protected $people;
+
+ /**
+ * @var JGoogleDataPlusActivities Google+ API object for people.
+ * @since 12.3
+ */
+ protected $activities;
+
+ /**
+ * @var JGoogleDataPlusComments Google+ API object for people.
+ * @since 12.3
+ */
+ protected $comments;
+
+ /**
+ * Constructor.
+ *
+ * @param JRegistry $options Google options object
+ * @param JGoogleAuth $auth Google data http client object
+ *
+ * @since 1234
+ */
+ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
+ {
+ // Setup the default API url if not already set.
+ $options->def('api.url', 'https://www.googleapis.com/plus/v1/');
+
+ parent::__construct($options, $auth);
+
+ if (isset($this->auth) && !$this->auth->getOption('scope'))
+ {
+ $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me');
+ }
+ }
+
+ /**
+ * Magic method to lazily create API objects
+ *
+ * @param string $name Name of property to retrieve
+ *
+ * @return JGoogleDataPlus Google+ API object (people, activities, comments).
+ *
+ * @since 12.3
+ */
+ public function __get($name)
+ {
+ switch ($name)
+ {
+ case 'people':
+ if ($this->people == null)
+ {
+ $this->people = new JGoogleDataPlusPeople($this->options, $this->auth);
+ }
+ return $this->people;
+
+ case 'activities':
+ if ($this->activities == null)
+ {
+ $this->activities = new JGoogleDataPlusActivities($this->options, $this->auth);
+ }
+ return $this->activities;
+
+ case 'comments':
+ if ($this->comments == null)
+ {
+ $this->comments = new JGoogleDataPlusComments($this->options, $this->auth);
+ }
+ return $this->comments;
+ }
+ }
+}
View
194 libraries/joomla/google/data/plus/activities.php
@@ -0,0 +1,194 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Google
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die;
+
+/**
+ * Google+ data class for the Joomla Platform.
+ *
+ * @package Joomla.Platform
+ * @subpackage Google
+ * @since 1234
+ */
+class JGoogleDataPlusActivities extends JGoogleData
+{
+ /**
+ * Constructor.
+ *
+ * @param JRegistry $options Google options object
+ * @param JGoogleAuth $auth Google data http client object
+ *
+ * @since 1234
+ */
+ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
+ {
+ parent::__construct($options, $auth);
+
+ if (isset($this->auth) && !$this->auth->getOption('scope'))
+ {
+ $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me');
+ }
+ }
+
+ /**
+ * List all of the activities in the specified collection for a particular user.
+ *
+ * @param string $userId The ID of the user to get activities for. The special value "me" can be used to indicate the authenticated user.
+ * @param string $collection The collection of activities to list. Acceptable values are: "public".
+ * @param string $fields Used to specify the fields you want returned.
+ * @param integer $max The maximum number of people to include in the response, used for paging.
+ * @param string $token The continuation token, used to page through large result sets. To get the next page of results, set this
+ * parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
+ * @param string $alt Specifies an alternative representation type. Acceptable values are: "json" - Use JSON format (default)
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function listActivities($userId, $collection, $fields = null, $max = 10, $token = null, $alt = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'people/' . $userId . '/activities/' . $collection;
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ // Check if max is specified.
+ if ($max != 10)
+ {
+ $url .= (strpos($url, '?') === false) ? '?maxResults=' : '&maxResults=';
+ $url .= $max;
+ }
+
+ // Check if token is specified.
+ if ($token)
+ {
+ $url .= (strpos($url, '?') === false) ? '?pageToken=' : '&pageToken=';
+ $url .= $token;
+ }
+
+ // Check if alt is specified.
+ if ($alt)
+ {
+ $url .= (strpos($url, '?') === false) ? '?alt=' : '&alt=';
+ $url .= $alt;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Get an activity.
+ *
+ * @param string $id The ID of the activity to get.
+ * @param string $fields Used to specify the fields you want returned.
+ * @param string $alt Specifies an alternative representation type. Acceptable values are: "json" - Use JSON format (default)
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function getActivity($id, $fields = null, $alt = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'activities/' . $id;
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ // Check if alt is specified.
+ if ($alt)
+ {
+ $url .= (strpos($url, '?') === false) ? '?alt=' : '&alt=';
+ $url .= $alt;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Search all public activities.
+ *
+ * @param string $query Full-text search query string.
+ * @param string $fields Used to specify the fields you want returned.
+ * @param string $language Specify the preferred language to search with. https://developers.google.com/+/api/search#available-languages
+ * @param integer $max The maximum number of people to include in the response, used for paging.
+ * @param string $order Specifies how to order search results. Acceptable values are "best" and "recent".
+ * @param string $token The continuation token, used to page through large result sets. To get the next page of results, set this
+ * parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function search($query, $fields = null, $language = null, $max = 10, $order = null, $token = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'activities?query=' . urlencode($query);
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '&fields=' . $fields;
+ }
+
+ // Check if language is specified.
+ if ($language)
+ {
+ $url .= '&language=' . $language;
+ }
+
+ // Check if max is specified.
+ if ($max != 10)
+ {
+ $url .= '&maxResults=' . $max;
+ }
+
+ // Check if order is specified.
+ if ($order)
+ {
+ $url .= '&orderBy=' . $order;
+ }
+
+ // Check of token is specified.
+ if ($token)
+ {
+ $url .= '&pageToken=' . $token;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
View
133 libraries/joomla/google/data/plus/comments.php
@@ -0,0 +1,133 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Google
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die;
+
+/**
+ * Google+ data class for the Joomla Platform.
+ *
+ * @package Joomla.Platform
+ * @subpackage Google
+ * @since 1234
+ */
+class JGoogleDataPlusComments extends JGoogleData
+{
+ /**
+ * Constructor.
+ *
+ * @param JRegistry $options Google options object
+ * @param JGoogleAuth $auth Google data http client object
+ *
+ * @since 1234
+ */
+ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
+ {
+ parent::__construct($options, $auth);
+
+ if (isset($this->auth) && !$this->auth->getOption('scope'))
+ {
+ $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me');
+ }
+ }
+
+ /**
+ * List all of the comments for an activity.
+ *
+ * @param string $activityId The ID of the activity to get comments for.
+ * @param string $fields Used to specify the fields you want returned.
+ * @param integer $max The maximum number of people to include in the response, used for paging.
+ * @param string $order The order in which to sort the list of comments. Acceptable values are "ascending" and "descending".
+ * @param string $token The continuation token, used to page through large result sets. To get the next page of results, set this
+ * parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
+ * @param string $alt Specifies an alternative representation type. Acceptable values are: "json" - Use JSON format (default)
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function listComments($activityId, $fields = null, $max = 20, $order = null, $token = null, $alt = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'activities/' . $activityId . '/comments';
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ // Check if max is specified.
+ if ($max != 20)
+ {
+ $url .= (strpos($url, '?') === false) ? '?maxResults=' : '&maxResults=';
+ $url .= $max;
+ }
+
+ // Check if order is specified.
+ if ($order)
+ {
+ $url .= (strpos($url, '?') === false) ? '?orderBy=' : '&orderBy=';
+ $url .= $order;
+ }
+
+ // Check of token is specified.
+ if ($token)
+ {
+ $url .= (strpos($url, '?') === false) ? '?pageToken=' : '&pageToken=';
+ $url .= $token;
+ }
+
+ // Check if alt is specified.
+ if ($alt)
+ {
+ $url .= (strpos($url, '?') === false) ? '?alt=' : '&alt=';
+ $url .= $alt;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Get a comment.
+ *
+ * @param string $id The ID of the comment to get.
+ * @param string $fields Used to specify the fields you want returned.
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function getComment($id, $fields = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'comments/' . $id;
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
View
171 libraries/joomla/google/data/plus/people.php
@@ -0,0 +1,171 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Google
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die;
+
+/**
+ * Google+ data class for the Joomla Platform.
+ *
+ * @package Joomla.Platform
+ * @subpackage Google
+ * @since 1234
+ */
+class JGoogleDataPlusPeople extends JGoogleData
+{
+ /**
+ * Constructor.
+ *
+ * @param JRegistry $options Google options object
+ * @param JGoogleAuth $auth Google data http client object
+ *
+ * @since 1234
+ */
+ public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
+ {
+ parent::__construct($options, $auth);
+
+ if (isset($this->auth) && !$this->auth->getOption('scope'))
+ {
+ $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me');
+ }
+ }
+
+ /**
+ * Get a person's profile.
+ *
+ * @param string $id The ID of the person to get the profile for. The special value "me" can be used to indicate the authenticated user.
+ * @param string $fields Used to specify the fields you want returned.
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function getPeople($id, $fields = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'people/' . $id;
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Search all public profiles.
+ *
+ * @param string $query Specify a query string for full text search of public text in all profiles.
+ * @param string $fields Used to specify the fields you want returned.
+ * @param string $language Specify the preferred language to search with. https://developers.google.com/+/api/search#available-languages
+ * @param integer $max The maximum number of people to include in the response, used for paging.
+ * @param string $token The continuation token, used to page through large result sets. To get the next page of results, set this
+ * parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function search($query, $fields = null, $language = null, $max = 10, $token = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'people?query=' . urlencode($query);
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '&fields=' . $fields;
+ }
+
+ // Check if language is specified.
+ if ($language)
+ {
+ $url .= '&language=' . $language;
+ }
+
+ // Check if max is specified.
+ if ($max != 10)
+ {
+ $url .= '&maxResults=' . $max;
+ }
+
+ // Check of token is specified.
+ if ($token)
+ {
+ $url .= '&pageToken=' . $token;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * List all of the people in the specified collection for a particular activity.
+ *
+ * @param string $activityId The ID of the activity to get the list of people for.
+ * @param string $collection The collection of people to list. Acceptable values are "plusoners" and "resharers".
+ * @param string $fields Used to specify the fields you want returned.
+ * @param integer $max The maximum number of people to include in the response, used for paging.
+ * @param string $token The continuation token, used to page through large result sets. To get the next page of results, set this
+ * parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
+ *
+ * @return mixed Data from Google
+ *
+ * @since 1234
+ */
+ public function listByActivity($activityId, $collection, $fields = null, $max = 10, $token = null)
+ {
+ if ($this->isAuthenticated())
+ {
+ $url = $this->getOption('api.url') . 'activities/' . $activityId . '/people/' . $collection;
+
+ // Check if fields is specified.
+ if ($fields)
+ {
+ $url .= '?fields=' . $fields;
+ }
+
+ // Check if max is specified.
+ if ($max != 10)
+ {
+ $url .= (strpos($url, '?') === false) ? '?maxResults=' : '&maxResults=';
+ $url .= $max;
+ }
+
+ // Check of token is specified.
+ if ($token)
+ {
+ $url .= (strpos($url, '?') === false) ? '?pageToken=' : '&pageToken=';
+ $url .= $token;
+ }
+
+ $jdata = $this->auth->query($url);
+ return json_decode($jdata->body, true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
View
53 libraries/joomla/google/embed.php
@@ -15,19 +15,19 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
abstract class JGoogleEmbed
{
/**
* @var JRegistry Options for the Google data object.
- * @since 12.2
+ * @since 12.3
*/
protected $options;
/**
* @var JURI URI of the page being rendered.
- * @since 12.2
+ * @since 12.3
*/
protected $uri;
@@ -129,51 +129,4 @@ public function setOption($key, $value)
return $this;
}
-
- /**
- * Create a javascript array from a PHP array
- *
- * @param array $array The array to convert to javascript
- * @param bool $escape Escape strings
- *
- * @return string The javscript code
- *
- * @since 12.2
- */
- static protected function arrayToJavascript($array, $escape = true)
- {
- $string = '';
- foreach ($array as $key => $value)
- {
- if (is_string($key))
- {
- $string .= $key . ':';
- }
-
- if ($escape && is_string($value))
- {
- $string .= '"' . str_replace('"', '\"', $value) . '"';
- }
- elseif (is_array($value))
- {
- $string .= '[' . self::arrayToJavascript($value) . ']';
- }
- elseif (is_bool($value))
- {
- $string .= $value ? 'true' : 'false';
- }
- elseif (is_null($value))
- {
- $string .= 'null';
- }
- else
- {
- $string .= $value;
- }
-
- $string .= ',';
- }
-
- return substr($string, 0, -1);
- }
}
View
28 libraries/joomla/google/embed/analytics.php
@@ -14,7 +14,7 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleEmbedAnalytics extends JGoogleEmbed
{
@@ -48,7 +48,7 @@ public function setCode($code)
/**
* Checks if the javascript is set to be asynchronous
*
- * @return bool True if asynchronous
+ * @return boolean True if asynchronous
*
* @since 12.2
*/
@@ -157,13 +157,13 @@ public function createCall($method, $params = array())
if ($this->isAsync())
{
$output = "_gaq.push(['{$method}',";
- $output .= self::arrayToJavascript($params);
+ $output .= substr(json_encode($params), 1, -1);
$output .= ']);';
}
else
{
$output = "pageTracker.{$method}(";
- $output .= self::arrayToJavascript($params);
+ $output .= substr(json_encode($params), 1, -1);
$output .= ');';
}
@@ -207,11 +207,11 @@ public function createCustomVar($slot, $name, $value, $scope = 3)
/**
* Track an analytics event
*
- * @param string $category The general event category
- * @param string $action The event action
- * @param string $label The event description
- * @param string $value The value of the event
- * @param bool $noninteract Don't allow this event to impact bounce statistics
+ * @param string $category The general event category
+ * @param string $action The event action
+ * @param string $label The event description
+ * @param string $value The value of the event
+ * @param boolean $noninteract Don't allow this event to impact bounce statistics
*
* @return array The added call
*
@@ -225,11 +225,11 @@ public function addEvent($category, $action, $label = null, $value = null, $noni
/**
* Get the code to track an analytics event
*
- * @param string $category The general event category
- * @param string $action The event action
- * @param string $label The event description
- * @param string $value The value of the event
- * @param bool $noninteract Don't allow this event to impact bounce statistics
+ * @param string $category The general event category
+ * @param string $action The event action
+ * @param string $label The event description
+ * @param string $value The value of the event
+ * @param boolean $noninteract Don't allow this event to impact bounce statistics
*
* @return string The created call
*
View
12 libraries/joomla/google/embed/maps.php
@@ -14,14 +14,14 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleEmbedMaps extends JGoogleEmbed
{
/**
* @var JHttp The HTTP client object to use in sending HTTP requests.
- * @since 12.2
+ * @since 12.3
*/
protected $http;
@@ -395,7 +395,7 @@ public function deleteMarker($index = null)
/**
* Checks if the javascript is set to be asynchronous
*
- * @return bool True if asynchronous
+ * @return boolean True if asynchronous
*
* @since 12.2
*/
@@ -460,7 +460,7 @@ public function setAsyncCallback($callback)
/**
* Checks if a sensor is set to be required
*
- * @return bool True if asynchronous
+ * @return boolean True if asynchronous
*
* @since 12.2
*/
@@ -548,7 +548,7 @@ public function getHeader()
$setup .= "zoom: {$zoom},";
$setup .= "center: new google.maps.LatLng({$center[0]},{$center[1]}),";
$setup .= "mapTypeId: google.maps.MapTypeId.{$maptype},";
- $setup .= self::arrayToJavascript($this->getAdditionalMapOptions());
+ $setup .= substr(json_encode($this->getAdditionalMapOptions()), 1, -1);
$setup .= '};';
$setup .= "var map = new google.maps.Map(document.getElementById('{$id}'), mapOptions);";
@@ -562,7 +562,7 @@ public function getHeader()
$setup .= "position: new google.maps.LatLng({$loc[0]},{$loc[1]}),";
$setup .= 'map: map,';
$setup .= "title:'{$title}',";
- $setup .= self::arrayToJavascript($options);
+ $setup .= substr(json_encode($options), 1, -1);
$setup .= '});';
}
View
13 libraries/joomla/google/google.php
@@ -17,31 +17,31 @@
*
* @package Joomla.Platform
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogle
{
/**
* @var JRegistry Options for the Google object.
- * @since 12.2
+ * @since 12.3
*/
protected $options;
/**
* @var JAuth The authentication client object to use in sending authenticated HTTP requests.
- * @since 12.2
+ * @since 12.3
*/
protected $auth;
/**
* @var JGoogleData Google API object for data request.
- * @since 12.2
+ * @since 12.3
*/
protected $data;
/**
* @var JGoogleEmbed Google API object for embed generation.
- * @since 12.2
+ * @since 12.3
*/
protected $embed;
@@ -82,6 +82,9 @@ public function data($name, $options = null, $auth = null)
}
switch ($name)
{
+ case 'plus':
+ case 'Plus':
+ return new JGoogleDataPlus($options, $auth);
case 'picasa':
case 'Picasa':
return new JGoogleDataPicasa($options, $auth);
View
43 libraries/joomla/oauth/v2client.php → libraries/joomla/oauth2/client.php
@@ -15,12 +15,12 @@
*
* @package Joomla.Platform
* @subpackage Oauth
- * @since 12.2
+ * @since 12.3
*/
-class JOauthV2client
+class JOAuth2Client
{
/**
- * @var JRegistry Options for the JOauthV2client object.
+ * @var JRegistry Options for the JOAuth2Client object.
* @since 12.2
*/
protected $options;
@@ -38,19 +38,27 @@ class JOauthV2client
protected $input;
/**
+ * @var JApplicationWeb The application object to send HTTP headers for redirects.
+ * @since 12.2
+ */
+ protected $application;
+
+ /**
* Constructor.
*
- * @param JRegistry $options JOauthV2client options object
- * @param JHttp $http The HTTP client object
- * @param JInput $input The input object
+ * @param JRegistry $options JOAuth2Client options object
+ * @param JHttp $http The HTTP client object
+ * @param JInput $input The input object
+ * @param JApplicationWeb $application The application object
*
* @since 12.2
*/
- public function __construct(JRegistry $options = null, JHttp $http = null, JInput $input = null)
+ public function __construct(JRegistry $options = null, JHttp $http = null, JInput $input = null, JApplicationWeb $application = null)
{
$this->options = isset($options) ? $options : new JRegistry;
$this->http = isset($http) ? $http : new JHttp($this->options);
$this->input = isset($input) ? $input : JFactory::getApplication()->input;
+ $this->application = isset($application) ? $application : new JApplicationWeb;
}
/**
@@ -60,7 +68,7 @@ public function __construct(JRegistry $options = null, JHttp $http = null, JInpu
*
* @since 12.2
*/
- public function auth()
+ public function authenticate()
{
if ($data['code'] = $this->input->get('code', false, 'raw'))
{
@@ -94,8 +102,7 @@ public function auth()
if ($this->getOption('sendheaders'))
{
- JResponse::setHeader('Location', $this->createUrl(), true);
- JResponse::sendHeaders();
+ $this->application->redirect($this->createUrl());
}
return false;
}
@@ -103,11 +110,11 @@ public function auth()
/**
* Verify if the client has been authenticated
*
- * @return bool Is authenticated
+ * @return boolean Is authenticated
*
* @since 12.2
*/
- public function isAuth()
+ public function isAuthenticated()
{
$token = $this->getToken();
@@ -247,7 +254,7 @@ public function query($url, $data = null, $headers = array(), $method = 'get', $
}
/**
- * Get an option from the JOauthV2client instance.
+ * Get an option from the JOAuth2Client instance.
*
* @param string $key The name of the option to get
*
@@ -261,12 +268,12 @@ public function getOption($key)
}
/**
- * Set an option for the JOauthV2client instance.
+ * Set an option for the JOAuth2Client instance.
*
* @param string $key The name of the option to set
* @param mixed $value The option value to set
*
- * @return JOauthV2client This object for method chaining
+ * @return JOAuth2Client This object for method chaining
*
* @since 12.2
*/
@@ -277,7 +284,7 @@ public function setOption($key, $value)
}
/**
- * Get the access token from the JOauthV2client instance.
+ * Get the access token from the JOAuth2Client instance.
*
* @return array The access token
*
@@ -289,11 +296,11 @@ public function getToken()
}
/**
- * Set an option for the JOauthV2client instance.
+ * Set an option for the JOAuth2Client instance.
*
* @param array $value The access token
*
- * @return JOauthV2client This object for method chaining
+ * @return JOAuth2Client This object for method chaining
*
* @since 12.2
*/
View
41 tests/suites/unit/joomla/google/JGoogleAuthOauth2Test.php
@@ -13,12 +13,12 @@
*
* @package Joomla.UnitTest
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleAuthOauth2Test extends PHPUnit_Framework_TestCase
{
/**
- * @var JRegistry Options for the JOauthV2client object.
+ * @var JRegistry Options for the JOAuth2Client object.
*/
protected $options;
@@ -33,11 +33,16 @@ class JGoogleAuthOauth2Test extends PHPUnit_Framework_TestCase
protected $input;
/**
- * @var JOauthV2client The OAuth client for sending requests to Google.
+ * @var JOAuth2Client The OAuth client for sending requests to Google.
*/
protected $oauth;
/**
+ * @var JApplicationWeb The application object to send HTTP headers for redirects.
+ */
+ protected $application;
+
+ /**
* @var JGoogleAuthOauth2 Object under test.
*/
protected $object;
@@ -51,10 +56,16 @@ class JGoogleAuthOauth2Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
+ $_SERVER['HTTP_HOST'] = 'mydomain.com';
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0';
+ $_SERVER['REQUEST_URI'] = '/index.php';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+
$this->options = new JRegistry;
$this->http = $this->getMock('JHttp', array('head', 'get', 'delete', 'trace', 'post', 'put', 'patch'), array($this->options));
$this->input = new JInput;
- $this->oauth = new JOauthV2client($this->options, $this->http, $this->input);
+ $this->application = new JApplicationWebInspector;
+ $this->oauth = new JOAuth2Client($this->options, $this->http, $this->input, $this->application);
$this->object = new JGoogleAuthOauth2($this->options, $this->oauth);
}
@@ -82,23 +93,13 @@ public function testAuth()
$this->object->setOption('redirecturi', 'http://localhost/oauth');
$this->object->setOption('sendheaders', true);
- $this->object->auth();
- $headers = JResponse::getHeaders();
- $location = false;
- foreach ($headers as $header)
- {
- if ($header['name'] == 'Location')
- {
- $location = true;
- $this->assertEquals($this->oauth->createUrl(), $header['value']);
- }
- }
- $this->assertTrue($location);
+ $this->object->authenticate();
+ $this->assertEquals(0, $this->application->closed);
$this->object->setOption('clientsecret', 'jeDs8rKw_jDJW8MMf-ff8ejs');
$this->input->set('code', '4/wEr_dK8SDkjfpwmc98KejfiwJP-f4wm.kdowmnr82jvmeisjw94mKFIJE48mcEM');
$this->http->expects($this->once())->method('post')->will($this->returnCallback('jsonGrantOauthCallback'));
- $result = $this->object->auth();
+ $result = $this->object->authenticate();
$this->assertEquals('accessvalue', $result['access_token']);
$this->assertEquals('refreshvalue', $result['refresh_token']);
$this->assertEquals(3600, $result['expires_in']);
@@ -113,7 +114,7 @@ public function testAuth()
*/
public function testIsAuth()
{
- $this->assertFalse($this->object->isAuth());
+ $this->assertFalse($this->object->isAuthenticated());
$token['access_token'] = 'accessvalue';
$token['refresh_token'] = 'refreshvalue';
@@ -121,13 +122,13 @@ public function testIsAuth()
$token['expires_in'] = 3600;
$this->oauth->setToken($token);
- $this->assertTrue($this->object->isAuth());
+ $this->assertTrue($this->object->isAuthenticated());
$token['created'] = time() - 4000;
$token['expires_in'] = 3600;
$this->oauth->setToken($token);
- $this->assertFalse($this->object->isAuth());
+ $this->assertFalse($this->object->isAuthenticated());
}
/**
View
17 tests/suites/unit/joomla/google/JGoogleDataAdsenseTest.php
@@ -13,12 +13,12 @@
*
* @package Joomla.UnitTest
* @subpackage Google
- * @since 12.2
+ * @since 12.3
*/
class JGoogleDataAdsenseTest extends PHPUnit_Framework_TestCase
{
/**
- * @var JRegistry Options for the JOauthV2client object.
+ * @var JRegistry Options for the JOAuth2Client object.
*/
protected $options;
@@ -33,7 +33,7 @@ class JGoogleDataAdsenseTest extends PHPUnit_Framework_TestCase
protected $input;
/**
- * @var JOauthV2client The OAuth client for sending requests to Google.
+ * @var JOAuth2Client The OAuth client for sending requests to Google.
*/
protected $oauth;
@@ -56,10 +56,15 @@ class JGoogleDataAdsenseTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
+ $_SERVER['HTTP_HOST'] = 'mydomain.com';
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0';
+ $_SERVER['REQUEST_URI'] = '/index.php';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+
$this->options = new JRegistry;
$this->http = $this->getMock('JHttp', array('head', 'get', 'delete', 'trace', 'post', 'put', 'patch'), array($this->options));
$this->input = new JInput;
- $this->oauth = new JOauthV2client($this->options, $this->http, $this->input);
+ $this->oauth = new JOAuth2Client($this->options, $this->http, $this->input);
$this->auth = new JGoogleAuthOauth2($this->options, $this->oauth);
$this->object = new JGoogleDataAdsense($this->options, $this->auth);
@@ -93,7 +98,7 @@ protected function tearDown()
*/
public function testAuth()
{
- $this->assertEquals($this->auth->auth(), $this->object->auth());
+ $this->assertEquals($this->auth->authenticate(), $this->object->authenticate());
}
/**
@@ -104,7 +109,7 @@ public function testAuth()
*/
public function testIsAuth()
{
- $this->assertEquals($this->auth->isAuth(), $this->object->authenticated());
+ $this->assertEquals($this->auth->isAuthenticated(), $this->object->isAuthenticated());
}
/**
View
17 tests/suites/unit/joomla/google/JGoogleDataCalendarTest.php
@@ -13,12 +13,12 @@
*
* @package Joomla.UnitTest
* @subpackage Google
-