]> git.donarmstrong.com Git - roundcube.git/blob - plugins/help/help.php
Imported Upstream version 0.3
[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     function init()
16     {
17       $this->add_texts('localization/', false);
18       
19       // register actions
20       $this->register_action('plugin.help', array($this, 'action'));
21       $this->register_action('plugin.helpabout', array($this, 'action'));
22       $this->register_action('plugin.helplicense', array($this, 'action'));
23
24       // add taskbar button
25       $this->add_button(array(
26         'name'  => 'helptask',
27         'class' => 'button-help',
28         'label' => 'help.help',
29         'href'  => './?_task=dummy&_action=plugin.help',
30         ), 'taskbar');
31
32       $skin = rcmail::get_instance()->config->get('skin');
33       if (!file_exists($this->home."/skins/$skin/help.css"))
34         $skin = 'default';
35
36       // add style for taskbar button (must be here) and Help UI    
37       $this->include_stylesheet("skins/$skin/help.css");
38     }
39
40     function action()
41     {
42       $rcmail = rcmail::get_instance();
43
44       $this->load_config();
45
46       // register UI objects
47       $rcmail->output->add_handlers(array(
48             'helpcontent' => array($this, 'content'),
49       ));
50
51       if ($rcmail->action == 'plugin.helpabout')
52         $rcmail->output->set_pagetitle($this->gettext('about'));
53       else if ($rcmail->action == 'plugin.helplicense')
54         $rcmail->output->set_pagetitle($this->gettext('license'));
55       else
56         $rcmail->output->set_pagetitle($this->gettext('help'));
57
58       $rcmail->output->send('help.help');
59     }
60     
61     function content($attrib)
62     {
63       $rcmail = rcmail::get_instance();
64
65       if ($rcmail->action == 'plugin.helpabout') {
66         return @file_get_contents($this->home.'/content/about.html');
67       }
68       else if ($rcmail->action == 'plugin.helplicense') {
69         return @file_get_contents($this->home.'/content/license.html');
70       }
71
72       // default content: iframe
73
74       if ($src = $rcmail->config->get('help_source'))
75         $attrib['src'] = $src;
76
77       if (empty($attrib['id']))
78         $attrib['id'] = 'rcmailhelpcontent';
79     
80       // allow the following attributes to be added to the <iframe> tag
81       $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
82       $framename = $attrib['id'];
83
84       $out = sprintf('<iframe name="%s"%s></iframe>'."\n", $framename, $attrib_str);
85     
86       return $out;
87     }
88     
89 }
90
91 ?>