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