]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/include/main.inc
Imported Upstream version 0.5.2+dfsg
[roundcube.git] / program / include / main.inc
index d02dca5e2d67db6d3c26f030c8b9da568fdc2b32..76db5670aa11e786cffe730a6fa08854ad81b421 100644 (file)
@@ -15,7 +15,7 @@
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: main.inc 4509 2011-02-09 10:51:50Z thomasb $
+ $Id: main.inc 4568 2011-02-24 12:12:09Z alec $
 
 */
 
@@ -972,7 +972,7 @@ function parse_attrib_string($str)
  * @return string Formatted date string
  */
 function format_date($date, $format=NULL)
-  {
+{
   global $CONFIG;
   
   $ts = NULL;
@@ -996,7 +996,7 @@ function format_date($date, $format=NULL)
 
   if (empty($ts))
     return '';
-   
+
   // get user's timezone
   if ($CONFIG['timezone'] === 'auto')
     $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600;
@@ -1008,7 +1008,7 @@ function format_date($date, $format=NULL)
 
   // convert time to user's timezone
   $timestamp = $ts - date('Z', $ts) + ($tz * 3600);
-  
+
   // get current timestamp in user's timezone
   $now = time();  // local time
   $now -= (int)date('Z'); // make GMT time
@@ -1016,30 +1016,33 @@ function format_date($date, $format=NULL)
   $now_date = getdate($now);
 
   $today_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday'], $now_date['year']);
-  $week_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday']-6, $now_date['year']);
+  $week_limit  = mktime(0, 0, 0, $now_date['mon'], $now_date['mday']-6, $now_date['year']);
 
   // define date format depending on current time
   if (!$format) {
-    if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now)
-      return sprintf('%s %s', rcube_label('today'), date($CONFIG['date_today'] ? $CONFIG['date_today'] : 'H:i', $timestamp));
+    if ($CONFIG['prettydate'] && $timestamp > $today_limit && $timestamp < $now) {
+      $format = $CONFIG['date_today'] ? $CONFIG['date_today'] : 'H:i';
+      $today  = true;
+    }
     else if ($CONFIG['prettydate'] && $timestamp > $week_limit && $timestamp < $now)
       $format = $CONFIG['date_short'] ? $CONFIG['date_short'] : 'D H:i';
     else
       $format = $CONFIG['date_long'] ? $CONFIG['date_long'] : 'd.m.Y H:i';
-    }
+  }
 
   // strftime() format
-  if (preg_match('/%[a-z]+/i', $format))
-    return strftime($format, $timestamp);
+  if (preg_match('/%[a-z]+/i', $format)) {
+    $format = strftime($format, $timestamp);
+    return $today ? (rcube_label('today') . ' ' . $format) : $format;
+  }
 
   // parse format string manually in order to provide localized weekday and month names
   // an alternative would be to convert the date() format string to fit with strftime()
   $out = '';
-  for($i=0; $i<strlen($format); $i++)
-    {
+  for($i=0; $i<strlen($format); $i++) {
     if ($format{$i}=='\\')  // skip escape chars
       continue;
-    
+
     // write char "as-is"
     if ($format{$i}==' ' || $format{$i-1}=='\\')
       $out .= $format{$i};
@@ -1059,11 +1062,22 @@ function format_date($date, $format=NULL)
       $out .= strftime('%x %X', $timestamp);
     else
       $out .= date($format{$i}, $timestamp);
+  }
+
+  if ($today) {
+    $label = rcube_label('today');
+    // replcae $ character with "Today" label (#1486120)
+    if (strpos($out, '$') !== false) {
+      $out = preg_replace('/\$/', $label, $out, 1);
+    }
+    else {
+      $out = $label . ' ' . $out;
     }
-  
-  return $out;
   }
 
+  return $out;
+}
+
 
 /**
  * Compose a valid representation of name and e-mail address
@@ -1679,7 +1693,7 @@ function rcube_html_editor($mode='')
 {
   global $RCMAIL, $CONFIG;
 
-  $hook = $RCMAIL->plugins->exec_hook('hmtl_editor', array('mode' => $mode));
+  $hook = $RCMAIL->plugins->exec_hook('html_editor', array('mode' => $mode));
 
   if ($hook['abort'])
     return;