File: EventQuery.php

package info (click to toggle)
zendframework 1.10.6-1squeeze2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 29,480 kB
  • ctags: 46,247
  • sloc: xml: 233,973; php: 195,700; sql: 90; sh: 19; makefile: 10
file content (491 lines) | stat: -rw-r--r-- 13,669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Gdata
 * @subpackage Calendar
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: EventQuery.php 20096 2010-01-06 02:05:09Z bkarwin $
 */

/**
 * Zend_Gdata_App_util
 */
require_once('Zend/Gdata/App/Util.php');

/**
 * Zend_Gdata_Query
 */
require_once('Zend/Gdata/Query.php');

/**
 * Assists in constructing queries for Google Calendar events
 *
 * @link http://code.google.com/apis/gdata/calendar/
 *
 * @category   Zend
 * @package    Zend_Gdata
 * @subpackage Calendar
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
{

    const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds';

    /**
     * The default URI used for feeds.
     */
    protected $_defaultFeedUri = self::CALENDAR_FEED_URI;

    /**
     * The comment ID to retrieve. If null, no specific comment will be
     * retrieved unless already included in the query URI. The event ID
     * ($_event) must be set, otherwise this property is ignored.
     */
    protected $_comments = null;

    /**
     * The calendar address to be requested by queries. This may be an email
     * address if requesting the primary calendar for a user. Defaults to
     * "default" (the currently authenticated user). A null value should be
     * used when the calendar address has already been set as part of the
     * query URI.
     */
    protected $_user = 'default';

    /*
     * The visibility to be requested by queries. Defaults to "public". A
     * null value should be used when the calendar address has already been
     * set as part of the query URI.
     */
    protected $_visibility = 'public';

    /**
     * Projection to be requested by queries. Defaults to "full". A null value
     * should be used when the calendar address has already been set as part
     * of the query URI.
     */
    protected $_projection = 'full';

    /**
     * The event ID to retrieve. If null, no specific event will be retrieved
     * unless already included in the query URI.
     */
    protected $_event = null;

    /**
     * Create Gdata_Calendar_EventQuery object.  If a URL is provided,
     * it becomes the base URL, and additional URL components may be
     * appended.  For instance, if $url is 'http://www.google.com/calendar',
     * the default URL constructed will be
     * 'http://www.google.com/calendar/default/public/full'.
     *
     * If the URL already contains a calendar ID, projection, visibility,
     * event ID, or comment ID, you will need to set these fields to null
     * to prevent them from being inserted. See this class's properties for
     * more information.
     *
     * @param string $url The URL to use as the base path for requests
     */
    public function __construct($url = null)
    {
        parent::__construct($url);
    }

    /**
     * @see $_comments
     * @param string $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setComments($value)
    {
        $this->_comments = $value;
        return $this;
    }

    /**
     * @see $_event
     * @param string $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setEvent($value)
    {
        $this->_event = $value;
        return $this;
    }

    /**
     * @see $_projection
     * @param string $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setProjection($value)
    {
        $this->_projection = $value;
        return $this;
    }

    /**
     * @see $_user
     * @param string $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setUser($value)
    {
        $this->_user = $value;
        return $this;
    }

    /**
     * @see $_visibility
     * @param bool $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setVisibility($value)
    {
        $this->_visibility = $value;
        return $this;
    }

    /**
     * @see $_comments;
     * @return string comments
     */
    public function getComments()
    {
        return $this->_comments;
    }

    /**
     * @see $_event;
     * @return string event
     */
    public function getEvent()
    {
        return $this->_event;
    }

    /**
     * @see $_projection
     * @return string projection
     */
    public function getProjection()
    {
        return $this->_projection;
    }

    /**
     * @see $_user
     * @return string user
     */
    public function getUser()
    {
        return $this->_user;
    }

    /**
     * @see $_visibility
     * @return string visibility
     */
    public function getVisibility()
    {
        return $this->_visibility;
    }

    /**
     * @param int $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setStartMax($value)
    {
        if ($value != null) {
            $this->_params['start-max'] = Zend_Gdata_App_Util::formatTimestamp($value);
        } else {
            unset($this->_params['start-max']);
        }
        return $this;
    }

    /**
     * @param int $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setStartMin($value)
    {
        if ($value != null) {
            $this->_params['start-min'] = Zend_Gdata_App_Util::formatTimestamp($value);
        } else {
            unset($this->_params['start-min']);
        }
        return $this;
    }

    /**
     * @param string $value
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setOrderBy($value)
    {
        if ($value != null) {
            $this->_params['orderby'] = $value;
        } else {
            unset($this->_params['orderby']);
        }
        return $this;
    }

    /**
     * @return int start-max
     */
    public function getStartMax()
    {
        if (array_key_exists('start-max', $this->_params)) {
            return $this->_params['start-max'];
        } else {
            return null;
        }
    }

    /**
     * @return int start-min
     */
    public function getStartMin()
    {
        if (array_key_exists('start-min', $this->_params)) {
            return $this->_params['start-min'];
        } else {
            return null;
        }
    }

    /**
     * @return string orderby
     */
    public function getOrderBy()
    {
        if (array_key_exists('orderby', $this->_params)) {
            return $this->_params['orderby'];
        } else {
            return null;
        }
    }

    /**
     * @return string sortorder
     */
    public function getSortOrder()
    {
        if (array_key_exists('sortorder', $this->_params)) {
            return $this->_params['sortorder'];
        } else {
            return null;
        }
    }

    /**
     * @return string sortorder
     */
    public function setSortOrder($value)
    {
        if ($value != null) {
            $this->_params['sortorder'] = $value;
        } else {
            unset($this->_params['sortorder']);
        }
        return $this;
    }

    /**
     * @return string recurrence-expansion-start
     */
    public function getRecurrenceExpansionStart()
    {
        if (array_key_exists('recurrence-expansion-start', $this->_params)) {
            return $this->_params['recurrence-expansion-start'];
        } else {
            return null;
        }
    }

    /**
     * @return string recurrence-expansion-start
     */
    public function setRecurrenceExpansionStart($value)
    {
        if ($value != null) {
            $this->_params['recurrence-expansion-start'] = Zend_Gdata_App_Util::formatTimestamp($value);
        } else {
            unset($this->_params['recurrence-expansion-start']);
        }
        return $this;
    }


    /**
     * @return string recurrence-expansion-end
     */
    public function getRecurrenceExpansionEnd()
    {
        if (array_key_exists('recurrence-expansion-end', $this->_params)) {
            return $this->_params['recurrence-expansion-end'];
        } else {
            return null;
        }
    }

    /**
     * @return string recurrence-expansion-end
     */
    public function setRecurrenceExpansionEnd($value)
    {
        if ($value != null) {
            $this->_params['recurrence-expansion-end'] = Zend_Gdata_App_Util::formatTimestamp($value);
        } else {
            unset($this->_params['recurrence-expansion-end']);
        }
        return $this;
    }

    /**
     * @param string $value Also accepts bools.
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function getSingleEvents()
    {
        if (array_key_exists('singleevents', $this->_params)) {
            $value = $this->_params['singleevents'];
            switch ($value) {
                case 'true':
                    return true;
                    break;
                case 'false':
                    return false;
                    break;
                default:
                    require_once 'Zend/Gdata/App/Exception.php';
                    throw new Zend_Gdata_App_Exception(
                            'Invalid query param value for futureevents: ' .
                            $value . ' It must be a boolean.');
            }
        } else {
            return null;
        }
    }

    /**
     * @param string $value Also accepts bools. If using a string, must be either "true" or "false".
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setSingleEvents($value)
    {
        if ($value !== null) {
            if (is_bool($value)) {
                $this->_params['singleevents'] = ($value?'true':'false');
            } elseif ($value == 'true' | $value == 'false') {
                $this->_params['singleevents'] = $value;
            } else {
                require_once 'Zend/Gdata/App/Exception.php';
                throw new Zend_Gdata_App_Exception(
                        'Invalid query param value for futureevents: ' .
                        $value . ' It must be a boolean.');
            }
        } else {
            unset($this->_params['singleevents']);
        }
        return $this;
    }

    /**
     * @return string futureevents
     */
    public function getFutureEvents()
    {
        if (array_key_exists('futureevents', $this->_params)) {
            $value = $this->_params['futureevents'];
            switch ($value) {
                case 'true':
                    return true;
                    break;
                case 'false':
                    return false;
                    break;
                default:
                    require_once 'Zend/Gdata/App/Exception.php';
                    throw new Zend_Gdata_App_Exception(
                            'Invalid query param value for futureevents: ' .
                            $value . ' It must be a boolean.');
            }
        } else {
            return null;
        }
    }

    /**
     * @param string $value Also accepts bools. If using a string, must be either "true" or "false" or
     *                      an exception will be thrown on retrieval.
     * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
     */
    public function setFutureEvents($value)
    {
        if ($value !== null) {
            if (is_bool($value)) {
                $this->_params['futureevents'] = ($value?'true':'false');
            } elseif ($value == 'true' | $value == 'false') {
                $this->_params['futureevents'] = $value;
            } else {
                require_once 'Zend/Gdata/App/Exception.php';
                throw new Zend_Gdata_App_Exception(
                        'Invalid query param value for futureevents: ' .
                        $value . ' It must be a boolean.');
            }
        } else {
            unset($this->_params['futureevents']);
        }
        return $this;
    }

    /**
     * @return string url
     */
    public function getQueryUrl()
    {
        if (isset($this->_url)) {
            $uri = $this->_url;
        } else {
            $uri = $this->_defaultFeedUri;
        }
        if ($this->getUser() != null) {
            $uri .= '/' . $this->getUser();
        }
        if ($this->getVisibility() != null) {
            $uri .= '/' . $this->getVisibility();
        }
        if ($this->getProjection() != null) {
            $uri .= '/' . $this->getProjection();
        }
        if ($this->getEvent() != null) {
            $uri .= '/' . $this->getEvent();
            if ($this->getComments() != null) {
                $uri .= '/comments/' . $this->getComments();
            }
        }
        $uri .= $this->getQueryString();
        return $uri;
    }

}