From 50539589c0765f559bbe87b7d78086194c2e2ee1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 16 Mar 2009 14:41:55 -0600 Subject: [PATCH] Simplify date display --- imp/js/src/DimpBase.js | 2 +- imp/lib/UI/Message.php | 20 ++++++-------------- imp/lib/Views/ShowMessage.php | 4 ++-- imp/message-mimp.php | 2 +- imp/message.php | 2 +- imp/thread.php | 2 +- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index 040c79dda..7e4507712 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -941,7 +941,7 @@ var DimpBase = { // Add date $('msgHeadersColl').select('.date').invoke('update', r.minidate); - $('msgHeaderDate').select('.date').invoke('update', r.fulldate); + $('msgHeaderDate').select('.date').invoke('update', r.localdate); // Add from/to/cc headers [ 'from', 'to', 'cc' ].each(function(a) { diff --git a/imp/lib/UI/Message.php b/imp/lib/UI/Message.php index f916b7f3a..b50751950 100644 --- a/imp/lib/UI/Message.php +++ b/imp/lib/UI/Message.php @@ -106,11 +106,9 @@ class IMP_UI_Message * * @param string $date The date string. * - * @return string The date string with the local time added on. If not - * in MIMP mode, the output has been run through - * htmlspecialchars(). + * @return string The local formatted time string. */ - public function addLocalTime($date) + public function getLocalTime($date) { if (empty($date)) { $ltime = false; @@ -120,9 +118,7 @@ class IMP_UI_Message } if (($ltime === false) || ($ltime === -1)) { - return ($_SESSION['imp']['view'] == 'mimp') - ? $date - : htmlspecialchars($date); + return ''; } $time_str = strftime($GLOBALS['prefs']->getValue('time_format'), $ltime); @@ -133,15 +129,11 @@ class IMP_UI_Message (date('d') != @date('d', $ltime))) { /* Not today, use the date. */ $date_str = strftime($GLOBALS['prefs']->getValue('date_format'), $ltime); - $local_date = sprintf('[%s %s %s]', $date_str, $time_str, $tz); - } else { - /* Else, it's today, use the time only. */ - $local_date = sprintf('[%s %s]', $time_str, $tz); + return sprintf('%s %s %s', $date_str, $time_str, $tz); } - return ($_SESSION['imp']['view'] == 'mimp') - ? $date . ' ' . $local_date - : htmlspecialchars($date) . ' ' . htmlspecialchars($local_date) . ''; + /* Else, it's today, use the time only. */ + return sprintf('%s %s', $time_str, $tz); } /** diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 75b504a00..53daf408f 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -180,9 +180,9 @@ class IMP_Views_ShowMessage } elseif ($val = $mime_headers->getValue($head)) { if ($head == 'date') { /* Add local time to date header. */ - $val = nl2br($imp_ui->addLocalTime($envelope['date'])); + $val = htmlspecialchars($imp_ui->getLocalTime($envelope['date'])); if ($preview) { - $result['fulldate'] = $val; + $result['localdate'] = $val; } } elseif (!$preview) { $val = htmlspecialchars($val); diff --git a/imp/message-mimp.php b/imp/message-mimp.php index c40c6aaa0..69c6fcc65 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -160,7 +160,7 @@ $user_identity = &Identity::singleton(array('imp', 'imp')); $basic_headers = $imp_ui->basicHeaders(); $display_headers = $msgAddresses = array(); -$format_date = $imp_ui->addLocalTime(nl2br($envelope['date'])); +$format_date = $imp_ui->getLocalTime($envelope['date']); if (!empty($format_date)) { $display_headers['date'] = $format_date; } diff --git a/imp/message.php b/imp/message.php index 4ee665895..156bdcd09 100644 --- a/imp/message.php +++ b/imp/message.php @@ -237,7 +237,7 @@ $imp_ui = new IMP_UI_Message(); $basic_headers = $imp_ui->basicHeaders(); $display_headers = $msgAddresses = array(); -$format_date = $imp_ui->addLocalTime(nl2br($envelope['date'])); +$format_date = $imp_ui->getLocalTime($envelope['date']); if (!empty($format_date)) { $display_headers['date'] = $format_date; } diff --git a/imp/thread.php b/imp/thread.php index 2c0992049..4abf24eb9 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -100,7 +100,7 @@ foreach ($loop_array as $mbox => $idxlist) { $curr_msg['idx'] = $idx; /* Get headers for the message. */ - $curr_msg['date'] = $imp_ui->addLocalTime(nl2br($envelope['date'])); + $curr_msg['date'] = $imp_ui->getLocalTime($envelope['date']); if (IMP::isSpecialFolder($mbox)) { $curr_msg['addr_to'] = true; -- 2.11.0