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