File indexing completed on 2025-01-26 05:29:33
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Calendar 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * Zend_Gdata_App_util 0026 */ 0027 // require_once('Zend/Gdata/App/Util.php'); 0028 0029 /** 0030 * Zend_Gdata_Query 0031 */ 0032 // require_once('Zend/Gdata/Query.php'); 0033 0034 /** 0035 * Assists in constructing queries for Google Calendar events 0036 * 0037 * @link http://code.google.com/apis/gdata/calendar/ 0038 * 0039 * @category Zend 0040 * @package Zend_Gdata 0041 * @subpackage Calendar 0042 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0043 * @license http://framework.zend.com/license/new-bsd New BSD License 0044 */ 0045 class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query 0046 { 0047 0048 const CALENDAR_FEED_URI = 'https://www.google.com/calendar/feeds'; 0049 0050 /** 0051 * The default URI used for feeds. 0052 */ 0053 protected $_defaultFeedUri = self::CALENDAR_FEED_URI; 0054 0055 /** 0056 * The comment ID to retrieve. If null, no specific comment will be 0057 * retrieved unless already included in the query URI. The event ID 0058 * ($_event) must be set, otherwise this property is ignored. 0059 */ 0060 protected $_comments = null; 0061 0062 /** 0063 * The calendar address to be requested by queries. This may be an email 0064 * address if requesting the primary calendar for a user. Defaults to 0065 * "default" (the currently authenticated user). A null value should be 0066 * used when the calendar address has already been set as part of the 0067 * query URI. 0068 */ 0069 protected $_user = 'default'; 0070 0071 /* 0072 * The visibility to be requested by queries. Defaults to "public". A 0073 * null value should be used when the calendar address has already been 0074 * set as part of the query URI. 0075 */ 0076 protected $_visibility = 'public'; 0077 0078 /** 0079 * Projection to be requested by queries. Defaults to "full". A null value 0080 * should be used when the calendar address has already been set as part 0081 * of the query URI. 0082 */ 0083 protected $_projection = 'full'; 0084 0085 /** 0086 * The event ID to retrieve. If null, no specific event will be retrieved 0087 * unless already included in the query URI. 0088 */ 0089 protected $_event = null; 0090 0091 /** 0092 * Create Gdata_Calendar_EventQuery object. If a URL is provided, 0093 * it becomes the base URL, and additional URL components may be 0094 * appended. For instance, if $url is 'https://www.google.com/calendar', 0095 * the default URL constructed will be 0096 * 'https://www.google.com/calendar/default/public/full'. 0097 * 0098 * If the URL already contains a calendar ID, projection, visibility, 0099 * event ID, or comment ID, you will need to set these fields to null 0100 * to prevent them from being inserted. See this class's properties for 0101 * more information. 0102 * 0103 * @param string $url The URL to use as the base path for requests 0104 */ 0105 public function __construct($url = null) 0106 { 0107 parent::__construct($url); 0108 } 0109 0110 /** 0111 * @see $_comments 0112 * @param string $value 0113 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0114 */ 0115 public function setComments($value) 0116 { 0117 $this->_comments = $value; 0118 return $this; 0119 } 0120 0121 /** 0122 * @see $_event 0123 * @param string $value 0124 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0125 */ 0126 public function setEvent($value) 0127 { 0128 $this->_event = $value; 0129 return $this; 0130 } 0131 0132 /** 0133 * @see $_projection 0134 * @param string $value 0135 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0136 */ 0137 public function setProjection($value) 0138 { 0139 $this->_projection = $value; 0140 return $this; 0141 } 0142 0143 /** 0144 * @see $_user 0145 * @param string $value 0146 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0147 */ 0148 public function setUser($value) 0149 { 0150 $this->_user = $value; 0151 return $this; 0152 } 0153 0154 /** 0155 * @see $_visibility 0156 * @param bool $value 0157 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0158 */ 0159 public function setVisibility($value) 0160 { 0161 $this->_visibility = $value; 0162 return $this; 0163 } 0164 0165 /** 0166 * @see $_comments; 0167 * @return string comments 0168 */ 0169 public function getComments() 0170 { 0171 return $this->_comments; 0172 } 0173 0174 /** 0175 * @see $_event; 0176 * @return string event 0177 */ 0178 public function getEvent() 0179 { 0180 return $this->_event; 0181 } 0182 0183 /** 0184 * @see $_projection 0185 * @return string projection 0186 */ 0187 public function getProjection() 0188 { 0189 return $this->_projection; 0190 } 0191 0192 /** 0193 * @see $_user 0194 * @return string user 0195 */ 0196 public function getUser() 0197 { 0198 return $this->_user; 0199 } 0200 0201 /** 0202 * @see $_visibility 0203 * @return string visibility 0204 */ 0205 public function getVisibility() 0206 { 0207 return $this->_visibility; 0208 } 0209 0210 /** 0211 * @param int $value 0212 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0213 */ 0214 public function setStartMax($value) 0215 { 0216 if ($value != null) { 0217 $this->_params['start-max'] = Zend_Gdata_App_Util::formatTimestamp($value); 0218 } else { 0219 unset($this->_params['start-max']); 0220 } 0221 return $this; 0222 } 0223 0224 /** 0225 * @param int $value 0226 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0227 */ 0228 public function setStartMin($value) 0229 { 0230 if ($value != null) { 0231 $this->_params['start-min'] = Zend_Gdata_App_Util::formatTimestamp($value); 0232 } else { 0233 unset($this->_params['start-min']); 0234 } 0235 return $this; 0236 } 0237 0238 /** 0239 * @param string $value 0240 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0241 */ 0242 public function setOrderBy($value) 0243 { 0244 if ($value != null) { 0245 $this->_params['orderby'] = $value; 0246 } else { 0247 unset($this->_params['orderby']); 0248 } 0249 return $this; 0250 } 0251 0252 /** 0253 * @return int start-max 0254 */ 0255 public function getStartMax() 0256 { 0257 if (array_key_exists('start-max', $this->_params)) { 0258 return $this->_params['start-max']; 0259 } else { 0260 return null; 0261 } 0262 } 0263 0264 /** 0265 * @return int start-min 0266 */ 0267 public function getStartMin() 0268 { 0269 if (array_key_exists('start-min', $this->_params)) { 0270 return $this->_params['start-min']; 0271 } else { 0272 return null; 0273 } 0274 } 0275 0276 /** 0277 * @return string orderby 0278 */ 0279 public function getOrderBy() 0280 { 0281 if (array_key_exists('orderby', $this->_params)) { 0282 return $this->_params['orderby']; 0283 } else { 0284 return null; 0285 } 0286 } 0287 0288 /** 0289 * @return string sortorder 0290 */ 0291 public function getSortOrder() 0292 { 0293 if (array_key_exists('sortorder', $this->_params)) { 0294 return $this->_params['sortorder']; 0295 } else { 0296 return null; 0297 } 0298 } 0299 0300 /** 0301 * @return string sortorder 0302 */ 0303 public function setSortOrder($value) 0304 { 0305 if ($value != null) { 0306 $this->_params['sortorder'] = $value; 0307 } else { 0308 unset($this->_params['sortorder']); 0309 } 0310 return $this; 0311 } 0312 0313 /** 0314 * @return string recurrence-expansion-start 0315 */ 0316 public function getRecurrenceExpansionStart() 0317 { 0318 if (array_key_exists('recurrence-expansion-start', $this->_params)) { 0319 return $this->_params['recurrence-expansion-start']; 0320 } else { 0321 return null; 0322 } 0323 } 0324 0325 /** 0326 * @return string recurrence-expansion-start 0327 */ 0328 public function setRecurrenceExpansionStart($value) 0329 { 0330 if ($value != null) { 0331 $this->_params['recurrence-expansion-start'] = Zend_Gdata_App_Util::formatTimestamp($value); 0332 } else { 0333 unset($this->_params['recurrence-expansion-start']); 0334 } 0335 return $this; 0336 } 0337 0338 0339 /** 0340 * @return string recurrence-expansion-end 0341 */ 0342 public function getRecurrenceExpansionEnd() 0343 { 0344 if (array_key_exists('recurrence-expansion-end', $this->_params)) { 0345 return $this->_params['recurrence-expansion-end']; 0346 } else { 0347 return null; 0348 } 0349 } 0350 0351 /** 0352 * @return string recurrence-expansion-end 0353 */ 0354 public function setRecurrenceExpansionEnd($value) 0355 { 0356 if ($value != null) { 0357 $this->_params['recurrence-expansion-end'] = Zend_Gdata_App_Util::formatTimestamp($value); 0358 } else { 0359 unset($this->_params['recurrence-expansion-end']); 0360 } 0361 return $this; 0362 } 0363 0364 /** 0365 * @param string $value Also accepts bools. 0366 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0367 */ 0368 public function getSingleEvents() 0369 { 0370 if (array_key_exists('singleevents', $this->_params)) { 0371 $value = $this->_params['singleevents']; 0372 switch ($value) { 0373 case 'true': 0374 return true; 0375 break; 0376 case 'false': 0377 return false; 0378 break; 0379 default: 0380 // require_once 'Zend/Gdata/App/Exception.php'; 0381 throw new Zend_Gdata_App_Exception( 0382 'Invalid query param value for futureevents: ' . 0383 $value . ' It must be a boolean.'); 0384 } 0385 } else { 0386 return null; 0387 } 0388 } 0389 0390 /** 0391 * @param string $value Also accepts bools. If using a string, must be either "true" or "false". 0392 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0393 */ 0394 public function setSingleEvents($value) 0395 { 0396 if ($value !== null) { 0397 if (is_bool($value)) { 0398 $this->_params['singleevents'] = ($value?'true':'false'); 0399 } elseif ($value == 'true' | $value == 'false') { 0400 $this->_params['singleevents'] = $value; 0401 } else { 0402 // require_once 'Zend/Gdata/App/Exception.php'; 0403 throw new Zend_Gdata_App_Exception( 0404 'Invalid query param value for futureevents: ' . 0405 $value . ' It must be a boolean.'); 0406 } 0407 } else { 0408 unset($this->_params['singleevents']); 0409 } 0410 return $this; 0411 } 0412 0413 /** 0414 * @return string futureevents 0415 */ 0416 public function getFutureEvents() 0417 { 0418 if (array_key_exists('futureevents', $this->_params)) { 0419 $value = $this->_params['futureevents']; 0420 switch ($value) { 0421 case 'true': 0422 return true; 0423 break; 0424 case 'false': 0425 return false; 0426 break; 0427 default: 0428 // require_once 'Zend/Gdata/App/Exception.php'; 0429 throw new Zend_Gdata_App_Exception( 0430 'Invalid query param value for futureevents: ' . 0431 $value . ' It must be a boolean.'); 0432 } 0433 } else { 0434 return null; 0435 } 0436 } 0437 0438 /** 0439 * @param string $value Also accepts bools. If using a string, must be either "true" or "false" or 0440 * an exception will be thrown on retrieval. 0441 * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface 0442 */ 0443 public function setFutureEvents($value) 0444 { 0445 if ($value !== null) { 0446 if (is_bool($value)) { 0447 $this->_params['futureevents'] = ($value?'true':'false'); 0448 } elseif ($value == 'true' | $value == 'false') { 0449 $this->_params['futureevents'] = $value; 0450 } else { 0451 // require_once 'Zend/Gdata/App/Exception.php'; 0452 throw new Zend_Gdata_App_Exception( 0453 'Invalid query param value for futureevents: ' . 0454 $value . ' It must be a boolean.'); 0455 } 0456 } else { 0457 unset($this->_params['futureevents']); 0458 } 0459 return $this; 0460 } 0461 0462 /** 0463 * @return string url 0464 */ 0465 public function getQueryUrl() 0466 { 0467 if (isset($this->_url)) { 0468 $uri = $this->_url; 0469 } else { 0470 $uri = $this->_defaultFeedUri; 0471 } 0472 if ($this->getUser() != null) { 0473 $uri .= '/' . $this->getUser(); 0474 } 0475 if ($this->getVisibility() != null) { 0476 $uri .= '/' . $this->getVisibility(); 0477 } 0478 if ($this->getProjection() != null) { 0479 $uri .= '/' . $this->getProjection(); 0480 } 0481 if ($this->getEvent() != null) { 0482 $uri .= '/' . $this->getEvent(); 0483 if ($this->getComments() != null) { 0484 $uri .= '/comments/' . $this->getComments(); 0485 } 0486 } 0487 $uri .= $this->getQueryString(); 0488 return $uri; 0489 } 0490 0491 }