thomascube
2012-03-31 48e9c14ebded89d858c8be0333f77f77a81b0877
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
45         $skin = $rcmail->config->get('skin');
46         if (!file_exists($this->home."/skins/$skin/help.css"))
47             $skin = 'default';
48
49         // add style for taskbar button (must be here) and Help UI    
50         $this->include_stylesheet("skins/$skin/help.css");
51     }
52
53     function action()
54     {
55         $rcmail = rcmail::get_instance();
56
57         $this->load_config();
58
59         // register UI objects
60         $rcmail->output->add_handlers(array(
61             'helpcontent' => array($this, 'content'),
62         ));
63
64         if ($rcmail->action == 'about')
65             $rcmail->output->set_pagetitle($this->gettext('about'));
66         else if ($rcmail->action == 'license')
67             $rcmail->output->set_pagetitle($this->gettext('license'));
68         else
69             $rcmail->output->set_pagetitle($this->gettext('help'));
70
71         $rcmail->output->send('help.help');
72     }
73
74     function content($attrib)
75     {
76         $rcmail = rcmail::get_instance();
77
78         if ($rcmail->action == 'about') {
79             return @file_get_contents($this->home.'/content/about.html');
80         }
81         else if ($rcmail->action == 'license') {
82             return @file_get_contents($this->home.'/content/license.html');
83         }
84
85         // default content: iframe
86         if ($src = $rcmail->config->get('help_source'))
87             $attrib['src'] = $src;
88
89         if (empty($attrib['id']))
90             $attrib['id'] = 'rcmailhelpcontent';
91
92         $attrib['name'] = $attrib['id'];
93
94         return html::tag('iframe', $attrib, '', array(
95             'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
96     }
97
98 }