好的,經過大量的搜索,我決定實現我自己的解決方案,因爲我找不到滿足我需求的解決方案。我已決定使用FullCalendar Plugin。它具有gCal功能,可以從日曆提要中獲取數據,但日曆需要公開才能使用此功能。所以我創造了我自己的。
在頁面視圖(calendar.phtml):
<?php if ($this->worker == "office"): ?>
<div id='calendar'></div>
<?php else: ?>
<iframe src="https://www.google.com/calendar/embed?showTitle=0&showCalendars=0&showTz=0&height=600&wkst=2&hl=en_GB&bgcolor=%23FFFFFF&src=YOU-CALENDAR-LINK&color=%2329527A&ctz=Europe%2FLondon&pvttk=YOUR-PRIVATE-KEY"
style="border-width:0;"
width="580"
height="600"
frameborder="0"
scrolling="no"></iframe>
<?php endif; ?>
在calendarAction方法:
$this->view->jQuery()->addStyleSheet($this->view->baseUrl('css/JQuery/fullcalendar.css'));
$this->view->jQuery()->addJavascriptFile($this->view->baseUrl('js/fullcalendar.js'));
$this->view->jQuery()->addJavascriptFile($this->view->baseUrl('js/myCal.js'));
在我的日曆的Controler我添加了一個函數返回一個JSON陣列(CalendarControler.php ):
$startDate = $this->_getParam('start');
$startDate = date("Y-m-d", $startDate);
$endDate = $this->_getParam('end');
$endDate = date("Y-m-d", $endDate);
// Remove the view & layout
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
// Query Google GData for the calendar
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$source = "YOU-APP-NAME";
$user = "USERNAME";
$pass = "PASSWORD";
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service,null,$source);
$cal = new Zend_Gdata_Calendar($client);
$events = array();
$query = $cal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setStartMin($startDate);
$query->setStartMax($endDate);
$eventFeed = $cal->getCalendarEventFeed($query);
// Loop through the returned events:
foreach ($eventFeed as $event)
{
$temp['id'] = $event->id->text;
$temp['title'] = $event->title->text;
$temp['allDay'] = false;
foreach ($event->when as $when)
{
$temp['start'] = date("D M j Y H:i:s eO", strtotime($when->startTime));
$temp['end'] = date("D M j Y H:i:s eO", strtotime($when->endTime));
}
array_push($events, $temp);
}
echo json_encode($events);
最後未完成的JS類(myCal.js) - 它是未完成的,因爲我是l掛鉤到fullcalendar的可編輯和添加動作,並使用一些ajax調用來創建對話框並添加新事件,編輯事件和刪除事件 - 否則這基本上就是一個私人嵌入式Google日曆(就像工作人員顯示的那樣) :
$j("#calendar").fullCalendar({
editable: false,
header: {
left: "prev,next today",
center: "title",
right: "month,basicWeek,agendaDay"},
events: "calendar/events"});
感謝您發表該內容。那麼,這是否仍然要求日曆是公開的,或者Gdata_ClientLogin是否允許登錄到可以訪問日曆的帳戶,以便顯示私人日曆? – jwinn 2012-01-25 16:46:37