From 505e00aad983adab70d4b001f450064cbda37b86 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Wed, 24 Jan 2007 06:51:15 +0000 Subject: [PATCH] Add preview pane to advanced default template. This serves as an example of how to use a plugin to provide backend functionality introduced by a template (preview pane needs to be turned on/off by settings in the display preferences, which the plugin does; actual preview pane output is done by the template set). Note any plugin can be turned on or off for a given skin using the template's own config file. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12197 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/preview_pane/INSTALL | 11 + plugins/preview_pane/README | 106 +++++++++ plugins/preview_pane/empty_frame.php | 23 ++ plugins/preview_pane/functions.php | 166 ++++++++++++++ plugins/preview_pane/index.php | 19 ++ plugins/preview_pane/setup.php | 122 ++++++++++ .../templates/default/empty_frame.tpl | 25 +++ plugins/preview_pane/version | 2 + templates/default_advanced/config.php | 2 +- templates/default_advanced/page_header.tpl | 114 ++++++++++ .../default_advanced/read_menubar_buttons.tpl | 187 +++++++++++++++ .../default_advanced/read_menubar_nav.tpl | 212 ++++++++++++++++++ templates/default_advanced/webmail.tpl | 70 ++++++ 13 files changed, 1058 insertions(+), 1 deletion(-) create mode 100644 plugins/preview_pane/INSTALL create mode 100644 plugins/preview_pane/README create mode 100644 plugins/preview_pane/empty_frame.php create mode 100644 plugins/preview_pane/functions.php create mode 100644 plugins/preview_pane/index.php create mode 100644 plugins/preview_pane/setup.php create mode 100644 plugins/preview_pane/templates/default/empty_frame.tpl create mode 100644 plugins/preview_pane/version create mode 100644 templates/default_advanced/page_header.tpl create mode 100644 templates/default_advanced/read_menubar_buttons.tpl create mode 100644 templates/default_advanced/read_menubar_nav.tpl create mode 100644 templates/default_advanced/webmail.tpl diff --git a/plugins/preview_pane/INSTALL b/plugins/preview_pane/INSTALL new file mode 100644 index 00000000..ffb477ef --- /dev/null +++ b/plugins/preview_pane/INSTALL @@ -0,0 +1,11 @@ +Installing Preview Pane +======================= + +This plugin should only be activated by a skin (template set) +that is capable of displaying a message preview pane. One +such skin (template set) is the "default advanced" one that +comes with the SquirrelMail base package. + +No manual activation or installation steps are required. + + diff --git a/plugins/preview_pane/README b/plugins/preview_pane/README new file mode 100644 index 00000000..ed8c6f9f --- /dev/null +++ b/plugins/preview_pane/README @@ -0,0 +1,106 @@ +Preview Pane plugin for SquirrelMail +==================================== +Ver 2.0, 2007/01/23 + +Original author: Paul Lesniewski + + +Description +=========== + +This plugin allows the user to turn on an extra frame below +the mailbox message list where the messages themselves are +displayed, very similar to many other popular (typically +non-web-based) email clients. + +Note that users must turn this functionality on by going to +the Options-->Display Preferences menu. + +This plugin is part of the SquirrelMail core package and +should never be replaced with a downloaded copy (that which +is available on the SquirrelMail website under Plugins is +only applicable to SquirrelMail 1.4.x). + +This plugin should be activated only by a skin (template set) +that is capable of displaying a message preview pane. One +such skin (template set) is the "default advanced" one that +comes with the SquirrelMail base package. + + + +License +======= + +This plugin is released under the GNU General Public +License (see the file COPYING for details). + + + +Requirements +============ + + * SquirrelMail version 1.5.2+ + + + +Help Requests +============= + +Help requests should be posted to the SquirrelMail Plugins +mailing list. + +Info about the SquirrelMail Plugins mailing list can be found +on the SquirrelMail web site. It is currently located at: + +http://lists.sourceforge.net/mailman/listinfo/squirrelmail-plugins +squirrelmail-plugins@lists.sourceforge.net + + + +Change Log +========== + + v2.0 2007/01/23 Paul Lesniewski + * Integration into SquirrelMail core + * Strip out most interface functionality; migrate to "default + advanced" template set + * Only works with 1.5.2+ + + v1.3 2007/01/19 Paul Lesniewski + * Introduce slight delay refreshing message list so read messages + actually refresh as having been read + * Added 1.4.9 patch; versions between 1.4.3 and 1.4.9 should be + patch-able with the 1.4.3 patch + * Added 1.4.9 patch for delete, move, next plugin + * Added 1.5.1 patch, then removed it ;-p 1.5.2 supports this + functionality natively. + * Patches run from plugin directory now + * Translations now kept in SquirrelMail locales packages, not in + this plugin; translators please send your translations to the + squirrelmail-i18n mailing list + * Added requisite informational functions in setup.php per plugin specs + * Use $PHP_SELF instead of REQUEST_URI, since apparently the latter is not + always 100% reliable. + * No longer support replacement source files; patches are more than enough + * Fully compatible with Windows plugin, version 1.7+ + + v1.2 2004/06/08 Paul Lesniewski + * Added javascript fix so delete link will work when messages are + viewed "in new window" - please give feedback if this causes problems + * Fixed missing locale switch (Thanks to Alexandros Vellis ) + * Added Greek locale (Thanks to Alexandros Vellis ) + * Updated patch for compatibility with Archive Mail plugin version 1.2 + * Fixed placement of Clear button (no, non Archive Mail users, that button + was never supposed to be so blatantly placed in the middle of your screen) + Please report placement problems if they persist. + * Updated patch for 1.5.1 (works only against 1.5.1cvs as of approximately + 06/08/04) + * Added patch for compatibility with the delete_move_next plugin under + SquirrelMail 1.4.x + + v1.1 2004/07/03 Paul Lesniewski + * Added option to split frames vertically instead of horizontally + + v1.0 2004/20/02 Paul Lesniewski + * Initial version + diff --git a/plugins/preview_pane/empty_frame.php b/plugins/preview_pane/empty_frame.php new file mode 100644 index 00000000..6a8801aa --- /dev/null +++ b/plugins/preview_pane/empty_frame.php @@ -0,0 +1,23 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage preview_pane + * + */ + + +include_once('../../include/init.php'); + +global $org_title; +displayHtmlHeader($org_title, '', FALSE, FALSE); + +$oTemplate->display('plugins/preview_pane/empty_frame.tpl'); + + diff --git a/plugins/preview_pane/functions.php b/plugins/preview_pane/functions.php new file mode 100644 index 00000000..824c9fd1 --- /dev/null +++ b/plugins/preview_pane/functions.php @@ -0,0 +1,166 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage preview_pane + * + */ + + +/** + * Build user options for display on "Display Preferences" page + * + */ +function preview_pane_show_options_do() +{ + + if (!checkForJavascript()) return; + + global $data_dir, $username; + $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0); + $previewPane_vertical_split = getPref($data_dir, $username, 'previewPane_vertical_split', 0); + $previewPane_size = getPref($data_dir, $username, 'previewPane_size', 300); + $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1); + + + global $optpage_data; + $optpage_data['vals'][1][] = array( + 'name' => 'use_previewPane', + 'caption' => _("Show Message Preview Pane"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'initial_value' => $use_previewPane, + 'refresh' => SMOPT_REFRESH_ALL, + ); + $optpage_data['vals'][1][] = array( + 'name' => 'previewPane_vertical_split', + 'caption' => _("Split Preview Pane Vertically"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'initial_value' => $previewPane_vertical_split, + 'refresh' => SMOPT_REFRESH_ALL, + ); + $optpage_data['vals'][1][] = array( + 'name' => 'previewPane_size', + 'caption' => _("Message Preview Pane Size"), + 'type' => SMOPT_TYPE_INTEGER, + 'initial_value' => $previewPane_size, + 'refresh' => SMOPT_REFRESH_ALL, + 'size' => SMOPT_SIZE_TINY, + ); + $optpage_data['vals'][1][] = array( + 'name' => 'pp_refresh_message_list', + 'caption' => _("Always Refresh Message List
When Using Preview Pane"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'initial_value' => $pp_refresh_message_list, + 'refresh' => SMOPT_REFRESH_ALL, + ); + +} + + +/** + * This function determines if the preview pane is in use + * (and JavaScript is available) + * + * @return boolean TRUE if the preview pane should be showing currently. + * + */ +function show_preview_pane() +{ + $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0); + return (checkForJavascript() && $use_previewPane); +} + + +/** + * Construct button that clears out any preview pane + * contents and inserts JavaScript function used by + * message subject link onclick handler. Also disallows + * the message list to be loaded into the bottom frame. + * + */ +function preview_pane_message_list_do() +{ + + if (!checkForJavascript()) return; + + global $plugins, $archive_mail_button_has_been_printed, + $username, $data_dir, $PHP_SELF, $base_uri; + + + $output = ''; + $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0); + + + // add refresh function called from code built in function + // preview_pane_change_message_target_do() + // + if ($use_previewPane == 1 + && getPref($data_dir, $username, 'pp_refresh_message_list', 1) == 1) + { +// sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER); + $request_uri = $PHP_SELF; + $output .= "\n"; + } + + + if ($use_previewPane == 1) + { + $output .= '' + + + // don't let message list load into preview pane at all + // + . "\n\n"; + } + + return array('mailbox_index_after' => $output); + +} + + +/** + * Points message targets to open in the preview pane + * (and possibly refresh message list as well) + * + */ +function preview_pane_change_message_target_do() +{ + + if (!checkForJavascript()) return; + + global $data_dir, $username, $target, $onclick, $PHP_SELF; +// sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER); + $request_uri = $PHP_SELF; + + + if (getPref($data_dir, $username, 'use_previewPane', 0) == 1) + { + $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1); + + $target = 'bottom'; + if ($pp_refresh_message_list) +// introduce a delay so read messages actually refresh after they are read +// $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " '; + $onclick .= ' setTimeout(\'pp_refresh()\', 500); '; + } + +} + + + diff --git a/plugins/preview_pane/index.php b/plugins/preview_pane/index.php new file mode 100644 index 00000000..5ca705c7 --- /dev/null +++ b/plugins/preview_pane/index.php @@ -0,0 +1,19 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage preview_pane + * + */ + + +/** + * Register this plugin with SquirrelMail + * + */ +function squirrelmail_plugin_init_preview_pane() +{ + + global $squirrelmail_plugin_hooks; + + + $squirrelmail_plugin_hooks['subject_link']['preview_pane'] + = 'preview_pane_change_message_target'; + $squirrelmail_plugin_hooks['optpage_loadhook_display']['preview_pane'] + = 'preview_pane_show_options'; + $squirrelmail_plugin_hooks['template_construct_message_list.tpl']['preview_pane'] + = 'preview_pane_message_list'; + +} + + +if (!defined('SM_PATH')) + define('SM_PATH', '../'); + + +/** + * Returns info about this plugin + * + */ +function preview_pane_info() +{ + + return array( + 'english_name' => 'Preview Pane', + 'version' => '2.0', + 'required_sm_version' => '1.5.2', + 'requires_configuration' => 0, + 'requires_source_patch' => 0, + 'required_plugins' => array( + ), + 'summary' => 'Provides a third frame below the message list for viewing message bodies.', + 'details' => 'This plugin allows the user to turn on an extra frame below the mailbox message list where the messages themselves are displayed, very similar to many other popular (typically non-web-based) email clients.', + ); + +} + + + +/** + * Returns version info about this plugin + * + */ +function preview_pane_version() +{ + + $info = preview_pane_info(); + return $info['version']; + +} + + + +/** + * Build user options for display on "Display Preferences" page + * + */ +function preview_pane_show_options() +{ + + include_once(SM_PATH . 'plugins/preview_pane/functions.php'); + preview_pane_show_options_do(); + +} + + + +/** + * Construct button that clears out any preview pane + * contents and inserts JavaScript function used by + * message subject link onclick handler. Also disallows + * the message list to be loaded into the bottom frame. + * + */ +function preview_pane_message_list() +{ + + include_once(SM_PATH . 'plugins/preview_pane/functions.php'); + return preview_pane_message_list_do(); + +} + + + +/** + * Points message targets to open in the preview pane + * (and possibly refresh message list as well) + * + */ +function preview_pane_change_message_target() +{ + + include_once(SM_PATH . 'plugins/preview_pane/functions.php'); + preview_pane_change_message_target_do(); + +} + + + diff --git a/plugins/preview_pane/templates/default/empty_frame.tpl b/plugins/preview_pane/templates/default/empty_frame.tpl new file mode 100644 index 00000000..b2ea0f02 --- /dev/null +++ b/plugins/preview_pane/templates/default/empty_frame.tpl @@ -0,0 +1,25 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage preview_pane + * + */ + + +// retrieve the template vars +// +extract($t); + + +?> + + diff --git a/plugins/preview_pane/version b/plugins/preview_pane/version new file mode 100644 index 00000000..bae18a37 --- /dev/null +++ b/plugins/preview_pane/version @@ -0,0 +1,2 @@ +Preview Pane +2.0-1.5.2 diff --git a/templates/default_advanced/config.php b/templates/default_advanced/config.php index 45df26d8..5cb32fda 100644 --- a/templates/default_advanced/config.php +++ b/templates/default_advanced/config.php @@ -39,7 +39,7 @@ $parent_template_set = 'default'; * will be disabled, and only those in $add_plugins will be enabled. * */ -$add_plugins = array(); +$add_plugins = array('preview_pane',); $remove_plugins = array(); diff --git a/templates/default_advanced/page_header.tpl b/templates/default_advanced/page_header.tpl new file mode 100644 index 00000000..a2880de7 --- /dev/null +++ b/templates/default_advanced/page_header.tpl @@ -0,0 +1,114 @@ + '' && strtolower( $shortBoxName ) <> 'none' ) { + $current_folder_str .= _("Current Folder") . ": $shortBoxName \n"; +} else { + $current_folder_str .= ' '; +} + +// Define our default link text. +$signout_link_default = _("Sign Out"); +$compose_link_default = _("Compose"); +$address_link_default = _("Addresses"); +$folders_link_default = _("Folders"); +$options_link_default = _("Options"); +$search_link_default = _("Search"); +$help_link_default = _("Help"); + +/* + * Create strings to use for links. If tempalte authors + * wish to use images instead, they may change the values + * below to img tags. + + * Example w/ image: + * $compose_str = ''; + */ + +$signout_str = $signout_link_default; +$compose_str = $compose_link_default; +$address_str = $address_link_default; +$folders_str = $folders_link_default; +$options_str = $options_link_default; +$search_str = $search_link_default; +$help_str = $help_link_default; + +$compose_link = makeComposeLink ('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage, $compose_str); +$signout_link = makeInternalLink ('src/signout.php', $signout_str, $frame_top); +$address_link = makeInternalLink ('src/addressbook.php', $address_str); +$folders_link = makeInternalLink ('src/folders.php', $folders_str); +$search_link = makeInternalLink ('src/search.php?mailbox='.$urlMailbox, $search_str); +$options_link = makeInternalLink ('src/options.php', $options_str); +$help_link = makeInternalLink ('src/help.php', $help_str); + +?> +> + + +
+ + + + + +
+ + + + + +
+
> + + + " />  + + " />  + + " />  + " /> +   |   + " /> + + + + + +
+   |   + +
+ + + '; ?> + + + +
+ + +
+ +
+ + + : + + '; + + + if ($can_be_copied) { + ?> + " /> + + +
+ +
+
diff --git a/templates/default_advanced/read_menubar_nav.tpl b/templates/default_advanced/read_menubar_nav.tpl new file mode 100644 index 00000000..ba76161d --- /dev/null +++ b/templates/default_advanced/read_menubar_nav.tpl @@ -0,0 +1,212 @@ + + + +
+ + + + +
+
diff --git a/templates/default_advanced/webmail.tpl b/templates/default_advanced/webmail.tpl new file mode 100644 index 00000000..365cdb31 --- /dev/null +++ b/templates/default_advanced/webmail.tpl @@ -0,0 +1,70 @@ +\n"; +} +else { + $output .= "\n"; +} + + +$left_frame = ''."\n"; + + +/** use preview pane? */ +if ($show_preview_pane) { + $right_frame = "\n" + . "\n" + . "\n" + . "\n"; + +/** no preview pane */ +} else { + $right_frame = ''."\n"; +} + + +if ($nav_on_left) { + $output .= $left_frame . $right_frame; +} else { + $output .= $right_frame . $left_frame; +} + +echo $output ."\n\n"; -- 2.25.1