From 9f1f754daf4b57a0d0d3aea95d2321716d218cf5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 22 Nov 2015 03:41:53 -0500 Subject: [PATCH] CS fixes --- plugins/help/help.php | 39 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 36 insertions(+), 3 deletions(-) diff --git a/plugins/help/help.php b/plugins/help/help.php index 66c4256..029ab97 100644 --- a/plugins/help/help.php +++ b/plugins/help/help.php @@ -33,6 +33,12 @@ $this->register_action('about', array($this, 'action')); $this->register_action('license', array($this, 'action')); + $this->add_hook('startup', array($this, 'startup')); + $this->add_hook('error_page', array($this, 'error_page')); + } + + function startup($args) + { $rcmail = rcmail::get_instance(); // add taskbar button @@ -61,6 +67,7 @@ // register UI objects $rcmail->output->add_handlers(array( 'helpcontent' => array($this, 'content'), + 'tablink' => array($this, 'tablink'), )); if ($rcmail->action == 'about') @@ -73,6 +80,20 @@ $rcmail->output->send('help.help'); } + function tablink($attrib) + { + $rcmail = rcmail::get_instance(); + + $attrib['name'] = 'helplink' . $attrib['action']; + $attrib['href'] = $rcmail->url(array('_action' => $attrib['action'], '_extwin' => !empty($_REQUEST['_extwin']) ? 1 : null)); + + // title might be already translated here, so revert to it's initial value + // so button() will translate it correctly + $attrib['title'] = $attrib['label']; + + return $rcmail->output->button($attrib); + } + function content($attrib) { $rcmail = rcmail::get_instance(); @@ -82,7 +103,8 @@ 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'))); + $default = $rcmail->url(array('_task' => 'settings', '_action' => 'about', '_framed' => 1)); + $src = $rcmail->config->get('help_about_url', $default); break; case 'license': @@ -119,13 +141,24 @@ return $rcmail->output->frame($attrib); } + function error_page($args) + { + $rcmail = rcmail::get_instance(); + + if ($args['code'] == 403 && $rcmail->request_status == rcube::REQUEST_ERROR_URL && ($url = $rcmail->config->get('help_csrf_info'))) { + $args['text'] .= '<p>' . html::a(array('href' => $url, 'target' => '_blank'), $this->gettext('csrfinfo')) . '</p>'; + } + + return $args; + } private function resolve_language($path) { // resolve language placeholder - $rcmail = rcmail::get_instance(); + $rcmail = rcmail::get_instance(); $langmap = $rcmail->config->get('help_language_map', array('*' => 'en_US')); - $lang = !empty($langmap[$_SESSION['language']]) ? $langmap[$_SESSION['language']] : $langmap['*']; + $lang = $langmap[$_SESSION['language']] ?: $langmap['*']; + return str_replace('%l', $lang, $path); } } -- Gitblit v1.9.1