source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Calendar/EventQuery.php@ 44

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