You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hide_blockquote.php 2.4KB

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