File indexing completed on 2024-12-22 05:36:46
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 * @see Zend_Gdata 0026 */ 0027 // require_once 'Zend/Gdata.php'; 0028 0029 /** 0030 * @see Zend_Gdata_Calendar_EventFeed 0031 */ 0032 // require_once 'Zend/Gdata/Calendar/EventFeed.php'; 0033 0034 /** 0035 * @see Zend_Gdata_Calendar_EventEntry 0036 */ 0037 // require_once 'Zend/Gdata/Calendar/EventEntry.php'; 0038 0039 /** 0040 * @see Zend_Gdata_Calendar_ListFeed 0041 */ 0042 // require_once 'Zend/Gdata/Calendar/ListFeed.php'; 0043 0044 /** 0045 * @see Zend_Gdata_Calendar_ListEntry 0046 */ 0047 // require_once 'Zend/Gdata/Calendar/ListEntry.php'; 0048 0049 /** 0050 * Service class for interacting with the Google Calendar data API 0051 * @link http://code.google.com/apis/gdata/calendar.html 0052 * 0053 * @category Zend 0054 * @package Zend_Gdata 0055 * @subpackage Calendar 0056 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0057 * @license http://framework.zend.com/license/new-bsd New BSD License 0058 */ 0059 class Zend_Gdata_Calendar extends Zend_Gdata 0060 { 0061 0062 const CALENDAR_FEED_URI = 'https://www.google.com/calendar/feeds'; 0063 const CALENDAR_EVENT_FEED_URI = 'https://www.google.com/calendar/feeds/default/private/full'; 0064 const AUTH_SERVICE_NAME = 'cl'; 0065 0066 protected $_defaultPostUri = self::CALENDAR_EVENT_FEED_URI; 0067 0068 /** 0069 * Namespaces used for Zend_Gdata_Calendar 0070 * 0071 * @var array 0072 */ 0073 public static $namespaces = array( 0074 array('gCal', 'http://schemas.google.com/gCal/2005', 1, 0) 0075 ); 0076 0077 /** 0078 * Create Gdata_Calendar object 0079 * 0080 * @param Zend_Http_Client $client (optional) The HTTP client to use when 0081 * when communicating with the Google servers. 0082 * @param string $applicationId The identity of the app in the form of Company-AppName-Version 0083 */ 0084 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') 0085 { 0086 $this->registerPackage('Zend_Gdata_Calendar'); 0087 $this->registerPackage('Zend_Gdata_Calendar_Extension'); 0088 parent::__construct($client, $applicationId); 0089 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); 0090 } 0091 0092 /** 0093 * Retreive feed object 0094 * 0095 * @param mixed $location The location for the feed, as a URL or Query 0096 * @return Zend_Gdata_Calendar_EventFeed 0097 */ 0098 public function getCalendarEventFeed($location = null) 0099 { 0100 if ($location == null) { 0101 $uri = self::CALENDAR_EVENT_FEED_URI; 0102 } else if ($location instanceof Zend_Gdata_Query) { 0103 $uri = $location->getQueryUrl(); 0104 } else { 0105 $uri = $location; 0106 } 0107 return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed'); 0108 } 0109 0110 /** 0111 * Retreive entry object 0112 * 0113 * @return Zend_Gdata_Calendar_EventEntry 0114 */ 0115 public function getCalendarEventEntry($location = null) 0116 { 0117 if ($location == null) { 0118 // require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 0119 throw new Zend_Gdata_App_InvalidArgumentException( 0120 'Location must not be null'); 0121 } else if ($location instanceof Zend_Gdata_Query) { 0122 $uri = $location->getQueryUrl(); 0123 } else { 0124 $uri = $location; 0125 } 0126 return parent::getEntry($uri, 'Zend_Gdata_Calendar_EventEntry'); 0127 } 0128 0129 0130 /** 0131 * Retrieve feed object 0132 * 0133 * @return Zend_Gdata_Calendar_ListFeed 0134 */ 0135 public function getCalendarListFeed() 0136 { 0137 $uri = self::CALENDAR_FEED_URI . '/default'; 0138 return parent::getFeed($uri,'Zend_Gdata_Calendar_ListFeed'); 0139 } 0140 0141 /** 0142 * Retreive entryobject 0143 * 0144 * @return Zend_Gdata_Calendar_ListEntry 0145 */ 0146 public function getCalendarListEntry($location = null) 0147 { 0148 if ($location == null) { 0149 // require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 0150 throw new Zend_Gdata_App_InvalidArgumentException( 0151 'Location must not be null'); 0152 } else if ($location instanceof Zend_Gdata_Query) { 0153 $uri = $location->getQueryUrl(); 0154 } else { 0155 $uri = $location; 0156 } 0157 return parent::getEntry($uri,'Zend_Gdata_Calendar_ListEntry'); 0158 } 0159 0160 public function insertEvent($event, $uri=null) 0161 { 0162 if ($uri == null) { 0163 $uri = $this->_defaultPostUri; 0164 } 0165 $newEvent = $this->insertEntry($event, $uri, 'Zend_Gdata_Calendar_EventEntry'); 0166 return $newEvent; 0167 } 0168 0169 }