rev.5 for setting date&time formats
Settings moved to language files. There are two default date settings and two default times settings for each language.
This commit is contained in:
parent
ed4ec053fe
commit
bf2c81afff
11 changed files with 86 additions and 33 deletions
|
@ -20,6 +20,16 @@ abstract class Page extends Model
|
|||
|
||||
$container->Lang->load('common');
|
||||
|
||||
$formats = $container->DATE_FORMATS;
|
||||
$formats[0] = __($formats[0]);
|
||||
$formats[1] = __($formats[1]);
|
||||
$container->DATE_FORMATS = $formats;
|
||||
|
||||
$formats = $container->TIME_FORMATS;
|
||||
$formats[0] = __($formats[0]);
|
||||
$formats[1] = __($formats[1]);
|
||||
$container->TIME_FORMATS = $formats;
|
||||
|
||||
$this->fIndex = 'index'; # string Указатель на активный пункт навигации
|
||||
$this->httpStatus = 200; # int HTTP статус ответа для данной страницы
|
||||
$this->httpHeaders = []; # array HTTP заголовки отличные от статуса
|
||||
|
|
|
@ -1066,8 +1066,6 @@ class Install extends Admin
|
|||
'o_board_title' => $v->title,
|
||||
'o_board_desc' => $v->descr,
|
||||
'o_default_timezone' => 0,
|
||||
'o_time_format' => 'H:i:s',
|
||||
'o_date_format' => 'Y-m-d',
|
||||
'o_timeout_visit' => 3600,
|
||||
'o_timeout_online' => 900,
|
||||
'o_redirect_delay' => 1,
|
||||
|
|
|
@ -39,8 +39,6 @@ class Options extends Admin
|
|||
'o_default_dst' => 'required|integer|in:0,1',
|
||||
'o_default_lang' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getLangs()),
|
||||
'o_default_style' => 'required|string:trim|in:' . \implode(',', $this->c->Func->getStyles()),
|
||||
'o_time_format' => 'required|string:trim|max:25',
|
||||
'o_date_format' => 'required|string:trim|max:25',
|
||||
'o_timeout_visit' => 'required|integer|min:0|max:99999',
|
||||
'o_timeout_online' => 'required|integer|min:0|max:99999|check_timeout',
|
||||
'o_redirect_delay' => 'required|integer|min:0|max:99999',
|
||||
|
@ -298,28 +296,10 @@ class Options extends Admin
|
|||
];
|
||||
|
||||
$timestamp = \time() + ($this->user->timezone + $this->user->dst) * 3600;
|
||||
$time = \ForkBB\dt($timestamp, false, $config->o_date_format, $config->o_time_format, true, true);
|
||||
$date = \ForkBB\dt($timestamp, true, $config->o_date_format, $config->o_time_format, false, true);
|
||||
|
||||
$form['sets']['timeouts'] = [
|
||||
'legend' => __('Timeouts subhead'),
|
||||
'fields' => [
|
||||
'o_time_format' => [
|
||||
'type' => 'text',
|
||||
'maxlength' => 25,
|
||||
'value' => $config->o_time_format,
|
||||
'caption' => __('Time format label'),
|
||||
'info' => __('Time format help', $time),
|
||||
'required' => true,
|
||||
],
|
||||
'o_date_format' => [
|
||||
'type' => 'text',
|
||||
'maxlength' => 25,
|
||||
'value' => $config->o_date_format,
|
||||
'caption' => __('Date format label'),
|
||||
'info' => __('Date format help', $date),
|
||||
'required' => true,
|
||||
],
|
||||
'o_timeout_visit' => [
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
|
|
|
@ -467,4 +467,29 @@ class Update extends Admin
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* rev.4 to rev.5
|
||||
*/
|
||||
protected function stageNumber4(array $args): ?int
|
||||
{
|
||||
unset($this->c->config->o_date_format);
|
||||
unset($this->c->config->o_time_format);
|
||||
|
||||
$this->c->config->save();
|
||||
|
||||
$query = 'UPDATE ::users
|
||||
SET time_format=time_format+1
|
||||
WHERE time_format>0';
|
||||
|
||||
$this->c->DB->exec($query);
|
||||
|
||||
$query = 'UPDATE ::users
|
||||
SET date_format=date_format+1
|
||||
WHERE date_format>0';
|
||||
|
||||
$this->c->DB->exec($query);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,11 +157,21 @@ class Config extends Profile
|
|||
$styles = $this->c->Func->getStyles();
|
||||
$timeFormat = [];
|
||||
foreach ($this->c->TIME_FORMATS as $key => $value) {
|
||||
$timeFormat[$key] = \ForkBB\dt(\time(), false, null, $value, true, true) . ($key ? '' : ' (' . __('Default') . ')');
|
||||
$timeFormat[$key] = \ForkBB\dt(\time(), false, null, $value, true, true)
|
||||
. (
|
||||
$key > 1
|
||||
? ''
|
||||
: ' (' . __('Default for language') . ')'
|
||||
);
|
||||
}
|
||||
$dateFormat = [];
|
||||
foreach ($this->c->DATE_FORMATS as $key => $value) {
|
||||
$dateFormat[$key] = \ForkBB\dt(\time(), true, $value, null, false, true) . ($key ? '' : ' (' . __('Default') . ')');
|
||||
$dateFormat[$key] = \ForkBB\dt(\time(), true, $value, null, false, true)
|
||||
. (
|
||||
$key > 1
|
||||
? ''
|
||||
: ' (' . __('Default for language') . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$form['sets']['essentials'] = [
|
||||
|
|
|
@ -42,7 +42,7 @@ if (
|
|||
}
|
||||
$c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix;
|
||||
|
||||
$c->FORK_REVISION = 4;
|
||||
$c->FORK_REVISION = 5;
|
||||
$c->START = $forkStart;
|
||||
$c->DIR_APP = __DIR__;
|
||||
$c->DIR_PUBLIC = $forkPublic;
|
||||
|
@ -50,8 +50,8 @@ $c->DIR_CONFIG = __DIR__ . '/config';
|
|||
$c->DIR_CACHE = __DIR__ . '/cache';
|
||||
$c->DIR_VIEWS = __DIR__ . '/templates';
|
||||
$c->DIR_LANG = __DIR__ . '/lang';
|
||||
$c->DATE_FORMATS = [$c->config->o_date_format, 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y'];
|
||||
$c->TIME_FORMATS = [$c->config->o_time_format, 'H:i:s', 'H:i', 'g:i:s a', 'g:i a'];
|
||||
$c->DATE_FORMATS = ['Y-m-d', 'd M Y', 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y'];
|
||||
$c->TIME_FORMATS = ['H:i:s', 'H:i', 'H:i:s', 'H:i', 'g:i:s a', 'g:i a'];
|
||||
|
||||
$controllers = ['Primary', 'Routing'];
|
||||
foreach ($controllers as $controller) {
|
||||
|
|
|
@ -35,8 +35,6 @@ return [
|
|||
'o_default_lang' => 'en',
|
||||
'o_default_style' => 'ForkBB',
|
||||
'o_redirect_delay' => 0,
|
||||
'o_date_format' => 'Y-m-d',
|
||||
'o_time_format' => 'H:i:s',
|
||||
'o_maintenance' => 0,
|
||||
'o_smtp_host' => '',
|
||||
'o_smtp_user' => '',
|
||||
|
|
|
@ -24,6 +24,22 @@ msgstr "."
|
|||
msgid "lang_thousands_sep"
|
||||
msgstr ","
|
||||
|
||||
# date format short ([0])
|
||||
msgid "Y-m-d"
|
||||
msgstr "Y-m-d"
|
||||
|
||||
# date format long ([1])
|
||||
msgid "d M Y"
|
||||
msgstr "d M Y"
|
||||
|
||||
# time format short ([1])
|
||||
msgid "H:i"
|
||||
msgstr "H:i"
|
||||
|
||||
# time format long ([0])
|
||||
msgid "H:i:s"
|
||||
msgstr "H:i:s"
|
||||
|
||||
msgid "Cancel"
|
||||
msgstr "Cancel"
|
||||
|
||||
|
|
|
@ -486,8 +486,8 @@ msgstr "Essentials"
|
|||
msgid "Time zone"
|
||||
msgstr "Time zone"
|
||||
|
||||
msgid "Default"
|
||||
msgstr "Default"
|
||||
msgid "Default for language"
|
||||
msgstr "Default for language"
|
||||
|
||||
msgid "For default"
|
||||
msgstr "Zero this field for the default settings."
|
||||
|
|
|
@ -24,6 +24,22 @@ msgstr ","
|
|||
msgid "lang_thousands_sep"
|
||||
msgstr " "
|
||||
|
||||
# date format short ([0])
|
||||
msgid "Y-m-d"
|
||||
msgstr "d.m.Y"
|
||||
|
||||
# date format long ([1])
|
||||
msgid "d M Y"
|
||||
msgstr "j M Y г."
|
||||
|
||||
# time format short ([1])
|
||||
msgid "H:i"
|
||||
msgstr "H:i"
|
||||
|
||||
# time format long ([0])
|
||||
msgid "H:i:s"
|
||||
msgstr "H:i:s"
|
||||
|
||||
msgid "Cancel"
|
||||
msgstr "Отменить"
|
||||
|
||||
|
|
|
@ -486,8 +486,8 @@ msgstr "Основное"
|
|||
msgid "Time zone"
|
||||
msgstr "Часовой пояс"
|
||||
|
||||
msgid "Default"
|
||||
msgstr "По умолчанию"
|
||||
msgid "Default for language"
|
||||
msgstr "По умолчанию для языка"
|
||||
|
||||
msgid "For default"
|
||||
msgstr "Обнулите поле для использования значения по умолчанию."
|
||||
|
|
Loading…
Add table
Reference in a new issue