Fix foreground color in flags in IMP
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 19 Nov 2009 22:19:01 +0000 (15:19 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 19 Nov 2009 22:20:23 +0000 (15:20 -0700)
imp/lib/Imap/Flags.php
imp/mailbox.php
imp/message.php

index fe496e6..1106edb 100644 (file)
@@ -82,7 +82,6 @@ class IMP_Imap_Flags
     {
         $this->_loadList();
 
-        $def_color = $GLOBALS['prefs']->getValue('msgflags_color');
         $avail_flags = array_keys($this->_flags);
 
         $ret = $types = array();
@@ -106,12 +105,7 @@ class IMP_Imap_Flags
             $ret[$key]['flag'] = $key;
 
             if (!empty($options['fgcolor'])) {
-                $ret[$key]['f'] = '#000';
-                if (!isset($ret[$key]['b'])) {
-                    $ret[$key]['b'] = $def_color;
-                } elseif (Horde_Image::brightness($this->_flags[$key]['b']) < 128) {
-                    $ret[$key]['f'] = '#f6f6f6';
-                }
+                $ret[$key] = $this->_getColor($key, $ret[$key]);
             }
 
             if (!empty($options['imap']) &&
@@ -248,6 +242,7 @@ class IMP_Imap_Flags
      * 'abbrev' - (string) The abbreviation to use.
      * 'bg' - (string) The background to use.
      * 'classname' - (string) If set, the flag classname to use.
+     * 'fg' - (string) The foreground color to use.
      * 'flag' - (string) The matched flag (lowercase).
      * 'div' - (string) A DIV HTML element, if 'div' option is true and a
      *         classname is defined.
@@ -319,11 +314,12 @@ class IMP_Imap_Flags
             }
         }
 
-        $def_color = $GLOBALS['prefs']->getValue('msgflags_color');
-
         foreach ($process as $key => $val) {
+            $color = $this->_getColor($key, $val);
+
             $tmp = array(
-                'bg' => isset($val['b']) ? $val['b'] : $def_color,
+                'bg' => $color['b'],
+                'fg' => $color['f'],
                 'flag' => $key,
                 'label' => $val['l'],
                 'type' => $val['t']
@@ -407,4 +403,24 @@ class IMP_Imap_Flags
         return array('flag' => $id, 'set' => true);
     }
 
+    /**
+     * Determines the colors for an entry.
+     *
+     * @param string $key  The flag key.
+     * @param array $in    The array of flag data.
+     *
+     * @return array  $in with the 'b' and 'f' keys populated.
+     */
+    protected function _getColor($key, $in)
+    {
+        $in['f'] = '#000';
+        if (!isset($in['b'])) {
+            $in['b'] = $GLOBALS['prefs']->getValue('msgflags_color');
+        } elseif (Horde_Image::brightness($this->_flags[$key]['b']) < 128) {
+            $in['f'] = '#f6f6f6';
+        }
+
+        return $in;
+    }
+
 }
index 8d9892e..036d6e7 100644 (file)
@@ -813,7 +813,7 @@ while (list(,$ob) = each($mbox_info['overview'])) {
             $flag_label = Horde_String::substr($val['label'], 0, 10) . '...';
         }
 
-        $msg['subject'] = '<span class="' . $val['classname'] . '" style="background:' . htmlspecialchars($val['bg']) . '" title="' . htmlspecialchars($val['label']) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject'];
+        $msg['subject'] = '<span class="' . $val['classname'] . '" style="background:' . htmlspecialchars($val['bg']) . ';color:' . htmlspecialchars($val['fg']) . '" title="' . htmlspecialchars($val['label']) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject'];
     }
 
     /* Set up threading tree now. */
index 9e3de7f..392c59f 100644 (file)
@@ -389,7 +389,7 @@ $flag_parse = $imp_flags->parse(array(
 
 foreach ($flag_parse as $val) {
     if ($val['type'] == 'imapp') {
-        $status .= '<span class="' . $val['classname'] . '" style="background:' . htmlspecialchars($val['bg']) . '">' . htmlspecialchars($val['label']) . '</span>';
+        $status .= '<span class="' . $val['classname'] . '" style="background:' . htmlspecialchars($val['bg']) . ';color:' . htmlspecialchars($val['fg']) . '">' . htmlspecialchars($val['label']) . '</span>';
     } else {
         $status .= $val['div'];
     }