views_handler_area_text_custom.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_area_text_custom.
  5. */
  6. /**
  7. * Views area text custom handler.
  8. *
  9. * @ingroup views_area_handlers
  10. */
  11. class views_handler_area_text_custom extends views_handler_area_text {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function option_definition() {
  16. $options = parent::option_definition();
  17. unset($options['format']);
  18. return $options;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function options_form(&$form, &$form_state) {
  24. parent::options_form($form, $form_state);
  25. // Alter the form element, to be a regular text area.
  26. $form['content']['#type'] = 'textarea';
  27. unset($form['content']['#format']);
  28. unset($form['content']['#wysiwyg']);
  29. // @todo Use the token refactored base class.
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function options_submit(&$form, &$form_state) {
  35. // Empty, so we don't inherit options_submit from the parent.
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function render($empty = FALSE) {
  41. if (!$empty || !empty($this->options['empty'])) {
  42. return $this->render_textarea_custom($this->options['content']);
  43. }
  44. return '';
  45. }
  46. /**
  47. * Render a text area with filter_xss_admin.
  48. *
  49. * @param string $value
  50. * The text area string to process.
  51. *
  52. * @return string
  53. * The string after it has been sanitized, optionally tokenized too.
  54. */
  55. public function render_textarea_custom($value) {
  56. if ($value) {
  57. if ($this->options['tokenize']) {
  58. $value = $this->view->style_plugin->tokenize_value($value, 0);
  59. }
  60. return $this->sanitize_value($value, 'xss_admin');
  61. }
  62. }
  63. }