commit | author | age
|
85a617
|
1 |
<?php |
AM |
2 |
|
|
3 |
/** |
|
4 |
* Quotation block hidding |
|
5 |
* |
|
6 |
* Plugin that adds a possibility to hide long blocks of cited text in messages. |
|
7 |
* |
|
8 |
* Configuration: |
|
9 |
* // Minimum number of citation lines. Longer citation blocks will be hidden. |
|
10 |
* // 0 - no limit (no hidding). |
bcedf0
|
11 |
* $config['hide_blockquote_limit'] = 0; |
85a617
|
12 |
* |
AM |
13 |
* @version @package_version@ |
|
14 |
* @license GNU GPLv3+ |
|
15 |
* @author Aleksander Machniak <alec@alec.pl> |
|
16 |
*/ |
|
17 |
class hide_blockquote extends rcube_plugin |
|
18 |
{ |
|
19 |
public $task = 'mail|settings'; |
|
20 |
|
|
21 |
function init() |
|
22 |
{ |
|
23 |
$rcmail = rcmail::get_instance(); |
|
24 |
|
|
25 |
if ($rcmail->task == 'mail' |
|
26 |
&& ($rcmail->action == 'preview' || $rcmail->action == 'show') |
|
27 |
&& ($limit = $rcmail->config->get('hide_blockquote_limit')) |
|
28 |
) { |
|
29 |
// include styles |
b2631b
|
30 |
$this->include_stylesheet($this->local_skin_path() . "/style.css"); |
85a617
|
31 |
|
AM |
32 |
// Script and localization |
|
33 |
$this->include_script('hide_blockquote.js'); |
|
34 |
$this->add_texts('localization', true); |
|
35 |
|
|
36 |
// set env variable for client |
|
37 |
$rcmail->output->set_env('blockquote_limit', $limit); |
|
38 |
} |
|
39 |
else if ($rcmail->task == 'settings') { |
|
40 |
$dont_override = $rcmail->config->get('dont_override', array()); |
|
41 |
if (!in_array('hide_blockquote_limit', $dont_override)) { |
|
42 |
$this->add_hook('preferences_list', array($this, 'prefs_table')); |
|
43 |
$this->add_hook('preferences_save', array($this, 'save_prefs')); |
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
function prefs_table($args) |
|
49 |
{ |
|
50 |
if ($args['section'] != 'mailview') { |
|
51 |
return $args; |
|
52 |
} |
|
53 |
|
|
54 |
$this->add_texts('localization'); |
|
55 |
|
|
56 |
$rcmail = rcmail::get_instance(); |
|
57 |
$limit = (int) $rcmail->config->get('hide_blockquote_limit'); |
|
58 |
$field_id = 'hide_blockquote_limit'; |
|
59 |
$input = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5)); |
|
60 |
|
|
61 |
$args['blocks']['main']['options']['hide_blockquote_limit'] = array( |
9f1f75
|
62 |
'title' => $this->gettext('quotelimit'), |
AM |
63 |
'content' => $input->show($limit ?: '') |
85a617
|
64 |
); |
AM |
65 |
|
|
66 |
return $args; |
|
67 |
} |
|
68 |
|
|
69 |
function save_prefs($args) |
|
70 |
{ |
|
71 |
if ($args['section'] == 'mailview') { |
61be82
|
72 |
$args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST); |
85a617
|
73 |
} |
AM |
74 |
|
|
75 |
return $args; |
|
76 |
} |
|
77 |
|
|
78 |
} |