Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2011-08-18 15:59:39 -04:00
commit 8c2e622552
6 changed files with 57 additions and 20 deletions

View File

@ -9,6 +9,7 @@ class ApiController extends Zend_Controller_Action
$context = $this->_helper->getHelper('contextSwitch'); $context = $this->_helper->getHelper('contextSwitch');
$context->addActionContext('version', 'json') $context->addActionContext('version', 'json')
->addActionContext('recorded-shows', 'json') ->addActionContext('recorded-shows', 'json')
->addActionContext('server-timestamp', 'json')
->addActionContext('upload-file', 'json') ->addActionContext('upload-file', 'json')
->addActionContext('upload-recorded', 'json') ->addActionContext('upload-recorded', 'json')
->addActionContext('media-monitor-setup', 'json') ->addActionContext('media-monitor-setup', 'json')
@ -56,6 +57,12 @@ class ApiController extends Zend_Controller_Action
$jsonStr = json_encode(array("version"=>AIRTIME_VERSION)); $jsonStr = json_encode(array("version"=>AIRTIME_VERSION));
echo $jsonStr; echo $jsonStr;
} }
public function serverTimestampAction(){
$this->view->serverTimestamp = array("timestamp"=>time(), "timezoneOffset"=> date("Z"));
}
/** /**
* Allows remote client to download requested media file. * Allows remote client to download requested media file.

View File

@ -61,10 +61,23 @@ function makeTimeStamp(date){
return timestamp; return timestamp;
} }
function adjustDateToServerDate(date, serverTimezoneOffset){
//date object stores time in the browser's localtime. We need to artificially shift
//it to
var timezoneOffset = date.getTimezoneOffset()*60*1000;
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
/* date object has been shifted to artificial UTC time. Now let's
* shift it to the server's timezone */
return date;
}
function dayClick(date, allDay, jsEvent, view) { function dayClick(date, allDay, jsEvent, view) {
var now, today, selected, chosenDate, chosenTime; var now, today, selected, chosenDate, chosenTime;
now = new Date(); now = adjustDateToServerDate(new Date(), serverTimezoneOffset);
if(view.name === "month") { if(view.name === "month") {
today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); today = new Date(now.getFullYear(), now.getMonth(), now.getDate());

View File

@ -4,6 +4,8 @@
* *
*/ */
var serverTimezoneOffset = 0;
function closeDialog(event, ui) { function closeDialog(event, ui) {
$("#schedule_calendar").fullCalendar( 'refetchEvents' ); $("#schedule_calendar").fullCalendar( 'refetchEvents' );
$(this).remove(); $(this).remove();
@ -292,18 +294,21 @@ function buildEditDialog(json){
} }
$(window).load(function() { function createFullCalendar(data){
serverTimezoneOffset = data.serverTimestamp.timezoneOffset;
var mainHeight = document.documentElement.clientHeight - 200 - 50; var mainHeight = document.documentElement.clientHeight - 200 - 50;
$('#schedule_calendar').fullCalendar({ $('#schedule_calendar').fullCalendar({
header: { header: {
left: 'prev, next, today', left: 'prev, next, today',
center: 'title', center: 'title',
right: 'agendaDay, agendaWeek, month' right: 'agendaDay, agendaWeek, month'
}, },
defaultView: 'month', defaultView: 'month',
editable: false, editable: false,
allDaySlot: false, allDaySlot: false,
axisFormat: 'H:mm', axisFormat: 'H:mm',
timeFormat: { timeFormat: {
agenda: 'H:mm{ - H:mm}', agenda: 'H:mm{ - H:mm}',
@ -312,17 +317,25 @@ $(window).load(function() {
contentHeight: mainHeight, contentHeight: mainHeight,
theme: true, theme: true,
lazyFetching: false, lazyFetching: false,
serverTimestamp: parseInt(data.serverTimestamp.timestamp, 10),
serverTimezoneOffset: parseInt(data.serverTimestamp.timezoneOffset, 10),
events: getFullCalendarEvents, events: getFullCalendarEvents,
//callbacks (in full-calendar-functions.js) //callbacks (in full-calendar-functions.js)
viewDisplay: viewDisplay, viewDisplay: viewDisplay,
dayClick: dayClick, dayClick: dayClick,
eventRender: eventRender, eventRender: eventRender,
eventAfterRender: eventAfterRender, eventAfterRender: eventAfterRender,
eventDrop: eventDrop, eventDrop: eventDrop,
eventResize: eventResize eventResize: eventResize
}); });
}
$(window).load(function() {
$.ajax({ url: "/Api/server-timestamp/format/json", dataType:"json", success:createFullCalendar
, error:function(jqXHR, textStatus, errorThrown){}});
}); });

View File

@ -2275,7 +2275,7 @@ function BasicView(element, calendar, viewName) {
function updateCells(firstTime) { function updateCells(firstTime) {
var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating? var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
var month = t.start.getMonth(); var month = t.start.getMonth();
var today = clearTime(new Date()); var today = clearTime(adjustDateToServerDate(new Date(), opt("serverTimezoneOffset")));
var cell; var cell;
var date; var date;
var row; var row;

View File

@ -297,8 +297,10 @@ class AirtimeInstall
public static function SetDefaultTimezone() public static function SetDefaultTimezone()
{ {
global $CC_DBC; global $CC_DBC;
$defaultTimezone = date_default_timezone_get();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')"; $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $CC_DBC->query($sql); $result = $CC_DBC->query($sql);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return false; return false;

View File

@ -20,8 +20,10 @@ class AirtimeInstall{
public static function SetDefaultTimezone() public static function SetDefaultTimezone()
{ {
global $CC_DBC; global $CC_DBC;
$defaultTimezone = date_default_timezone_get();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')"; $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $CC_DBC->query($sql); $result = $CC_DBC->query($sql);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return false; return false;