diff --git a/lib/Drupal/views/Plugin/views/area/TextCustom.php b/lib/Drupal/views/Plugin/views/area/TextCustom.php new file mode 100644 index 0000000000000000000000000000000000000000..de49c993c7cf9a239c298cb8577fc0a3b0ceabb3 --- /dev/null +++ b/lib/Drupal/views/Plugin/views/area/TextCustom.php @@ -0,0 +1,64 @@ +<?php + +/** + * @file + * Definition of Drupal\views\Plugin\views\area\TextCustom. + */ + +namespace Drupal\views\Plugin\views\area; + +use Drupal\Core\Annotation\Plugin; + +/** + * Views area text handler. + * + * @ingroup views_area_handlers + */ + +/** + * @Plugin( + * plugin_id = "text_custom" + * ) + */ +class TextCustom extends AreaPluginBase { + + function option_definition() { + $options = parent::option_definition(); + unset($options['format']); + return $options; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + // Alter the form element, to be a regular text area. + $form['content']['#type'] = 'textarea'; + unset($form['content']['#format']); + unset($form['content']['#wysiwyg']); + } + + // Empty, so we don't inherit options_submit from the parent. + function options_submit(&$form, &$form_state) { + } + + function render($empty = FALSE) { + if (!$empty || !empty($this->options['empty'])) { + return $this->render_textarea_custom($this->options['content']); + } + + return ''; + } + + /** + * Render a text area with filter_xss_admin. + */ + function render_textarea_custom($value) { + if ($value) { + if ($this->options['tokenize']) { + $value = $this->view->style_plugin->tokenize_value($value, 0); + } + return $this->sanitize_value($value, 'xss_admin'); + } + } + +} diff --git a/modules/views.views.inc b/modules/views.views.inc index 9f04f6806894bc3baca8055cd33afafceb34e305..64e2209e110177525add1c46860acadd8fe4c0e4 100644 --- a/modules/views.views.inc +++ b/modules/views.views.inc @@ -57,14 +57,13 @@ function views_views_data() { ), ); - // @todo: this class seems to be missing. -// $data['views']['area_text_custom'] = array( -// 'title' => t('Unfiltered text'), -// 'help' => t('Add unrestricted, custom text or markup. This is similar to the custom text field.'), -// 'area' => array( -// 'handler' => 'views_handler_area_text_custom', -// ), -// ); + $data['views']['area_text_custom'] = array( + 'title' => t('Unfiltered text'), + 'help' => t('Add unrestricted, custom text or markup. This is similar to the custom text field.'), + 'area' => array( + 'plugin_id' => 'text_custom', + ), + ); $data['views']['view'] = array( 'title' => t('View area'),