diff --git a/handlers/views_handler_area_text.inc b/handlers/views_handler_area_text.inc index 51815c046aa8bd311ada821918b793b4aad5d188..84e7b3446ff45660e3fab718e988818c3166c81a 100644 --- a/handlers/views_handler_area_text.inc +++ b/handlers/views_handler_area_text.inc @@ -31,7 +31,7 @@ function options_form(&$form, &$form_state) { '#wysiwyg' => FALSE, ); - + // @TODO: Refactor token handling into a base class. $form['tokenize'] = array( '#type' => 'checkbox', '#title' => t('Use replacement tokens from the first row'), diff --git a/handlers/views_handler_area_text_custom.inc b/handlers/views_handler_area_text_custom.inc new file mode 100644 index 0000000000000000000000000000000000000000..d3ec79a85fddf7b56f53aa4382f12885fc019506 --- /dev/null +++ b/handlers/views_handler_area_text_custom.inc @@ -0,0 +1,56 @@ +<?php + +/** + * @file + * Definition of views_handler_area_text_custom. + */ + +/** + * Views area text custom handler. + * + * @ingroup views_area_handlers + */ +class views_handler_area_text_custom extends views_handler_area_text { + + 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']); + + // @TODO: Use the token refactored base class. + } + + // 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($this->options['content']); + } + + return ''; + } + + /** + * Render a text area with filter_xss_admin. + */ + function render_textarea($value) { + if ($value) { + if ($this->options['tokenize']) { + $value = $this->view->style_plugin->tokenize_value($value, 0); + } + return filter_xss_admin($value); + } + } + +} diff --git a/modules/views.views.inc b/modules/views.views.inc index 5ea55bc6d2041abbd83a8ff527366dd931be2c6f..2029aa8b1cd790a79dbb3d09f50c243412cd4110 100644 --- a/modules/views.views.inc +++ b/modules/views.views.inc @@ -57,6 +57,14 @@ function views_views_data() { ), ); + $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']['view'] = array( 'title' => t('View area'), 'help' => t('Insert a view inside an area.'), diff --git a/views.info b/views.info index 4aee7d4d733e50a80a6956ca93dc049b09fb00e3..5663eff35fdd4e8e6b2f202a24e5a86b6115c243 100644 --- a/views.info +++ b/views.info @@ -12,6 +12,7 @@ dependencies[] = ctools files[] = handlers/views_handler_area.inc files[] = handlers/views_handler_area_result.inc files[] = handlers/views_handler_area_text.inc +files[] = handlers/views_handler_area_text_custom.inc files[] = handlers/views_handler_area_view.inc files[] = handlers/views_handler_argument.inc files[] = handlers/views_handler_argument_date.inc