242e7780684d317c75dbce81385b33cd3c41a537
[squirrelmail.git] / templates / default / left_main.tpl
1 <?php
2 /**
3 * left_main.tpl
4 *
5 * Basic template to the left main window. The following variables are
6 * avilable in this template:
7 * $clock - formatted string containing last refresh
8 * $mailbox_listing - string containing HTML to display default mailbox
9 * tree
10 * $location_of_bar - string "left" or "right" indicating where the frame
11 * is located. Currently only used in
12 * left_main_advanced.tpl
13 * $left_size - width of left column in pixels. Currently
14 * only used in left_main_advanced. tpl
15 * $imapConnection - IMAP connection handle. Needed to allow plugins to
16 * read the mailbox.
17 * $icon_theme_path - Path to the desired icon theme. If the user/admin
18 * has disabled icons, this will be NULL.
19 *
20 * $unread_notification_enabled - Boolean TRUE if the user wants to see
21 * unread message count on mailboxes
22 * $unread_notification_cummulative - Boolean TRUE if the user has enabled
23 * cummulative message counts.
24 * $unread_notification_allFolders - Boolean TRUE if the user wants to see
25 * unread message count on ALL folders or just the
26 * mailbox.
27 * $unread_notification_displayTotal - Boolean TRUE if the user wants to
28 * see the total number of messages in addition to the
29 * unread message count.
30 * $collapsable_folders_enabled - Boolean TRUE if the user has enabled
31 * collapsable folders.
32 * $use_special_folder_color - Boolean TRUE if the use has chosen to tag
33 * "Special" folders in a different color.
34 * $message_recycling_enabled - Boolean TRUE if messages that get deleted
35 * go to the Trash folder. FALSE if they are
36 * permanently deleted.
37 *
38 * $mailboxes - Associative array of current mailbox structure.
39 * Provided so template authors know what they have to
40 * work with when building a custom mailbox tree.
41 * Array contains the following elements:
42 * $a['MailboxName'] = String containing the name of the mailbox
43 * $a['MailboxFullName'] = String containing full IMAP name of mailbox
44 * $a['MessageCount'] = integer of all messages in the mailbox
45 * $a['UnreadCount'] = integer of unseen message in the mailbox
46 * $a['ViewLink'] = array containing elements needed to view the
47 * mailbox. Elements are:
48 * 'Target' = target frame for link
49 * 'URL' = target URL for link
50 * $a['IsRecent'] = boolean TRUE if mailbox is tagged "recent"
51 * $a['IsSpecial'] = boolean TRUE if mailbox is tagged "special"
52 * $a['IsRoot'] = boolean TRUE if mailbox is the root mailbox
53 * $a['IsNoSelect'] = boolean TRUE if mailbox is tagged "noselect"
54 * $a['IsInbox'] = boolean TRUE if mailbox is the Inbox.
55 * $a['IsSent'] = boolean TRUE if mailbox is the Sent box
56 * $a['IsTrash'] = boolean TRUE if mailbox is the Trash box
57 * $a['IsDraft'] = boolean TRUE if mailbox is the Draft box
58 * $a['IsNoInferiors'] = boolean TRUE of mailbox is tagged "no
59 * inferiors"
60 * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently
61 * collapsed
62 *
63 * $a['CollapseLink'] = array containg elements needed to
64 * expand/collapse the mailbox. Elements are:
65 * 'Target' = target frame for link
66 * 'URL' = target URL for link
67 * 'Icon' = the icon to use, based on
68 * user prefs
69 * $a['ChildBoxes'] = array containing this same data structure for
70 * each child folder/mailbox.
71 * $a ['CummulativeMessageCount'] = integer of total messages in all
72 * folders in this mailbox, exlcuding trash
73 * folders.
74 * $a ['CummulativeUnreadCount'] = integer of total unseen messages
75 * in all folders in this mailbox, excluding
76 * trash folders.
77 *
78 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
79 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
80 * @version $Id$
81 * @package squirrelmail
82 * @subpackage templates
83 */
84
85 // include required files
86 include_once(SM_PATH . 'templates/util_global.php');
87
88 /*
89 * Recursively parse the mailbox structure to build the navigation tree.
90 *
91 * @since 1.5.2
92 */
93 function buildMailboxTree ($box, $settings, $indent_factor=0) {
94 // stop condition
95 if (empty($box)) {
96 return '';
97 }
98
99 $pre = '<span style="white-space: nowrap;">';
100 $end = '';
101 $indent = str_repeat('&nbsp;&nbsp;',$indent_factor);
102
103 // Get unseeen/total message info if needed
104 $unseen_str = '';
105 if ($settings['unreadNotificationEnabled']) {
106 // We only display the unread count if we on the Inbox or we are told
107 // to display it on all folders AND there is more than 1 unread message
108 if ( $settings['unreadNotificationAllFolders'] ||
109 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
110 ) {
111 $unseen = $settings['unreadNotificationCummulative'] ?
112 $box['CummulativeUnreadCount'] :
113 $box['UnreadCount'];
114
115 if ($unseen > 0) {
116 $unseen_str = $unseen;
117
118 // Add the total messages if desired
119 if ($settings['unreadNotificationDisplayTotal']) {
120 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
121 $box['CummulativeMessageCount'] :
122 $box['MessageCount']);
123 }
124
125 $unseen_str = '<span class="'.
126 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
127 '">' . $unseen_str .
128 '</span>';
129 }
130 }
131 }
132
133 /*
134 * If the box has any children, and collapsable folders have been enabled
135 * we need to output the expand/collapse link.
136 */
137 if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled']) {
138 $link = $indent .
139 '<a href="'.$box['CollapseLink']['URL'].'" ' .
140 'target="'.$box['CollapseLink']['Target'].'" ' .
141 'style="text-decoration:none" ' .
142 '>' .
143 $box['CollapseLink']['Icon'] .
144 '</a>';
145 $pre .= $link;
146 } else {
147 $pre .= $indent . '&nbsp;&nbsp;';
148 }
149
150 /**
151 * Add folder icon. Template authors may choose to display a different
152 * image based on whatever logic they see fit here.
153 */
154 $folder_icon = '';
155 if (!is_null($settings['iconThemePath'])) {
156 switch (true) {
157 case $box['IsInbox']:
158 $folder_icon = getIcon($settings['iconThemePath'], 'inbox.png', '', $box['MailboxName']);
159 break;
160 case $box['IsSent']:
161 $folder_icon = getIcon($settings['iconThemePath'], 'senti.png', '', $box['MailboxName']);
162 break;
163 case $box['IsTrash']:
164 $folder_icon = getIcon($settings['iconThemePath'], 'delitem.png', '', $box['MailboxName']);
165 break;
166 case $box['IsDraft']:
167 $folder_icon = getIcon($settings['iconThemePath'], 'draft.png', '', $box['MailboxName']);
168 break;
169 case $box['IsNoInferiors']:
170 $folder_icon = getIcon($settings['iconThemePath'], 'folder_noinf.png', '', $box['MailboxName']);
171 break;
172 default:
173 $folder_icon = getIcon($settings['iconThemePath'], 'folder.png', '', $box['MailboxName']);
174 break;
175 }
176 $folder_icon .= '&nbsp;';
177 }
178 $pre .= $folder_icon;
179
180 /*
181 * The Trash folder should only be displayed if message recycling has
182 * been enabled, i.e. when deleted is a message moved to the trash or
183 * deleted forever?
184 */
185 $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
186 'target="'.$box['ViewLink']['Target'].'" ' .
187 'style="text-decoration:none">';
188
189 if ($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
190 $pre .= $view_link;
191
192 // Boxes with unread messages should be emphasized
193 if ($box['UnreadCount'] > 0) {
194 $pre .= '<em>';
195 $end .= '</em>';
196 }
197 $end .= '</a>';
198
199 // Print unread info
200 if ($box['UnreadCount'] > 0) {
201 if (!empty($unseen_str)) {
202 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
203 }
204 $end .= "\n<small>" .
205 '&nbsp;&nbsp;[<a href="empty_trash.php">'. _("Purge").'</a>]' .
206 '</small>';
207 }
208 } else {
209 // Add a few other things for all other folders...
210 if (!$box['IsNoSelect']) {
211 $pre .= $view_link;
212
213 // Boxes with unread messages should be emphasized
214 if ($box['UnreadCount'] > 0) {
215 $pre .= '<em>';
216 $end .= '</em>';
217 }
218 $end .= '</a>';
219 }
220
221 // Display unread info...
222 if (!empty($unseen_str)) {
223 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
224 }
225 }
226
227 $span = '';
228 $spanend = '';
229 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
230 $span = '<span class="leftspecial">';
231 $spanend = '</span>';
232 } elseif ( $box['IsNoSelect'] ) {
233 $span = '<span class="leftnoselect">';
234 $spanend = '</span>';
235 }
236
237 // let plugins fiddle with end of line
238 $end .= concat_hook_function('left_main_after_each_folder',
239 array(isset($numMessages) ? $numMessages : '',
240 $box['MailboxFullName'], $settings['imapConnection']));
241
242 $end .= '</span>';
243
244 $out = '';
245 if (!$box['IsRoot']) {
246 $out = $span . $pre .
247 str_replace(
248 array(' ','<','>'),
249 array('&nbsp;','&lt;','&gt;'),
250 $box['MailboxName']) .
251 $end . $spanend . '<br />' . "\n";
252 $indent_factor++;
253 }
254
255 if (!$box['IsCollapsed'] || $box['IsRoot']) {
256 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
257 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $indent_factor);
258 }
259 }
260
261 return $out;
262 }
263
264 // Retrieve the template vars
265 extract($t);
266
267 /*
268 * Build an array to pass user prefs to the function that builds the tree in
269 * order to avoid using globals, which are dirty, filthy things in templates. :)
270 */
271 $settings = array();
272 $settings['imapConnection'] = $imapConnection;
273 $settings['iconThemePath'] = $icon_theme_path;
274 $settings['unreadNotificationEnabled'] = $unread_notification_enabled;
275 $settings['unreadNotificationAllFolders'] = $unread_notification_allFolders;
276 $settings['unreadNotificationDisplayTotal'] = $unread_notification_displayTotal;
277 $settings['unreadNotificationCummulative'] = $unread_notification_cummulative;
278 $settings['useSpecialFolderColor'] = $use_special_folder_color;
279 $settings['messageRecyclingEnabled'] = $message_recycling_enabled;
280 $settings['collapsableFoldersEnabled'] = $collapsable_folders_enabled;
281
282 ?>
283 <body class="sqm_leftMain">
284 <div class="sqm_leftMain">
285 <?php do_hook('left_main_before'); ?>
286 <table class="sqm_wrapperTable" cellspacing="0">
287 <tr>
288 <td>
289 <table cellspacing="0">
290 <tr>
291 <td style="text-align:center">
292 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
293 <span class="sqm_clock"><?php echo $clock; ?></span>
294 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
295 </td>
296 </tr>
297 </table>
298 <br />
299 <?php echo buildMailboxTree($mailboxes, $settings); ?>
300 </tr>
301 </td>
302 </table>
303 <?php do_hook('left_main_after'); ?>
304 </div>