This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
threecol.php
executable file
·93 lines (79 loc) · 2.85 KB
/
threecol.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* ThreeCol
*
* Plugin to switch Roundcube to a three column layout
*
* @version @package_version@
* @author Philip Weir
*/
class threecol extends rcube_plugin
{
public $task = 'mail|settings';
private $driver;
function init()
{
$rcmail = rcube::get_instance();
$no_override = array_flip($rcmail->config->get('dont_override', array()));
$this->driver = $this->home .'/skins/'. $rcmail->config->get('skin') .'/func.php';
if (is_readable($this->driver)) {
if ($rcmail->task == 'mail' && $rcmail->action == '' && $rcmail->config->get('previewpane_layout', 'below') == 'right') {
$this->add_hook('render_page', array($this, 'render'));
$this->include_script($this->local_skin_path() .'/threecol.js');
$this->include_stylesheet($this->local_skin_path() .'/threecol.css');
}
elseif ($rcmail->task == 'settings' && !isset($no_override['previewpane_layout'])) {
$this->add_hook('preferences_list', array($this, 'show_settings'));
$this->add_hook('preferences_save', array($this, 'save_settings'));
}
}
else {
rcube::raise_error(array(
'code' => 600,
'type' => 'php',
'file' => __FILE__,
'line' => __LINE__,
'message' => "ThreeCol plugin: Unable to open driver file $this->driver"
), true, false);
}
}
function render($args)
{
include_once($this->driver);
if (!function_exists('render_page')) {
rcube::raise_error(array(
'code' => 600,
'type' => 'php',
'file' => __FILE__,
'line' => __LINE__,
'message' => "ThreeCol plugin: Broken driver: $this->driver"
), true, false);
}
$args = render_page($args);
return $args;
}
function show_settings($args)
{
if ($args['section'] == 'mailbox') {
$this->add_texts('localization/');
$field_id = 'rcmfd_previewpane_layout';
$select = new html_select(array('name' => '_previewpane_layout', 'id' => $field_id));
$select->add(rcmail::Q($this->gettext('threecol.none')), 'none');
$select->add(rcmail::Q($this->gettext('threecol.below')), 'below');
$select->add(rcmail::Q($this->gettext('threecol.right')), 'right');
// add new option at the top of the list
$val = rcube::get_instance()->config->get('preview_pane') ? rcube::get_instance()->config->get('previewpane_layout', 'below') : 'none';
$args['blocks']['main']['options']['preview_pane']['content'] = $select->show($val);
}
return $args;
}
function save_settings($args)
{
if ($args['section'] == 'mailbox') {
$args['prefs']['preview_pane'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) == 'none' ? false : true;
$args['prefs']['previewpane_layout'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) != 'none' ? rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) : rcube::get_instance()->config->get('previewpane_layout', 'below');
}
return $args;
}
}
?>