web/enmi/Zend/Gdata/Photos/UserQuery.php
changeset 19 1c2f13fd785c
parent 0 4eba9c11703f
equal deleted inserted replaced
18:bd595ad770fc 19:1c2f13fd785c
       
     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-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  * @version    $Id: UserQuery.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Gapps_Query
       
    26  */
       
    27 require_once('Zend/Gdata/Gapps/Query.php');
       
    28 
       
    29 /**
       
    30  * Assists in constructing queries for user entries.
       
    31  * Instances of this class can be provided in many places where a URL is
       
    32  * required.
       
    33  *
       
    34  * For information on submitting queries to a server, see the
       
    35  * service class, Zend_Gdata_Photos.
       
    36  *
       
    37  * @category   Zend
       
    38  * @package    Zend_Gdata
       
    39  * @subpackage Photos
       
    40  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    41  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    42  */
       
    43 class Zend_Gdata_Photos_UserQuery extends Zend_Gdata_Query
       
    44 {
       
    45 
       
    46     /**
       
    47      * Indicates the format of data returned in Atom feeds. Can be either
       
    48      * 'api' or 'base'. Default value is 'api'.
       
    49      *
       
    50      * @var string
       
    51      */
       
    52     protected $_projection = 'api';
       
    53 
       
    54     /**
       
    55      * Indicates whether to request a feed or entry in queries. Default
       
    56      * value is 'feed';
       
    57      *
       
    58      * @var string
       
    59      */
       
    60     protected $_type = 'feed';
       
    61 
       
    62     /**
       
    63      * A string which, if not null, indicates which user should
       
    64      * be retrieved by this query. If null, the default user will be used
       
    65      * instead.
       
    66      *
       
    67      * @var string
       
    68      */
       
    69     protected $_user = Zend_Gdata_Photos::DEFAULT_USER;
       
    70 
       
    71     /**
       
    72      * Create a new Query object with default values.
       
    73      */
       
    74     public function __construct()
       
    75     {
       
    76         parent::__construct();
       
    77     }
       
    78 
       
    79     /**
       
    80      * Set's the format of data returned in Atom feeds. Can be either
       
    81      * 'api' or 'base'. Normally, 'api' will be desired. Default is 'api'.
       
    82      *
       
    83      * @param string $value
       
    84      * @return Zend_Gdata_Photos_UserQuery Provides a fluent interface
       
    85      */
       
    86     public function setProjection($value)
       
    87     {
       
    88         $this->_projection = $value;
       
    89         return $this;
       
    90     }
       
    91 
       
    92     /**
       
    93      * Gets the format of data in returned in Atom feeds.
       
    94      *
       
    95      * @see setProjection
       
    96      * @return string projection
       
    97      */
       
    98     public function getProjection()
       
    99     {
       
   100         return $this->_projection;
       
   101     }
       
   102 
       
   103     /**
       
   104      * Set's the type of data returned in queries. Can be either
       
   105      * 'feed' or 'entry'. Normally, 'feed' will be desired. Default is 'feed'.
       
   106      *
       
   107      * @param string $value
       
   108      * @return Zend_Gdata_Photos_UserQuery Provides a fluent interface
       
   109      */
       
   110     public function setType($value)
       
   111     {
       
   112         $this->_type = $value;
       
   113         return $this;
       
   114     }
       
   115 
       
   116     /**
       
   117      * Gets the type of data in returned in queries.
       
   118      *
       
   119      * @see setType
       
   120      * @return string type
       
   121      */
       
   122     public function getType()
       
   123     {
       
   124         return $this->_type;
       
   125     }
       
   126 
       
   127     /**
       
   128      * Set the user to query for. When set, this user's feed will be
       
   129      * returned. If not set or null, the default user's feed will be returned
       
   130      * instead.
       
   131      *
       
   132      * @param string $value The user to retrieve, or null for the default
       
   133      *          user.
       
   134      */
       
   135      public function setUser($value)
       
   136      {
       
   137          if ($value !== null) {
       
   138              $this->_user = $value;
       
   139          } else {
       
   140              $this->_user = Zend_Gdata_Photos::DEFAULT_USER;
       
   141          }
       
   142      }
       
   143 
       
   144     /**
       
   145      * Get the user which is to be returned.
       
   146      *
       
   147      * @see setUser
       
   148      * @return string The visibility to retrieve.
       
   149      */
       
   150     public function getUser()
       
   151     {
       
   152         return $this->_user;
       
   153     }
       
   154 
       
   155     /**
       
   156      * Set the visibility filter for entries returned. Only entries which
       
   157      * match this value will be returned. If null or unset, the default
       
   158      * value will be used instead.
       
   159      *
       
   160      * Valid values are 'all' (default), 'public', and 'private'.
       
   161      *
       
   162      * @param string $value The visibility to filter by, or null to use the
       
   163      *          default value.
       
   164      */
       
   165      public function setAccess($value)
       
   166      {
       
   167          if ($value !== null) {
       
   168              $this->_params['access'] = $value;
       
   169          } else {
       
   170              unset($this->_params['access']);
       
   171          }
       
   172      }
       
   173 
       
   174     /**
       
   175      * Get the visibility filter for entries returned.
       
   176      *
       
   177      * @see setAccess
       
   178      * @return string The visibility to filter by, or null for the default
       
   179      *          user.
       
   180      */
       
   181     public function getAccess()
       
   182     {
       
   183         return $this->_params['access'];
       
   184     }
       
   185 
       
   186     /**
       
   187      * Set the tag for entries that are returned. Only entries which
       
   188      * match this value will be returned. If null or unset, this filter will
       
   189      * not be applied.
       
   190      *
       
   191      * See http://code.google.com/apis/picasaweb/reference.html#Parameters
       
   192      * for a list of valid values.
       
   193      *
       
   194      * @param string $value The tag to filter by, or null if no
       
   195      *          filter is to be applied.
       
   196      */
       
   197      public function setTag($value)
       
   198      {
       
   199          if ($value !== null) {
       
   200              $this->_params['tag'] = $value;
       
   201          } else {
       
   202              unset($this->_params['tag']);
       
   203          }
       
   204      }
       
   205 
       
   206     /**
       
   207      * Get the tag filter for entries returned.
       
   208      *
       
   209      * @see setTag
       
   210      * @return string The tag to filter by, or null if no filter
       
   211      *          is to be applied.
       
   212      */
       
   213     public function getTag()
       
   214     {
       
   215         return $this->_params['tag'];
       
   216     }
       
   217 
       
   218     /**
       
   219      * Set the kind of entries that are returned. Only entries which
       
   220      * match this value will be returned. If null or unset, this filter will
       
   221      * not be applied.
       
   222      *
       
   223      * See http://code.google.com/apis/picasaweb/reference.html#Parameters
       
   224      * for a list of valid values.
       
   225      *
       
   226      * @param string $value The kind to filter by, or null if no
       
   227      *          filter is to be applied.
       
   228      */
       
   229      public function setKind($value)
       
   230      {
       
   231          if ($value !== null) {
       
   232              $this->_params['kind'] = $value;
       
   233          } else {
       
   234              unset($this->_params['kind']);
       
   235          }
       
   236      }
       
   237 
       
   238     /**
       
   239      * Get the kind of entries to be returned.
       
   240      *
       
   241      * @see setKind
       
   242      * @return string The kind to filter by, or null if no filter
       
   243      *          is to be applied.
       
   244      */
       
   245     public function getKind()
       
   246     {
       
   247         return $this->_params['kind'];
       
   248     }
       
   249 
       
   250     /**
       
   251      * Set the maximum image size for entries returned. Only entries which
       
   252      * match this value will be returned. If null or unset, this filter will
       
   253      * not be applied.
       
   254      *
       
   255      * See http://code.google.com/apis/picasaweb/reference.html#Parameters
       
   256      * for a list of valid values.
       
   257      *
       
   258      * @param string $value The image size to filter by, or null if no
       
   259      *          filter is to be applied.
       
   260      */
       
   261      public function setImgMax($value)
       
   262      {
       
   263          if ($value !== null) {
       
   264              $this->_params['imgmax'] = $value;
       
   265          } else {
       
   266              unset($this->_params['imgmax']);
       
   267          }
       
   268      }
       
   269 
       
   270     /**
       
   271      * Get the maximum image size filter for entries returned.
       
   272      *
       
   273      * @see setImgMax
       
   274      * @return string The image size size to filter by, or null if no filter
       
   275      *          is to be applied.
       
   276      */
       
   277     public function getImgMax()
       
   278     {
       
   279         return $this->_params['imgmax'];
       
   280     }
       
   281 
       
   282     /**
       
   283      * Set the thumbnail size filter for entries returned. Only entries which
       
   284      * match this value will be returned. If null or unset, this filter will
       
   285      * not be applied.
       
   286      *
       
   287      * See http://code.google.com/apis/picasaweb/reference.html#Parameters
       
   288      * for a list of valid values.
       
   289      *
       
   290      * @param string $value The thumbnail size to filter by, or null if no
       
   291      *          filter is to be applied.
       
   292      */
       
   293      public function setThumbsize($value)
       
   294      {
       
   295          if ($value !== null) {
       
   296              $this->_params['thumbsize'] = $value;
       
   297          } else {
       
   298              unset($this->_params['thumbsize']);
       
   299          }
       
   300      }
       
   301 
       
   302     /**
       
   303      * Get the thumbnail size filter for entries returned.
       
   304      *
       
   305      * @see setThumbsize
       
   306      * @return string The thumbnail size to filter by, or null if no filter
       
   307      *          is to be applied.
       
   308      */
       
   309     public function getThumbsize()
       
   310     {
       
   311         return $this->_params['thumbsize'];
       
   312     }
       
   313 
       
   314     /**
       
   315      * Returns the URL generated for this query, based on it's current
       
   316      * parameters.
       
   317      *
       
   318      * @return string A URL generated based on the state of this query.
       
   319      * @throws Zend_Gdata_App_InvalidArgumentException
       
   320      */
       
   321     public function getQueryUrl($incomingUri = null)
       
   322     {
       
   323         $uri = Zend_Gdata_Photos::PICASA_BASE_URI;
       
   324 
       
   325         if ($this->getType() !== null) {
       
   326             $uri .= '/' . $this->getType();
       
   327         } else {
       
   328             require_once 'Zend/Gdata/App/InvalidArgumentException.php';
       
   329             throw new Zend_Gdata_App_InvalidArgumentException(
       
   330                     'Type must be feed or entry, not null');
       
   331         }
       
   332 
       
   333         if ($this->getProjection() !== null) {
       
   334             $uri .= '/' . $this->getProjection();
       
   335         } else {
       
   336             require_once 'Zend/Gdata/App/InvalidArgumentException.php';
       
   337             throw new Zend_Gdata_App_InvalidArgumentException(
       
   338                     'Projection must not be null');
       
   339         }
       
   340 
       
   341         if ($this->getUser() !== null) {
       
   342             $uri .= '/user/' . $this->getUser();
       
   343         } else {
       
   344             // Should never occur due to setter behavior
       
   345             require_once 'Zend/Gdata/App/InvalidArgumentException.php';
       
   346             throw new Zend_Gdata_App_InvalidArgumentException(
       
   347                     'User must not be null');
       
   348         }
       
   349 
       
   350         $uri .= $incomingUri;
       
   351         $uri .= $this->getQueryString();
       
   352         return $uri;
       
   353     }
       
   354 
       
   355 }