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.
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
25 * @see Zend_Gdata_Gapps_Query
27 require_once('Zend/Gdata/Gapps/Query.php');
30 * Assists in constructing queries for user entries.
31 * Instances of this class can be provided in many places where a URL is
34 * For information on submitting queries to a server, see the
35 * service class, Zend_Gdata_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
43 class Zend_Gdata_Photos_UserQuery
extends Zend_Gdata_Query
47 * Indicates the format of data returned in Atom feeds. Can be either
48 * 'api' or 'base'. Default value is 'api'.
52 protected $_projection = 'api';
55 * Indicates whether to request a feed or entry in queries. Default
60 protected $_type = 'feed';
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
69 protected $_user = Zend_Gdata_Photos
::DEFAULT_USER
;
72 * Create a new Query object with default values.
74 public function __construct()
76 parent
::__construct();
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'.
83 * @param string $value
84 * @return Zend_Gdata_Photos_UserQuery Provides a fluent interface
86 public function setProjection($value)
88 $this->_projection
= $value;
93 * Gets the format of data in returned in Atom feeds.
96 * @return string projection
98 public function getProjection()
100 return $this->_projection
;
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'.
107 * @param string $value
108 * @return Zend_Gdata_Photos_UserQuery Provides a fluent interface
110 public function setType($value)
112 $this->_type
= $value;
117 * Gets the type of data in returned in queries.
120 * @return string type
122 public function getType()
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
132 * @param string $value The user to retrieve, or null for the default
135 public function setUser($value)
137 if ($value !== null) {
138 $this->_user
= $value;
140 $this->_user
= Zend_Gdata_Photos
::DEFAULT_USER
;
145 * Get the user which is to be returned.
148 * @return string The visibility to retrieve.
150 public function getUser()
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.
160 * Valid values are 'all' (default), 'public', and 'private'.
162 * @param string $value The visibility to filter by, or null to use the
165 public function setAccess($value)
167 if ($value !== null) {
168 $this->_params
['access'] = $value;
170 unset($this->_params
['access']);
175 * Get the visibility filter for entries returned.
178 * @return string The visibility to filter by, or null for the default
181 public function getAccess()
183 return $this->_params
['access'];
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
191 * See http://code.google.com/apis/picasaweb/reference.html#Parameters
192 * for a list of valid values.
194 * @param string $value The tag to filter by, or null if no
195 * filter is to be applied.
197 public function setTag($value)
199 if ($value !== null) {
200 $this->_params
['tag'] = $value;
202 unset($this->_params
['tag']);
207 * Get the tag filter for entries returned.
210 * @return string The tag to filter by, or null if no filter
213 public function getTag()
215 return $this->_params
['tag'];
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
223 * See http://code.google.com/apis/picasaweb/reference.html#Parameters
224 * for a list of valid values.
226 * @param string $value The kind to filter by, or null if no
227 * filter is to be applied.
229 public function setKind($value)
231 if ($value !== null) {
232 $this->_params
['kind'] = $value;
234 unset($this->_params
['kind']);
239 * Get the kind of entries to be returned.
242 * @return string The kind to filter by, or null if no filter
245 public function getKind()
247 return $this->_params
['kind'];
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
255 * See http://code.google.com/apis/picasaweb/reference.html#Parameters
256 * for a list of valid values.
258 * @param string $value The image size to filter by, or null if no
259 * filter is to be applied.
261 public function setImgMax($value)
263 if ($value !== null) {
264 $this->_params
['imgmax'] = $value;
266 unset($this->_params
['imgmax']);
271 * Get the maximum image size filter for entries returned.
274 * @return string The image size size to filter by, or null if no filter
277 public function getImgMax()
279 return $this->_params
['imgmax'];
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
287 * See http://code.google.com/apis/picasaweb/reference.html#Parameters
288 * for a list of valid values.
290 * @param string $value The thumbnail size to filter by, or null if no
291 * filter is to be applied.
293 public function setThumbsize($value)
295 if ($value !== null) {
296 $this->_params
['thumbsize'] = $value;
298 unset($this->_params
['thumbsize']);
303 * Get the thumbnail size filter for entries returned.
306 * @return string The thumbnail size to filter by, or null if no filter
309 public function getThumbsize()
311 return $this->_params
['thumbsize'];
315 * Returns the URL generated for this query, based on it's current
318 * @return string A URL generated based on the state of this query.
319 * @throws Zend_Gdata_App_InvalidArgumentException
321 public function getQueryUrl($incomingUri = null)
323 $uri = Zend_Gdata_Photos
::PICASA_BASE_URI
;
325 if ($this->getType() !== null) {
326 $uri .= '/' . $this->getType();
328 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
329 throw new Zend_Gdata_App_InvalidArgumentException(
330 'Type must be feed or entry, not null');
333 if ($this->getProjection() !== null) {
334 $uri .= '/' . $this->getProjection();
336 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
337 throw new Zend_Gdata_App_InvalidArgumentException(
338 'Projection must not be null');
341 if ($this->getUser() !== null) {
342 $uri .= '/user/' . $this->getUser();
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');
350 $uri .= $incomingUri;
351 $uri .= $this->getQueryString();