Use $icon_theme_path rather than $settings['iconThemePath'].
[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['templateID'] - contains the ID of the current
12 * template set. This may be needed by third
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.
31 *
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
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
54 * $a['ChildBoxes'] = array containing this same data structure for
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.
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
69 * @author Steve Brown
70 */
71
72 /** include required files */
73 include_once(SM_PATH . 'templates/util_global.php');
74
75 /*
76 * Recursively parse the mailbox structure to build the navigation tree.
77 *
78 * @since 1.5.2
79 */
80 function buildMailboxTree ($box, $settings, $icon_theme_path, $indent_factor=0) {
81 // stop condition
82 if (empty($box)) {
83 return '';
84 }
85
86 $pre = '<span style="white-space: nowrap;">';
87 $end = '';
88 $indent = str_repeat('&nbsp;&nbsp;',$indent_factor);
89
90 // Get unseeen/total message info if needed
91 $unseen_str = '';
92 if ($settings['unreadNotificationEnabled']) {
93 // We only display the unread count if we on the Inbox or we are told
94 // to display it on all folders AND there is more than 1 unread message
95 if ( $settings['unreadNotificationAllFolders'] ||
96 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
97 ) {
98 $unseen = $settings['unreadNotificationCummulative'] ?
99 $box['CummulativeUnreadCount'] :
100 $box['UnreadCount'];
101
102 if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
103 $unseen_str = $unseen;
104
105 // Add the total messages if desired
106 if ($settings['unreadNotificationDisplayTotal']) {
107 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
108 $box['CummulativeMessageCount'] :
109 $box['MessageCount']);
110 }
111
112 $unseen_str = '<span class="'.
113 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
114 '">' . $unseen_str .
115 '</span>';
116 }
117 }
118 }
119
120 /*
121 * If the box has any children, and collapsable folders have been enabled
122 * we need to output the expand/collapse link.
123 */
124 if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled']) {
125 $link = $indent .
126 '<a href="'.$box['CollapseLink']['URL'].'" ' .
127 'target="'.$box['CollapseLink']['Target'].'" ' .
128 'style="text-decoration:none" ' .
129 '>' .
130 $box['CollapseLink']['Icon'] .
131 '</a>';
132 $pre .= $link;
133 } else {
134 $pre .= $indent . '&nbsp;&nbsp;';
135 }
136
137 /**
138 * Add folder icon. Template authors may choose to display a different
139 * image based on whatever logic they see fit here.
140 */
141 $folder_icon = '';
142 if (!is_null($settings['iconThemePath'])) {
143 switch (true) {
144 case $box['IsInbox']:
145 $folder_icon = getIcon($icon_theme_path, 'inbox.png', '', $box['MailboxName']);
146 break;
147 case $box['IsSent']:
148 $folder_icon = getIcon($icon_theme_path, 'senti.png', '', $box['MailboxName']);
149 break;
150 case $box['IsTrash']:
151 $folder_icon = getIcon($icon_theme_path, 'delitem.png', '', $box['MailboxName']);
152 break;
153 case $box['IsDraft']:
154 $folder_icon = getIcon($icon_theme_path, 'draft.png', '', $box['MailboxName']);
155 break;
156 case $box['IsNoInferiors']:
157 $folder_icon = getIcon($icon_theme_path, 'folder_noinf.png', '', $box['MailboxName']);
158 break;
159 default:
160 $folder_icon = getIcon($icon_theme_path, 'folder.png', '', $box['MailboxName']);
161 break;
162 }
163 $folder_icon .= '&nbsp;';
164 }
165 $pre .= $folder_icon;
166
167 /*
168 * The Trash folder should only be displayed if message recycling has
169 * been enabled, i.e. when deleted is a message moved to the trash or
170 * deleted forever?
171 */
172 $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
173 'target="'.$box['ViewLink']['Target'].'" ' .
174 'style="text-decoration:none">';
175
176 if ($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
177 $pre .= $view_link;
178
179 // Boxes with unread messages should be emphasized
180 if ($box['UnreadCount'] > 0) {
181 $pre .= '<em>';
182 $end .= '</em>';
183 }
184 $end .= '</a>';
185
186 // Print unread info
187 if ($box['MessageCount'] > 0 || count($box['ChildBoxes'])) {
188 if (!empty($unseen_str)) {
189 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
190 }
191 $end .= "\n<small>" .
192 '&nbsp;&nbsp;[<a href="empty_trash.php">'. _("Purge").'</a>]' .
193 '</small>';
194 }
195 } else {
196 // Add a few other things for all other folders...
197 if (!$box['IsNoSelect']) {
198 $pre .= $view_link;
199
200 // Boxes with unread messages should be emphasized
201 if ($box['UnreadCount'] > 0) {
202 $pre .= '<em>';
203 $end .= '</em>';
204 }
205 $end .= '</a>';
206 }
207
208 // Display unread info...
209 if (!empty($unseen_str)) {
210 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
211 }
212 }
213
214 $span = '';
215 $spanend = '';
216 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
217 $span = '<span class="leftspecial">';
218 $spanend = '</span>';
219 } elseif ( $box['IsNoSelect'] ) {
220 $span = '<span class="leftnoselect">';
221 $spanend = '</span>';
222 }
223
224 /********
225 * Pulling imapConnection due to segfaults that cannot be tracked down. Best
226 * we can determine,its some combination of this var and >= 4 plugins enabled.
227 * No further clue from anyone.
228 ********
229
230 // let plugins fiddle with end of line
231 $end .= concat_hook_function('left_main_after_each_folder',
232 array(isset($numMessages) ? $numMessages : '',
233 $box['MailboxFullName'], $settings['imapConnection']));
234 */
235
236 $end .= '</span>';
237
238 $out = '';
239 if (!$box['IsRoot']) {
240 $out = $span . $pre .
241 str_replace(
242 array(' ','<','>'),
243 array('&nbsp;','&lt;','&gt;'),
244 $box['MailboxName']) .
245 $end . $spanend . '<br />' . "\n";
246 $indent_factor++;
247 }
248
249 if (!$box['IsCollapsed'] || $box['IsRoot']) {
250 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
251 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $indent_factor);
252 }
253 }
254
255 return $out;
256 }
257
258 // Retrieve the template vars
259 extract($t);
260
261 ?>
262 <body class="sqm_leftMain">
263 <div class="sqm_leftMain">
264 <?php do_hook('left_main_before'); ?>
265 <table class="sqm_wrapperTable" cellspacing="0">
266 <tr>
267 <td>
268 <table cellspacing="0">
269 <tr>
270 <td style="text-align:center">
271 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
272 <span class="sqm_clock"><?php echo $clock; ?></span>
273 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
274 </td>
275 </tr>
276 </table>
277 <br />
278 <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
279 </td>
280 </tr>
281 </table>
282 <?php do_hook('left_main_after'); ?>
283 </div>