Thomas Bruederli
2012-10-15 27be4e7644637255d7adbf5386ec883d9c2c64cd
commit | author | age
48e9c1 1 <?php
T 2
3 /**
4  * Help Plugin
5  *
6  * @author Aleksander 'A.L.E.C' Machniak
7  * @license GNU GPLv3+
8  *
9  * Configuration (see config.inc.php.dist)
10  * 
11  **/
12
13 class help extends rcube_plugin
14 {
15     // all task excluding 'login' and 'logout'
16     public $task = '?(?!login|logout).*';
17     // we've got no ajax handlers
18     public $noajax = true;
19     // skip frames
20     public $noframe = true;
21
22     function init()
23     {
24         $rcmail = rcmail::get_instance();
25
26         $this->add_texts('localization/', false);
27
28         // register task
29         $this->register_task('help');
30
31         // register actions
32         $this->register_action('index', array($this, 'action'));
33         $this->register_action('about', array($this, 'action'));
34         $this->register_action('license', array($this, 'action'));
35
36         // add taskbar button
37         $this->add_button(array(
38             'command'    => 'help',
39             'class'      => 'button-help',
40             'classsel'   => 'button-help button-selected',
41             'innerclass' => 'button-inner',
42             'label'      => 'help.help',
43         ), 'taskbar');
44
bc92ca 45         // add style for taskbar button (must be here) and Help UI
AM 46         $skin_path = $this->local_skin_path();
47         if (is_file($this->home . "/$skin_path/help.css")) {
48             $this->include_stylesheet("$skin_path/help.css");
49         }
48e9c1 50     }
T 51
52     function action()
53     {
54         $rcmail = rcmail::get_instance();
55
56         $this->load_config();
57
58         // register UI objects
59         $rcmail->output->add_handlers(array(
60             'helpcontent' => array($this, 'content'),
61         ));
62
63         if ($rcmail->action == 'about')
64             $rcmail->output->set_pagetitle($this->gettext('about'));
65         else if ($rcmail->action == 'license')
66             $rcmail->output->set_pagetitle($this->gettext('license'));
67         else
68             $rcmail->output->set_pagetitle($this->gettext('help'));
69
70         $rcmail->output->send('help.help');
71     }
72
73     function content($attrib)
74     {
75         $rcmail = rcmail::get_instance();
76
77         if ($rcmail->action == 'about') {
78             return @file_get_contents($this->home.'/content/about.html');
79         }
80         else if ($rcmail->action == 'license') {
81             return @file_get_contents($this->home.'/content/license.html');
82         }
83
84         // default content: iframe
85         if ($src = $rcmail->config->get('help_source'))
86             $attrib['src'] = $src;
87
88         if (empty($attrib['id']))
89             $attrib['id'] = 'rcmailhelpcontent';
90
91         $attrib['name'] = $attrib['id'];
92
93         return html::tag('iframe', $attrib, '', array(
94             'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
95     }
96
97 }