From b89befd4e6d0d7c2605a27c033e385394c87e141 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 19 Nov 2009 15:19:01 -0700 Subject: [PATCH] Fix foreground color in flags in IMP --- imp/lib/Imap/Flags.php | 36 ++++++++++++++++++++++++++---------- imp/mailbox.php | 2 +- imp/message.php | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/imp/lib/Imap/Flags.php b/imp/lib/Imap/Flags.php index fe496e6b6..1106edb91 100644 --- a/imp/lib/Imap/Flags.php +++ b/imp/lib/Imap/Flags.php @@ -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; + } + } diff --git a/imp/mailbox.php b/imp/mailbox.php index 8d9892e52..036d6e743 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -813,7 +813,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { $flag_label = Horde_String::substr($val['label'], 0, 10) . '...'; } - $msg['subject'] = '' . htmlspecialchars($flag_label) . '' . $msg['subject']; + $msg['subject'] = '' . htmlspecialchars($flag_label) . '' . $msg['subject']; } /* Set up threading tree now. */ diff --git a/imp/message.php b/imp/message.php index 9e3de7f85..392c59f82 100644 --- a/imp/message.php +++ b/imp/message.php @@ -389,7 +389,7 @@ $flag_parse = $imp_flags->parse(array( foreach ($flag_parse as $val) { if ($val['type'] == 'imapp') { - $status .= '' . htmlspecialchars($val['label']) . ''; + $status .= '' . htmlspecialchars($val['label']) . ''; } else { $status .= $val['div']; } -- 2.11.0