Update moment.js and add timezone in template

This commit is contained in:
Frederic Guillot
2015-02-08 17:37:13 -05:00
parent 92509c43c4
commit d634a53e9c
7 changed files with 42 additions and 13 deletions

View File

@@ -610,6 +610,17 @@ class Helper
return $this->config->getJsLanguageCode(); return $this->config->getJsLanguageCode();
} }
/**
* Get current timezone
*
* @access public
* @return string
*/
public function getTimezone()
{
return $this->config->getCurrentTimezone();
}
/** /**
* Get the link to toggle subtask status * Get the link to toggle subtask status
* *

View File

@@ -201,6 +201,21 @@ class Config extends Base
Translator::load($this->getCurrentLanguage()); Translator::load($this->getCurrentLanguage());
} }
/**
* Get current timezone
*
* @access public
* @return string
*/
public function getCurrentTimezone()
{
if ($this->userSession->isLogged() && ! empty($this->session['user']['timezone'])) {
return $this->session['user']['timezone'];
}
return $this->get('application_timezone', 'UTC');
}
/** /**
* Set timezone * Set timezone
* *
@@ -208,12 +223,7 @@ class Config extends Base
*/ */
public function setupTimezone() public function setupTimezone()
{ {
if ($this->userSession->isLogged() && ! empty($this->session['user']['timezone'])) { date_default_timezone_set($this->getCurrentTimezone());
date_default_timezone_set($this->session['user']['timezone']);
}
else {
date_default_timezone_set($this->get('application_timezone', 'UTC'));
}
} }
/** /**

View File

@@ -100,6 +100,7 @@ class TaskFilter extends Base
foreach ($this->query->findAll() as $task) { foreach ($this->query->findAll() as $task) {
$events[] = array( $events[] = array(
'timezoneParam' => $this->config->getCurrentTimezone(),
'id' => $task['id'], 'id' => $task['id'],
'title' => t('#%d', $task['id']).' '.$task['title'], 'title' => t('#%d', $task['id']).' '.$task['title'],
'start' => date('Y-m-d', $task['date_due']), 'start' => date('Y-m-d', $task['date_due']),

View File

@@ -25,7 +25,11 @@
<title><?= isset($title) ? $this->e($title) : 'Kanboard' ?></title> <title><?= isset($title) ? $this->e($title) : 'Kanboard' ?></title>
</head> </head>
<body data-status-url="<?= $this->u('app', 'status') ?>" data-login-url="<?= $this->u('user', 'login') ?>" data-js-lang="<?= $this->jsLang() ?>"> <body data-status-url="<?= $this->u('app', 'status') ?>"
data-login-url="<?= $this->u('user', 'login') ?>"
data-timezone="<?= $this->getTimezone() ?>"
data-js-lang="<?= $this->jsLang() ?>">
<?php if (isset($no_layout) && $no_layout): ?> <?php if (isset($no_layout) && $no_layout): ?>
<?= $content_for_layout ?> <?= $content_for_layout ?>
<?php else: ?> <?php else: ?>

File diff suppressed because one or more lines are too long

View File

@@ -70,6 +70,7 @@ Kanboard.Calendar = (function() {
lang: $("body").data("js-lang"), lang: $("body").data("js-lang"),
editable: true, editable: true,
eventLimit: true, eventLimit: true,
defaultView: "agendaWeek",
header: { header: {
left: 'prev,next today', left: 'prev,next today',
center: 'title', center: 'title',

File diff suppressed because one or more lines are too long