summaryrefslogtreecommitdiff
path: root/plugins/help/help.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-07-04 14:51:58 +0200
committerThomas Bruederli <thomas@roundcube.net>2013-07-04 14:51:58 +0200
commit08167e91140e533dbc52279071767813fee8401c (patch)
tree92353916927b774b093f916f945276ae2e75318f /plugins/help/help.php
parentcb1715cd165b5f0883d96e6350239f74fdb76a58 (diff)
Improve help plugin with some options to display contents according to the current task/step
Diffstat (limited to 'plugins/help/help.php')
-rw-r--r--plugins/help/help.php57
1 files changed, 47 insertions, 10 deletions
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 @@
<?php
/**
- * Help Plugin
+ * Roundcube Help Plugin
*
* @author Aleksander 'A.L.E.C' Machniak
+ * @author Thomas Bruederli <thomas@roundcube.net>
* @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);
+ }
}