left_main.tpl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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['iconThemePath'] - Path to the desired icon theme. If
  16. * the user has disabled icons, this will be NULL.
  17. * $settings['templateID'] - contains the ID of the current
  18. * template set. This may be needed by third
  19. * party packages that don't integrate easily.
  20. * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user
  21. * wants to see unread message count on mailboxes
  22. * $settings['unreadNotificationCummulative'] - Boolean TRUE if the
  23. * user has enabled cummulative message counts.
  24. * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the
  25. * user wants to see unread message count on ALL
  26. * folders or just the Inbox.
  27. * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the
  28. * user wants to see the total number of messages in
  29. * addition to the unread message count.
  30. * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user
  31. * has enabled collapsable folders.
  32. * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has
  33. * chosen to tag "Special" folders in a different color
  34. * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages
  35. * that get deleted go to the Trash folder. FALSE if
  36. * they are permanently deleted.
  37. *
  38. * $mailboxes - Associative array of current mailbox structure.
  39. * Provided so template authors know what they have to
  40. * work with when building a custom mailbox tree.
  41. * Array contains the following elements:
  42. * $a['MailboxName'] = String containing the name of the mailbox
  43. * $a['MailboxFullName'] = String containing full IMAP name of mailbox
  44. * $a['MessageCount'] = integer of all messages in the mailbox
  45. * $a['UnreadCount'] = integer of unseen message in the mailbox
  46. * $a['ViewLink'] = array containing elements needed to view the
  47. * mailbox. Elements are:
  48. * 'Target' = target frame for link
  49. * 'URL' = target URL for link
  50. * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent"
  51. * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special"
  52. * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox
  53. * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect"
  54. * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed
  55. * $a['CollapseLink'] = array containg elements needed to expand/collapse
  56. * the mailbox. Elements are:
  57. * 'Target' = target frame for link
  58. * 'URL' = target URL for link
  59. * 'Icon' = the icon to use, based on user prefs
  60. * $a['ChildBoxes'] = array containing this same data structure for
  61. * each child folder/mailbox of the current
  62. * mailbox.
  63. * $a['CummulativeMessageCount'] = integer of total messages in all
  64. * folders in this mailbox, exlcuding
  65. * trash folders.
  66. * $a['CummulativeUnreadCount'] = integer of total unseen messages
  67. * in all folders in this mailbox,
  68. * excluding trash folders.
  69. *
  70. * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  71. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  72. * @version $Id$
  73. * @package squirrelmail
  74. * @subpackage templates
  75. * @author Steve Brown
  76. */
  77. /*
  78. * Recursively parse the mailbox structure to build the navigation tree.
  79. *
  80. * @param array $box Array containing mailbox data
  81. * @param array $settings Array containing perferences, etc, passed to template
  82. * @param string $icon_theme_path
  83. * @param integer $indent_factor Counter used to control indent spacing
  84. * @since 1.5.2
  85. * @author Steve Brown
  86. */
  87. function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) {
  88. static $counter;
  89. // stop condition
  90. if (empty($box)) {
  91. return '';
  92. }
  93. $out = '';
  94. if ($box['IsRoot']) {
  95. // Determine the path to the correct images
  96. $out .= 'mailboxes = new dTree("mailboxes", "'.$icon_theme_path.'");'."\n";
  97. $out .= 'mailboxes.config.inOrder = true;'."\n";
  98. $counter = -1;
  99. } else {
  100. $counter++;
  101. $name = $box['MailboxName'];
  102. $pre = '<span style="white-space: nowrap;">';
  103. $end = '';
  104. // Get unseeen/total message info if needed
  105. $unseen_str = '';
  106. if ($settings['unreadNotificationEnabled']) {
  107. // We only display the unread count if we on the Inbox or we are told
  108. // to display it on all folders AND there is more than 1 unread message
  109. if ( $settings['unreadNotificationAllFolders'] ||
  110. (!$settings['unreadNotificationAllFolders'] && strtolower($box['MailboxFullName'])=='inbox')
  111. ) {
  112. $unseen = $settings['unreadNotificationCummulative'] ?
  113. $box['CummulativeUnreadCount'] :
  114. $box['UnreadCount'];
  115. if (!$box['IsNoSelect'] && ($unseen > 0 || $settings['unreadNotificationDisplayTotal'])) {
  116. $unseen_str = $unseen;
  117. // Add the total messages if desired
  118. if ($settings['unreadNotificationDisplayTotal']) {
  119. $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
  120. $box['CummulativeMessageCount'] :
  121. $box['MessageCount']);
  122. }
  123. $unseen_str = '<span class="'.
  124. ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
  125. '">' . $unseen_str .
  126. '</span>';
  127. }
  128. }
  129. }
  130. /**
  131. * Add folder icon.
  132. */
  133. $img = '';
  134. $img_open = '';
  135. switch (true) {
  136. case $box['IsInbox']:
  137. $img = 'base.png';
  138. $img_open = 'base.png';
  139. break;
  140. case $box['IsTrash']:
  141. $img = 'trash.png';
  142. $img_open = 'trash.png';
  143. break;
  144. case $box['IsNoSelect']:
  145. case $box['IsNoInferiors']:
  146. $img = 'page.png';
  147. $img_open = 'page.png';
  148. break;
  149. default:
  150. $img = 'folder.png';
  151. $img_open = 'folderopen.png';
  152. break;
  153. }
  154. $display_folder = true;
  155. if (!$settings['messageRecyclingEnabled'] && $box['IsTrash']) {
  156. $display_folder = false;
  157. }
  158. if($settings['messageRecyclingEnabled'] && $box['IsTrash']) {
  159. // Boxes with unread messages should be emphasized
  160. if ($box['UnreadCount'] > 0) {
  161. $pre .= '<em>';
  162. $end .= '</em>';
  163. }
  164. // Print unread info
  165. if ($box['UnreadCount'] > 0) {
  166. if (!empty($unseen_str)) {
  167. $end .= '&nbsp;<small>('.$unseen_str.')</small>';
  168. }
  169. }
  170. } else {
  171. // Add a few other things for all other folders...
  172. if (!$box['IsNoSelect']) {
  173. // Boxes with unread messages should be emphasized
  174. if ($box['UnreadCount'] > 0) {
  175. $pre .= '<em>';
  176. $end .= '</em>';
  177. }
  178. }
  179. // Display unread info...
  180. if (!empty($unseen_str)) {
  181. $end .= '&nbsp;<small>('.$unseen_str.')</small>';
  182. }
  183. }
  184. // Add any extra output that may have been added by plugins, etc
  185. //
  186. if (!empty($box['ExtraOutput']))
  187. $end .= $box['ExtraOutput'];
  188. $span = '';
  189. $spanend = '';
  190. if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
  191. $span = '<span class="leftspecial">';
  192. $spanend = '</span>';
  193. } elseif ( $box['IsNoSelect'] ) {
  194. $span = '<span class="leftnoselect">';
  195. $spanend = '</span>';
  196. }
  197. $name = str_replace(
  198. array(' ','<','>'),
  199. array('&nbsp;','&lt;','&gt;'),
  200. $box['MailboxName']);
  201. $title = $name;
  202. if ($box['IsNoSelect']) {
  203. $url = '';
  204. $target = '';
  205. } else {
  206. $url = $box['ViewLink']['URL'];
  207. $target = $box['ViewLink']['Target'];
  208. $name = $span . $pre . $name . $end . $spanend;
  209. }
  210. if ($display_folder) {
  211. $out .= 'mailboxes.add('.$counter.', '.$parent_node.', ' .
  212. '"'.addslashes($name).'", "'.$url.'", "'.$title.'", ' .
  213. '"'.$target.'", ' .
  214. '"'.getIconPath($icon_theme_path, $img).'", ' .
  215. '"'.getIconPath($icon_theme_path, $img_open).'"' .
  216. ');'."\n";
  217. }
  218. }
  219. $parent_node = $counter;
  220. for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
  221. $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $icon_theme_path, $parent_node);
  222. }
  223. if ($box['IsRoot']) {
  224. $out .= 'document.write(mailboxes);'."\n";
  225. }
  226. return $out;
  227. //FIXME: somewhere above, need to insert the left_main_after_each_folder hook, or if no plugin hooks allowed in templates, at least the output from that hook (but I think it might be impossible not to have the hook here in this fxn
  228. }
  229. /* retrieve the template vars */
  230. extract($t);
  231. ?>
  232. <body class="sqm_leftMain">
  233. <script type="text/javascript">
  234. <!--
  235. /**
  236. * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily.
  237. * See http://www.destroydrop.com/javascripts/tree/
  238. *
  239. * |---------------------------------------------------|
  240. * | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
  241. * |---------------------------------------------------|
  242. * | Copyright (c) 2002-2003 Geir Landrö |
  243. * | |
  244. * | This script can be used freely as long as all |
  245. * | copyright messages are intact. |
  246. * | |
  247. * | Updated: 17.04.2003 |
  248. * |---------------------------------------------------|
  249. **/
  250. //-->
  251. </script>
  252. <div class="sqm_leftMain">
  253. <?php if (!empty($plugin_output['left_main_before'])) echo $plugin_output['left_main_before']; ?>
  254. <div class="dtree">
  255. <table class="sqm_wrapperTable" cellspacing="0">
  256. <tr>
  257. <td>
  258. <table cellspacing="0">
  259. <tr>
  260. <td style="text-align:center">
  261. <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
  262. <span class="sqm_clock"><?php echo $clock; ?></span>
  263. <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check mail"); ?></a>]</small></span>
  264. </td>
  265. </tr>
  266. </table>
  267. </td>
  268. </tr>
  269. </table>
  270. <p>
  271. <a href="javascript:mailboxes.openAll()"><?php echo _("Open all") ?></a>
  272. &nbsp;&nbsp;|&nbsp;&nbsp;
  273. <a href="javascript:mailboxes.closeAll()"><?php echo _("Close all") ?></a>
  274. <?php
  275. if ($settings['messageRecyclingEnabled']) {
  276. echo '<br />';
  277. echo '<a href="empty_trash.php">' . _("Purge trash") . '</a>';
  278. }
  279. ?>
  280. </p>
  281. <script type="text/javascript">
  282. <!--
  283. <?php echo buildMailboxTree($mailboxes, $settings, $icon_theme_path); ?>
  284. -->
  285. </script>
  286. </div>
  287. <?php if (!empty($plugin_output['left_main_after'])) echo $plugin_output['left_main_after']; ?>
  288. </div>