Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customizable number and date formats
#1
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:
    // -------------------------------- 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:
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:
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->_logDateFormattime())." ".$user->getLogin()." (".$_SERVER['REMOTE_ADDR'].") ".basename($_SERVER["REQUEST_URI"], ".php").$msg."\n");
    
fclose($h);


Or apply patch:
[ATTACHMENT NOT FOUND]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)