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