New icon theming. Also added basic template for left_main.php
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 21 Feb 2006 00:02:30 +0000 (00:02 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 21 Feb 2006 00:02:30 +0000 (00:02 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10781 7612ce4b-ef26-0410-bec9-ea0150e637f0

16 files changed:
images/themes/default/theme.php
images/themes/template/index.php [new file with mode: 0644]
images/themes/template/theme.php [new file with mode: 0644]
images/themes/xp/theme.php
include/load_prefs.php
include/options/display.php
src/left_main.php
src/right_main.php
src/search.php
templates/default/left_main.tpl [new file with mode: 0644]
templates/default/left_main_advanced.tpl [new file with mode: 0644]
templates/default/message_list.tpl
templates/default/stylesheet.tpl
templates/util_global.php [new file with mode: 0644]
templates/util_left_main.php [new file with mode: 0644]
templates/util_message_list.php

index 245d0436f6b4a3ec6d6eedc056703d5c56af6a33..13e5aed695e6f6f0aff7f8bf9619d8e9969b806d 100644 (file)
@@ -9,5 +9,5 @@
  * @package squirrelmail
  * @subpackage themes
  */
  * @package squirrelmail
  * @subpackage themes
  */
-    $icon_themes[] = array('NAME'=>_("Default"),'PATH'=> 'default');
+    $icon_themes[] = array('NAME'=>_("Default"),'PATH'=> SM_PATH.'images/');
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
diff --git a/images/themes/template/index.php b/images/themes/template/index.php
new file mode 100644 (file)
index 0000000..007b4c4
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/**
+ * index.php
+ *
+ * This file simply takes any attempt to view source files and sends those
+ * people to the login screen. At this point no attempt is made to see if the
+ * person is logged in or not.
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage themes
+ */
+
+header('Location: ../index.php');
+
+?>
\ No newline at end of file
diff --git a/images/themes/template/theme.php b/images/themes/template/theme.php
new file mode 100644 (file)
index 0000000..a062486
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Theme description
+ *
+ * @copyright &copy; 2004-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage themes
+ */
+    $icon_themes[] = array('NAME'=>_("Template Default"),'PATH'=> $sTplDir.'images/');
+?>
\ No newline at end of file
index aff67886ca277dd4fd68bf84ef04005cf3895d43..e7a76edd1cde06511c7f98ed931e891a3c06d401 100644 (file)
@@ -9,5 +9,5 @@
  * @package squirrelmail
  * @subpackage themes
  */
  * @package squirrelmail
  * @subpackage themes
  */
-    $icon_themes[] = array('NAME'=>_("XP"),'PATH'=> 'xp');
+    $icon_themes[] = array('NAME'=>_("XP"),'PATH'=> SM_PATH . 'images/themes/xp/');
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index 06848aee8327b7e40800548e7beb1d6d7a741807..337efc1dda8a18cd6ee8274ce25af3697385bebd 100644 (file)
@@ -103,7 +103,14 @@ if (!defined('download_php')) {
 }
 
 // user's icon theme, if using icons
 }
 
 // user's icon theme, if using icons
-$icon_theme = getPref($data_dir, $username, 'icon_theme', 'xp' );
+$icon_theme = getPref($data_dir, $username, 'icon_theme', 'images/themes/xp/' );
+
+/*
+ * NOTE: The $icon_theme_path var should contain the path to the icon 
+ *       theme to use.  If the admin has disabled icons, or the user has
+ *       set the icon theme to "None," no icons will be used.
+ */
+$icon_theme_path = (!$use_icons || $icon_theme=='none') ? NULL : $icon_theme;
 
 // show (or not) flag and unflag buttons on mailbox list screen
 $show_flag_buttons = getPref($data_dir, $username, 'show_flag_buttons', SMPREF_ON );
 
 // show (or not) flag and unflag buttons on mailbox list screen
 $show_flag_buttons = getPref($data_dir, $username, 'show_flag_buttons', SMPREF_ON );
index 0c07e5af9841abfa323243e859015c391dcbf34c..573f2ba4f6af2a4d5b61d50c65883c452afa1898 100644 (file)
@@ -216,6 +216,28 @@ function load_optpage_data_display() {
                            SMPREF_TIME_24HR => _("24-hour clock"))
     );
 
                            SMPREF_TIME_24HR => _("24-hour clock"))
     );
 
+    /* Icon theme selection */
+    if ($use_icons) {
+        global $icon_themes, $icon_theme;
+        $temp = array();
+        for ($count = 0; $count < sizeof($icon_themes); $count++) {
+            $temp[$count] = $icon_themes[$count]['NAME'];
+            if ($icon_theme == $icon_themes[$count]['PATH'])
+                $value = $count;
+        }
+        if (sizeof($icon_themes) > 0) {
+            $optvals[SMOPT_GRP_GENERAL][] = array(
+                'name'          => 'icon_theme',
+                'caption'       => _("Icon Theme"),
+                'type'          => SMOPT_TYPE_STRLIST,
+                'refresh'       => SMOPT_REFRESH_NONE,
+                'posvals'       => $temp,
+                'initial_value' => $value,
+                'save'          => 'icon_theme_save'
+            );
+        }
+    }
+
     /*** Load the General Options into the array ***/
     $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
     $optvals[SMOPT_GRP_MAILBOX] = array();
     /*** Load the General Options into the array ***/
     $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
     $optvals[SMOPT_GRP_MAILBOX] = array();
@@ -242,27 +264,6 @@ function load_optpage_data_display() {
         'refresh' => SMOPT_REFRESH_NONE
     );
 
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    if ($use_icons) {
-        global $icon_themes, $icon_theme;
-        $temp = array();
-        for ($count = 0; $count < sizeof($icon_themes); $count++) {
-            $temp[$count] = $icon_themes[$count]['NAME'];
-            if ($icon_theme == $icon_themes[$count]['PATH'])
-                $value = $count;
-        }
-        if (sizeof($icon_themes) > 0) {
-            $optvals[SMOPT_GRP_MAILBOX][] = array(
-                'name'          => 'icon_theme',
-                'caption'       => _("Message Flags Icon Theme"),
-                'type'          => SMOPT_TYPE_STRLIST,
-                'refresh'       => SMOPT_REFRESH_NONE,
-                'posvals'       => $temp,
-                'initial_value' => $value,
-                'save'          => 'icon_theme_save'
-            );
-        }
-    }
-
     $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'show_flag_buttons',
         'caption' => _("Show Flag / Unflag Buttons"),
     $optvals[SMOPT_GRP_MAILBOX][] = array(
         'name'    => 'show_flag_buttons',
         'caption' => _("Show Flag / Unflag Buttons"),
index 222cd49d4521eb8b504b2a1e6098a8f837cfc023..262a97175823828a5fe6d2117d84e69fcb5e2f86 100644 (file)
@@ -26,6 +26,10 @@ require_once(SM_PATH . 'functions/page_header.php');
 require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'functions/date.php');
 
 require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'functions/date.php');
 
+/** add required includes */
+include_once(SM_PATH . 'templates/util_global.php');
+include_once(SM_PATH . 'templates/util_left_main.php');
+
 /* These constants are used for folder stuff. */
 define('SM_BOX_UNCOLLAPSED', 0);
 define('SM_BOX_COLLAPSED',   1);
 /* These constants are used for folder stuff. */
 define('SM_BOX_UNCOLLAPSED', 0);
 define('SM_BOX_COLLAPSED',   1);
@@ -33,170 +37,20 @@ define('SM_BOX_COLLAPSED',   1);
 /* --------------------- FUNCTIONS ------------------------- */
 
 
 /* --------------------- FUNCTIONS ------------------------- */
 
 
+
 /**
 /**
- * Recursive function to output a tree of folders.
- * It is called on a list of boxes and iterates over that tree.
+ * Recursive functions to output a tree of folders.
+ * They are called on a list of boxes and iterates over that tree.
  *
  *
+ * NOTE: These functions are deprecated and replaced with templates in 1.5.2.
+ *       They remain until the advanced tree tempalte is completed also,
+ *       at which point both functions below will be removed
+ * 
  * @since 1.3.0
  * @since 1.3.0
+ * @deprecated
  */
  */
-function ListBoxes ($boxes, $j=0 ) {
-    global $data_dir, $username, $color, $unseen_notify, $unseen_type,
-           $move_to_trash, $trash_folder, $collapse_folders, $imapConnection,
-           $use_icons, $icon_theme, $use_special_folder_color, $unseen_cum;
-
-    // stop condition
-    if (empty($boxes)) {
-        return;
-    }
-
-    $pre = '<span style="white-space: nowrap;">';
-    $end = '';
-    $collapse = false;
-    $unseen_found = false;
-    $unseen = 0;
-
-    $mailbox = $boxes->mailboxname_full;
-    $leader = str_repeat('&nbsp;&nbsp;',$j);
-    $mailboxURL = urlencode($mailbox);
-
-    /* get unseen/total messages information */
-    /* Only need to display info when option is set */
-    if (isset($unseen_notify) && ($unseen_notify > 1)) {
-        /* handle Cumulative Unread Message Notification */
-        if ($collapse && $unseen_cum) {
-            foreach ($boxes->mbxs as $cumn_box) {
-                if (!empty($cumn_box->unseen)) $boxes->unseen += $cumn_box->unseen;
-                if (!empty($cumn_box->total)) $boxes->total += $cumn_box->total;
-            }
-        }
-        if (($boxes->unseen !== false) || ($boxes->total !== false)) {
-            if ($boxes->unseen !== false) {
-                $unseen = $boxes->unseen;
-            }
-            /*
-             * Should only display unseen info if the folder is inbox
-             * or you set the option for all folders
-             */
-            if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
-                $unseen_string = $unseen;
-                /* If users requests, display message count too */
-                if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
-                    $unseen_string .= '/' . $boxes->total;
-                }
-                if (isset($boxes->recent) && $boxes->recent) {
-                    $unseen_string = "<span class=\"leftrecent\">($unseen_string)</span>";
-                } else {
-                    $unseen_string = "<span class=\"leftunseen\">($unseen_string)</span>";
-                }
-
-                /*
-                 * Finally allow the script to display the values by setting a boolean.
-                 * This can only occur if the unseen count is great than 0 (if you have
-                 * unseen count only), or you have the message count too.
-                 */
-                if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
-                    $unseen_found = true;
-                }
-            }
-        }
-    }
-
-    if (isset($boxes->mbxs[0]) && $collapse_folders) {
-        $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
-        $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
-        $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
-        if ($collapse) {
-            if ($use_icons && $icon_theme != 'none') {
-                $link .= "unfold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/plus.png" border="0" height="7" width="7" />&nbsp;';
-            } else {
-                $link .= "unfold=$mailboxURL\">$leader+&nbsp;";
-            }
-        } else {
-            if ($use_icons && $icon_theme != 'none') {
-                $link .= "fold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/minus.png" border="0" height="7" width="7" />&nbsp;';
-            } else {
-                $link .= "fold=$mailboxURL\">$leader-&nbsp;";
-            }
-        }
-        $link .= '</a>';
-        $pre .= $link;
-    } else {
-        $pre.= $leader . '&nbsp;&nbsp;';
-    }
-
-    /* If there are unseen message, bold the line. */
-    if (($move_to_trash) && ($mailbox == $trash_folder)) {
-
-        if ( !is_numeric($boxes->total) ) {
-            $result = sqimap_status_messages($imapConnection, $mailbox);
-            $boxes->total = $result['MESSAGES'];
-            $boxes->unseen = $result['UNSEEN'];
-        }
-
-        $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
-        if ($unseen > 0) {
-            $pre .= '<b>';
-            $end .= '</b>';
-        }
-        $end .= '</a>';
-        if ($boxes->total > 0) {
-            /* Print unseen information. */
-            if ($unseen_found) {
-                $end .= "&nbsp;<small>$unseen_string</small>";
-            }
-            $end .= "\n<small>" .
-                 '&nbsp;&nbsp;[<a href="empty_trash.php">'._("Purge").'</a>]'.
-                 '</small>';
-        }
-    } else {
-        if (!$boxes->is_noselect) {
-            $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
-            if ($unseen > 0) {
-                $pre .= '<b>';
-                $end .= '</b>';
-            }
-            $end .= '</a>';
-        }
-        /* Print unseen information. */
-        if ($unseen_found) {
-            $end .= "&nbsp;<small>$unseen_string</small>";
-        }
-
-    }
-
-    $span = '';
-    $spanend = '';
-    if ($use_special_folder_color && $boxes->is_special) {
-        $span = "<span class=\"leftspecial\">";
-        $spanend = "</span>";
-    } elseif ( $boxes->is_noselect ) {
-        $span = "<span class=\"leftnoselect\">";
-        $spanend = '</span>';
-    }
-
-
-    // let plugins fiddle with end of line
-    $end .= concat_hook_function('left_main_after_each_folder',
-        array(isset($numMessages) ? $numMessages : '',
-              $boxes->mailboxname_full, $imapConnection));
-
-    $end .= '</span>';
-
-    if (!$boxes->is_root) {
-        echo "" . $span . $pre .
-            str_replace(
-                array(' ','<','>'),
-                array('&nbsp;','&lt;','&gt;'),
-                $boxes->mailboxname_sub) .
-            $end. $spanend .'<br />' . "\n";
-        $j++;
-    }
-
-    if (!$collapse || $boxes->is_root) {
-        for ($i = 0; $i <count($boxes->mbxs); $i++) {
-            ListBoxes($boxes->mbxs[$i],$j);
-        }
-    }
+function ListBoxes ($boxes, $j=0) {
+    return '';
 }
 
 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
 }
 
 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
@@ -314,6 +168,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
         array(isset($numMessages) ? $numMessages : '',
               $boxes->mailboxname_full, $imapConnection));
 
         array(isset($numMessages) ? $numMessages : '',
               $boxes->mailboxname_full, $imapConnection));
 
+    $out = '';
     if (!$boxes->is_root) {
         if ($use_folder_images) {
             if ($boxes->is_inbox) {
     if (!$boxes->is_root) {
         if ($use_folder_images) {
             if ($boxes->is_inbox) {
@@ -334,7 +189,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
             $folder_img = '';
         }
         if (!isset($boxes->mbxs[0])) {
             $folder_img = '';
         }
         if (!isset($boxes->mbxs[0])) {
-            echo '   ' . html_tag( 'div',
+            $out .= '   ' . html_tag( 'div',
                             $pre . $folder_img .
                                 str_replace( array(' ','<','>'),
                                              array('&nbsp;','&lt;','&gt;'),
                             $pre . $folder_img .
                                 str_replace( array(' ','<','>'),
                                              array('&nbsp;','&lt;','&gt;'),
@@ -343,27 +198,29 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
                             'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
         } else {
 
                             'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
         } else {
 
-            echo '   ' . html_tag( 'div',
+            $out .= '   ' . html_tag( 'div',
                             $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
                             'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
                             $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
                             'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
-            echo '   <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
+            $out .= '   <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
         }
     }
 
     $visible = ($collapse ? ' style="display:none"' : ' style="display:block"');
     if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
         }
     }
 
     $visible = ($collapse ? ' style="display:none"' : ' style="display:block"');
     if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
-        echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
+        $out .= html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
 
     if ($j !='ID.0000') {
        $j = $j .'.0000';
     }
     for ($i = 0; $i <count($boxes->mbxs); $i++) {
         $j++;
 
     if ($j !='ID.0000') {
        $j = $j .'.0000';
     }
     for ($i = 0; $i <count($boxes->mbxs); $i++) {
         $j++;
-        ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
+        $out .= ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
     }
     if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
     }
     if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
-        echo '</div>'."\n\n";
+        $out .= '</div>'."\n\n";
     }
     }
+    
+    return $out;
 }
 
 
 }
 
 
@@ -402,18 +259,9 @@ if (!empty($left_refresh) &&
  * $advanced_tree and is a boolean var which is default set to default
  * SM behaviour.
  * Setting $advanced tree to true causes SM to display a experimental
  * $advanced_tree and is a boolean var which is default set to default
  * SM behaviour.
  * Setting $advanced tree to true causes SM to display a experimental
- * mailbox-tree with dhtml behaviour.
- * It only works on browsers which supports css and javascript. The used
- * javascript is experimental and doesn't support all browsers.
- * It has been tested on IE6 an Konquerer 3.0.0-2.
- * It is now tested and working on: (please test and update this list)
- * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
- * XWindow: ?
- * Mac: ?
- * In the function ListAdvancedBoxes there is another var $use_folder_images.
- * setting this to true is only usefull if the images exists in ../images.
- *
- * Feel free to experiment with the code and report bugs and enhancements
+ * mailbox-tree with dhtml behaviour.  
+ * 
+ * See templates/default/left_main_advanced.tpl
  **/
 
 /* set this to true if you want to see a nicer mailboxtree */
  **/
 
 /* set this to true if you want to see a nicer mailboxtree */
@@ -421,238 +269,6 @@ if (empty($advanced_tree)) {
     $advanced_tree=false;
 }
 
     $advanced_tree=false;
 }
 
-if ($advanced_tree) {
-$xtra .= <<<HEREDOC
-<script type="text/javascript">
-<!--
-    function preload() {
-      if (document.images) {
-        var treeImages = new Array;
-        var arguments = preload.arguments;
-        for (var i = 0; i<arguments.length; i++) {
-          treeImages[i] = new Image();
-          treeImages[i].src = arguments[i];
-        }
-      }
-    }
-    var vTreeImg;
-    var vTreeDiv;
-    var vTreeSrc;
-    function fTreeTimeout() {
-      if (vTreeDiv.readyState == "complete")
-        vTreeImg.src = vTreeSrc;
-      else
-        setTimeout("fTreeTimeout()", 100);
-    }
-    function hidechilds(img) {
-      id = img.id + ".0000";
-      form_id = "mbx[" + img.id +"F]";
-      if (document.all) { //IE, Opera7
-        div = document.all[id];
-        if (div) {
-           if (div.style.display == "none") {
-              vTreeSrc = "../images/minus.png";
-              style = "block";
-              value = 0;
-           }
-           else {
-              vTreeSrc = "../images/plus.png";
-              style = "none";
-              value = 1;
-           }
-           vTreeImg = img;
-           vTreeDiv = div;
-           if (typeof vTreeDiv.readyState != "undefined") //IE
-              setTimeout("fTreeTimeout()",100);
-           else //Non IE
-              vTreeImg.src = vTreeSrc;
-           div.style.display = style;
-           document.all[form_id].value = value;
-        }
-      }
-      else if (document.getElementById) { //Gecko
-        div = document.getElementById(id);
-        if (div) {
-           if (div.style.display == "none") {
-              src = "../images/minus.png";
-              style = "block";
-              value = 0;
-           }
-           else {
-              src = "../images/plus.png";
-              style = "none";
-              value = 1;
-           }
-           div.style.display = style;
-           img.src = src;
-           document.getElementById(form_id).value = value;
-        }
-      }
-    }
-   function buttonover(el,on) {
-      if (!on) {
-         el.style.background="$color[0]";}
-      else {
-         el.style.background="$color[9]";}
-   }
-   function buttonclick(el,on) {
-      if (!on) {
-         el.style.border="groove";}
-      else {
-         el.style.border="ridge";}
-   }
-   function hideframe(hide) {
-      left_size = "$left_size";
-      if (document.all) {
-        masterf = window.parent.document.all["fs1"];
-        leftf = window.parent.document.all["left"];
-        leftcontent = document.all["leftframe"];
-        leftbutton = document.all["showf"];
-      } else if (document.getElementById) {
-        masterf = window.parent.document.getElementById("fs1");
-        leftf = window.parent.document.getElementById("left");
-        leftcontent = document.getElementById("leftframe");
-        leftbutton = document.getElementById("showf");
-      } else {
-        return false;
-      }
-      if(hide) {
-         new_col = calc_col("20");
-         masterf.cols = new_col;
-         document.body.scrollLeft=0;
-         document.body.style.overflow="hidden";
-         leftcontent.style.display = "none";
-         leftbutton.style.display="block";
-      } else {
-         masterf.cols = calc_col(left_size);
-         document.body.style.overflow="";
-         leftbutton.style.display="none";
-         leftcontent.style.display="block";
-      }
-   }
-   function calc_col(c_w) {
-HEREDOC;
-   if ($location_of_bar == 'right') {
-       $xtra .= '     right=true;';
-   } else {
-       $xtra .= '     right=false;';
-   }
-$xtra .= <<<HEREDOC
-   if (right) {
-         new_col = '*,'+c_w;
-     } else {
-         new_col = c_w+',*';
-     }
-     return new_col;
-   }
-   function resizeframe(direction) {
-     if (document.all) {
-        masterf = window.parent.document.all["fs1"];
-     } else if (document.getElementById) {
-        window.parent.document.getElementById("fs1");
-     } else {
-        return false;
-     }
-HEREDOC;
-   if ($location_of_bar == 'right') {
-       $xtra .= '  colPat=/^\*,(\d+)$/;';
-   } else {
-       $xtra .= '  colPat=/^(\d+),.*$/;';
-   }
-$xtra .= <<<HEREDOC
-     old_col = masterf.cols;
-     colPat.exec(old_col);
-     if (direction) {
-        new_col_width = parseInt(RegExp.$1) + 25;
-     } else {
-        if (parseInt(RegExp.$1) > 35) {
-           new_col_width = parseInt(RegExp.$1) - 25;
-        }
-     }
-     masterf.cols = calc_col(new_col_width);
-   }
-//-->
-</script>
-
-HEREDOC;
-
-/* style definitions */
-
-$xtra .= <<<HEREDOC
-<style type="text/css">
-<!--
-  body {
-     margin: 0px 0px 0px 0px;
-     padding: 5px 5px 5px 5px;
-  }
-  img {
-     vertical-align: middle;
-  }
-  .button {
-     border:outset;
-     border-color: $color[9];
-     background:$color[0];
-     color:$color[6];
-     width:99%;
-     heigth:99%;
-  }
-  .mbx_par {
-     font-size:1.0em;
-     margin-left:4px;
-     margin-right:0px;
-     white-space: nowrap;
-  }
-  a.mbx_link {
-      text-decoration: none;
-      background-color: $color[0];
-      display: inline;
-  }
-  a:hover.mbx_link {
-      background-color: $color[9];
-  }
-  a.mbx_link img {
-      border-style: none;
-  }
-  .mbx_sub {
-     padding-left:5px;
-     padding-right:0px;
-     margin-left:4px;
-     margin-right:0px;
-     font-size:0.9em;
-     white-space: nowrap;
-  }
-  .par_area {
-     margin-top:0px;
-     margin-left:4px;
-     margin-right:0px;
-     padding-left:10px;
-     padding-bottom:5px;
-     border-left: solid;
-     border-left-width:0.1em;
-     border-left-color:$color[9];
-     border-bottom: solid;
-     border-bottom-width:0.1em;
-     border-bottom-color:$color[9];
-     display: block;
-  }
-  .mailboxes {
-     padding-bottom:3px;
-     margin-right:4px;
-     padding-right:4px;
-     margin-left:4px;
-     padding-left:4px;
-     border: groove;
-     border-width:0.1em;
-     border-color:$color[9];
-     background: $color[0];
-     font-size: smaller;
-  }
--->
-</style>
-
-HEREDOC;
-}
-
 // get mailbox list and cache it
 $mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
 
 // get mailbox list and cache it
 $mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
 
@@ -691,33 +307,7 @@ if ($auto_create_special && !isset($auto_create_done)) {
         $mailboxes=sqimap_get_mailboxes($imapConnection,true,$show_only_subscribed_folders);
 }
 
         $mailboxes=sqimap_get_mailboxes($imapConnection,true,$show_only_subscribed_folders);
 }
 
-if ($advanced_tree) {
-    echo "\n<body" .
-            ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
-            " class=\"leftmain\">\n<div class=\"leftmain\">\n";
-} else {
-    echo "\n<body class=\"leftmain\">\n<div class=\"leftmain\">\n";
-}
-
-do_hook('left_main_before');
-if ($advanced_tree) {
-   /* nice future feature, needs layout !! volunteers?   */
-   $right_pos = $left_size - 20;
-/*   echo '<div style="position:absolute;top:0;border=solid;border-width:0.1em;border-color:blue;"><div id="hidef" style="width=20;font-size:12"><a href="javascript:hideframe(true)"><b>&lt;&lt;</b></a></div>';
-   echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>&gt;&gt;</b></a></div>';
-   echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>&gt;</b></a></div>';
-   echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b>&lt;</b></a></div></div>';
-   echo '<div id="leftframe"><br /><br />';*/
-}
-
-echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
-    html_tag( 'tr' ) .
-    html_tag( 'td', '', 'left' ) .
-    html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0"' ) .
-    html_tag( 'tr' ) .
-    html_tag( 'td', '', 'center' ) .
-    '<font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
-
+$clock = '';
 if ($date_format != 6) {
     /* First, display the clock. */
     if ($hour_format == 1) {
 if ($date_format != 6) {
     /* First, display the clock. */
     if ($hour_format == 1) {
@@ -752,17 +342,11 @@ if ($date_format != 6) {
     }
     $clk = str_replace(' ','&nbsp;',$clk);
 
     }
     $clk = str_replace(' ','&nbsp;',$clk);
 
-    echo '<small><span style="white-space: nowrap;">'
+    $clock = '<small><span style="white-space: nowrap;">'
        . str_replace(' ', '&nbsp;', _("Last Refresh"))
        . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
 }
 
        . str_replace(' ', '&nbsp;', _("Last Refresh"))
        . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
 }
 
-/* Next, display the refresh button. */
-echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
-     _("Check mail") . "</a>]</small></div></td></tr></table><br />\n\n";
-
-/* Lastly, display the folder list. */
-
 if ( $collapse_folders ) {
     /* If directed, collapse or uncollapse a folder. */
     if (isset($fold)) {
 if ( $collapse_folders ) {
     /* If directed, collapse or uncollapse a folder. */
     if (isset($fold)) {
@@ -791,32 +375,54 @@ if (empty($unseen_notify)) {
         $unseen_notify = 0;
     }
 }
         $unseen_notify = 0;
     }
 }
+
 /**
  * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from
  * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond
  */
 $boxes = sqimap_mailbox_tree($imapConnection,$mailboxes,$show_only_subscribed_folders);
 
 /**
  * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from
  * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond
  */
 $boxes = sqimap_mailbox_tree($imapConnection,$mailboxes,$show_only_subscribed_folders);
 
+$mailbox_listing = '';
 if (isset($advanced_tree) && $advanced_tree) {
 if (isset($advanced_tree) && $advanced_tree) {
-    echo '<form name="collapse" action="left_main.php" method="post" ' .
+    $mailbox_listing = '<form name="collapse" action="left_main.php" method="post" ' .
          'enctype="multipart/form-data">'."\n";
          'enctype="multipart/form-data">'."\n";
-    echo '<button type="submit" class="button" onmouseover="buttonover(this,true)" onmouseout="buttonover(this,false)" onmousedown="buttonclick(this,true)" onmouseup="buttonclick(this,false)">'. _("Save folder tree") .'</button><br /><br />';
-    echo '<div id="mailboxes" class="mailboxes">'."\n\n";
+    $mailbox_listing .= '<button type="submit" class="button" onmouseover="buttonover(this,true)" onmouseout="buttonover(this,false)" onmousedown="buttonclick(this,true)" onmouseup="buttonclick(this,false)">'. _("Save folder tree") .'</button><br /><br />';
+    $mailbox_listing .= '<div id="mailboxes" class="mailboxes">'."\n\n";
     sqgetGlobalVar('mbx', $mbx, SQ_POST);
     if (!isset($mbx)) $mbx=NULL;
     sqgetGlobalVar('mbx', $mbx, SQ_POST);
     if (!isset($mbx)) $mbx=NULL;
-    ListAdvancedBoxes($boxes, $mbx);
-    echo '</div>';
-    echo '</form>'."\n";
+    $mailbox_listing .=ListAdvancedBoxes($boxes, $mbx);
+    $mailbox_listing .= '</div>';
+    $mailbox_listing .= '</form>'."\n";
 } else {
 } else {
-    ListBoxes($boxes);
+    $mailbox_listing = ListBoxes($boxes);
 }
 
 }
 
-do_hook('left_main_after');
-sqimap_logout($imapConnection);
+$mailbox_structure = getBoxStructure($boxes);
+
+$oTemplate->assign('clock', $clock);
+$oTemplate->assign('mailbox_listing', $mailbox_listing);
+$oTemplate->assign('location_of_bar', $location_of_bar);
+$oTemplate->assign('left_size', $left_size);
+
+$oTemplate->assign('mailboxes', $mailbox_structure);
+$oTemplate->assign('imapConnection', $imapConnection);
+
+$oTemplate->assign('unread_notification_enabled', $unseen_notify!=1);
+$oTemplate->assign('unread_notification_cummulative', $unseen_cum==1);
+$oTemplate->assign('unread_notification_allFolders', $unseen_notify == 3);
+$oTemplate->assign('unread_notification_displayTotal', $unseen_type == 2);
+$oTemplate->assign('collapsable_folders_enabled', $collapse_folders==1);
+$oTemplate->assign('icon_theme_path', $icon_theme_path);
+$oTemplate->assign('use_special_folder_color', $use_special_folder_color);
+$oTemplate->assign('message_recycling_enabled', $move_to_trash);
+$oTemplate->assign('trash_folder_name', $trash_folder);
+
+if (isset($advanced_tree) && $advanced_tree)    {
+    $oTemplate->display('left_main_advanced.tpl');
+}   else    { 
+    $oTemplate->display('left_main.tpl');
+}
 
 
-?>
-</td></tr></table>
-</div>
-<?php
+sqimap_logout($imapConnection);
 $oTemplate->display('footer.tpl');
 ?>
\ No newline at end of file
 $oTemplate->display('footer.tpl');
 ?>
\ No newline at end of file
index ccbaf6d4632fb9c18e873d5ea9c641431263ddf6..1ad78c92968bf7ca2326f2582ec65e5463312488 100644 (file)
@@ -331,9 +331,7 @@ if ($aMailbox['EXISTS'] > 0) {
     $oTemplate->assign('compact_paginator', $compact_paginator);
     $oTemplate->assign('javascript_on', $javascript_on);
     $oTemplate->assign('enablesort', (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false);
     $oTemplate->assign('compact_paginator', $compact_paginator);
     $oTemplate->assign('javascript_on', $javascript_on);
     $oTemplate->assign('enablesort', (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false);
-    // Aaaaaahhhhhhh FIX ME DO NOT USE the string "none" for a var when you mean the boolean false or null
-    $oTemplate->assign('icon_theme', (isset($icon_theme) && $icon_theme !== 'none') ? $icon_theme : false);
-    $oTemplate->assign('use_icons', (isset($use_icons)) ? $use_icons : false);
+    $oTemplate->assign('icon_theme_path', $icon_theme_path);
     $oTemplate->assign('aOrder', array_keys($aColumns));
     $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false);
     $oTemplate->assign('color', $color);
     $oTemplate->assign('aOrder', array_keys($aColumns));
     $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false);
     $oTemplate->assign('color', $color);
index f6fb1f2a18f10e3f096edbd3ea0aecd66dcf7fda..8e08124e4a9bed06558af31a0e63c2f817457e73 100644 (file)
@@ -1602,13 +1602,13 @@ if ($submit == $search_button_text) {
                         foreach ($aTemplate as $k => $v) {
                             $oTemplate->assign($k, $v);
                         }
                         foreach ($aTemplate as $k => $v) {
                             $oTemplate->assign($k, $v);
                         }
+
                         $oTemplate->assign('page_selector',  $page_selector);
                         $oTemplate->assign('page_selector_max', $page_selector_max);
                         $oTemplate->assign('compact_paginator', $compact_paginator);
                         $oTemplate->assign('javascript_on', $javascript_on);
                         $oTemplate->assign('enablesort', (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false);
                         $oTemplate->assign('page_selector',  $page_selector);
                         $oTemplate->assign('page_selector_max', $page_selector_max);
                         $oTemplate->assign('compact_paginator', $compact_paginator);
                         $oTemplate->assign('javascript_on', $javascript_on);
                         $oTemplate->assign('enablesort', (isset($aProps['config']['enablesort'])) ? $aProps['config']['enablesort'] : false);
-                        // Aaaaaahhhhhhh FIX ME DO NOT USE the string "none" for a var when you mean the boolean false or null
-                        $oTemplate->assign('icon_theme', (isset($icon_theme) && $icon_theme !== 'none') ? $icon_theme : false);
+                        $oTemplate->assign('icon_theme_path', $icon_theme_path);
                         $oTemplate->assign('use_icons', (isset($use_icons)) ? $use_icons : false);
                         $oTemplate->assign('aOrder', array_keys($aColumns));
                         $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false);
                         $oTemplate->assign('use_icons', (isset($use_icons)) ? $use_icons : false);
                         $oTemplate->assign('aOrder', array_keys($aColumns));
                         $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors: false);
diff --git a/templates/default/left_main.tpl b/templates/default/left_main.tpl
new file mode 100644 (file)
index 0000000..7991cd0
--- /dev/null
@@ -0,0 +1,268 @@
+<?php
+/**
+ * left_main.tpl
+ *
+ * Basic template to the left main window.  The following variables are 
+ * avilable in this template:
+ *      $clock           - formatted string containing last refresh
+ *      $mailbox_listing - string containing HTML to display default mailbox tree
+ *      $location_of_bar - string "left" or "right" indicating where the frame
+ *                         is located.  Currently only used in
+ *                         left_main_advanced.tpl
+ *      $left_size       - width of left column in pixels.  Currently only used
+ *                         in left_main_advanced.tpl
+ *      $imapConnection  - IMAP connection handle.  Needed to allow plugins to 
+ *                         read the mailbox.
+ *      $icon_theme_path - Path to the desired icon theme.  If no icon theme has
+ *                         been chosen, this will be the template directory.  If
+ *                         the user has disabled icons, this will be NULL.
+ *
+ *      $unread_notification_enabled - Boolean TRUE if the user wants to see unread 
+ *                             message count on mailboxes
+ *      $unread_notification_cummulative - Boolean TRUE if the user has enabled
+ *                             cummulative message counts.
+ *      $unread_notification_allFolders - Boolean TRUE if the user wants to see
+ *                             unread message count on ALL folders or just the
+ *                             mailbox.
+ *      $unread_notification_displayTotal - Boolean TRUE if the user wants to
+ *                             see the total number of messages in addition to
+ *                             the unread message count.
+ *      $collapsable_folders_enabled - Boolean TRUE if the user has enabled collapsable
+ *                             folders.
+ *      $use_special_folder_color - Boolean TRUE if the use has chosen to tag
+ *                             "Special" folders in a different color.
+ *      $message_recycling_enabled - Boolean TRUE if messages that get deleted go to
+ *                             the Trash folder.  FALSE if they are permanently
+ *                             deleted.
+ *      $trash_folder_name   - Name of the Trash folder.
+ * 
+ *      $mailboxes       - Associative array of current mailbox structure.
+ *                         Provided so template authors know what they have to
+ *                         work with when building a custom mailbox tree.
+ *                         Array contains the following elements:
+ *          $a['MailboxName']   = String containing the name of the mailbox
+ *          $a['MailboxFullName'] = String containing full IMAP name of mailbox
+ *          $a['MessageCount']  = integer of all messages in the mailbox
+ *          $a['UnreadCount']   = integer of unseen message in the mailbox
+ *          $a['ViewLink']      = array containing elements needed to view the
+ *                                mailbox.  Elements are:
+ *                                  'Target' = target frame for link
+ *                                  'URL'    = target URL for link
+ *          $a['IsRecent']      = boolean TRUE if the mailbox is tagged "recent"
+ *          $a['IsSpecial']     = boolean TRUE if the mailbox is tagged "special"
+ *          $a['IsRoot']        = boolean TRUE if the mailbox is the root mailbox
+ *          $a['IsNoSelect']    = boolean TRUE if the mailbox is tagged "noselect"
+ *          $a['IsCollapsed']   = boolean TRUE if the mailbox is currently collapsed
+ *          $a['CollapseLink']  = array containg elements needed to expand/collapse
+ *                                the mailbox.  Elements are:
+ *                                  'Target' = target frame for link
+ *                                  'URL'    = target URL for link
+ *                                  'Icon'   = the icon to use, based on user prefs
+ *          $a['ChildBoxes']    = array containing this same data structure for
+ *                                each child folder/mailbox of the current
+ *                                mailbox. 
+ *          $a['CummulativeMessageCount']   = integer of total messages in all
+ *                                            folders in this mailbox, exlcuding
+ *                                            trash folders.
+ *          $a['CummulativeUnreadCount']    = integer of total unseen messages
+ *                                            in all folders in this mailbox,
+ *                                            excluding trash folders.
+ *  
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+
+// include required files
+include_once(SM_PATH . 'templates/util_global.php');
+
+/*
+ * Recursively parse the mailbox structure to build the navigation tree.
+ * 
+ * @since 1.5.2
+ */
+function buildMailboxTree ($box, $settings, $indent_factor=0) {
+    // stop condition
+    if (empty($box)) {
+        return '';
+    }
+
+#    echo '<b>'.$box['MailboxName'].':</b> '.dump_array($box).'<hr>';
+    $pre = '<span style="white-space: nowrap;">';
+    $end = '';
+    $indent = str_repeat('&nbsp;&nbsp;',$indent_factor);
+
+    // Get unseeen/total message info if needed
+    $unseen_str = '';
+    if ($settings['unreadNotificationEnabled'])   {
+        // We only display the unread count if we on the Inbox or we are told
+        // to display it on all folders. 
+        if ( $settings['unreadNotificationAllFolders'] || 
+             (!$settings['unreadNotifictionAllFolders'] && strtolower($box['MailboxFullName'])=='inbox') 
+           )  {
+            $unseen_str = $settings['unreadNotificationCummulative'] ? 
+                            $box['CummulativeUnreadCount'] : 
+                            $box['UnreadCount'];
+            
+            // Add the total messages if desired
+            if ($settings['unreadNotificationDisplayTotal'])    {
+                $unseen_str .= '/' . ($settings['unreadNotificationCummulative'] ?
+                                        $box['CummulativeMessageCount'] :
+                                        $box['MessageCount']);
+            }
+            
+            $unseen_str = '<span class="'. 
+                          ($box['IsRecent'] ? 'leftrecent' : 'leftunseen') .
+                          '">' . $unseen_str .
+                          '</span>';
+        }
+    }
+
+    /*
+     * If the box has any children, and collapsable folders have been enabled
+     * we need to output the expand/collapse link.
+     */
+    if (sizeof($box['ChildBoxes'])>0 && $settings['collapsableFoldersEnabled'])    {
+        $link = $indent . 
+                '<a href="'.$box['CollapseLink']['URL'].'" ' .
+                'target="'.$box['CollapseLink']['Target'].'" ' .
+                'style="text-decoration:none" ' .
+#                'alt="'.$box['CollapseLink']['Alt'].'" ' .
+#                'title="'.$box['CollapseLink']['Alt'].'">' .
+                '>' .   
+                $box['CollapseLink']['Icon'] . 
+                '</a>';   
+        $pre .= $link;   
+    } else { 
+        $pre .= $indent . '&nbsp;&nbsp;';
+    }
+      
+    /*
+     * The Trash folder should only be displayed if message recycling has
+     * been enabled, i.e. when deleted is a message moved to the trash or
+     * deleted forever?
+     */
+    $view_link = '<a href="'.$box['ViewLink']['URL'].'" ' .
+                 'target="'.$box['ViewLink']['Target'].'" ' .
+                 'style="text-decoration:none">';
+     
+    if ($settings['messageRecyclingEnabled'] && $box['MailboxFullName'] == $settings['trashFolderName']) {
+        $pre .= $view_link;
+
+        // Boxes with unread messages should be emphasized
+        if ($box['UnreadCount'] > 0) {
+            $pre .= '<em>';
+            $end .= '</em>';
+        }
+        $end .= '</a>';
+        
+        // Print unread info
+        if ($box['UnreadCount'] > 0) {
+            if (!empty($unseen_str)) {
+                $end .= '&nbsp;<small>('.$unseen_str.')</small>';
+            }
+            $end .= "\n<small>" .
+                    '&nbsp;&nbsp;[<a href="empty_trash.php">'. _("Purge").'</a>]' .
+                    '</small>';
+        }
+    } else {
+        // Add a few other things for all other folders...
+        if (!$box['IsNoSelect']) {
+            $pre .= $view_link;
+    
+            // Boxes with unread messages should be emphasized
+            if ($box['UnreadCount'] > 0) {
+                $pre .= '<em>';
+                $end .= '</em>';
+            }
+            $end .= '</a>';
+        }
+        
+        // Display unread info...
+        if (!empty($unseen_str)) {
+            $end .= '&nbsp;<small>('.$unseen_str.')</small>';
+        }
+    }
+     
+    $span = '';
+    $spanend = '';
+    if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) {
+        $span = '<span class="leftspecial">';
+        $spanend = '</span>';
+    } elseif ( $box['IsNoSelect'] ) {
+        $span = '<span class="leftnoselect">';
+        $spanend = '</span>';
+    }
+
+    // let plugins fiddle with end of line
+    $end .= concat_hook_function('left_main_after_each_folder',
+            array(isset($numMessages) ? $numMessages : '',
+            $box['MailboxFullName'], $settings['imapConnection']));
+
+    $end .= '</span>';
+
+    $out = '';
+    if (!$box['IsRoot']) {
+        $out = $span . $pre .
+               str_replace(
+                    array(' ','<','>'),
+                    array('&nbsp;','&lt;','&gt;'),
+                    $box['MailboxName']) .
+               $end . $spanend . '<br />' . "\n";
+        $indent_factor++;
+    }
+
+    if (!$box['IsCollapsed'] || $box['IsRoot']) {
+        for ($i = 0; $i<sizeof($box['ChildBoxes']); $i++) {
+            $out .= buildMailboxTree($box['ChildBoxes'][$i], $settings, $indent_factor);
+        }
+    }
+    
+    return $out;
+}
+
+// Retrieve the template vars
+extract($t);
+  
+/*
+ * Build an array to pass user prefs to the function that builds the tree in
+ * order to avoid using globals, which are dirty, filthy things in templates. :)
+ */         
+$settings = array();
+$settings['imapConnection'] = $imapConnection;
+$settings['iconThemePath'] = $icon_theme_path;
+$settings['unreadNotificationEnabled'] = $unread_notification_enabled;
+$settings['unreadNotificationAllFolders'] = $unread_notification_allFolders;
+$settings['unreadNotificationDisplayTotal'] = $unread_notification_displayTotal;
+$settings['unreadNotificationCummulative'] = $unread_notification_cummulative;
+$settings['useSpecialFolderColor'] = $use_special_folder_color;
+$settings['messageRecyclingEnabled'] = $message_recycling_enabled;
+$settings['trashFolderName'] = $trash_folder_name;
+$settings['collapsableFoldersEnabled'] = $collapsable_folders_enabled;
+
+?>
+<body class="sqm_leftMain">
+<div class="sqm_leftMain">
+<?php do_hook('left_main_before'); ?>
+<table class="sqm_wrapperTable" cellspacing="0">
+ <tr>
+  <td>
+   <table cellspacing="0">
+    <tr>
+     <td style="text-align:center">
+      <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
+      <span class="sqm_clock"><?php echo $clock; ?></span>
+      <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check Mail"); ?></a>]</small></span>
+     </td>
+    </tr>
+   </table>
+   <br />
+   <?php echo buildMailboxTree($mailboxes, $settings); ?>
+  </tr>
+ </td>
+</table>
+<?php do_hook('left_main_after'); ?>
+</div>
diff --git a/templates/default/left_main_advanced.tpl b/templates/default/left_main_advanced.tpl
new file mode 100644 (file)
index 0000000..f0b0fdc
--- /dev/null
@@ -0,0 +1,384 @@
+<?php
+/**
+ * left_main_advanced.tpl
+ *
+ * Displays an experimental mailbox-tree with dhtml behaviour.  
+ * It only works on browsers which supports css and javascript. The used
+ * javascript is experimental and doesn't support all browsers.
+ * It has been tested on IE6 an Konquerer 3.0.0-2.
+ * It is now tested and working on: (please test and update this list)
+ * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
+ * XWindow: ?
+ * Mac: ?
+ * In the function ListAdvancedBoxes there is another var $use_folder_images.
+ * setting this to true is only usefull if the images exists in ../images.
+ *
+ * Feel free to experiment with the code and report bugs and enhancements
+ *
+ * The following variables are avilable in this template:
+ *      $clock           - formatted string containing last refresh
+ *      $mailbox_listing - string containing HTML to display default mailbox tree
+ *      $location_of_bar - string "left" or "right" indicating where the frame
+ *                         is located.  Currently only used in
+ *                         left_main_advanced.tpl
+ *      $left_size       - width of left column in pixels.  Currently only used
+ *                         in left_main_advanced.tpl
+ *      $imapConnection  - IMAP connection handle.  Needed to allow plugins to 
+ *                         read the mailbox.
+ *      $icon_theme_path - Path to the desired icon theme.  If no icon theme has
+ *                         been chosen, this will be the template directory.  If
+ *                         the user has disabled icons, this will be NULL.
+ *
+ *      $unread_notification_enabled - Boolean TRUE if the user wants to see unread 
+ *                             message count on mailboxes
+ *      $unread_notification_cummulative - Boolean TRUE if the user has enabled
+ *                             cummulative message counts.
+ *      $unread_notification_allFolders - Boolean TRUE if the user wants to see
+ *                             unread message count on ALL folders or just the
+ *                             mailbox.
+ *      $unread_notification_displayTotal - Boolean TRUE if the user wants to
+ *                             see the total number of messages in addition to
+ *                             the unread message count.
+ *      $collapsable_folders_enabled - Boolean TRUE if the user has enabled collapsable
+ *                             folders.
+ *      $use_special_folder_color - Boolean TRUE if the use has chosen to tag
+ *                             "Special" folders in a different color.
+ *      $message_recycling_enabled - Boolean TRUE if messages that get deleted go to
+ *                             the Trash folder.  FALSE if they are permanently
+ *                             deleted.
+ *      $trash_folder_name   - Name of the Trash folder.
+ * 
+ *      $mailboxes       - Associative array of current mailbox structure.
+ *                         Provided so template authors know what they have to
+ *                         work with when building a custom mailbox tree.
+ *                         Array contains the following elements:
+ *          $a['MailboxName']   = String containing the name of the mailbox
+ *          $a['MailboxFullName'] = String containing full IMAP name of mailbox
+ *          $a['MessageCount']  = integer of all messages in the mailbox
+ *          $a['UnreadCount']   = integer of unseen message in the mailbox
+ *          $a['ViewLink']      = array containing elements needed to view the
+ *                                mailbox.  Elements are:
+ *                                  'Target' = target frame for link
+ *                                  'URL'    = target URL for link
+ *          $a['IsRecent']      = boolean TRUE if the mailbox is tagged "recent"
+ *          $a['IsSpecial']     = boolean TRUE if the mailbox is tagged "special"
+ *          $a['IsRoot']        = boolean TRUE if the mailbox is the root mailbox
+ *          $a['IsNoSelect']    = boolean TRUE if the mailbox is tagged "noselect"
+ *          $a['IsCollapsed']   = boolean TRUE if the mailbox is currently collapsed
+ *          $a['CollapseLink']  = array containg elements needed to expand/collapse
+ *                                the mailbox.  Elements are:
+ *                                  'Target' = target frame for link
+ *                                  'URL'    = target URL for link
+ *                                  'Icon'   = the icon to use, based on user prefs
+ *          $a['ChildBoxes']    = array containing this same data structure for
+ *                                each child folder/mailbox of the current
+ *                                mailbox. 
+ *          $a['CummulativeMessageCount']   = integer of total messages in all
+ *                                            folders in this mailbox, exlcuding
+ *                                            trash folders.
+ *          $a['CummulativeUnreadCount']    = integer of total unseen messages
+ *                                            in all folders in this mailbox,
+ *                                            excluding trash folders.
+ *
+ * *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+
+/*
+ * Recursively parse the mailbox structure to build the navigation tree.
+ * 
+ * @param array $box Array containing mailbox data
+ * @param array $settings Array containing perferences, etc, passed to template
+ * @param integer $indent_factor Counter used to control indent spacing
+ * @since 1.5.2
+ * @author Steve Brown
+ */
+function buildMailboxTree ($box, $settings, $indent_factor=0) {
+    // Work in progress...
+}
+
+/* retrieve the template vars */
+extract($t);
+
+/*
+ * Build an array to pass user prefs to the function that builds the tree in
+ * order to avoid using globals, which are dirty, filthy things in templates. :)
+ */         
+$settings = array();
+$settings['imapConnection'] = $imapConnection;
+$settings['iconThemePath'] = $icon_theme_path;
+$settings['unreadNotificationEnabled'] = $unread_notification_enabled;
+$settings['unreadNotificationAllFolders'] = $unread_notification_allFolders;
+$settings['unreadNotificationDisplayTotal'] = $unread_notification_displayTotal;
+$settings['unreadNotificationCummulative'] = $unread_notification_cummulative;
+$settings['useSpecialFolderColor'] = $use_special_folder_color;
+$settings['messageRecyclingEnabled'] = $message_recycling_enabled;
+$settings['trashFolderName'] = $trash_folder_name;
+$settings['collapsableFoldersEnabled'] = $collapsable_folders_enabled;
+
+?>
+<body class="sqm_leftMain">
+<script type="text/javascript" src="js/test.js"></script>
+<script type="text/javascript">
+<!--
+/**
+ * Advanced tree makes uses dTree JavaScript package by Geir Landrö heavily. 
+ * See http://www.destroydrop.com/javascripts/tree/
+ */
+    function preload() {
+      if (document.images) {
+        var treeImages = new Array;
+        var arguments = preload.arguments;
+        for (var i = 0; i<arguments.length; i++) {
+          treeImages[i] = new Image();
+          treeImages[i].src = arguments[i];
+        }
+      }
+    }
+    var vTreeImg;
+    var vTreeDiv;
+    var vTreeSrc;
+    function fTreeTimeout() {
+      if (vTreeDiv.readyState == "complete")
+        vTreeImg.src = vTreeSrc;
+      else
+        setTimeout("fTreeTimeout()", 100);
+    }
+    function hidechilds(img) {
+      id = img.id + ".0000";
+      form_id = "mbx[" + img.id +"F]";
+      if (document.all) { //IE, Opera7
+        div = document.all[id];
+        if (div) {
+           if (div.style.display == "none") {
+              vTreeSrc = "../images/minus.png";
+              style = "block";
+              value = 0;
+           }
+           else {
+              vTreeSrc = "../images/plus.png";
+              style = "none";
+              value = 1;
+           }
+           vTreeImg = img;
+           vTreeDiv = div;
+           if (typeof vTreeDiv.readyState != "undefined") //IE
+              setTimeout("fTreeTimeout()",100);
+           else //Non IE
+              vTreeImg.src = vTreeSrc;
+           div.style.display = style;
+           document.all[form_id].value = value;
+        }
+      }
+      else if (document.getElementById) { //Gecko
+        div = document.getElementById(id);
+        if (div) {
+           if (div.style.display == "none") {
+              src = "../images/minus.png";
+              style = "block";
+              value = 0;
+           }
+           else {
+              src = "../images/plus.png";
+              style = "none";
+              value = 1;
+           }
+           div.style.display = style;
+           img.src = src;
+           document.getElementById(form_id).value = value;
+        }
+      }
+    }
+   function buttonover(el,on) {
+      if (!on) {
+         el.style.background="$color[0]";}
+      else {
+         el.style.background="$color[9]";}
+   }
+   function buttonclick(el,on) {
+      if (!on) {
+         el.style.border="groove";}
+      else {
+         el.style.border="ridge";}
+   }
+   function hideframe(hide) {
+      left_size = "$left_size";
+      if (document.all) {
+        masterf = window.parent.document.all["fs1"];
+        leftf = window.parent.document.all["left"];
+        leftcontent = document.all["leftframe"];
+        leftbutton = document.all["showf"];
+      } else if (document.getElementById) {
+        masterf = window.parent.document.getElementById("fs1");
+        leftf = window.parent.document.getElementById("left");
+        leftcontent = document.getElementById("leftframe");
+        leftbutton = document.getElementById("showf");
+      } else {
+        return false;
+      }
+      if(hide) {
+         new_col = calc_col("20");
+         masterf.cols = new_col;
+         document.body.scrollLeft=0;
+         document.body.style.overflow="hidden";
+         leftcontent.style.display = "none";
+         leftbutton.style.display="block";
+      } else {
+         masterf.cols = calc_col(left_size);
+         document.body.style.overflow="";
+         leftbutton.style.display="none";
+         leftcontent.style.display="block";
+      }
+   }
+   function calc_col(c_w) {
+    <?php
+        if ($location_of_bar == 'right') {
+            echo '     right=true;';
+        } else {
+            echo '     right=false;';
+        }
+    ?>
+   if (right) {
+         new_col = '*,'+c_w;
+     } else {
+         new_col = c_w+',*';
+     }
+     return new_col;
+   }
+   function resizeframe(direction) {
+     if (document.all) {
+        masterf = window.parent.document.all["fs1"];
+     } else if (document.getElementById) {
+        window.parent.document.getElementById("fs1");
+     } else {
+        return false;
+     }
+    <?php
+        if ($location_of_bar == 'right') {
+            echo '  colPat=/^\*,(\d+)$/;';
+        } else {
+            echo '  colPat=/^(\d+),.*$/;';
+        }
+    ?>
+     old_col = masterf.cols;
+     colPat.exec(old_col);
+     if (direction) {
+        new_col_width = parseInt(RegExp.$1) + 25;
+     } else {
+        if (parseInt(RegExp.$1) > 35) {
+           new_col_width = parseInt(RegExp.$1) - 25;
+        }
+     }
+     masterf.cols = calc_col(new_col_width);
+   }
+//-->
+</script>
+<style type="text/css">
+<!--
+  body {
+     margin: 0px 0px 0px 0px;
+     padding: 5px 5px 5px 5px;
+  }
+  img {
+     vertical-align: middle;
+  }
+  .button {
+     border:outset;
+     border-color: <?php echo $color[9]; ?>;
+     background: <?php echo $color[0]; ?>;
+     color: <?php echo $color[6]; ?>;
+     width:99%;
+     heigth:99%;
+  }
+  .mbx_par {
+     font-size:1.0em;
+     margin-left:4px;
+     margin-right:0px;
+     white-space: nowrap;
+  }
+  a.mbx_link {
+      text-decoration: none;
+      background-color: <?php echo $color[0]; ?>;
+      display: inline;
+  }
+  a:hover.mbx_link {
+      background-color: <?php echo $color[9]; ?>;
+  }
+  a.mbx_link img {
+      border-style: none;
+  }
+  .mbx_sub {
+     padding-left:5px;
+     padding-right:0px;
+     margin-left:4px;
+     margin-right:0px;
+     font-size:0.9em;
+     white-space: nowrap;
+  }
+  .par_area {
+     margin-top:0px;
+     margin-left:4px;
+     margin-right:0px;
+     padding-left:10px;
+     padding-bottom:5px;
+     border-left: solid;
+     border-left-width:0.1em;
+     border-left-color: <?php echo $color[9]; ?>;
+     border-bottom: solid;
+     border-bottom-width:0.1em;
+     border-bottom-color: <?php echo $color[9]; ?>;
+     display: block;
+  }
+  .mailboxes {
+     padding-bottom:3px;
+     margin-right:4px;
+     padding-right:4px;
+     margin-left:4px;
+     padding-left:4px;
+     border: groove;
+     border-width:0.1em;
+     border-color: <?php echo $color[9]; ?>;
+     background: <?php echo $color[0]; ?>;
+     font-size: smaller;
+  }
+-->
+</style>
+<div class="sqm_leftMain">
+<?php
+$right_pos = $left_size - 20;
+?>
+<div style="position:absolute; top:0; border:0.1em solid blue;">
+ <div id="hidef" style="width=20;font-size:12"><a href="javascript:hideframe(true)"><b>&lt;&lt;</b></a></div>
+ <div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>&gt;&gt;</b></a></div>
+ <div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>&gt;</b></a></div>
+ <div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b>&lt;</b></a></div>
+</div>
+<div id="leftframe">
+<br />
+<br />
+<br />
+<?php do_hook('left_main_before'); ?>
+<table class="sqm_wrapperTable" cellspacing="0">
+ <tr>
+  <td>
+   <table cellspacing="0">
+    <tr>
+     <td style="text-align:center">
+      <span class="sqm_folderHeader"><?php echo _("Folders"); ?></span><br />
+      <span class="sqm_clock"><?php echo $clock; ?></span>
+      <span class="sqm_refreshButton"><small>[<a href="../src/left_main.php" target="left"><?php echo _("Check Mail"); ?></a>]</small></span>
+     </td>
+    </tr>
+   </table>
+   <br />
+   <?php echo $mailbox_listing; ?>
+  </tr>
+ </td>
+</table>
+<?php do_hook('left_main_after'); ?>
+</div>    
+<?php var_dump($template_dir); ?>
\ No newline at end of file
index 748329c25a2fa1003090a08544a951e6bc10a1c9..a335c183da15c45a2d60df15f9644a4c987c94ca 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 /** add required includes */
  */
 
 /** add required includes */
+include_once(SM_PATH . 'templates/util_global.php');
 include_once(SM_PATH . 'templates/util_message_list.php');
 
 /* retrieve the template vars */
 include_once(SM_PATH . 'templates/util_message_list.php');
 
 /* retrieve the template vars */
@@ -77,16 +78,10 @@ if (!($javascript_on && $fancy_index_highlite)) {
 }
 
 /**
 }
 
 /**
- * Check usage of images for attachments, flags and priority
- */
-$bIcons = ($use_icons && $icon_theme) ? true : false;
-
-/**
- * Location of icon images
- */
-if ($bIcons) {
-    $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
-}
+ * All icon functionality is now handled through $icon_theme_path.
+ * $icon_theme_path will contain the path to the user-selected theme.  If it is
+ * NULL, the user and/or admin have turned off icons.
+*/
 
 // set this to an empty string to turn off extra
 // highlighting of checked rows
 
 // set this to an empty string to turn off extra
 // highlighting of checked rows
@@ -245,27 +240,15 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
           case SQM_COL_DATE:       echo _("Date")."\n";     break;
           case SQM_COL_SUBJ:       echo _("Subject")."\n";  break;
           case SQM_COL_FLAGS:
           case SQM_COL_DATE:       echo _("Date")."\n";     break;
           case SQM_COL_SUBJ:       echo _("Subject")."\n";  break;
           case SQM_COL_FLAGS:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />'."\n";
-               } else {
-                  echo  '&nbsp;'."\n";
-               }
-               break;
+                echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
+                break;
           case SQM_COL_SIZE:       echo  _("Size")."\n";    break;
           case SQM_COL_PRIO:
           case SQM_COL_SIZE:       echo  _("Size")."\n";    break;
           case SQM_COL_PRIO:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />'."\n";
-               } else {
-                  echo  '!'."\n";
-               }
-               break;
+                echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
+                break;
           case SQM_COL_ATTACHMENT:
           case SQM_COL_ATTACHMENT:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>'."\n";
-               } else {
-                  echo  '+'."\n";
-               }
-               break;
+                echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
+                break;
           case SQM_COL_INT_DATE:   echo _("Received")."\n"; break;
           case SQM_COL_TO:         echo _("To")."\n";       break;
           case SQM_COL_CC:         echo _("Cc")."\n";       break;
           case SQM_COL_INT_DATE:   echo _("Received")."\n"; break;
           case SQM_COL_TO:         echo _("To")."\n";       break;
           case SQM_COL_CC:         echo _("Cc")."\n";       break;
@@ -275,20 +258,19 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
         // add the sort buttons
         if (isset($aSortSupported[$iCol])) {
             if ($sort == $aSortSupported[$iCol][0]) {
         // add the sort buttons
         if (isset($aSortSupported[$iCol])) {
             if ($sort == $aSortSupported[$iCol][0]) {
-               $newsort = $aSortSupported[$iCol][1];
-               $img = 'up_pointer.png';
+                $newsort = $aSortSupported[$iCol][1];
+                $img = 'up_pointer.png';
             } else if ($sort == $aSortSupported[$iCol][1]) {
             } else if ($sort == $aSortSupported[$iCol][1]) {
-               $newsort = 0;
-               $img = 'down_pointer.png';
+                $newsort = 0;
+                $img = 'down_pointer.png';
             } else {
             } else {
-               $newsort = $aSortSupported[$iCol][0];
-               $img = 'sort_none.png';
+                $newsort = $aSortSupported[$iCol][0];
+                $img = 'sort_none.png';
             }
             /* Now that we have everything figured out, show the actual button. */
             }
             /* Now that we have everything figured out, show the actual button. */
-            echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">";
-            echo '<img src="../images/' . $img
-                . '" border="0" width="12" height="10" alt="sort" title="'
-                . _("Click here to change the sorting of the message list") .'" /></a>'."\n";
+            echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">" .
+                 getIcon($icon_theme_path, $img, '&nbsp;', _("Click here to change the sorting of the message list")) . "\n" .
+                 '</a>';
         }
 ?>
                     </td>
         }
 ?>
                     </td>
@@ -336,12 +318,8 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      */
     if (isset($aColumns[SQM_COL_FLAGS])) {
         $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
      */
     if (isset($aColumns[SQM_COL_FLAGS])) {
         $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
-        if ($bIcons) {
+        $sFlags = getFlagIcon($aFlags, $icon_theme_path);
 
 
-            $sFlags = getFlagIcon($aFlags, $sImageLocation);
-        } else {
-            $sFlags = getFlagText($aFlags);
-        }
         /* add the flag string to the value index */
         $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
     }
         /* add the flag string to the value index */
         $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
     }
@@ -349,25 +327,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      * Check the priority column
      */
     if (isset($aColumns[SQM_COL_PRIO])) {
      * Check the priority column
      */
     if (isset($aColumns[SQM_COL_PRIO])) {
-        /* FIX ME, we should use separate templates for icons */
-        if ($bIcons) {
-            $sValue = '<img src="' . $sImageLocation;
-            switch ($aColumns[SQM_COL_PRIO]['value']) {
-                case 1:
-                case 2:  $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
-                case 5:  $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> '  ; break;
-                default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> '           ; break;
-            }
-        } else {
-            $sValue = '';
-            switch ($aColumns[SQM_COL_PRIO]['value']) {
-                case 1:
-                case 2: $sValue .= '<span class="high_priority">!</span>'; break;
-        // use downwards arrow for low priority emails
-                case 5: $sValue .= '<span class="low_priority">&#8595;</span>'; break;
-                default: break;
-            }
-        }
+        $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
         $aColumns[SQM_COL_PRIO]['value'] = $sValue;
     }
 
         $aColumns[SQM_COL_PRIO]['value'] = $sValue;
     }
 
@@ -375,15 +335,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      * Check the attachment column
      */
     if (isset($aColumns[SQM_COL_ATTACHMENT])) {
      * Check the attachment column
      */
     if (isset($aColumns[SQM_COL_ATTACHMENT])) {
-        /* FIX ME, we should use separate templates for icons */
-        if ($bIcons) {
-            $sValue = '<img src="' . $sImageLocation;
-            $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
-                    ? 'attach.png" border="0" height="10" width="6" alt=""/>'
-                    : 'transparent.png" border="0" width="6" alt="" />';
-        } else {
-            $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
-        }
+        $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path); 
         $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
     }
 
         $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
     }
 
index 59ad74b480a23323f0b303d9aac2df84226812e9..c2c00f2882825a6e37636c915dbfda1aba10c1b8 100644 (file)
@@ -65,7 +65,7 @@ body {
     color:  <?php echo SQM_TEXT_STANDARD; ?>;
     background-color: <?php echo SQM_BACKGROUND; ?>;
 }
     color:  <?php echo SQM_TEXT_STANDARD; ?>;
     background-color: <?php echo SQM_BACKGROUND; ?>;
 }
-body.leftmain {
+body.sqm_leftMain {
     color:  <?php echo SQM_TEXT_STANDARD_LEFT; ?>;
     background-color: <?php echo SQM_BACKGROUND_LEFT; ?>;
     text-align: left;
     color:  <?php echo SQM_TEXT_STANDARD_LEFT; ?>;
     background-color: <?php echo SQM_BACKGROUND_LEFT; ?>;
     text-align: left;
@@ -77,10 +77,10 @@ a:link, a:visited, a:hover, a:active {
 }
 
 /* left links */
 }
 
 /* left links */
-.leftmain a:link, .leftmain a:visited, .leftmain a:hover, .leftmain a:active {
+.sqm_leftMain a:link, .sqm_leftMain a:visited, .sqm_leftMain a:hover, .sqm_leftMain a:active {
     color:  <?php echo SQM_LINK_LEFT; ?>;
 }
     color:  <?php echo SQM_LINK_LEFT; ?>;
 }
-.leftunseen, .leftrecent, .leftspecial, .leftspecial a:link, .leftspecial a:visited, .leftspecial a:hover, .leftspecial a:active {
+.leftunseen, .leftspecial, .leftspecial a:link, .leftspecial a:visited, .leftspecial a:hover, .leftspecial a:active {
     color:  <?php echo SQM_TEXT_SPECIAL; ?>;
 }
 .leftrecent {
     color:  <?php echo SQM_TEXT_SPECIAL; ?>;
 }
 .leftrecent {
@@ -103,7 +103,7 @@ a:link, a:visited, a:hover, a:active {
     border-spacing:0;
     width:99%
 }
     border-spacing:0;
     width:99%
 }
-.leftmain table {
+sqm_leftMain table {
     border:0;
     padding:0;
     margin:0;
     border:0;
     padding:0;
     margin:0;
@@ -203,6 +203,9 @@ em          {
 small  {
     font-size:80%;
 }
 small  {
     font-size:80%;
 }
+img   {
+    border:0;
+}
 
 /* login.tpl definitions */
 #sqm_login table {
 
 /* login.tpl definitions */
 #sqm_login table {
@@ -220,7 +223,6 @@ small       {
 .sqm_loginImage {
     margin-left:auto;
     margin-right:auto;
 .sqm_loginImage {
     margin-left:auto;
     margin-right:auto;
-    border:0;
     padding:2px;
 }
 .sqm_loginTop {
     padding:2px;
 }
 .sqm_loginTop {
@@ -367,7 +369,7 @@ small       {
 }
 
 .message_list_controls {
 }
 
 .message_list_controls {
-    background: <?php echo $color[0]; ?>;
+    background: <? echo $color[0]; ?>;
 }
 
 .message_control_button {
 }
 
 .message_control_button {
diff --git a/templates/util_global.php b/templates/util_global.php
new file mode 100644 (file)
index 0000000..9c8f391
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * util_global.php
+ *
+ * Utility functions for use with all templates.  Do not echo output here!
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+/**
+ * Checks for an image icon and returns a complete HTML img tag or a text
+ * string with the text icon based on what is found and user prefs.
+ * 
+ * @param string $icon_theme_path User's chosen icon set
+ * @param string $icon_name File name of the desired icon
+ * @param string $text_icon Text-based icon to display if desired
+ * @param string $alt_text Optional.  Text for alt/title attribute of image
+ * @param integer $w Optional.  Width of requested image.
+ * @param integer $h Optional.  Height of requested image.
+ * @return string $icon String containing icon that can be echo'ed
+ * @author Steve Brown
+ * @since 1.5.2
+ */
+function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL, $h=NULL) {
+    $icon = '';
+    if (is_null($icon_theme_path)) {
+        $icon = $text_icon;
+    } else {
+        // Desired icon exists in the current theme?
+        if (is_file($icon_theme_path . $icon_name)) {
+            $icon_path = $icon_theme_path . $icon_name;
+
+        // Icon not found, return the SQM default icon
+        } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) {
+            $icon_path = SM_PATH . 'images/themes/default/'.$icon_name;
+        } 
+        
+        // If we found an icon, build an img tag to display it.  If we didn't
+        // find an image, we will revert back to the text icon.
+        if (!is_null($icon_path)) {
+            $icon = '<img src="'.$icon_path.'" ' .
+                    (!empty($alt_text) ? 'alt="'.$alt_text.'" title="'.$alt_text.'" ' : '') .
+                    (!is_null($w) ? 'width="'.$w.'" ' : '') .
+                    (!is_null($h) ? 'height="'.$h.'" ' : '') .
+                    ' />';
+        } else {
+            $icon = $text_icon;
+        }
+    }
+    return $icon;    
+}
+?>
\ No newline at end of file
diff --git a/templates/util_left_main.php b/templates/util_left_main.php
new file mode 100644 (file)
index 0000000..aa63b45
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * util_left_main.php
+ *
+ * Provides some functions for use in left_main.php and templates.  Do not echo
+ * output from these functions!
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage templates
+ */
+/**
+ * Recursively iterates a mailboxes object to get the cummulative count of
+ * messages for all folderes below the current mailbox.
+ * 
+ * @param object $boxes Object of the class mailboxes
+ * @param string $type Whether to fetch unseen only or all messages
+ * @author Steve Brown
+ * @since 1.5.2
+ */
+function getMessageCount ($boxes, $type='total')
+{
+    // The Trash folder isn't counted...
+    if ($boxes->mailboxname_full == $GLOBALS['trash_folder'])
+        return 0;
+        
+    $count = 0;
+    if (strtolower($type) == 'unseen')
+        $field = 'unseen';
+    else $field = 'total';
+    
+    
+    $count += !empty($boxes->{$field}) ? $boxes->{$field} : 0;
+    for ($j = 0; $j <count($boxes->mbxs); $j++) {
+        $count += getMessageCount($boxes->mbxs[$j], $type);
+    }
+    
+    return $count;    
+}
+
+/**
+ * Recursively iterates a mailboxes object to build a data structure that is
+ * easy for template authors to work with.
+ * 
+ * @param object $boxes Object of the class mailboxes
+ * @author Steve Brown
+ * @since 1.5.2
+ */
+function getBoxStructure ($boxes)
+{
+    global $data_dir, $username, $icon_theme_path;
+        
+    // Stop condition   
+    if (empty($boxes))  {
+        return array();
+    }
+    
+    $mailbox = $boxes->mailboxname_full;
+    $mailboxURL = urlencode($mailbox);
+    $box = array();
+
+    $box['MailboxFullName'] = $mailbox;
+    $box['MailboxName'] = $boxes->mailboxname_sub;
+    $box['MessageCount'] = !empty($boxes->total) ? $boxes->total : 0;
+    $box['UnreadCount'] = !empty($boxes->unseen) ? $boxes->unseen : 0;
+    
+    // Needed in case user enables cummulative message counts
+    $box['CummulativeMessageCount'] = getMessageCount($boxes, 'total');
+    $box['CummulativeUnreadCount'] = getMessageCount($boxes, 'unseen');
+    
+    $box['ViewLink'] = array( 'Target' => 'right',
+                              'URL'    => 'right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox='.$mailboxURL
+                            );
+                              
+    $box['IsRecent'] = isset($boxes->recent) && $boxes->recent;
+    $box['IsSpecial'] = isset($boxes->is_special) && $boxes->is_special;
+    $box['IsRoot'] =  isset($boxes->is_root) && $boxes->is_root;
+    $box['IsNoSelect'] = isset($boxes->is_noselect) && $boxes->is_noselect;
+
+    $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
+    $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
+    $collapse = (int)$collapse == SM_BOX_COLLAPSED;
+    $box['IsCollapsed'] = $collapse;
+
+    /*
+     * Check for an image needed here.  If the file exists in $icon_theme_path
+     * assume the template provides all icons.  If not, we will use the 
+     * SQM default images.  If icons have been disabled, $icon_theme_path
+     * will be NULL.
+     */
+     
+    $text_icon = $box['IsCollapsed'] ? '+' : '-';
+    $icon_file = $box['IsCollapsed'] ? 'plus.png' : 'minus.png';
+    $icon_alt = $box['IsCollapsed'] ? 'Expand Box' : 'Collapse Box';
+    $icon = getIcon($icon_theme_path, $icon_file, $text_icon, $icon_alt);
+    
+    $box['CollapseLink'] = array ( 'Target' => 'left',
+                                   'URL'    => 'left_main.php?'.($box['IsCollapsed'] ? 'unfold' : 'fold') .'='.$mailboxURL,
+                                   'Icon'   => $icon .'&nbsp;'
+                                 ); 
+
+    $box['ChildBoxes'] = array();
+    for ($i = 0; $i <count($boxes->mbxs); $i++) {
+        $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs[$i]);
+    }
+    
+    return $box;
+}
+
+?>
\ No newline at end of file
index 0170d22f199007a1fbebd7a0afec8b0888bf3be0..6d7c4c1aabf23c131227e7c2d4eff79972d66182 100644 (file)
@@ -67,17 +67,15 @@ function calcMessageListColumnWidth($aOrder) {
 }
 
 /**
 }
 
 /**
- * Function to retrieve the correct flag icon belonging to the set of
- * provided flags
- *
+ * Function to retrieve correct icon based on provided message flags.  This is 
+ * a merge/replacement for getFlagIcon() and getFlagText() functions.
+ * 
  * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
  * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
- * @param string $sImageLocation directory location of flagicons
- * @return string $sFlags string with the correct img html tag
- * @author Marc Groot Koerkamp
+ * @param string $icon_theme_path path to user's currently selected icon theme.
+ * @return string $icon full HTML img tag or text icon, depending on of user prefs
+ * @author Steve Brown
  */
  */
-function getFlagIcon($aFlags, $sImageLocation) {
-    $sFlags = '';
-
+function getFlagIcon ($aFlags, $icon_theme_path) {
     /**
      * 0  = unseen
      * 1  = seen
     /**
      * 0  = unseen
      * 1  = seen
@@ -100,27 +98,29 @@ function getFlagIcon($aFlags, $sImageLocation) {
     /**
      * Use static vars to avoid initialisation of the array on each displayed row
      */
     /**
      * Use static vars to avoid initialisation of the array on each displayed row
      */
-    static $aFlagImages, $aFlagValues;
-    if (!isset($aFlagImages)) {
-        $aFlagImages = array(
-                            array('msg_new.png','('._("New").')'),
-                            array('msg_read.png','('._("Read").')'),
-                            array('msg_new_deleted.png','('._("Deleted").')'),
-                            array('msg_read_deleted.png','('._("Deleted").')'),
-                            array('msg_new_reply.png','('._("Answered").')'),
-                            array('msg_read_reply.png','('._("Answered").')'),
-                            array('msg_read_deleted_reply.png','('._("Answered").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')'),
-                            array('flagged.png', '('._("Flagged").')')
-                            ); // as you see the list is not completed yet.
-        $aFlagValues = array('seen'     => 1,
+    static $flag_icons, $flag_values;
+    if (!isset($flag_icons)) {
+        // This is by no means complete...
+        $flag_icons = array (   //     Image icon name               Text Icon  Alt/Title Text
+                                array ('msg_new.png',                '&nbsp;',  '('._("New").')') ,
+                                array ('msg_read.png',               '&nbsp;',  '('._("Read").')'),
+                                array ('msg_new_deleted.png',        _("D"),    '('._("Deleted").')'),
+                                array ('msg_read_deleted.png',       _("D"),    '('._("Deleted").')'),
+                                array ('msg_new_reply.png',          _("A"),    '('._("Answered").')'),
+                                array ('msg_read_reply.png',         _("A"),    '('._("Answered").')'),
+                                array ('msg_read_deleted_reply.png', _("D"),    '('._("Answered").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')'),
+                                array ('flagged.png',                _("F"),    '('._("Flagged").')')
+                            );
+        
+        $flag_values = array('seen'     => 1,
                              'deleted'  => 2,
                              'answered' => 4,
                              'flagged'  => 8,
                              'deleted'  => 2,
                              'answered' => 4,
                              'flagged'  => 8,
@@ -130,109 +130,74 @@ function getFlagIcon($aFlags, $sImageLocation) {
     /**
      * The flags entry contain all items displayed in the flag column.
      */
     /**
      * The flags entry contain all items displayed in the flag column.
      */
-    $iFlagIndx = 0;
+    $icon = '';
+
+    $index = 0;
     foreach ($aFlags as $flag => $flagvalue) {
     foreach ($aFlags as $flag => $flagvalue) {
-        /* FIX ME, we should use separate templates for icons */
          switch ($flag) {
             case 'deleted':
             case 'answered':
             case 'seen':
          switch ($flag) {
             case 'deleted':
             case 'answered':
             case 'seen':
-            case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break;
+            case 'flagged': if ($flagvalue) $index += $flag_values[$flag]; break;
             default: break;
         }
     }
             default: break;
         }
     }
-    if (isset($aFlagImages[$iFlagIndx])) {
-        $aFlagEntry = $aFlagImages[$iFlagIndx];
+    
+    if (isset($flag_icons[$index])) {
+        $data = $flag_icons[$index];
     } else {
     } else {
-        $aFlagEntry = end($aFlagImages);
+        $data = end($flag_icons);
     }
 
     }
 
-    $sFlags = '<img src="' . $sImageLocation . $aFlagEntry[0].'"'.
-              ' border="0" alt="'.$aFlagEntry[1].'" title="'. $aFlagEntry[1] .'" height="12" width="18" />' ;
-    if (!$sFlags) { $sFlags = '&nbsp;'; }
-    return $sFlags;
+    $icon = getIcon($icon_theme_path, $data[0], $data[1], $data[2]);
+    return $icon;
 }
 
 }
 
+
 /**
 /**
- * Function to retrieve the correct flag text belonging to the set of
- * provided flags
- *
- * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
- * @return string $sFlags string with the correct flag text
- * @author Marc Groot Koerkamp
+ * Function to retrieve correct priority icon based on user prefs
+ * 
+ * @param integer $priority priority value of message
+ * @param string $icon_theme_path path to user's currently selected icon theme.
+ * @return string $icon full HTML img tag or text icon, depending on of user prefs
+ * @author Steve Brown
  */
  */
-function getFlagText($aFlags) {
-    $sFlags = '';
+function getPriorityIcon ($priority, $icon_theme_path) {
+    $icon = '';
 
 
-    /**
-     * 0  = unseen
-     * 1  = seen
-     * 2  = deleted
-     * 3  = deleted seen
-     * 4  = answered
-     * 5  = answered seen
-     * 6  = answered deleted
-     * 7  = answered deleted seen
-     * 8  = flagged
-     * 9  = flagged seen
-     * 10 = flagged deleted
-     * 11 = flagged deleted seen
-     * 12 = flagged answered
-     * 13 = flagged aswered seen
-     * 14 = flagged answered deleted
-     * 15 = flagged anserwed deleted seen
-     */
-    /**
-     * Use static vars to avoid initialisation of the array on each displayed row
-     */
-    static $aFlagText, $aFlagValues;
-    if (!isset($aFlagText)) {
-        $aFlagText = array(
-                            array('&nbsp;', '('._("New").')'),
-                            array('&nbsp;', '('._("Read").')'),
-                            array(_("D")  , '('._("Deleted").')'),
-                            array(_("D")  , '('._("Deleted").')'),
-                            array(_("A")  , '('._("Answered").')'),
-                            array(_("A")  , '('._("Answered").')'),
-                            array(_("D")  , '('._("Answered").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')'),
-                            array(_("F")  , '('._("Flagged").')')
-                            ); // as you see the list is not completed yet.
-        $aFlagValues = array('seen'     => 1,
-                             'deleted'  => 2,
-                             'answered' => 4,
-                             'flagged'  => 8,
-                             'draft'    => 16);
+    switch ($priority) {
+        case 1:
+        case 2:
+            $icon = getIcon($icon_theme_path, 'prio_high.png', '<span class="high_priority">!</span>');
+            break;
+        case 5:
+            $icon = getIcon($icon_theme_path, 'prio_low.png', '<span class="low_priority">&#8595;</span>');
+            break;
+        default:
+            $icon = getIcon($icon_theme_path, 'transparent.png', '', '', 5);
+            break;
     }
     }
+    
+    return $icon;
+}
 
 
-    /**
-     * The flags entry contain all items displayed in the flag column.
-     */
-    $iFlagIndx = 0;
-    foreach ($aFlags as $flag => $flagvalue) {
-        /* FIX ME, we should use separate templates for icons */
-        switch ($flag) {
-            case 'deleted':
-            case 'answered':
-            case 'seen':
-            case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break;
-            default: break;
-        }
-    }
-    if (isset($aFlagText[$iFlagIndx])) {
-        $sFlags = $aFlagText[$iFlagIndx][0];
-    } else {
-        $aLast = end($aFlagText);
-        $sFlags = $aLast[0];
-    }
-    if (!$sFlags) { $sFlags = '&nbsp;'; }
-    return $sFlags;
+/**
+ * Function to retrieve correct attchment icon based on user prefs
+ * 
+ * @param boolean $attach TRUE if the message has an attachment
+ * @param string $icon_theme_path path to user's currently selected icon theme.
+ * @return string $icon full HTML img tag or text icon, depending on of user prefs
+ * @author Steve Brown
+ */
+function getAttachmentIcon ($attach, $icon_theme_path) {
+    $icon = '';
+    
+    $icon_file = $attach ? 'attach.png' : 'transparent.png';
+    $text = $attach ? '+' : '';
+    $icon = getIcon($icon_theme_path, $icon_file, $text);
+
+    return $icon;
 }
 }
+
+
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file