LetoDMS Community Forum
Customizable number and date formats - Printable Version

+- LetoDMS Community Forum (https://community.letodms.com)
+-- Forum: Customization (https://community.letodms.com/forumdisplay.php?fid=5)
+--- Forum: Addons/Mods (https://community.letodms.com/forumdisplay.php?fid=14)
+--- Thread: Customizable number and date formats (/showthread.php?tid=218)



Customizable number and date formats - calcumat - 01-09-2011

If you want your own number formats and date/time formats, you can change inc/inc.Utils.php file and set own formats here.
But - I think better place for formats and customization is in inc/inc.Settings.php, so I write this modification.

First, add this new settings to inc/inc.Settings.php:
PHP Code:
<?php 
// -------------------------------- User interface settings -----------------------------------
// how to display document sizes - number of decimal places and separators .
var $_decimalPlaces = 1;
var
$_decimalSeparator = ".";
var
$_thousandsSeparator = "'";

// date / time formats (see PHP documentation for date() function for symbols)
// f.e.: http://php.net/manual/en/function.date.php
var $_dateFormatShort = "d.m.Y";
var
$_dateFormatLong = "d.m.Y - H:i";
var
$_logDateFormat = "d.m.Y - H:i";
[ATTACHMENT NOT FOUND]


Then apply patch to file inc/inc.Util.php - change first 3 functions to:
PHP Code:
<?php 
function formatted_size($size_bytes) {
global
$settings;
if (
$size_bytes>=1048576) return number_format($size_bytes/1048576,$settings->_decimalPlaces,$settings->_decimalSeparator,$settings->_thousandsSeparator)." MB";
else if (
$size_bytes>=1024) return number_format($size_bytes/1024,$settings->_decimalPlaces,$settings->_decimalSeparator,$settings->_thousandsSeparator)." kB";
return
number_format($size_bytes,0,"",$settings->_thousandsSeparator)." B";
}

function
getReadableDate($timestamp) {
global
$settings;
return
date($settings->_dateFormatShort, $timestamp);
}

function
getLongReadableDate($timestamp) {
global
$settings;
return
date($settings->_dateFormatLong, $timestamp);
}
And change function add_log_line:
PHP Code:
<?php 
function add_log_line($msg="")
{
global
$settings,$user;

if (
$settings->_logFileEnable!=TRUE) return;

if (
$settings->_logFileRotation=="h") $logname=date("YmdH", time());
else if (
$settings->_logFileRotation=="d") $logname=date("Ymd", time());
else
$logname=date("Ym", time());

$h = fopen($settings->_contentDir.$logname.".log", "a");
fwrite($h,date($settings->_logDateFormat, time())." ".$user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg."\n");
fclose($h);
}

Or apply patch:
[ATTACHMENT NOT FOUND]