From: stevetruckstuff Date: Tue, 21 Feb 2006 00:02:30 +0000 (+0000) Subject: New icon theming. Also added basic template for left_main.php X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=2999753577cd5fb23d7a88e2978c60d8bade44a6 New icon theming. Also added basic template for left_main.php git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10781 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/images/themes/default/theme.php b/images/themes/default/theme.php index 245d0436..13e5aed6 100644 --- a/images/themes/default/theme.php +++ b/images/themes/default/theme.php @@ -9,5 +9,5 @@ * @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 diff --git a/images/themes/template/index.php b/images/themes/template/index.php new file mode 100644 index 00000000..007b4c45 --- /dev/null +++ b/images/themes/template/index.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/images/themes/template/theme.php b/images/themes/template/theme.php new file mode 100644 index 00000000..a0624869 --- /dev/null +++ b/images/themes/template/theme.php @@ -0,0 +1,13 @@ +_("Template Default"),'PATH'=> $sTplDir.'images/'); +?> \ No newline at end of file diff --git a/images/themes/xp/theme.php b/images/themes/xp/theme.php index aff67886..e7a76edd 100644 --- a/images/themes/xp/theme.php +++ b/images/themes/xp/theme.php @@ -9,5 +9,5 @@ * @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 diff --git a/include/load_prefs.php b/include/load_prefs.php index 06848aee..337efc1d 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -103,7 +103,14 @@ if (!defined('download_php')) { } // 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 ); diff --git a/include/options/display.php b/include/options/display.php index 0c07e5af..573f2ba4 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -216,6 +216,28 @@ function load_optpage_data_display() { 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(); @@ -242,27 +264,6 @@ function load_optpage_data_display() { '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"), diff --git a/src/left_main.php b/src/left_main.php index 222cd49d..262a9717 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -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'); +/** 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); @@ -33,170 +37,20 @@ define('SM_BOX_COLLAPSED', 1); /* --------------------- 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 + * @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 = ''; - $end = ''; - $collapse = false; - $unseen_found = false; - $unseen = 0; - - $mailbox = $boxes->mailboxname_full; - $leader = str_repeat('  ',$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 = "($unseen_string)"; - } else { - $unseen_string = "($unseen_string)"; - } - - /* - * 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 = '$leader '; - } else { - $link .= "unfold=$mailboxURL\">$leader+ "; - } - } else { - if ($use_icons && $icon_theme != 'none') { - $link .= "fold=$mailboxURL\">$leader '; - } else { - $link .= "fold=$mailboxURL\">$leader- "; - } - } - $link .= ''; - $pre .= $link; - } else { - $pre.= $leader . '  '; - } - - /* 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 .= ""; - if ($unseen > 0) { - $pre .= ''; - $end .= ''; - } - $end .= ''; - if ($boxes->total > 0) { - /* Print unseen information. */ - if ($unseen_found) { - $end .= " $unseen_string"; - } - $end .= "\n" . - '  ['._("Purge").']'. - ''; - } - } else { - if (!$boxes->is_noselect) { - $pre .= ""; - if ($unseen > 0) { - $pre .= ''; - $end .= ''; - } - $end .= ''; - } - /* Print unseen information. */ - if ($unseen_found) { - $end .= " $unseen_string"; - } - - } - - $span = ''; - $spanend = ''; - if ($use_special_folder_color && $boxes->is_special) { - $span = ""; - $spanend = ""; - } elseif ( $boxes->is_noselect ) { - $span = ""; - $spanend = ''; - } - - - // 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 .= ''; - - if (!$boxes->is_root) { - echo "" . $span . $pre . - str_replace( - array(' ','<','>'), - array(' ','<','>'), - $boxes->mailboxname_sub) . - $end. $spanend .'
' . "\n"; - $j++; - } - - if (!$collapse || $boxes->is_root) { - for ($i = 0; $i mbxs); $i++) { - ListBoxes($boxes->mbxs[$i],$j); - } - } +function ListBoxes ($boxes, $j=0) { + return ''; } 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)); + $out = ''; 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])) { - echo ' ' . html_tag( 'div', + $out .= ' ' . html_tag( 'div', $pre . $folder_img . str_replace( array(' ','<','>'), array(' ','<','>'), @@ -343,27 +198,29 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n"; } else { - echo ' ' . html_tag( 'div', + $out .= ' ' . html_tag( 'div', $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub . $end , 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n"; - echo ' '."\n"; + $out .= ' '."\n"; } } $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 mbxs); $i++) { $j++; - ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j); + $out .= ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j); } if (isset($boxes->mbxs[0]) && !$boxes->is_root) { - echo ''."\n\n"; + $out .= ''."\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 - * 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 */ @@ -421,238 +269,6 @@ if (empty($advanced_tree)) { $advanced_tree=false; } -if ($advanced_tree) { -$xtra .= << - - - -HEREDOC; - -/* style definitions */ - -$xtra .= << - - - -HEREDOC; -} - // 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); } -if ($advanced_tree) { - echo "\n\n
\n"; -} else { - echo "\n\n
\n"; -} - -do_hook('left_main_before'); -if ($advanced_tree) { - /* nice future feature, needs layout !! volunteers? */ - $right_pos = $left_size - 20; -/* echo '
'; - echo ''; - echo ''; - echo '
'; - echo '


';*/ -} - -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' ) . - ''. _("Folders") . "
\n\n"; - +$clock = ''; if ($date_format != 6) { /* First, display the clock. */ if ($hour_format == 1) { @@ -752,17 +342,11 @@ if ($date_format != 6) { } $clk = str_replace(' ',' ',$clk); - echo '' + $clock = '' . str_replace(' ', ' ', _("Last Refresh")) . ":
$clk

\n"; } -/* Next, display the refresh button. */ -echo '
\n\n"; - -/* Lastly, display the folder list. */ - if ( $collapse_folders ) { /* If directed, collapse or uncollapse a folder. */ if (isset($fold)) { @@ -791,32 +375,54 @@ if (empty($unseen_notify)) { $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); +$mailbox_listing = ''; if (isset($advanced_tree) && $advanced_tree) { - echo '
'."\n"; - echo '

'; - echo '
'."\n\n"; + $mailbox_listing .= '

'; + $mailbox_listing .= '
'."\n\n"; sqgetGlobalVar('mbx', $mbx, SQ_POST); if (!isset($mbx)) $mbx=NULL; - ListAdvancedBoxes($boxes, $mbx); - echo '
'; - echo ''."\n"; + $mailbox_listing .=ListAdvancedBoxes($boxes, $mbx); + $mailbox_listing .= '
'; + $mailbox_listing .= ''."\n"; } 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'); +} -?> - -
-display('footer.tpl'); ?> \ No newline at end of file diff --git a/src/right_main.php b/src/right_main.php index ccbaf6d4..1ad78c92 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -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); - // 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); diff --git a/src/search.php b/src/search.php index f6fb1f2a..8e08124e 100644 --- a/src/search.php +++ b/src/search.php @@ -1602,13 +1602,13 @@ if ($submit == $search_button_text) { 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); - // 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); diff --git a/templates/default/left_main.tpl b/templates/default/left_main.tpl new file mode 100644 index 00000000..7991cd05 --- /dev/null +++ b/templates/default/left_main.tpl @@ -0,0 +1,268 @@ +'.$box['MailboxName'].': '.dump_array($box).'
'; + $pre = ''; + $end = ''; + $indent = str_repeat('  ',$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 = '' . $unseen_str . + ''; + } + } + + /* + * 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 . + '' . + '>' . + $box['CollapseLink']['Icon'] . + ''; + $pre .= $link; + } else { + $pre .= $indent . '  '; + } + + /* + * 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 = ''; + + if ($settings['messageRecyclingEnabled'] && $box['MailboxFullName'] == $settings['trashFolderName']) { + $pre .= $view_link; + + // Boxes with unread messages should be emphasized + if ($box['UnreadCount'] > 0) { + $pre .= ''; + $end .= ''; + } + $end .= ''; + + // Print unread info + if ($box['UnreadCount'] > 0) { + if (!empty($unseen_str)) { + $end .= ' ('.$unseen_str.')'; + } + $end .= "\n" . + '  ['. _("Purge").']' . + ''; + } + } 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 .= ''; + $end .= ''; + } + $end .= ''; + } + + // Display unread info... + if (!empty($unseen_str)) { + $end .= ' ('.$unseen_str.')'; + } + } + + $span = ''; + $spanend = ''; + if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) { + $span = ''; + $spanend = ''; + } elseif ( $box['IsNoSelect'] ) { + $span = ''; + $spanend = ''; + } + + // 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 .= ''; + + $out = ''; + if (!$box['IsRoot']) { + $out = $span . $pre . + str_replace( + array(' ','<','>'), + array(' ','<','>'), + $box['MailboxName']) . + $end . $spanend . '
' . "\n"; + $indent_factor++; + } + + if (!$box['IsCollapsed'] || $box['IsRoot']) { + for ($i = 0; $i + +
+ + + + + +
+ + + + +
+
+ + [] +
+
+ +
+ +
diff --git a/templates/default/left_main_advanced.tpl b/templates/default/left_main_advanced.tpl new file mode 100644 index 00000000..f0b0fdc1 --- /dev/null +++ b/templates/default/left_main_advanced.tpl @@ -0,0 +1,384 @@ + + + + + +
+ +
+ + + + +
+
+
+
+
+ + + + + +
+ + + + +
+
+ + [] +
+
+ +
+ +
+ \ No newline at end of file diff --git a/templates/default/message_list.tpl b/templates/default/message_list.tpl index 748329c2..a335c183 100644 --- a/templates/default/message_list.tpl +++ b/templates/default/message_list.tpl @@ -13,6 +13,7 @@ */ /** add required includes */ +include_once(SM_PATH . 'templates/util_global.php'); 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 @@ -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: - if ($bIcons) { - echo '!'."\n"; - } else { - echo ' '."\n"; - } - break; + echo getIcon($icon_theme_path, 'msg_new.png', ' ', _("Message Flags")) . "\n"; + break; case SQM_COL_SIZE: echo _("Size")."\n"; break; case SQM_COL_PRIO: - if ($bIcons) { - echo '!'."\n"; - } else { - echo '!'."\n"; - } - break; + echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n"; + break; case SQM_COL_ATTACHMENT: - if ($bIcons) { - echo '+'."\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; @@ -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]) { - $newsort = $aSortSupported[$iCol][1]; - $img = 'up_pointer.png'; + $newsort = $aSortSupported[$iCol][1]; + $img = 'up_pointer.png'; } else if ($sort == $aSortSupported[$iCol][1]) { - $newsort = 0; - $img = 'down_pointer.png'; + $newsort = 0; + $img = 'down_pointer.png'; } 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. */ - echo " "; - echo 'sort'."\n"; + echo " " . + getIcon($icon_theme_path, $img, ' ', _("Click here to change the sorting of the message list")) . "\n" . + ''; } ?> @@ -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 ($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; } @@ -349,25 +327,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16]; * Check the priority column */ if (isset($aColumns[SQM_COL_PRIO])) { - /* FIX ME, we should use separate templates for icons */ - if ($bIcons) { - $sValue = ' ' ; 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 .= '!'; break; - // use downwards arrow for low priority emails - case 5: $sValue .= ''; break; - default: break; - } - } + $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path); $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])) { - /* FIX ME, we should use separate templates for icons */ - if ($bIcons) { - $sValue = '' - : '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; } diff --git a/templates/default/stylesheet.tpl b/templates/default/stylesheet.tpl index 59ad74b4..c2c00f28 100644 --- a/templates/default/stylesheet.tpl +++ b/templates/default/stylesheet.tpl @@ -65,7 +65,7 @@ body { color: ; background-color: ; } -body.leftmain { +body.sqm_leftMain { color: ; background-color: ; text-align: left; @@ -77,10 +77,10 @@ a:link, a:visited, a:hover, a:active { } /* 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: ; } -.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: ; } .leftrecent { @@ -103,7 +103,7 @@ a:link, a:visited, a:hover, a:active { border-spacing:0; width:99% } -.leftmain table { +sqm_leftMain table { border:0; padding:0; margin:0; @@ -203,6 +203,9 @@ em { small { font-size:80%; } +img { + border:0; +} /* login.tpl definitions */ #sqm_login table { @@ -220,7 +223,6 @@ small { .sqm_loginImage { margin-left:auto; margin-right:auto; - border:0; padding:2px; } .sqm_loginTop { @@ -367,7 +369,7 @@ small { } .message_list_controls { - background: ; + background: ; } .message_control_button { diff --git a/templates/util_global.php b/templates/util_global.php new file mode 100644 index 00000000..9c8f3912 --- /dev/null +++ b/templates/util_global.php @@ -0,0 +1,56 @@ +'; + } 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 index 00000000..aa63b45d --- /dev/null +++ b/templates/util_left_main.php @@ -0,0 +1,114 @@ +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 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&startMessage=1&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 .' ' + ); + + $box['ChildBoxes'] = array(); + for ($i = 0; $i mbxs); $i++) { + $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs[$i]); + } + + return $box; +} + + +?> \ No newline at end of file diff --git a/templates/util_message_list.php b/templates/util_message_list.php index 0170d22f..6d7c4c1a 100644 --- a/templates/util_message_list.php +++ b/templates/util_message_list.php @@ -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 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 @@ -100,27 +98,29 @@ function getFlagIcon($aFlags, $sImageLocation) { /** * 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', ' ', '('._("New").')') , + array ('msg_read.png', ' ', '('._("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, @@ -130,109 +130,74 @@ function getFlagIcon($aFlags, $sImageLocation) { /** * The flags entry contain all items displayed in the flag column. */ - $iFlagIndx = 0; + $icon = ''; + + $index = 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; + case 'flagged': if ($flagvalue) $index += $flag_values[$flag]; break; default: break; } } - if (isset($aFlagImages[$iFlagIndx])) { - $aFlagEntry = $aFlagImages[$iFlagIndx]; + + if (isset($flag_icons[$index])) { + $data = $flag_icons[$index]; } else { - $aFlagEntry = end($aFlagImages); + $data = end($flag_icons); } - $sFlags = ''.$aFlagEntry[1].'' ; - if (!$sFlags) { $sFlags = ' '; } - 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(' ', '('._("New").')'), - array(' ', '('._("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', '!'); + break; + case 5: + $icon = getIcon($icon_theme_path, 'prio_low.png', ''); + 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 = ' '; } - 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