]> git.donarmstrong.com Git - roundcube.git/blob - plugins/help/help.php
0c70b3a695d463704f5a2a77fc1fbf2c119e6897
[roundcube.git] / plugins / help / help.php
1 <?php
2
3 /**
4  * Help Plugin
5  *
6  * @author Aleksander 'A.L.E.C' Machniak
7  * @licence GNU GPL
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('', 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                 'name'  => 'helptask',
39                 'class' => 'button-help',
40                 'label' => 'help.help',
41                 'href'  => './?_task=help',
42             'onclick' => sprintf("return %s.command('help')", JS_OBJECT_NAME)
43             ), 'taskbar');
44
45         $rcmail->output->add_script(
46             JS_OBJECT_NAME . ".enable_command('help', true);\n" .
47             JS_OBJECT_NAME . ".help = function () { location.href = './?_task=help'; }",
48             'head');
49
50         $skin = $rcmail->config->get('skin');
51         if (!file_exists($this->home."/skins/$skin/help.css"))
52                 $skin = 'default';
53
54         // add style for taskbar button (must be here) and Help UI    
55         $this->include_stylesheet("skins/$skin/help.css");
56     }
57
58     function action()
59     {
60         $rcmail = rcmail::get_instance();
61
62         $this->load_config();
63
64         // register UI objects
65         $rcmail->output->add_handlers(array(
66                 'helpcontent' => array($this, 'content'),
67         ));
68
69         if ($rcmail->action == 'about')
70                 $rcmail->output->set_pagetitle($this->gettext('about'));
71         else if ($rcmail->action == 'license')
72             $rcmail->output->set_pagetitle($this->gettext('license'));
73         else
74             $rcmail->output->set_pagetitle($this->gettext('help'));
75
76         $rcmail->output->send('help.help');
77     }
78
79     function content($attrib)
80     {
81         $rcmail = rcmail::get_instance();
82
83         if ($rcmail->action == 'about') {
84                 return @file_get_contents($this->home.'/content/about.html');
85         }
86         else if ($rcmail->action == 'license') {
87                 return @file_get_contents($this->home.'/content/license.html');
88         }
89
90         // default content: iframe
91
92         if ($src = $rcmail->config->get('help_source'))
93                 $attrib['src'] = $src;
94
95         if (empty($attrib['id']))
96             $attrib['id'] = 'rcmailhelpcontent';
97     
98         // allow the following attributes to be added to the <iframe> tag
99         $attrib_str = create_attrib_string($attrib, array(
100             'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
101
102         $out = sprintf('<iframe name="%s"%s></iframe>'."\n", $attrib['id'], $attrib_str);
103     
104         return $out;
105     }
106
107 }