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