[44] | 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 | * @see Zend_Gdata
|
---|
| 25 | */
|
---|
| 26 | require_once 'Zend/Gdata.php';
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * @see Zend_Gdata_Calendar_EventFeed
|
---|
| 30 | */
|
---|
| 31 | require_once 'Zend/Gdata/Calendar/EventFeed.php';
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * @see Zend_Gdata_Calendar_EventEntry
|
---|
| 35 | */
|
---|
| 36 | require_once 'Zend/Gdata/Calendar/EventEntry.php';
|
---|
| 37 |
|
---|
| 38 | /**
|
---|
| 39 | * @see Zend_Gdata_Calendar_ListFeed
|
---|
| 40 | */
|
---|
| 41 | require_once 'Zend/Gdata/Calendar/ListFeed.php';
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * @see Zend_Gdata_Calendar_ListEntry
|
---|
| 45 | */
|
---|
| 46 | require_once 'Zend/Gdata/Calendar/ListEntry.php';
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * Service class for interacting with the Google Calendar data API
|
---|
| 50 | * @link http://code.google.com/apis/gdata/calendar.html
|
---|
| 51 | *
|
---|
| 52 | * @category Zend
|
---|
| 53 | * @package Zend_Gdata
|
---|
| 54 | * @subpackage Calendar
|
---|
| 55 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 56 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 57 | */
|
---|
| 58 | class Zend_Gdata_Calendar extends Zend_Gdata
|
---|
| 59 | {
|
---|
| 60 |
|
---|
| 61 | const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds';
|
---|
| 62 | const CALENDAR_EVENT_FEED_URI = 'http://www.google.com/calendar/feeds/default/private/full';
|
---|
| 63 | const AUTH_SERVICE_NAME = 'cl';
|
---|
| 64 |
|
---|
| 65 | protected $_defaultPostUri = self::CALENDAR_EVENT_FEED_URI;
|
---|
| 66 |
|
---|
| 67 | /**
|
---|
| 68 | * Namespaces used for Zend_Gdata_Calendar
|
---|
| 69 | *
|
---|
| 70 | * @var array
|
---|
| 71 | */
|
---|
| 72 | public static $namespaces = array(
|
---|
| 73 | array('gCal', 'http://schemas.google.com/gCal/2005', 1, 0)
|
---|
| 74 | );
|
---|
| 75 |
|
---|
| 76 | /**
|
---|
| 77 | * Create Gdata_Calendar object
|
---|
| 78 | *
|
---|
| 79 | * @param Zend_Http_Client $client (optional) The HTTP client to use when
|
---|
| 80 | * when communicating with the Google servers.
|
---|
| 81 | * @param string $applicationId The identity of the app in the form of Company-AppName-Version
|
---|
| 82 | */
|
---|
| 83 | public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
|
---|
| 84 | {
|
---|
| 85 | $this->registerPackage('Zend_Gdata_Calendar');
|
---|
| 86 | $this->registerPackage('Zend_Gdata_Calendar_Extension');
|
---|
| 87 | parent::__construct($client, $applicationId);
|
---|
| 88 | $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /**
|
---|
| 92 | * Retreive feed object
|
---|
| 93 | *
|
---|
| 94 | * @param mixed $location The location for the feed, as a URL or Query
|
---|
| 95 | * @return Zend_Gdata_Calendar_EventFeed
|
---|
| 96 | */
|
---|
| 97 | public function getCalendarEventFeed($location = null)
|
---|
| 98 | {
|
---|
| 99 | if ($location == null) {
|
---|
| 100 | $uri = self::CALENDAR_EVENT_FEED_URI;
|
---|
| 101 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
| 102 | $uri = $location->getQueryUrl();
|
---|
| 103 | } else {
|
---|
| 104 | $uri = $location;
|
---|
| 105 | }
|
---|
| 106 | return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed');
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /**
|
---|
| 110 | * Retreive entry object
|
---|
| 111 | *
|
---|
| 112 | * @return Zend_Gdata_Calendar_EventEntry
|
---|
| 113 | */
|
---|
| 114 | public function getCalendarEventEntry($location = null)
|
---|
| 115 | {
|
---|
| 116 | if ($location == null) {
|
---|
| 117 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
| 118 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
| 119 | 'Location must not be null');
|
---|
| 120 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
| 121 | $uri = $location->getQueryUrl();
|
---|
| 122 | } else {
|
---|
| 123 | $uri = $location;
|
---|
| 124 | }
|
---|
| 125 | return parent::getEntry($uri, 'Zend_Gdata_Calendar_EventEntry');
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /**
|
---|
| 130 | * Retrieve feed object
|
---|
| 131 | *
|
---|
| 132 | * @return Zend_Gdata_Calendar_ListFeed
|
---|
| 133 | */
|
---|
| 134 | public function getCalendarListFeed()
|
---|
| 135 | {
|
---|
| 136 | $uri = self::CALENDAR_FEED_URI . '/default';
|
---|
| 137 | return parent::getFeed($uri,'Zend_Gdata_Calendar_ListFeed');
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | /**
|
---|
| 141 | * Retreive entryobject
|
---|
| 142 | *
|
---|
| 143 | * @return Zend_Gdata_Calendar_ListEntry
|
---|
| 144 | */
|
---|
| 145 | public function getCalendarListEntry($location = null)
|
---|
| 146 | {
|
---|
| 147 | if ($location == null) {
|
---|
| 148 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
| 149 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
| 150 | 'Location must not be null');
|
---|
| 151 | } else if ($location instanceof Zend_Gdata_Query) {
|
---|
| 152 | $uri = $location->getQueryUrl();
|
---|
| 153 | } else {
|
---|
| 154 | $uri = $location;
|
---|
| 155 | }
|
---|
| 156 | return parent::getEntry($uri,'Zend_Gdata_Calendar_ListEntry');
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | public function insertEvent($event, $uri=null)
|
---|
| 160 | {
|
---|
| 161 | if ($uri == null) {
|
---|
| 162 | $uri = $this->_defaultPostUri;
|
---|
| 163 | }
|
---|
| 164 | $newEvent = $this->insertEntry($event, $uri, 'Zend_Gdata_Calendar_EventEntry');
|
---|
| 165 | return $newEvent;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | }
|
---|