Add timezone configuration option

This commit is contained in:
Frédéric Guillot 2014-02-25 19:03:46 -05:00
parent 01c3175c1b
commit 3bc7f019c5
6 changed files with 24 additions and 2 deletions

View File

@ -21,6 +21,9 @@ Router\before(function($action) {
$language = Model\Config\get('language') ?: 'en_US'; $language = Model\Config\get('language') ?: 'en_US';
if ($language !== 'en_US') PicoTools\Translator\load($language); if ($language !== 'en_US') PicoTools\Translator\load($language);
// Set timezone
date_default_timezone_set(Model\Config\get('timezone') ?: 'UTC');
// HTTP secure headers // HTTP secure headers
$frame_src = \PicoFeed\Filter::$iframe_whitelist; $frame_src = \PicoFeed\Filter::$iframe_whitelist;
$frame_src[] = 'https://login.persona.org'; $frame_src[] = 'https://login.persona.org';

View File

@ -36,6 +36,7 @@ Router\get_action('config', function() {
'values' => Model\Config\get_all(), 'values' => Model\Config\get_all(),
'db_size' => filesize(DB_FILENAME), 'db_size' => filesize(DB_FILENAME),
'languages' => Model\Config\get_languages(), 'languages' => Model\Config\get_languages(),
'timezones' => Model\Config\get_timezones(),
'autoflush_options' => Model\Config\get_autoflush_options(), 'autoflush_options' => Model\Config\get_autoflush_options(),
'paging_options' => Model\Config\get_paging_options(), 'paging_options' => Model\Config\get_paging_options(),
'theme_options' => Model\Config\get_themes(), 'theme_options' => Model\Config\get_themes(),
@ -69,6 +70,7 @@ Router\post_action('config', function() {
'values' => Model\Config\get_all(), 'values' => Model\Config\get_all(),
'db_size' => filesize(DB_FILENAME), 'db_size' => filesize(DB_FILENAME),
'languages' => Model\Config\get_languages(), 'languages' => Model\Config\get_languages(),
'timezones' => Model\Config\get_timezones(),
'autoflush_options' => Model\Config\get_autoflush_options(), 'autoflush_options' => Model\Config\get_autoflush_options(),
'paging_options' => Model\Config\get_paging_options(), 'paging_options' => Model\Config\get_paging_options(),
'theme_options' => Model\Config\get_themes(), 'theme_options' => Model\Config\get_themes(),

View File

@ -206,4 +206,5 @@ return array(
'%d weeks ago' => 'Il y a %d semaines', '%d weeks ago' => 'Il y a %d semaines',
'%d month ago' => 'Il y a %d mois', '%d month ago' => 'Il y a %d mois',
'%d months ago' => 'Il y a %d mois', '%d months ago' => 'Il y a %d mois',
'Timezone' => 'Fuseau horaire',
); );

View File

@ -16,7 +16,7 @@ use SimpleValidator\Validator;
use SimpleValidator\Validators; use SimpleValidator\Validators;
use PicoDb\Database; use PicoDb\Database;
const DB_VERSION = 21; const DB_VERSION = 22;
const HTTP_USERAGENT = 'Miniflux - http://miniflux.net'; const HTTP_USERAGENT = 'Miniflux - http://miniflux.net';
const HTTP_FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36'; const HTTP_FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36';
@ -35,6 +35,13 @@ function write_debug()
} }
} }
// Get available timezone
function get_timezones()
{
$timezones = \timezone_identifiers_list();
return array_combine(array_values($timezones), $timezones);
}
// Get all supported languages // Get all supported languages
function get_languages() function get_languages()
{ {
@ -172,7 +179,7 @@ function get($name)
} }
else { else {
if (! isset($_SESSION['config'])) { if (! isset($_SESSION['config'][$name])) {
$_SESSION['config'] = get_all(); $_SESSION['config'] = get_all();
} }
@ -192,6 +199,7 @@ function get_all()
->columns( ->columns(
'username', 'username',
'language', 'language',
'timezone',
'autoflush', 'autoflush',
'nocontent', 'nocontent',
'items_per_page', 'items_per_page',

View File

@ -2,6 +2,11 @@
namespace Schema; namespace Schema;
function version_22($pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN timezone TEXT DEFAULT 'UTC'");
}
function version_21($pdo) function version_21($pdo)
{ {

View File

@ -13,6 +13,9 @@
<?= Helper\form_label(t('Confirmation'), 'confirmation') ?> <?= Helper\form_label(t('Confirmation'), 'confirmation') ?>
<?= Helper\form_password('confirmation', $values, $errors) ?><br/> <?= Helper\form_password('confirmation', $values, $errors) ?><br/>
<?= Helper\form_label(t('Timezone'), 'timezone') ?>
<?= Helper\form_select('timezone', $timezones, $values, $errors) ?><br/>
<?= Helper\form_label(t('Language'), 'language') ?> <?= Helper\form_label(t('Language'), 'language') ?>
<?= Helper\form_select('language', $languages, $values, $errors) ?><br/> <?= Helper\form_select('language', $languages, $values, $errors) ?><br/>