6 * The following functions are utility functions for this template. Do not
7 * echo output in those functions.
9 * @copyright © 2005-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
16 * @param array $aOrder
19 function calcMessageListColumnWidth($aOrder) {
21 * Width of the displayed columns
31 SQM_COL_ATTACHMENT
=> 1,
32 SQM_COL_INT_DATE
=> 10,
39 * Calculate the width of the subject column based on the
40 * widths of the other columns
42 if (isset($aOrder[SQM_COL_SUBJ
])) {
43 foreach($aOrder as $iCol) {
44 if ($iCol != SQM_COL_SUBJ
) {
45 $aWidthTpl[SQM_COL_SUBJ
] -= $aWidthTpl[$iCol];
49 foreach($aOrder as $iCol) {
50 $aWidth[$iCol] = $aWidthTpl[$iCol];
53 $iCheckTotalWidth = $iTotalWidth = 0;
54 foreach($aOrder as $iCol) { $iTotalWidth +
= $aWidth[$iCol];}
56 $iTotalWidth = ($iTotalWidth) ?
$iTotalWidth : 100; // divide by zero check. shouldn't be needed
57 // correct the width to 100%
58 foreach($aOrder as $iCol) {
59 $aWidth[$iCol] = round( (100 / $iTotalWidth) * $aWidth[$iCol] , 0);
60 $iCheckTotalWidth +
= $aWidth[$iCol];
62 if ($iCheckTotalWidth > 100) { // correction needed
63 $iCol = array_search(max($aWidth),$aWidth);
64 $aWidth[$iCol] -= $iCheckTotalWidth-100;
70 * Function to retrieve correct icon based on provided message flags. This is
71 * a merge/replacement for getFlagIcon() and getFlagText() functions.
73 * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
74 * @param string $icon_theme_path path to user's currently selected icon theme.
75 * @return string $icon full HTML img tag or text icon, depending on of user prefs
78 function getFlagIcon ($aFlags, $icon_theme_path) {
86 * 6 = answered deleted
87 * 7 = answered deleted seen
90 * 10 = flagged deleted
91 * 11 = flagged deleted seen
92 * 12 = flagged answered
93 * 13 = flagged aswered seen
94 * 14 = flagged answered deleted
95 * 15 = flagged anserwed deleted seen
99 * Use static vars to avoid initialisation of the array on each displayed row
101 static $flag_icons, $flag_values;
102 if (!isset($flag_icons)) {
103 // This is by no means complete...
104 $flag_icons = array ( // Image icon name Text Icon Alt/Title Text
105 array ('msg_new.png', ' ', '('._("New").')') ,
106 array ('msg_read.png', ' ', '('._("Read").')'),
107 array ('msg_new_deleted.png', _("D"), '('._("Deleted").')'),
108 array ('msg_read_deleted.png', _("D"), '('._("Deleted").')'),
109 array ('msg_new_reply.png', _("A"), '('._("Answered").')'),
110 array ('msg_read_reply.png', _("A"), '('._("Answered").')'),
111 array ('msg_read_deleted_reply.png', _("D"), '('._("Answered").')'),
112 array ('flagged.png', _("F"), '('._("Flagged").')'),
113 array ('flagged.png', _("F"), '('._("Flagged").')'),
114 array ('flagged.png', _("F"), '('._("Flagged").')'),
115 array ('flagged.png', _("F"), '('._("Flagged").')'),
116 array ('flagged.png', _("F"), '('._("Flagged").')'),
117 array ('flagged.png', _("F"), '('._("Flagged").')'),
118 array ('flagged.png', _("F"), '('._("Flagged").')'),
119 array ('flagged.png', _("F"), '('._("Flagged").')'),
120 array ('flagged.png', _("F"), '('._("Flagged").')')
123 $flag_values = array('seen' => 1,
131 * The flags entry contain all items displayed in the flag column.
136 foreach ($aFlags as $flag => $flagvalue) {
141 case 'flagged': if ($flagvalue) $index +
= $flag_values[$flag]; break;
146 if (isset($flag_icons[$index])) {
147 $data = $flag_icons[$index];
149 $data = end($flag_icons);
152 $icon = getIcon($icon_theme_path, $data[0], $data[1], $data[2]);
158 * Function to retrieve correct priority icon based on user prefs
160 * @param integer $priority priority value of message
161 * @param string $icon_theme_path path to user's currently selected icon theme.
162 * @return string $icon full HTML img tag or text icon, depending on of user prefs
163 * @author Steve Brown
165 function getPriorityIcon ($priority, $icon_theme_path) {
171 $icon = getIcon($icon_theme_path, 'prio_high.png', '<span class="high_priority">!</span>');
174 $icon = getIcon($icon_theme_path, 'prio_low.png', '<span class="low_priority">↓</span>');
177 $icon = getIcon($icon_theme_path, 'transparent.png', '', '', 5);
185 * Function to retrieve correct attchment icon based on user prefs
187 * @param boolean $attach TRUE if the message has an attachment
188 * @param string $icon_theme_path path to user's currently selected icon theme.
189 * @return string $icon full HTML img tag or text icon, depending on of user prefs
190 * @author Steve Brown
192 function getAttachmentIcon ($attach, $icon_theme_path) {
195 $icon_file = $attach ?
'attach.png' : 'transparent.png';
196 $text = $attach ?
'+' : '';
197 $icon = getIcon($icon_theme_path, $icon_file, $text);