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