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 Calendar |
---|
19 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
21 | * @version $Id: EventQuery.php 24594 2012-01-05 21:27:01Z matthew $ |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * Zend_Gdata_App_util |
---|
26 | */ |
---|
27 | require_once('Zend/Gdata/App/Util.php'); |
---|
28 | |
---|
29 | /** |
---|
30 | * Zend_Gdata_Query |
---|
31 | */ |
---|
32 | require_once('Zend/Gdata/Query.php'); |
---|
33 | |
---|
34 | /** |
---|
35 | * Assists in constructing queries for Google Calendar events |
---|
36 | * |
---|
37 | * @link http://code.google.com/apis/gdata/calendar/ |
---|
38 | * |
---|
39 | * @category Zend |
---|
40 | * @package Zend_Gdata |
---|
41 | * @subpackage Calendar |
---|
42 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
43 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
44 | */ |
---|
45 | class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query |
---|
46 | { |
---|
47 | |
---|
48 | const CALENDAR_FEED_URI = 'https://www.google.com/calendar/feeds'; |
---|
49 | |
---|
50 | /** |
---|
51 | * The default URI used for feeds. |
---|
52 | */ |
---|
53 | protected $_defaultFeedUri = self::CALENDAR_FEED_URI; |
---|
54 | |
---|
55 | /** |
---|
56 | * The comment ID to retrieve. If null, no specific comment will be |
---|
57 | * retrieved unless already included in the query URI. The event ID |
---|
58 | * ($_event) must be set, otherwise this property is ignored. |
---|
59 | */ |
---|
60 | protected $_comments = null; |
---|
61 | |
---|
62 | /** |
---|
63 | * The calendar address to be requested by queries. This may be an email |
---|
64 | * address if requesting the primary calendar for a user. Defaults to |
---|
65 | * "default" (the currently authenticated user). A null value should be |
---|
66 | * used when the calendar address has already been set as part of the |
---|
67 | * query URI. |
---|
68 | */ |
---|
69 | protected $_user = 'default'; |
---|
70 | |
---|
71 | /* |
---|
72 | * The visibility to be requested by queries. Defaults to "public". A |
---|
73 | * null value should be used when the calendar address has already been |
---|
74 | * set as part of the query URI. |
---|
75 | */ |
---|
76 | protected $_visibility = 'public'; |
---|
77 | |
---|
78 | /** |
---|
79 | * Projection to be requested by queries. Defaults to "full". A null value |
---|
80 | * should be used when the calendar address has already been set as part |
---|
81 | * of the query URI. |
---|
82 | */ |
---|
83 | protected $_projection = 'full'; |
---|
84 | |
---|
85 | /** |
---|
86 | * The event ID to retrieve. If null, no specific event will be retrieved |
---|
87 | * unless already included in the query URI. |
---|
88 | */ |
---|
89 | protected $_event = null; |
---|
90 | |
---|
91 | /** |
---|
92 | * Create Gdata_Calendar_EventQuery object. If a URL is provided, |
---|
93 | * it becomes the base URL, and additional URL components may be |
---|
94 | * appended. For instance, if $url is 'https://www.google.com/calendar', |
---|
95 | * the default URL constructed will be |
---|
96 | * 'https://www.google.com/calendar/default/public/full'. |
---|
97 | * |
---|
98 | * If the URL already contains a calendar ID, projection, visibility, |
---|
99 | * event ID, or comment ID, you will need to set these fields to null |
---|
100 | * to prevent them from being inserted. See this class's properties for |
---|
101 | * more information. |
---|
102 | * |
---|
103 | * @param string $url The URL to use as the base path for requests |
---|
104 | */ |
---|
105 | public function __construct($url = null) |
---|
106 | { |
---|
107 | parent::__construct($url); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * @see $_comments |
---|
112 | * @param string $value |
---|
113 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
114 | */ |
---|
115 | public function setComments($value) |
---|
116 | { |
---|
117 | $this->_comments = $value; |
---|
118 | return $this; |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * @see $_event |
---|
123 | * @param string $value |
---|
124 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
125 | */ |
---|
126 | public function setEvent($value) |
---|
127 | { |
---|
128 | $this->_event = $value; |
---|
129 | return $this; |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * @see $_projection |
---|
134 | * @param string $value |
---|
135 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
136 | */ |
---|
137 | public function setProjection($value) |
---|
138 | { |
---|
139 | $this->_projection = $value; |
---|
140 | return $this; |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * @see $_user |
---|
145 | * @param string $value |
---|
146 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
147 | */ |
---|
148 | public function setUser($value) |
---|
149 | { |
---|
150 | $this->_user = $value; |
---|
151 | return $this; |
---|
152 | } |
---|
153 | |
---|
154 | /** |
---|
155 | * @see $_visibility |
---|
156 | * @param bool $value |
---|
157 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
158 | */ |
---|
159 | public function setVisibility($value) |
---|
160 | { |
---|
161 | $this->_visibility = $value; |
---|
162 | return $this; |
---|
163 | } |
---|
164 | |
---|
165 | /** |
---|
166 | * @see $_comments; |
---|
167 | * @return string comments |
---|
168 | */ |
---|
169 | public function getComments() |
---|
170 | { |
---|
171 | return $this->_comments; |
---|
172 | } |
---|
173 | |
---|
174 | /** |
---|
175 | * @see $_event; |
---|
176 | * @return string event |
---|
177 | */ |
---|
178 | public function getEvent() |
---|
179 | { |
---|
180 | return $this->_event; |
---|
181 | } |
---|
182 | |
---|
183 | /** |
---|
184 | * @see $_projection |
---|
185 | * @return string projection |
---|
186 | */ |
---|
187 | public function getProjection() |
---|
188 | { |
---|
189 | return $this->_projection; |
---|
190 | } |
---|
191 | |
---|
192 | /** |
---|
193 | * @see $_user |
---|
194 | * @return string user |
---|
195 | */ |
---|
196 | public function getUser() |
---|
197 | { |
---|
198 | return $this->_user; |
---|
199 | } |
---|
200 | |
---|
201 | /** |
---|
202 | * @see $_visibility |
---|
203 | * @return string visibility |
---|
204 | */ |
---|
205 | public function getVisibility() |
---|
206 | { |
---|
207 | return $this->_visibility; |
---|
208 | } |
---|
209 | |
---|
210 | /** |
---|
211 | * @param int $value |
---|
212 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
213 | */ |
---|
214 | public function setStartMax($value) |
---|
215 | { |
---|
216 | if ($value != null) { |
---|
217 | $this->_params['start-max'] = Zend_Gdata_App_Util::formatTimestamp($value); |
---|
218 | } else { |
---|
219 | unset($this->_params['start-max']); |
---|
220 | } |
---|
221 | return $this; |
---|
222 | } |
---|
223 | |
---|
224 | /** |
---|
225 | * @param int $value |
---|
226 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
227 | */ |
---|
228 | public function setStartMin($value) |
---|
229 | { |
---|
230 | if ($value != null) { |
---|
231 | $this->_params['start-min'] = Zend_Gdata_App_Util::formatTimestamp($value); |
---|
232 | } else { |
---|
233 | unset($this->_params['start-min']); |
---|
234 | } |
---|
235 | return $this; |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * @param string $value |
---|
240 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
241 | */ |
---|
242 | public function setOrderBy($value) |
---|
243 | { |
---|
244 | if ($value != null) { |
---|
245 | $this->_params['orderby'] = $value; |
---|
246 | } else { |
---|
247 | unset($this->_params['orderby']); |
---|
248 | } |
---|
249 | return $this; |
---|
250 | } |
---|
251 | |
---|
252 | /** |
---|
253 | * @return int start-max |
---|
254 | */ |
---|
255 | public function getStartMax() |
---|
256 | { |
---|
257 | if (array_key_exists('start-max', $this->_params)) { |
---|
258 | return $this->_params['start-max']; |
---|
259 | } else { |
---|
260 | return null; |
---|
261 | } |
---|
262 | } |
---|
263 | |
---|
264 | /** |
---|
265 | * @return int start-min |
---|
266 | */ |
---|
267 | public function getStartMin() |
---|
268 | { |
---|
269 | if (array_key_exists('start-min', $this->_params)) { |
---|
270 | return $this->_params['start-min']; |
---|
271 | } else { |
---|
272 | return null; |
---|
273 | } |
---|
274 | } |
---|
275 | |
---|
276 | /** |
---|
277 | * @return string orderby |
---|
278 | */ |
---|
279 | public function getOrderBy() |
---|
280 | { |
---|
281 | if (array_key_exists('orderby', $this->_params)) { |
---|
282 | return $this->_params['orderby']; |
---|
283 | } else { |
---|
284 | return null; |
---|
285 | } |
---|
286 | } |
---|
287 | |
---|
288 | /** |
---|
289 | * @return string sortorder |
---|
290 | */ |
---|
291 | public function getSortOrder() |
---|
292 | { |
---|
293 | if (array_key_exists('sortorder', $this->_params)) { |
---|
294 | return $this->_params['sortorder']; |
---|
295 | } else { |
---|
296 | return null; |
---|
297 | } |
---|
298 | } |
---|
299 | |
---|
300 | /** |
---|
301 | * @return string sortorder |
---|
302 | */ |
---|
303 | public function setSortOrder($value) |
---|
304 | { |
---|
305 | if ($value != null) { |
---|
306 | $this->_params['sortorder'] = $value; |
---|
307 | } else { |
---|
308 | unset($this->_params['sortorder']); |
---|
309 | } |
---|
310 | return $this; |
---|
311 | } |
---|
312 | |
---|
313 | /** |
---|
314 | * @return string recurrence-expansion-start |
---|
315 | */ |
---|
316 | public function getRecurrenceExpansionStart() |
---|
317 | { |
---|
318 | if (array_key_exists('recurrence-expansion-start', $this->_params)) { |
---|
319 | return $this->_params['recurrence-expansion-start']; |
---|
320 | } else { |
---|
321 | return null; |
---|
322 | } |
---|
323 | } |
---|
324 | |
---|
325 | /** |
---|
326 | * @return string recurrence-expansion-start |
---|
327 | */ |
---|
328 | public function setRecurrenceExpansionStart($value) |
---|
329 | { |
---|
330 | if ($value != null) { |
---|
331 | $this->_params['recurrence-expansion-start'] = Zend_Gdata_App_Util::formatTimestamp($value); |
---|
332 | } else { |
---|
333 | unset($this->_params['recurrence-expansion-start']); |
---|
334 | } |
---|
335 | return $this; |
---|
336 | } |
---|
337 | |
---|
338 | |
---|
339 | /** |
---|
340 | * @return string recurrence-expansion-end |
---|
341 | */ |
---|
342 | public function getRecurrenceExpansionEnd() |
---|
343 | { |
---|
344 | if (array_key_exists('recurrence-expansion-end', $this->_params)) { |
---|
345 | return $this->_params['recurrence-expansion-end']; |
---|
346 | } else { |
---|
347 | return null; |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | /** |
---|
352 | * @return string recurrence-expansion-end |
---|
353 | */ |
---|
354 | public function setRecurrenceExpansionEnd($value) |
---|
355 | { |
---|
356 | if ($value != null) { |
---|
357 | $this->_params['recurrence-expansion-end'] = Zend_Gdata_App_Util::formatTimestamp($value); |
---|
358 | } else { |
---|
359 | unset($this->_params['recurrence-expansion-end']); |
---|
360 | } |
---|
361 | return $this; |
---|
362 | } |
---|
363 | |
---|
364 | /** |
---|
365 | * @param string $value Also accepts bools. |
---|
366 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
367 | */ |
---|
368 | public function getSingleEvents() |
---|
369 | { |
---|
370 | if (array_key_exists('singleevents', $this->_params)) { |
---|
371 | $value = $this->_params['singleevents']; |
---|
372 | switch ($value) { |
---|
373 | case 'true': |
---|
374 | return true; |
---|
375 | break; |
---|
376 | case 'false': |
---|
377 | return false; |
---|
378 | break; |
---|
379 | default: |
---|
380 | require_once 'Zend/Gdata/App/Exception.php'; |
---|
381 | throw new Zend_Gdata_App_Exception( |
---|
382 | 'Invalid query param value for futureevents: ' . |
---|
383 | $value . ' It must be a boolean.'); |
---|
384 | } |
---|
385 | } else { |
---|
386 | return null; |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | /** |
---|
391 | * @param string $value Also accepts bools. If using a string, must be either "true" or "false". |
---|
392 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
393 | */ |
---|
394 | public function setSingleEvents($value) |
---|
395 | { |
---|
396 | if ($value !== null) { |
---|
397 | if (is_bool($value)) { |
---|
398 | $this->_params['singleevents'] = ($value?'true':'false'); |
---|
399 | } elseif ($value == 'true' | $value == 'false') { |
---|
400 | $this->_params['singleevents'] = $value; |
---|
401 | } else { |
---|
402 | require_once 'Zend/Gdata/App/Exception.php'; |
---|
403 | throw new Zend_Gdata_App_Exception( |
---|
404 | 'Invalid query param value for futureevents: ' . |
---|
405 | $value . ' It must be a boolean.'); |
---|
406 | } |
---|
407 | } else { |
---|
408 | unset($this->_params['singleevents']); |
---|
409 | } |
---|
410 | return $this; |
---|
411 | } |
---|
412 | |
---|
413 | /** |
---|
414 | * @return string futureevents |
---|
415 | */ |
---|
416 | public function getFutureEvents() |
---|
417 | { |
---|
418 | if (array_key_exists('futureevents', $this->_params)) { |
---|
419 | $value = $this->_params['futureevents']; |
---|
420 | switch ($value) { |
---|
421 | case 'true': |
---|
422 | return true; |
---|
423 | break; |
---|
424 | case 'false': |
---|
425 | return false; |
---|
426 | break; |
---|
427 | default: |
---|
428 | require_once 'Zend/Gdata/App/Exception.php'; |
---|
429 | throw new Zend_Gdata_App_Exception( |
---|
430 | 'Invalid query param value for futureevents: ' . |
---|
431 | $value . ' It must be a boolean.'); |
---|
432 | } |
---|
433 | } else { |
---|
434 | return null; |
---|
435 | } |
---|
436 | } |
---|
437 | |
---|
438 | /** |
---|
439 | * @param string $value Also accepts bools. If using a string, must be either "true" or "false" or |
---|
440 | * an exception will be thrown on retrieval. |
---|
441 | * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface |
---|
442 | */ |
---|
443 | public function setFutureEvents($value) |
---|
444 | { |
---|
445 | if ($value !== null) { |
---|
446 | if (is_bool($value)) { |
---|
447 | $this->_params['futureevents'] = ($value?'true':'false'); |
---|
448 | } elseif ($value == 'true' | $value == 'false') { |
---|
449 | $this->_params['futureevents'] = $value; |
---|
450 | } else { |
---|
451 | require_once 'Zend/Gdata/App/Exception.php'; |
---|
452 | throw new Zend_Gdata_App_Exception( |
---|
453 | 'Invalid query param value for futureevents: ' . |
---|
454 | $value . ' It must be a boolean.'); |
---|
455 | } |
---|
456 | } else { |
---|
457 | unset($this->_params['futureevents']); |
---|
458 | } |
---|
459 | return $this; |
---|
460 | } |
---|
461 | |
---|
462 | /** |
---|
463 | * @return string url |
---|
464 | */ |
---|
465 | public function getQueryUrl() |
---|
466 | { |
---|
467 | if (isset($this->_url)) { |
---|
468 | $uri = $this->_url; |
---|
469 | } else { |
---|
470 | $uri = $this->_defaultFeedUri; |
---|
471 | } |
---|
472 | if ($this->getUser() != null) { |
---|
473 | $uri .= '/' . $this->getUser(); |
---|
474 | } |
---|
475 | if ($this->getVisibility() != null) { |
---|
476 | $uri .= '/' . $this->getVisibility(); |
---|
477 | } |
---|
478 | if ($this->getProjection() != null) { |
---|
479 | $uri .= '/' . $this->getProjection(); |
---|
480 | } |
---|
481 | if ($this->getEvent() != null) { |
---|
482 | $uri .= '/' . $this->getEvent(); |
---|
483 | if ($this->getComments() != null) { |
---|
484 | $uri .= '/comments/' . $this->getComments(); |
---|
485 | } |
---|
486 | } |
---|
487 | $uri .= $this->getQueryString(); |
---|
488 | return $uri; |
---|
489 | } |
---|
490 | |
---|
491 | } |
---|