Source for file comments.php

Documentation is available at comments.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Google
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Google+ data class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Google
  17.  * @since       1234
  18.  */
  19. {
  20.     /**
  21.      * Constructor.
  22.      *
  23.      * @param   JRegistry    $options  Google options object
  24.      * @param   JGoogleAuth  $auth     Google data http client object
  25.      *
  26.      * @since   1234
  27.      */
  28.     public function __construct(JRegistry $options nullJGoogleAuth $auth null)
  29.     {
  30.         parent::__construct($options$auth);
  31.  
  32.         if (isset($this->auth&& !$this->auth->getOption('scope'))
  33.         {
  34.             $this->auth->setOption('scope''https://www.googleapis.com/auth/plus.me');
  35.         }
  36.     }
  37.  
  38.     /**
  39.      * List all of the comments for an activity.
  40.      *
  41.      * @param   string   $activityId  The ID of the activity to get comments for.
  42.      * @param   string   $fields      Used to specify the fields you want returned.
  43.      * @param   integer  $max         The maximum number of people to include in the response, used for paging.
  44.      * @param   string   $order       The order in which to sort the list of comments. Acceptable values are "ascending" and "descending".
  45.      * @param   string   $token       The continuation token, used to page through large result sets. To get the next page of results, set this
  46.      *                                    parameter to the value of "nextPageToken" from the previous response. This token may be of any length.
  47.      * @param   string   $alt         Specifies an alternative representation type. Acceptable values are: "json" - Use JSON format (default)
  48.      *
  49.      * @return  mixed  Data from Google
  50.      *
  51.      * @since   1234
  52.      */
  53.     public function listComments($activityId$fields null$max 20$order null$token null$alt null)
  54.     {
  55.         if ($this->isAuthenticated())
  56.         {
  57.             $url $this->getOption('api.url''activities/' $activityId '/comments';
  58.  
  59.             // Check if fields is specified.
  60.             if ($fields)
  61.             {
  62.                 $url .= '?fields=' $fields;
  63.             }
  64.  
  65.             // Check if max is specified.
  66.             if ($max != 20)
  67.             {
  68.                 $url .= (strpos($url'?'=== false'?maxResults=' '&maxResults=';
  69.                 $url .= $max;
  70.             }
  71.  
  72.             // Check if order is specified.
  73.             if ($order)
  74.             {
  75.                 $url .= (strpos($url'?'=== false'?orderBy=' '&orderBy=';
  76.                 $url .= $order;
  77.             }
  78.  
  79.             // Check of token is specified.
  80.             if ($token)
  81.             {
  82.                 $url .= (strpos($url'?'=== false'?pageToken=' '&pageToken=';
  83.                 $url .= $token;
  84.             }
  85.  
  86.             // Check if alt is specified.
  87.             if ($alt)
  88.             {
  89.                 $url .= (strpos($url'?'=== false'?alt=' '&alt=';
  90.                 $url .= $alt;
  91.             }
  92.  
  93.             $jdata $this->auth->query($url);
  94.  
  95.             return json_decode($jdata->bodytrue);
  96.         }
  97.         else
  98.         {
  99.             return false;
  100.         }
  101.     }
  102.  
  103.     /**
  104.      * Get a comment.
  105.      *
  106.      * @param   string  $id      The ID of the comment to get.
  107.      * @param   string  $fields  Used to specify the fields you want returned.
  108.      *
  109.      * @return  mixed  Data from Google
  110.      *
  111.      * @since   1234
  112.      */
  113.     public function getComment($id$fields null)
  114.     {
  115.         if ($this->isAuthenticated())
  116.         {
  117.             $url $this->getOption('api.url''comments/' $id;
  118.  
  119.             // Check if fields is specified.
  120.             if ($fields)
  121.             {
  122.                 $url .= '?fields=' $fields;
  123.             }
  124.  
  125.             $jdata $this->auth->query($url);
  126.  
  127.             return json_decode($jdata->bodytrue);
  128.         }
  129.         else
  130.         {
  131.             return false;
  132.         }
  133.     }
  134. }

Documentation generated on Tue, 19 Nov 2013 14:56:07 +0100 by phpDocumentor 1.4.3