From 08167e91140e533dbc52279071767813fee8401c Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 4 Jul 2013 14:51:58 +0200 Subject: Improve help plugin with some options to display contents according to the current task/step --- plugins/help/config.inc.php.dist | 29 ++++++++++++- plugins/help/content/about.html | 27 ------------ plugins/help/help.js | 25 +++++++++++ plugins/help/help.php | 57 +++++++++++++++++++++----- plugins/help/localization/de_DE.inc | 2 +- plugins/help/package.xml | 9 ++-- plugins/help/skins/classic/templates/help.html | 8 ++-- plugins/help/skins/larry/templates/help.html | 2 +- 8 files changed, 109 insertions(+), 50 deletions(-) delete mode 100644 plugins/help/content/about.html create mode 100644 plugins/help/help.js diff --git a/plugins/help/config.inc.php.dist b/plugins/help/config.inc.php.dist index d440dbbcc..0fd321eca 100644 --- a/plugins/help/config.inc.php.dist +++ b/plugins/help/config.inc.php.dist @@ -1,5 +1,30 @@ /' or only '' strings as keys +// The values will be appended to the 'help_source' URL +$rcmail_config['help_index_map'] = array( + 'login' => 'login.html', + 'mail' => 'mail/index.html', + 'mail/compose' => 'mail/compose.html', +); + +// Map to translate Roundcube language codes into help document languages +// The '*' entry will be used as default +$rcmail_config['help_language_map'] = array('*' => 'en_US'); + +// Enter an absolute URL to a page displaying information about this webmail +// Alternatively, create a HTML file under /content/about.html +$rcmail_config['help_about_url'] = null; + +// Enter an absolute URL to a page displaying information about this webmail +// Alternatively, put your license text to /content/license.html +$rcmail_config['help_license_url'] = null; + +// Determine whether to open the help in a new window +$rcmail_config['help_open_extwin'] = false; + diff --git a/plugins/help/content/about.html b/plugins/help/content/about.html deleted file mode 100644 index 6e9632bec..000000000 --- a/plugins/help/content/about.html +++ /dev/null @@ -1,27 +0,0 @@ -
-

Copyright © 2005-2012, The Roundcube Dev Team

- -

-This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License (with exceptions -for skins & plugins) as published by the Free Software Foundation, -either version 3 of the License, or (at your option) any later version. -

-

-This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -

-

-You should have received a copy of the GNU General Public License -along with this program. If not, see www.gnu.org/licenses. -

- -

-For more details about licensing and the expections for skins and plugins -see roundcube.net/license. -

- -


Website: roundcube.net

-
diff --git a/plugins/help/help.js b/plugins/help/help.js new file mode 100644 index 000000000..0fb36bd00 --- /dev/null +++ b/plugins/help/help.js @@ -0,0 +1,25 @@ +/* + * Help plugin client script + * @version 1.4 + */ + +// hook into switch-task event to open the help window +if (window.rcmail) { + rcmail.addEventListener('beforeswitch-task', function(prop) { + // catch clicks to help task button + if (prop == 'help') { + if (rcmail.task == 'help') // we're already there + return false; + + var url = rcmail.url('help/index', { _rel: rcmail.task + (rcmail.env.action ? '/'+rcmail.env.action : '') }); + if (rcmail.env.help_open_extwin) { + rcmail.open_window(url, false, false); + } + else { + rcmail.redirect(url, false); + } + + return false; + } + }); +} diff --git a/plugins/help/help.php b/plugins/help/help.php index 69da6828e..66c4256a0 100644 --- a/plugins/help/help.php +++ b/plugins/help/help.php @@ -1,9 +1,10 @@ * @license GNU GPLv3+ * * Configuration (see config.inc.php.dist) @@ -21,6 +22,7 @@ class help extends rcube_plugin function init() { + $this->load_config(); $this->add_texts('localization/', false); // register task @@ -31,6 +33,8 @@ class help extends rcube_plugin $this->register_action('about', array($this, 'action')); $this->register_action('license', array($this, 'action')); + $rcmail = rcmail::get_instance(); + // add taskbar button $this->add_button(array( 'command' => 'help', @@ -40,6 +44,9 @@ class help extends rcube_plugin 'label' => 'help.help', ), 'taskbar'); + $this->include_script('help.js'); + $rcmail->output->set_env('help_open_extwin', $rcmail->config->get('help_open_extwin', false), true); + // add style for taskbar button (must be here) and Help UI $skin_path = $this->local_skin_path(); if (is_file($this->home . "/$skin_path/help.css")) { @@ -51,8 +58,6 @@ class help extends rcube_plugin { $rcmail = rcmail::get_instance(); - $this->load_config(); - // register UI objects $rcmail->output->add_handlers(array( 'helpcontent' => array($this, 'content'), @@ -72,16 +77,39 @@ class help extends rcube_plugin { $rcmail = rcmail::get_instance(); - if ($rcmail->action == 'about') { - return @file_get_contents($this->home.'/content/about.html'); - } - else if ($rcmail->action == 'license') { - return @file_get_contents($this->home.'/content/license.html'); + switch ($rcmail->action) { + case 'about': + if (is_readable($this->home . '/content/about.html')) { + return @file_get_contents($this->home . '/content/about.html'); + } + $src = $rcmail->config->get('help_about_url', $rcmail->url(array('_task' => 'settings', '_action' => 'about'))); + break; + + case 'license': + if (is_readable($this->home . '/content/license.html')) { + return @file_get_contents($this->home . '/content/license.html'); + } + $src = $rcmail->config->get('help_license_url', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html'); + break; + + default: + $src = $rcmail->config->get('help_source'); + + // resolve task/action for depp linking + $index_map = $rcmail->config->get('help_index_map', array()); + $rel = $_REQUEST['_rel']; + list($task,$action) = explode('/', $rel); + if ($add = $index_map[$rel]) + $src .= $add; + else if ($add = $index_map[$task]) + $src .= $add; + break; } // default content: iframe - if ($src = $rcmail->config->get('help_source')) - $attrib['src'] = $src; + if (!empty($src)) { + $attrib['src'] = $this->resolve_language($src); + } if (empty($attrib['id'])) $attrib['id'] = 'rcmailhelpcontent'; @@ -91,4 +119,13 @@ class help extends rcube_plugin return $rcmail->output->frame($attrib); } + + private function resolve_language($path) + { + // resolve language placeholder + $rcmail = rcmail::get_instance(); + $langmap = $rcmail->config->get('help_language_map', array('*' => 'en_US')); + $lang = !empty($langmap[$_SESSION['language']]) ? $langmap[$_SESSION['language']] : $langmap['*']; + return str_replace('%l', $lang, $path); + } } diff --git a/plugins/help/localization/de_DE.inc b/plugins/help/localization/de_DE.inc index 70c50646e..250657da6 100644 --- a/plugins/help/localization/de_DE.inc +++ b/plugins/help/localization/de_DE.inc @@ -18,7 +18,7 @@ $labels = array(); $labels['help'] = 'Hilfe'; -$labels['about'] = 'Über'; +$labels['about'] = 'Über'; $labels['license'] = 'Lizenz'; ?> diff --git a/plugins/help/package.xml b/plugins/help/package.xml index 889efd17d..d39143ba1 100644 --- a/plugins/help/package.xml +++ b/plugins/help/package.xml @@ -5,7 +5,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> help pear.roundcube.net - Help for Roundcube + Online Help for Roundcube Plugin adds a new item (Help) in taskbar. Aleksander Machniak @@ -13,10 +13,10 @@ alec@alec.pl yes - 2012-11-11 + 2013-07-03 - 1.3 - 1.2 + 1.4 + 1.4 stable @@ -31,7 +31,6 @@ - diff --git a/plugins/help/skins/classic/templates/help.html b/plugins/help/skins/classic/templates/help.html index 2e430ecf3..8a398e7b3 100644 --- a/plugins/help/skins/classic/templates/help.html +++ b/plugins/help/skins/classic/templates/help.html @@ -9,21 +9,21 @@ function help_init_settings_tabs() { var action, tab = '#helptabdefault'; if (window.rcmail && (action = rcmail.env.action)) { - tab = '#helptab' + (action ? action : 'default'); + tab = '#helptab' + (action ? action : 'default'); } $(tab).addClass('tablink-selected'); } - +
- - + +
diff --git a/plugins/help/skins/larry/templates/help.html b/plugins/help/skins/larry/templates/help.html index 39caaa62f..592a94c66 100644 --- a/plugins/help/skins/larry/templates/help.html +++ b/plugins/help/skins/larry/templates/help.html @@ -4,7 +4,7 @@ <roundcube:object name="pagetitle" /> - + -- cgit v1.2.3