From: Steve B. <ste...@us...> - 2006-02-21 00:02:37
|
Update of /cvsroot/squirrelmail/squirrelmail/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23640/templates Modified Files: util_message_list.php Added Files: util_global.php util_left_main.php Log Message: New icon theming. Also added basic template for left_main.php --- NEW FILE --- <?php /** * util_global.php * * Utility functions for use with all templates. Do not echo output here! * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail * @subpackage templates */ /** * Checks for an image icon and returns a complete HTML img tag or a text * string with the text icon based on what is found and user prefs. * * @param string $icon_theme_path User's chosen icon set * @param string $icon_name File name of the desired icon * @param string $text_icon Text-based icon to display if desired * @param string $alt_text Optional. Text for alt/title attribute of image * @param integer $w Optional. Width of requested image. * @param integer $h Optional. Height of requested image. * @return string $icon String containing icon that can be echo'ed * @author Steve Brown * @since 1.5.2 */ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL, $h=NULL) { $icon = ''; if (is_null($icon_theme_path)) { $icon = $text_icon; } else { // Desired icon exists in the current theme? if (is_file($icon_theme_path . $icon_name)) { $icon_path = $icon_theme_path . $icon_name; // Icon not found, return the SQM default icon } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) { $icon_path = SM_PATH . 'images/themes/default/'.$icon_name; } // If we found an icon, build an img tag to display it. If we didn't // find an image, we will revert back to the text icon. if (!is_null($icon_path)) { $icon = '<img src="'.$icon_path.'" ' . (!empty($alt_text) ? 'alt="'.$alt_text.'" title="'.$alt_text.'" ' : '') . (!is_null($w) ? 'width="'.$w.'" ' : '') . (!is_null($h) ? 'height="'.$h.'" ' : '') . ' />'; } else { $icon = $text_icon; } } return $icon; } ?> --- NEW FILE --- <?php /** * util_left_main.php * * Provides some functions for use in left_main.php and templates. Do not echo * output from these functions! * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail * @subpackage templates */ /** * Recursively iterates a mailboxes object to get the cummulative count of * messages for all folderes below the current mailbox. * * @param object $boxes Object of the class mailboxes * @param string $type Whether to fetch unseen only or all messages * @author Steve Brown * @since 1.5.2 */ function getMessageCount ($boxes, $type='total') { // The Trash folder isn't counted... if ($boxes->mailboxname_full == $GLOBALS['trash_folder']) return 0; $count = 0; if (strtolower($type) == 'unseen') $field = 'unseen'; else $field = 'total'; $count += !empty($boxes->{$field}) ? $boxes->{$field} : 0; for ($j = 0; $j <count($boxes->mbxs); $j++) { $count += getMessageCount($boxes->mbxs[$j], $type); } return $count; } /** * Recursively iterates a mailboxes object to build a data structure that is * easy for template authors to work with. * * @param object $boxes Object of the class mailboxes * @author Steve Brown * @since 1.5.2 */ function getBoxStructure ($boxes) { global $data_dir, $username, $icon_theme_path; // Stop condition if (empty($boxes)) { return array(); } $mailbox = $boxes->mailboxname_full; $mailboxURL = urlencode($mailbox); $box = array(); $box['MailboxFullName'] = $mailbox; $box['MailboxName'] = $boxes->mailboxname_sub; $box['MessageCount'] = !empty($boxes->total) ? $boxes->total : 0; $box['UnreadCount'] = !empty($boxes->unseen) ? $boxes->unseen : 0; // Needed in case user enables cummulative message counts $box['CummulativeMessageCount'] = getMessageCount($boxes, 'total'); $box['CummulativeUnreadCount'] = getMessageCount($boxes, 'unseen'); $box['ViewLink'] = array( 'Target' => 'right', 'URL' => 'right_main.php?PG_SHOWALL=0&startMessage=1&mailbox='.$mailboxURL ); $box['IsRecent'] = isset($boxes->recent) && $boxes->recent; $box['IsSpecial'] = isset($boxes->is_special) && $boxes->is_special; $box['IsRoot'] = isset($boxes->is_root) && $boxes->is_root; $box['IsNoSelect'] = isset($boxes->is_noselect) && $boxes->is_noselect; $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); $collapse = (int)$collapse == SM_BOX_COLLAPSED; $box['IsCollapsed'] = $collapse; /* * Check for an image needed here. If the file exists in $icon_theme_path * assume the template provides all icons. If not, we will use the * SQM default images. If icons have been disabled, $icon_theme_path * will be NULL. */ $text_icon = $box['IsCollapsed'] ? '+' : '-'; $icon_file = $box['IsCollapsed'] ? 'plus.png' : 'minus.png'; $icon_alt = $box['IsCollapsed'] ? 'Expand Box' : 'Collapse Box'; $icon = getIcon($icon_theme_path, $icon_file, $text_icon, $icon_alt); $box['CollapseLink'] = array ( 'Target' => 'left', 'URL' => 'left_main.php?'.($box['IsCollapsed'] ? 'unfold' : 'fold') .'='.$mailboxURL, 'Icon' => $icon .' ' ); $box['ChildBoxes'] = array(); for ($i = 0; $i <count($boxes->mbxs); $i++) { $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs[$i]); } return $box; } ?> Index: util_message_list.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/templates/util_message_list.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- util_message_list.php 23 Jan 2006 18:46:27 -0000 1.6 +++ util_message_list.php 21 Feb 2006 00:02:30 -0000 1.7 @@ -67,17 +67,15 @@ } /** - * Function to retrieve the correct flag icon belonging to the set of - * provided flags + * Function to retrieve correct icon based on provided message flags. This is + * a merge/replacement for getFlagIcon() and getFlagText() functions. * * @param array $aFlags associative array with seen,deleted,anwered and flag keys. - * @param string $sImageLocation directory location of flagicons - * @return string $sFlags string with the correct img html tag - * @author Marc Groot Koerkamp + * @param string $icon_theme_path path to user's currently selected icon theme. + * @return string $icon full HTML img tag or text icon, depending on of user prefs + * @author Steve Brown */ -function getFlagIcon($aFlags, $sImageLocation) { - $sFlags = ''; - +function getFlagIcon ($aFlags, $icon_theme_path) { /** * 0 = unseen * 1 = seen @@ -100,27 +98,29 @@ /** * Use static vars to avoid initialisation of the array on each displayed row */ - static $aFlagImages, $aFlagValues; - if (!isset($aFlagImages)) { - $aFlagImages = array( - array('msg_new.png','('._("New").')'), - array('msg_read.png','('._("Read").')'), - array('msg_new_deleted.png','('._("Deleted").')'), - array('msg_read_deleted.png','('._("Deleted").')'), - array('msg_new_reply.png','('._("Answered").')'), - array('msg_read_reply.png','('._("Answered").')'), - array('msg_read_deleted_reply.png','('._("Answered").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')'), - array('flagged.png', '('._("Flagged").')') - ); // as you see the list is not completed yet. - $aFlagValues = array('seen' => 1, + static $flag_icons, $flag_values; + if (!isset($flag_icons)) { + // This is by no means complete... + $flag_icons = array ( // Image icon name Text Icon Alt/Title Text + array ('msg_new.png', ' ', '('._("New").')') , + array ('msg_read.png', ' ', '('._("Read").')'), + array ('msg_new_deleted.png', _("D"), '('._("Deleted").')'), + array ('msg_read_deleted.png', _("D"), '('._("Deleted").')'), + array ('msg_new_reply.png', _("A"), '('._("Answered").')'), + array ('msg_read_reply.png', _("A"), '('._("Answered").')'), + array ('msg_read_deleted_reply.png', _("D"), '('._("Answered").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')'), + array ('flagged.png', _("F"), '('._("Flagged").')') + ); + + $flag_values = array('seen' => 1, 'deleted' => 2, 'answered' => 4, 'flagged' => 8, @@ -130,109 +130,74 @@ /** * The flags entry contain all items displayed in the flag column. */ - $iFlagIndx = 0; + $icon = ''; + + $index = 0; foreach ($aFlags as $flag => $flagvalue) { - /* FIX ME, we should use separate templates for icons */ switch ($flag) { case 'deleted': case 'answered': case 'seen': - case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break; + case 'flagged': if ($flagvalue) $index += $flag_values[$flag]; break; default: break; } } - if (isset($aFlagImages[$iFlagIndx])) { - $aFlagEntry = $aFlagImages[$iFlagIndx]; + + if (isset($flag_icons[$index])) { + $data = $flag_icons[$index]; } else { - $aFlagEntry = end($aFlagImages); + $data = end($flag_icons); } - $sFlags = '<img src="' . $sImageLocation . $aFlagEntry[0].'"'. - ' border="0" alt="'.$aFlagEntry[1].'" title="'. $aFlagEntry[1] .'" height="12" width="18" />' ; - if (!$sFlags) { $sFlags = ' '; } - return $sFlags; + $icon = getIcon($icon_theme_path, $data[0], $data[1], $data[2]); + return $icon; } + /** - * Function to retrieve the correct flag text belonging to the set of - * provided flags + * Function to retrieve correct priority icon based on user prefs * - * @param array $aFlags associative array with seen,deleted,anwered and flag keys. - * @return string $sFlags string with the correct flag text - * @author Marc Groot Koerkamp + * @param integer $priority priority value of message + * @param string $icon_theme_path path to user's currently selected icon theme. + * @return string $icon full HTML img tag or text icon, depending on of user prefs + * @author Steve Brown */ -function getFlagText($aFlags) { - $sFlags = ''; +function getPriorityIcon ($priority, $icon_theme_path) { + $icon = ''; - /** - * 0 = unseen - * 1 = seen - * 2 = deleted - * 3 = deleted seen - * 4 = answered - * 5 = answered seen - * 6 = answered deleted - * 7 = answered deleted seen - * 8 = flagged - * 9 = flagged seen - * 10 = flagged deleted - * 11 = flagged deleted seen - * 12 = flagged answered - * 13 = flagged aswered seen - * 14 = flagged answered deleted - * 15 = flagged anserwed deleted seen - */ - /** - * Use static vars to avoid initialisation of the array on each displayed row - */ - static $aFlagText, $aFlagValues; - if (!isset($aFlagText)) { - $aFlagText = array( - array(' ', '('._("New").')'), - array(' ', '('._("Read").')'), - array(_("D") , '('._("Deleted").')'), - array(_("D") , '('._("Deleted").')'), - array(_("A") , '('._("Answered").')'), - array(_("A") , '('._("Answered").')'), - array(_("D") , '('._("Answered").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')'), - array(_("F") , '('._("Flagged").')') - ); // as you see the list is not completed yet. - $aFlagValues = array('seen' => 1, - 'deleted' => 2, - 'answered' => 4, - 'flagged' => 8, - 'draft' => 16); + switch ($priority) { + case 1: + case 2: + $icon = getIcon($icon_theme_path, 'prio_high.png', '<span class="high_priority">!</span>'); + break; + case 5: + $icon = getIcon($icon_theme_path, 'prio_low.png', '<span class="low_priority">↓</span>'); + break; + default: + $icon = getIcon($icon_theme_path, 'transparent.png', '', '', 5); + break; } - /** - * The flags entry contain all items displayed in the flag column. - */ - $iFlagIndx = 0; - foreach ($aFlags as $flag => $flagvalue) { - /* FIX ME, we should use separate templates for icons */ - switch ($flag) { - case 'deleted': - case 'answered': - case 'seen': - case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break; - default: break; - } - } - if (isset($aFlagText[$iFlagIndx])) { - $sFlags = $aFlagText[$iFlagIndx][0]; - } else { - $aLast = end($aFlagText); - $sFlags = $aLast[0]; + return $icon; } - if (!$sFlags) { $sFlags = ' '; } - return $sFlags; + +/** + * Function to retrieve correct attchment icon based on user prefs + * + * @param boolean $attach TRUE if the message has an attachment + * @param string $icon_theme_path path to user's currently selected icon theme. + * @return string $icon full HTML img tag or text icon, depending on of user prefs + * @author Steve Brown + */ +function getAttachmentIcon ($attach, $icon_theme_path) { + $icon = ''; + + $icon_file = $attach ? 'attach.png' : 'transparent.png'; + $text = $attach ? '+' : ''; + $icon = getIcon($icon_theme_path, $icon_file, $text); + + return $icon; } + + ?> \ No newline at end of file |