initial support customizable date format

This commit is contained in:
Uwe Steinmann 2020-12-01 18:25:22 +01:00
parent f482c42db3
commit 6bb4218e44
4 changed files with 22 additions and 2 deletions

View File

@ -132,6 +132,10 @@ class Settings { /* {{{ */
var $_availablelanguages = array();
// default language (name of a subfolder in folder "languages")
var $_language = "en_GB";
// default date format
var $_dateformat = "Y-m-d";
// default date/time format
var $_datetimformat = "Y-m-d H:i:s";
// users are notified about document-changes that took place within the last $_updateNotifyTime seconds
var $_updateNotifyTime = 86400;
// files with one of the following endings can be viewed online
@ -453,6 +457,8 @@ class Settings { /* {{{ */
$this->_footNote = strval($tab["footNote"]);
$this->_printDisclaimer = Settings::boolVal($tab["printDisclaimer"]);
$this->_language = strval($tab["language"]);
$this->_dateformat = strval($tab["dateformat"]);
$this->_datetimeformat = strval($tab["datetimeformat"]);
if(trim(strval($tab["availablelanguages"])))
$this->_availablelanguages = explode(',',strval($tab["availablelanguages"]));
$this->_theme = strval($tab["theme"]);
@ -826,6 +832,8 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "footNote", $this->_footNote);
$this->setXMLAttributValue($node, "printDisclaimer", $this->_printDisclaimer);
$this->setXMLAttributValue($node, "language", $this->_language);
$this->setXMLAttributValue($node, "dateformat", $this->_dateformat);
$this->setXMLAttributValue($node, "datetimeformat", $this->_datetimeformat);
$this->setXMLAttributValue($node, "availablelanguages", implode(',', $this->_availablelanguages));
$this->setXMLAttributValue($node, "theme", $this->_theme);
$this->setXMLAttributValue($node, "overrideTheme", $this->_overrideTheme);

View File

@ -27,11 +27,19 @@ function formatted_size($size_bytes) { /* {{{ */
} /* }}} */
function getReadableDate($timestamp) { /* {{{ */
return date("Y-m-d", $timestamp);
global $settings;
if($settings->_dateformat)
return date($settings->_dateformat, $timestamp);
else
return date("Y-m-d", $timestamp);
} /* }}} */
function getLongReadableDate($timestamp) { /* {{{ */
return date("Y-m-d H:i:s", $timestamp);
global $settings;
if($settings->_datetimeformat)
return date($settings->_datetimeformat, $timestamp);
else
return date("Y-m-d H:i:s", $timestamp);
} /* }}} */
/*

View File

@ -59,6 +59,8 @@ if ($action == "saveSettings")
$settings->_footNote = $_POST["footNote"];
$settings->_printDisclaimer = getBoolValue("printDisclaimer");
$settings->_language = $_POST["language"];
$settings->_dateformat = $_POST["dateformat"];
$settings->_datetimeformat = $_POST["datetimeformat"];
if(empty($_POST["availablelanguages"]))
$settings->_availablelanguages = array();
else

View File

@ -284,6 +284,8 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
<?php $this->showConfigCheckbox('settings_printDisclaimer', 'printDisclaimer'); ?>
<?php $this->showConfigOption('settings_available_languages', 'availablelanguages', getAvailableLanguages(), true, true); ?>
<?php $this->showConfigOption('settings_language', 'language', getAvailableLanguages(), false, true); ?>
<?php $this->showConfigText('settings_dateformat', 'dateformat'); ?>
<?php $this->showConfigText('settings_datetimeformat', 'datetimeformat'); ?>
<?php $this->showConfigOption('settings_theme', 'theme', UI::getStyles(), false, false); ?>
<?php $this->showConfigCheckbox('settings_overrideTheme', 'overrideTheme'); ?>
<?php $this->showConfigCheckbox('settings_onePageMode', 'onePageMode'); ?>