0
|
1 <?php
|
|
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).
|
|
11 * $config['hide_blockquote_limit'] = 0;
|
|
12 *
|
|
13 * @license GNU GPLv3+
|
|
14 * @author Aleksander Machniak <alec@alec.pl>
|
|
15 */
|
|
16 class hide_blockquote extends rcube_plugin
|
|
17 {
|
|
18 public $task = 'mail|settings';
|
|
19
|
|
20 function init()
|
|
21 {
|
|
22 $rcmail = rcmail::get_instance();
|
|
23
|
|
24 if ($rcmail->task == 'mail'
|
|
25 && ($rcmail->action == 'preview' || $rcmail->action == 'show')
|
|
26 && ($limit = $rcmail->config->get('hide_blockquote_limit'))
|
|
27 ) {
|
|
28 // include styles
|
|
29 $this->include_stylesheet($this->local_skin_path() . "/style.css");
|
|
30
|
|
31 // Script and localization
|
|
32 $this->include_script('hide_blockquote.js');
|
|
33 $this->add_texts('localization', true);
|
|
34
|
|
35 // set env variable for client
|
|
36 $rcmail->output->set_env('blockquote_limit', $limit);
|
|
37 }
|
|
38 else if ($rcmail->task == 'settings') {
|
|
39 $dont_override = $rcmail->config->get('dont_override', array());
|
|
40 if (!in_array('hide_blockquote_limit', $dont_override)) {
|
|
41 $this->add_hook('preferences_list', array($this, 'prefs_table'));
|
|
42 $this->add_hook('preferences_save', array($this, 'save_prefs'));
|
|
43 }
|
|
44 }
|
|
45 }
|
|
46
|
|
47 function prefs_table($args)
|
|
48 {
|
|
49 if ($args['section'] != 'mailview') {
|
|
50 return $args;
|
|
51 }
|
|
52
|
|
53 $this->add_texts('localization');
|
|
54
|
|
55 $rcmail = rcmail::get_instance();
|
|
56 $limit = (int) $rcmail->config->get('hide_blockquote_limit');
|
|
57 $field_id = 'hide_blockquote_limit';
|
|
58 $input = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5));
|
|
59
|
|
60 $args['blocks']['main']['options']['hide_blockquote_limit'] = array(
|
|
61 'title' => $this->gettext('quotelimit'),
|
|
62 'content' => $input->show($limit ?: '')
|
|
63 );
|
|
64
|
|
65 return $args;
|
|
66 }
|
|
67
|
|
68 function save_prefs($args)
|
|
69 {
|
|
70 if ($args['section'] == 'mailview') {
|
|
71 $args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST);
|
|
72 }
|
|
73
|
|
74 return $args;
|
|
75 }
|
|
76
|
|
77 }
|