Converting images from gif to png
[squirrelmail.git] / templates / default_advanced / left_main.tpl
CommitLineData
93222bea 1<?php
2/**
3 * left_main.tpl
4 *
5 * Displays an experimental mailbox-tree with dhtml behaviour.
6 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
7 * See http://www.destroydrop.com/javascripts/tree/
8 *
9 * It only works on browsers which supports css and javascript.
10 *
11 * The following variables are avilable in this template:
12 * $clock - formatted string containing last refresh
13 * $settings - Array containing user perferences needed by this
14 * template. Indexes are as follows:
15 * $settings['imapConnection'] - IMAP connection handle. Needed to
16 * allow plugins to read the mailbox.
17 * $settings['iconThemePath'] - Path to the desired icon theme. If
18 * the user has disabled icons, this will be NULL.
19 * $settings['templateDirectory'] - contains the path to the current
20 * template directory. This may be needed by third
21 * party packages that don't integrate easily.
22 * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
23 * wants to see unread message count on mailboxes
24 * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
25 * user has enabled cummulative message counts.
26 * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
27 * user wants to see unread message count on ALL
28 * folders or just the Inbox.
29 * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
30 * user wants to see the total number of messages in
31 * addition to the unread message count.
32 * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
33 * has enabled collapsable folders.
34 * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
35 * chosen to tag "Special" folders in a different color
36 * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
37 * that get deleted go to the Trash folder. FALSE if
38 * they are permanently deleted.
39 *
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
64 * mailbox.
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.
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 * @author Steve Brown
78 */
79
80// include required files
81include_once(SM_PATH . 'templates/util_global.php');
82
83/*
84 * Recursively parse the mailbox structure to build the navigation tree.
85 *
86 * @param array $box Array containing mailbox data
87 * @param array $settings Array containing perferences, etc, passed to template
88 * @param integer $indent_factor Counter used to control indent spacing
89 * @since 1.5.2
90 * @author Steve Brown
91 */
92function buildMailboxTree ($box, $settings, $parent_node=-1) {
93 static $counter;
94
95 // stop condition
96 if (empty($box)) {
97 return '';
98 }
99
100 $image_path = $settings['templateDirectory'] . 'images/';
101 $out = '';
102 if ($box['IsRoot']) {
103 // Determine the path to the correct images
104 $out .= 'mailboxes = new dTree("mailboxes", "'.$image_path.'");'."\n";
105 $out .= 'mailboxes.config.inOrder = true;'."\n";
106 $counter = -1;
107 } else {
108 $counter++;
109 $name = $box['MailboxName'];
110 $pre = '<span style="white-space: nowrap;">';
111 $end = '';
112
113 // Get unseeen/total message info if needed
114 $unseen_str = '';
115 if ($settings['unreadNotificationEnabled']) {
116 // We only display the unread count if we on the Inbox or we are told
117 // to display it on all folders AND there is more than 1 unread message
118 if ( $settings['unreadNotificationAllFolders'] ||
119 (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
120 ) {
121 $unseen = $settings['unreadNotificationCummulative'] ?
122 $box['CummulativeUnreadCount'] :
123 $box['UnreadCount'];
124
125 if ($unseen > 0) {
126 $unseen_str = $unseen;
127
128 // Add the total messages if desired
129 if ($settings['unreadNotificationDisplayTotal']) {
130 $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
131 $box['CummulativeMessageCount'] :
132 $box['MessageCount']);
133 }
134
135 $unseen_str = '<span class="'.
136 ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
137 '">' . $unseen_str .
138 '</span>';
139 }
140 }
141 }
142
143 /**
144 * Add folder icon.
145 */
146 $img = '';
147 $img_open = '';
148 switch (true) {
149 case $box['IsInbox']:
94432dfa 150 $img = $image_path . 'base.png';
151 $img_open = $image_path . 'base.png';
93222bea 152 break;
153 case $box['IsTrash']:
94432dfa 154 $img = $image_path . 'trash.png';
155 $img_open = $image_path . 'trash.png';
93222bea 156 break;
157 case $box['IsNoSelect']:
158 case $box['IsNoInferiors']:
94432dfa 159 $img = $image_path . 'page.png';
160 $img_open = $image_path . 'page.png';
93222bea 161 break;
162 default:
94432dfa 163 $img = $image_path . 'folder.png';
164 $img_open = $image_path . 'folderopen.png';
93222bea 165 break;
166 }
167
168 $display_folder = true;
169 if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) {
170 $display_folder = false;
171 }
172
173 if($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
174 // Boxes with unread messages should be emphasized
175 if ($box['UnreadCount'] > 0) {
176 $pre .= '<em>';
177 $end .= '</em>';
178 }
179
180 // Print unread info
181 if ($box['UnreadCount'] > 0) {
182 if (!empty($unseen_str)) {
183 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
184 }
185 }
186 } else {
187 // Add a few other things for all other folders...
188 if (!$box['IsNoSelect']) {
189 // Boxes with unread messages should be emphasized
190 if ($box['UnreadCount'] > 0) {
191 $pre .= '<em>';
192 $end .= '</em>';
193 }
194 }
195
196 // Display unread info...
197 if (!empty($unseen_str)) {
198 $end .= '&nbsp;<small>('.$unseen_str.')</small>';
199 }
200 }
201
202 $span = '';
203 $spanend = '';
204 if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
205 $span = '<span class="leftspecial">';
206 $spanend = '</span>';
207 } elseif ( $box['IsNoSelect'] ) {
208 $span = '<span class="leftnoselect">';
209 $spanend = '</span>';
210 }
211
212 /**
213 * NOTE: Plugins would horribly break this advanced tree, so we are
214 * going to skip that part altogether.
215 */
216
217 $name = str_replace(
218 array(' ','<','>'),
219 array('&nbsp;','&lt;','&gt;'),
220 $box['MailboxName']);
221 $title = $name;
222
223 if ($box['IsNoSelect']) {
224 $url = '';
225 $target = '';
226 } else {
227 $url = $box['ViewLink']['URL'];
228 $target = $box['ViewLink']['Target'];
229 $name = $span . $pre . $name . $end . $spanend;
230 }
231
232 if ($display_folder) {
233 $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' .
234 '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' .
235 '"'.$target.'", ' .
236 '"'.$img.'", ' .
237 '"'.$img_open.'"' .
238 ');'."\n";
239 }
240 }
241
242 $parent_node = $counter;
243 for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
244 $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $parent_node);
245 }
246
247 if ($box['IsRoot']) {
248 $out .= 'document.write(mailboxes);'."\n";
249 }
250
251 return $out;
252}
253
254/* retrieve the template vars */
255extract($t);
256
257?>
258<body class="sqm_leftMain">
259<script type="text/javascript">
260<!--
261/**
262 * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
263 * See http://www.destroydrop.com/javascripts/tree/
264 *
265 * |---------------------------------------------------|
266 * | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
267 * |---------------------------------------------------|
268 * | Copyright (c) 2002-2003 Geir Landrö |
269 * | |
270 * | This script can be used freely as long as all |
271 * | copyright messages are intact. |
272 * | |
273 * | Updated: 17.04.2003 |
274 * |---------------------------------------------------|
275 **/
276//-->
277</script>
278<div class="sqm_leftMain">
279<?php do_hook('left_main_before'); ?>
280<div class="dtree">
281<table class="sqm_wrapperTable" cellspacing="0">
282 <tr>
283 <td>
284 <table cellspacing="0">
285 <tr>
286 <td style="text-align:center">
287 <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
288 <span class="sqm_clock"><?php echo $clock; ?></span>
289 <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
290 </td>
291 </tr>
292 </table>
293 </td>
294 </tr>
295</table>
296<p>
297<a href="javascript:mailboxes.openAll()">Open All</a>
298&nbsp;&nbsp;|&nbsp;&nbsp;
299<a href="javascript:mailboxes.closeAll()">Close All</a>
300<?php
301if ($settings['messageRecyclingEnabled']) {
302 echo '<br />';
303 echo '<a href="empty_trash.php">Purge Trash</a>';
304}
305?>
306</p>
307<script type="text/javascript">
308<!--
309<?php echo buildMailboxTree($mailboxes, $settings); ?>
310-->
311</script>
312</div>
313<?php do_hook('left_main_after'); ?>
314</div>