Adding comment for future developer(s)
[squirrelmail.git] / templates / default / left_main.tpl
CommitLineData
29997535 1<?php
2/**
3 * left_main.tpl
4 *
44452136 5 * Basic template to the left main window.
6 *
7 * The following variables are avilable in this template:
29997535 8 * $clock - formatted string containing last refresh
44452136 9 * $settings - Array containing user perferences needed by this
10 * template. Indexes are as follows:
4f5c9970 11 * $settings['templateID'] - contains the ID of the current
12 * template set. This may be needed by third
44452136 13 * party packages that don't integrate easily.
14 * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
15 * wants to see unread message count on mailboxes
16 * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
17 * user has enabled cummulative message counts.
18 * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
19 * user wants to see unread message count on ALL
20 * folders or just the Inbox.
21 * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
22 * user wants to see the total number of messages in
23 * addition to the unread message count.
24 * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
25 * has enabled collapsable folders.
26 * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
27 * chosen to tag "Special" folders in a different color
28 * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
29 * that get deleted go to the Trash folder. FALSE if
30 * they are permanently deleted.
e945d2c2 31 *
29997535 32 * $mailboxes - Associative array of current mailbox structure.
33 * Provided so template authors know what they have to
34 * work with when building a custom mailbox tree.
35 * Array contains the following elements:
36 * $a['MailboxName'] = String containing the name of the mailbox
37 * $a['MailboxFullName'] = String containing full IMAP name of mailbox
38 * $a['MessageCount'] = integer of all messages in the mailbox
39 * $a['UnreadCount'] = integer of unseen message in the mailbox
40 * $a['ViewLink'] = array containing elements needed to view the
41 * mailbox. Elements are:
42 * 'Target' = target frame for link
43 * 'URL' = target URL for link
44452136 44 * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent"
45 * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special"
46 * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox
47 * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect"
48 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed
49 * $a['CollapseLink'] = array containg elements needed to expand/collapse
50 * the mailbox. Elements are:
51 * 'Target' = target frame for link
52 * 'URL' = target URL for link
53 * 'Icon' = the icon to use, based on user prefs
29997535 54 * $a['ChildBoxes'] = array containing this same data structure for
44452136 55 * each child folder/mailbox of the current
56 * mailbox.
57 * $a['CummulativeMessageCount'] = integer of total messages in all
58 * folders in this mailbox, exlcuding
59 * trash folders.
60 * $a['CummulativeUnreadCount'] = integer of total unseen messages
61 * in all folders in this mailbox,
62 * excluding trash folders.
29997535 63 *
64 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
65 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
66 * @version $Id$
67 * @package squirrelmail
68 * @subpackage templates
44452136 69 * @author Steve Brown
29997535 70 */
71
29997535 72
73/*
74 * Recursively parse the mailbox structure to build the navigation tree.
e945d2c2 75 *
29997535 76 * @since 1.5.2
77 */
5e8e22db 78function buildMailboxTree ($box, $settings, $icon_theme_path, $indent_factor=0) {
29997535 79 // stop condition
80 if (empty($box)) {
81 return '';
82 }
83
29997535 84 $pre = '<span style="white-space: nowrap;">';
85 $end = '';
86 $indent = str_repeat('&nbsp;&nbsp;',$indent_factor);
87
88 // Get unseeen/total message info if needed
89 $unseen_str = '';
90 if ($settings['unreadNotificationEnabled']) {
91 // We only display the unread count if we on the Inbox or we are told
1644256e 92 // to display it on all folders AND there is more than 1 unread message
e945d2c2 93 if ( $settings['unreadNotificationAllFolders'] ||
42b0ed18 94 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
29997535 95 ) {
1644256e 96 $unseen = $settings['unreadNotificationCummulative'] ?
e945d2c2 97 $box['CummulativeUnreadCount'] :
29997535 98 $box['UnreadCount'];
1644256e 99
6248fde9 100 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
1644256e 101 $unseen_str = $unseen;
102
103 // Add the total messages if desired
104 if ($settings['unreadNotificationDisplayTotal']) {
105 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
106 $box['CummulativeMessageCount'] :
107 $box['MessageCount']);
108 }
e945d2c2 109
1644256e 110 $unseen_str = '<span class="'.
111 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
112 '">' . $unseen_str .
113 '</span>';
29997535 114 }
29997535 115 }
116 }
117
118 /*
119 * If the box has any children, and collapsable folders have been enabled
120 * we need to output the expand/collapse link.
121 */
122 if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled']) {
e945d2c2 123 $link = $indent .
29997535 124 '<a href="'.$box['CollapseLink']['URL'].'" ' .
125 'target="'.$box['CollapseLink']['Target'].'" ' .
126 'style="text-decoration:none" ' .
e945d2c2 127 '>' .
128 $box['CollapseLink']['Icon'] .
129 '</a>';
130 $pre .= $link;
131 } else {
29997535 132 $pre .= $indent . '&nbsp;&nbsp;';
133 }
e945d2c2 134
1644256e 135 /**
136 * Add folder icon. Template authors may choose to display a different
137 * image based on whatever logic they see fit here.
138 */
139 $folder_icon = '';
c2bdb921 140 if (!is_null($icon_theme_path)) {
1644256e 141 switch (true) {
142 case $box['IsInbox']:
5e8e22db 143 $folder_icon = getIcon($icon_theme_path, 'inbox.png', '', $box['MailboxName']);
1644256e 144 break;
145 case $box['IsSent']:
5e8e22db 146 $folder_icon = getIcon($icon_theme_path, 'senti.png', '', $box['MailboxName']);
1644256e 147 break;
148 case $box['IsTrash']:
5e8e22db 149 $folder_icon = getIcon($icon_theme_path, 'delitem.png', '', $box['MailboxName']);
1644256e 150 break;
151 case $box['IsDraft']:
5e8e22db 152 $folder_icon = getIcon($icon_theme_path, 'draft.png', '', $box['MailboxName']);
1644256e 153 break;
154 case $box['IsNoInferiors']:
5e8e22db 155 $folder_icon = getIcon($icon_theme_path, 'folder_noinf.png', '', $box['MailboxName']);
1644256e 156 break;
157 default:
5e8e22db 158 $folder_icon = getIcon($icon_theme_path, 'folder.png', '', $box['MailboxName']);
1644256e 159 break;
160 }
161 $folder_icon .= '&nbsp;';
162 }
163 $pre .= $folder_icon;
164
29997535 165 /*
166 * The Trash folder should only be displayed if message recycling has
167 * been enabled, i.e. when deleted is a message moved to the trash or
168 * deleted forever?
169 */
170 $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
171 'target="'.$box['ViewLink']['Target'].'" ' .
172 'style="text-decoration:none">';
e945d2c2 173
1644256e 174 if ($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
29997535 175 $pre .= $view_link;
176
177 // Boxes with unread messages should be emphasized
178 if ($box['UnreadCount'] > 0) {
179 $pre .= '<em>';
180 $end .= '</em>';
181 }
182 $end .= '</a>';
e945d2c2 183
29997535 184 // Print unread info
ad648d4c 185 if ($box['MessageCount'] > 0 || count($box['ChildBoxes'])) {
29997535 186 if (!empty($unseen_str)) {
187 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
188 }
189 $end .= "\n<small>" .
190 '&nbsp;&nbsp;[<a href="empty_trash.php">'. _("Purge").'</a>]' .
191 '</small>';
192 }
193 } else {
194 // Add a few other things for all other folders...
195 if (!$box['IsNoSelect']) {
196 $pre .= $view_link;
e945d2c2 197
29997535 198 // Boxes with unread messages should be emphasized
199 if ($box['UnreadCount'] > 0) {
200 $pre .= '<em>';
201 $end .= '</em>';
202 }
203 $end .= '</a>';
204 }
e945d2c2 205
29997535 206 // Display unread info...
207 if (!empty($unseen_str)) {
208 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
209 }
210 }
e945d2c2 211
29997535 212 $span = '';
213 $spanend = '';
214 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
215 $span = '<span class="leftspecial">';
216 $spanend = '</span>';
217 } elseif ( $box['IsNoSelect'] ) {
218 $span = '<span class="leftnoselect">';
219 $spanend = '</span>';
220 }
221
535ca371 222/********
223 * Pulling imapConnection due to segfaults that cannot be tracked down. Best
6e515418 224 * we can determine, it's some combination of this var and >= 4 plugins enabled.
535ca371 225 * No further clue from anyone.
6e515418 226 ********
227 * Update: syntax of this hook call changed a bit, so if the error is so anomalous,
228 * it might be worth trying this again to see if it is still segfaulting
535ca371 229 ********
230
29997535 231 // let plugins fiddle with end of line
b71975ad 232// FIXME: no hooks in templates! Although note that I'm not sure we can avoid it here because the context of which folder we are displaying is important to the hook, unless we preemptively iterate through all folders and collect the output from the hook call for that and give that to the template.... seems like overkill; I say this hook remains
29997535 233 $end .= concat_hook_function('left_main_after_each_folder',
6e515418 234 $temp=array(isset($numMessages) ? &$numMessages : '',
235 &$box['MailboxFullName'], &$settings['imapConnection']));
535ca371 236*/
29997535 237
238 $end .= '</span>';
239
240 $out = '';
241 if (!$box['IsRoot']) {
242 $out = $span . $pre .
243 str_replace(
244 array(' ','<','>'),
245 array('&nbsp;','&lt;','&gt;'),
246 $box['MailboxName']) .
247 $end . $spanend . '<br />' . "\n";
248 $indent_factor++;
249 }
250
251 if (!$box['IsCollapsed'] || $box['IsRoot']) {
252 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
c2bdb921 253 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $indent_factor);
29997535 254 }
255 }
e945d2c2 256
29997535 257 return $out;
258}
259
260// Retrieve the template vars
261extract($t);
e945d2c2 262
29997535 263?>
264<body class="sqm_leftMain">
265<div class="sqm_leftMain">
b71975ad 266<?php if (!empty($plugin_output['left_main_before'])) echo $plugin_output['left_main_before']; ?>
29997535 267<table class="sqm_wrapperTable" cellspacing="0">
268 <tr>
269 <td>
270 <table cellspacing="0">
271 <tr>
272 <td style="text-align:center">
273 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
274 <span class="sqm_clock"><?php echo $clock; ?></span>
e945d2c2 275 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
29997535 276 </td>
277 </tr>
278 </table>
279 <br />
5e8e22db 280 <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
fddbf0d4 281 </td>
282 </tr>
283</table>
b71975ad 284<?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?>
fddbf0d4 285</div>