4 * message_list_util.php
6 * Helper functions for message list templates.
8 * The following functions are utility functions for templates. Do not
9 * echo output in these functions.
11 * @copyright © 2005-2009 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * @package squirrelmail
19 * @param array $aOrder
22 function calcMessageListColumnWidth($aOrder) {
24 * Width of the displayed columns
34 SQM_COL_ATTACHMENT
=> 1,
35 SQM_COL_INT_DATE
=> 15,
42 * Calculate the width of the subject column based on the
43 * widths of the other columns
45 if (isset($aOrder[SQM_COL_SUBJ
])) {
46 foreach($aOrder as $iCol) {
47 if ($iCol != SQM_COL_SUBJ
) {
48 $aWidthTpl[SQM_COL_SUBJ
] -= $aWidthTpl[$iCol];
53 foreach($aOrder as $iCol) {
54 $aWidth[$iCol] = $aWidthTpl[$iCol];
57 $iCheckTotalWidth = $iTotalWidth = 0;
58 foreach($aOrder as $iCol) { $iTotalWidth +
= $aWidth[$iCol];}
60 $iTotalWidth = ($iTotalWidth) ?
$iTotalWidth : 100; // divide by zero check. shouldn't be needed
62 // correct the width to 100%
63 foreach($aOrder as $iCol) {
64 $aWidth[$iCol] = round( (100 / $iTotalWidth) * $aWidth[$iCol] , 0);
65 $iCheckTotalWidth +
= $aWidth[$iCol];
67 if ($iCheckTotalWidth > 100) { // correction needed
68 $iCol = array_search(max($aWidth),$aWidth);
69 $aWidth[$iCol] -= $iCheckTotalWidth-100;
76 * Function to retrieve correct icon based on provided message flags. This is
77 * a merge/replacement for getFlagIcon() and getFlagText() functions.
79 * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
80 * @param string $icon_theme_path path to user's currently selected icon theme.
81 * @return string $icon full HTML img tag or text icon, depending on of user prefs
84 function getFlagIcon ($aFlags, $icon_theme_path) {
92 * 6 = answered deleted
93 * 7 = answered deleted seen
96 * 10 = flagged deleted
97 * 11 = flagged deleted seen
98 * 12 = flagged answered
99 * 13 = flagged aswered seen
100 * 14 = flagged answered deleted
101 * 15 = flagged anserwed deleted seen
104 * 33 = forwarded seen
105 * 34 = forwarded deleted
106 * 35 = forwarded deleted seen
108 * 41 = flagged forwarded seen
109 * 42 = flagged forwarded deleted
110 * 43 = flagged forwarded deleted seen
114 * Use static vars to avoid initialisation of the array on each displayed row
117 static $flag_icons, $flag_values;
118 if (!isset($flag_icons)) {
119 // This is by no means complete...
120 $flag_icons = array (
121 // Image icon name Text Icon Alt/Title Text
122 // --------------- --------- --------------
123 array ('msg_new.png', $nbsp, '('._("New").')') ,
124 array ('msg_read.png', $nbsp, '('._("Read").')'),
125 array ('msg_new_deleted.png', _("D"), '('._("Deleted").')'),
126 array ('msg_read_deleted.png', _("D"), '('._("Deleted").')'),
127 array ('msg_new_reply.png', _("A"), '('._("Answered").')'),
128 array ('msg_read_reply.png', _("A"), '('._("Answered").')'),
129 array ('msg_new_deleted_reply.png', _("D"), '('._("Answered").')'),
130 array ('msg_read_deleted_reply.png', _("D"), '('._("Answered").')'),
131 array ('flagged.png', _("F"), '('._("Flagged").')'),
132 array ('flagged.png', _("F"), '('._("Flagged").')'),
133 array ('flagged.png', _("F"), '('._("Flagged").')'),
134 array ('flagged.png', _("F"), '('._("Flagged").')'),
135 array ('flagged.png', _("F"), '('._("Flagged").')'),
136 array ('flagged.png', _("F"), '('._("Flagged").')'),
137 array ('flagged.png', _("F"), '('._("Flagged").')'),
138 array ('flagged.png', _("F"), '('._("Flagged").')'),
155 array ('msg_new_forwarded.png', _("O"), '('._("Forwarded").')'),
156 array ('msg_read_forwarded.png', _("O"), '('._("Forwarded").')'),
157 array ('msg_new_deleted_forwarded.png', _("D"), '('._("Forwarded").')'),
158 array ('msg_read_deleted_forwarded.png', _("D"), '('._("Forwarded").')'),
164 array ('flagged.png', _("F"), '('._("Flagged").')'),
165 array ('flagged.png', _("F"), '('._("Flagged").')'),
166 array ('flagged.png', _("F"), '('._("Flagged").')'),
169 $flag_values = array('seen' => 1,
178 * The flags entry contain all items displayed in the flag column.
183 foreach ($aFlags as $flag => $flagvalue) {
189 case 'flagged': if ($flagvalue) $index +
= $flag_values[$flag]; break;
194 if (!empty($flag_icons[$index])) {
195 $data = $flag_icons[$index];
197 //FIXME: previously this default was set to the last value of the $flag_icons array (when it was index 15 - flagged anserwed deleted seen) but I don't understand why... am changing it to flagged (index 15 just shows (only) the flag icon anyway)
198 $data = $flag_icons[8]; // default to just flagged
201 $icon = getIcon($icon_theme_path, $data[0], $data[1], $data[2]);
207 * Function to retrieve correct priority icon based on user prefs
209 * @param integer $priority priority value of message
210 * @param string $icon_theme_path path to user's currently selected icon theme.
211 * @return string $icon full HTML img tag or text icon, depending on of user prefs
212 * @author Steve Brown
214 function getPriorityIcon ($priority, $icon_theme_path) {
220 $icon = getIcon($icon_theme_path, 'prio_high.png', create_span('!', 'high_priority'), _("High priority"));
223 $icon = getIcon($icon_theme_path, 'prio_low.png', create_span('↓', 'low_priority'), _("Low priority"));
226 $icon = getIcon($icon_theme_path, 'transparent.png', '', _("Normal priority"), 5);
235 * Function to retrieve correct attchment icon based on user prefs
237 * @param boolean $attach TRUE if the message has an attachment
238 * @param string $icon_theme_path path to user's currently selected icon theme.
239 * @return string $icon full HTML img tag or text icon, depending on of user prefs
240 * @author Steve Brown
242 function getAttachmentIcon ($attach, $icon_theme_path) {
245 $icon_file = $attach ?
'attach.png' : 'transparent.png';
246 $alt_text = $attach ?
_("Attachment") : _("No attachment");
247 $text = $attach ?
'+' : '';
248 $icon = getIcon($icon_theme_path, $icon_file, $text, $alt_text);