diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 8ca3debe96..a9e266d5f9 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -447,4 +447,7 @@ define("CHART_DEFAULT_ALPHA", 50); /* Statwin */ define("STATWIN_DEFAULT_CHART_WIDTH", 555); define("STATWIN_DEFAULT_CHART_HEIGHT", 245); + +/* Dashboard */ +define("DASHBOARD_DEFAULT_COUNT_CELLS", 9); ?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d7b027bef2..ae711e3fa2 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2535,4 +2535,80 @@ function get_refresh_time_array() { (string)SECONDS_30MINUTES => __('30 minutes'), (string)SECONDS_1HOUR => __('1 hour')); } + +function date2strftime_format($date_format) { + $replaces_list = array( + 'D' => '%a', + 'l' => '%A', + 'd' => '%d', + 'j' => '%e', + 'N' => '%u', + 'w' => '%w', + 'W' => '%W', + 'M' => '%b', + 'F' => '%B', + 'm' => '%m', + 'o' => '%G', + 'y' => '%y', + 'Y' => '%Y', + 'H' => '%H', + 'h' => '%I', + 'g' => '%l', + 'a' => '%P', + 'A' => '%p', + 'i' => '%M', + 's' => '%S', + 'u' => '%s', + 'O' => '%z', + 'T' => '%Z', + '%' => '%%', + ); + + $return = ""; + + //character to character because + // Replacement order gotcha + // http://php.net/manual/en/function.str-replace.php + $chars = str_split($date_format); + foreach ($chars as $c) { + if (isset($replaces_list[$c])) { + $return .= $replaces_list[$c]; + } + else { + $return .= $c; + } + } + + return $return; +} + +function pandora_setlocale() { + global $config; + + $replace_locale = array( + 'ca' => 'ca_ES', + 'de' => 'de_DE', + 'en_GB' => 'de', + 'es' => 'es_ES', + 'fr' => 'fr_FR', + 'it' => 'it_IT', + 'nl' => 'nl_BE', + 'pl' => 'pl_PL', + 'pt' => 'pt_PT', + 'pt_BR' => 'pt_BR', + 'sk' => 'sk_SK', + 'tr' => 'tr_TR', + 'cs' => 'cs_CZ', + 'el' => 'el_GR', + 'ru' => 'ru_RU', + 'ar' => 'ar_MA', + 'ja' => 'ja_JP', + 'zh_CN' => 'zh_CN', + ); + + $user_language = get_user_language($config['id_user']); + + setlocale(LC_ALL, + str_replace(array_keys($replace_locale), $replace_locale, $user_language)); +} ?> diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index cffa339c32..7a91d70dd3 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -431,7 +431,7 @@ function ui_print_timestamp ($unixtime, $return = false, $option = array ()) { $style = 'style="white-space:nowrap;"'; } else { - $style = 'style="'.$option["style"].'"'; + $style = 'style="' . $option["style"] . '"'; } if (!empty ($option["prominent"])) { @@ -447,12 +447,15 @@ function ui_print_timestamp ($unixtime, $return = false, $option = array ()) { //prominent_time is either timestamp or comparation if ($unixtime <= 0) { - $title = __('Unknown').'/'.__('Never'); + $title = __('Unknown') . '/' . __('Never'); $data = __('Unknown'); } elseif ($prominent == "timestamp") { + pandora_setlocale(); + $title = human_time_comparation ($unixtime); - $data = date ($config["date_format"], $unixtime); + $data = strftime(date2strftime_format($config["date_format"]), + $unixtime); } else { $title = date ($config["date_format"], $unixtime); diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index b4a4ceb104..229a770363 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -77,20 +77,24 @@ if ($multiple_delete) { if ($show_sent) { //sent view $num_messages = messages_get_count_sent($config['id_user']); if ($num_messages > 0 && !is_ajax()) { - echo '

'.__('You have').' '.$num_messages.' '.' '.__('sent message(s)').'.

'; + echo '

' . __('You have') . ' ' . $num_messages . ' ' . + ' ' . __('sent message(s)') . '.

'; } $messages = messages_get_overview_sent ('', 'DESC'); } else { //messages received $num_messages = messages_get_count ($config["id_user"]); if ($num_messages > 0 && !is_ajax()) { - echo '

'.__('You have').' '.$num_messages.' '.' '.__('unread message(s)').'.

'; + echo '

' . __('You have') . ' ' . $num_messages . ' ' . + ' ' . __('unread message(s)') . '.

'; } $messages = messages_get_overview (); } if (empty ($messages)) { - ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no messages.') ) ); + ui_print_info_message ( + array('no_close'=>true, + 'message'=> __('There are no messages.') ) ); } else { $table = new stdClass(); @@ -180,7 +184,9 @@ else { } $data[2] .= ''; - $data[3] = ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp")); + $data[3] = ui_print_timestamp( + $message["timestamp"], true, + array ("prominent" => "timestamp")); if ($show_sent) { $data[4] = '"; echo ""; echo ""; echo "
"; - if (!empty($messages)){ + if (!empty($messages)) { if ($show_sent) echo '
'; else echo ''; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + html_print_submit_button(__('Delete'), 'delete_btn', + false, 'class="sub delete"'); echo "
"; } echo '
';