好吧,经过大量的搜索,我决定实现我自己的解决方案查找,因为我在那里找不到符合我需要的解决方案查找。
我决定用
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; ?>
在日历法中:
$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'));
在日历控制器中,我添加了一个函数来返回JSON数组(calendarController.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)——它是未完成的,因为我将挂接到可编辑和添加完整日历的操作上,并使用一些Ajax调用来创建对话框和添加新事件、编辑事件和删除事件——否则,这基本上是一个私有的嵌入Google日历。R(如向工人展示的内容):
$j("#calendar").fullCalendar({
editable: false,
header: {
left: "prev,next today",
center: "title",
right: "month,basicWeek,agendaDay"},
events: "calendar/events"});