Issue #2144505 by tstoeckler, YesCT, Gábor Hojtsy, vijaycs85, webflo: Views does not use the text format type for formatted text
parent
ff4d10b79e
commit
48813a20a3
|
@ -173,7 +173,7 @@ display:
|
||||||
area:
|
area:
|
||||||
id: area
|
id: area
|
||||||
table: views
|
table: views
|
||||||
field: area
|
field: area_text_custom
|
||||||
empty: true
|
empty: true
|
||||||
content: 'This view is empty.'
|
content: 'This view is empty.'
|
||||||
plugin_id: text_custom
|
plugin_id: text_custom
|
||||||
|
|
|
@ -34,7 +34,7 @@ display:
|
||||||
relationship: none
|
relationship: none
|
||||||
table: views
|
table: views
|
||||||
tokenize: false
|
tokenize: false
|
||||||
plugin_id: text
|
plugin_id: text_custom
|
||||||
node_listing_empty:
|
node_listing_empty:
|
||||||
admin_label: ''
|
admin_label: ''
|
||||||
empty: true
|
empty: true
|
||||||
|
|
|
@ -26,11 +26,8 @@ views.area.text:
|
||||||
label: 'Text'
|
label: 'Text'
|
||||||
mapping:
|
mapping:
|
||||||
content:
|
content:
|
||||||
type: text
|
type: text_format
|
||||||
label: 'The shown text of the area'
|
label: 'The formatted text of the area'
|
||||||
format:
|
|
||||||
type: string
|
|
||||||
label: 'The filter format the content is in'
|
|
||||||
tokenize:
|
tokenize:
|
||||||
type: boolean
|
type: boolean
|
||||||
label: 'Should replacement tokens be used from the first row'
|
label: 'Should replacement tokens be used from the first row'
|
||||||
|
|
|
@ -23,8 +23,12 @@ class Text extends TokenizeAreaPluginBase {
|
||||||
*/
|
*/
|
||||||
protected function defineOptions() {
|
protected function defineOptions() {
|
||||||
$options = parent::defineOptions();
|
$options = parent::defineOptions();
|
||||||
$options['content'] = array('default' => '', 'format_key' => 'format');
|
$options['content'] = array(
|
||||||
$options['format'] = array('default' => NULL);
|
'contains' => array(
|
||||||
|
'value' => array('default' => ''),
|
||||||
|
'format' => array('default' => NULL),
|
||||||
|
),
|
||||||
|
);
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,32 +41,22 @@ class Text extends TokenizeAreaPluginBase {
|
||||||
$form['content'] = array(
|
$form['content'] = array(
|
||||||
'#title' => $this->t('Content'),
|
'#title' => $this->t('Content'),
|
||||||
'#type' => 'text_format',
|
'#type' => 'text_format',
|
||||||
'#default_value' => $this->options['content'],
|
'#default_value' => $this->options['content']['value'],
|
||||||
'#rows' => 6,
|
'#rows' => 6,
|
||||||
'#format' => isset($this->options['format']) ? $this->options['format'] : filter_default_format(),
|
'#format' => isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(),
|
||||||
'#editor' => FALSE,
|
'#editor' => FALSE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
|
|
||||||
$content = $form_state->getValue(array('options', 'content'));
|
|
||||||
$form_state->setValue(array('options', 'format'), $content['format']);
|
|
||||||
$form_state->setValue(array('options', 'content'), $content['value']);
|
|
||||||
parent::submitOptionsForm($form, $form_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function render($empty = FALSE) {
|
public function render($empty = FALSE) {
|
||||||
$format = isset($this->options['format']) ? $this->options['format'] : filter_default_format();
|
$format = isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format();
|
||||||
if (!$empty || !empty($this->options['empty'])) {
|
if (!$empty || !empty($this->options['empty'])) {
|
||||||
return array(
|
return array(
|
||||||
'#type' => 'processed_text',
|
'#type' => 'processed_text',
|
||||||
'#text' => $this->tokenizeValue($this->options['content']),
|
'#text' => $this->tokenizeValue($this->options['content']['value']),
|
||||||
'#format' => $format,
|
'#format' => $format,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,18 +45,20 @@ class AreaTextTest extends ViewUnitTestBase {
|
||||||
'id' => 'area',
|
'id' => 'area',
|
||||||
'table' => 'views',
|
'table' => 'views',
|
||||||
'field' => 'area',
|
'field' => 'area',
|
||||||
'content' => $string,
|
'content' => array(
|
||||||
|
'value' => $string,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Execute the view.
|
// Execute the view.
|
||||||
$this->executeView($view);
|
$this->executeView($view);
|
||||||
|
|
||||||
$view->display_handler->handlers['header']['area']->options['format'] = $this->randomString();
|
$view->display_handler->handlers['header']['area']->options['content']['format'] = $this->randomString();
|
||||||
$build = $view->display_handler->handlers['header']['area']->render();
|
$build = $view->display_handler->handlers['header']['area']->render();
|
||||||
$this->assertEqual('', drupal_render($build), 'Nonexistent format should return empty markup.');
|
$this->assertEqual('', drupal_render($build), 'Nonexistent format should return empty markup.');
|
||||||
|
|
||||||
$view->display_handler->handlers['header']['area']->options['format'] = filter_default_format();
|
$view->display_handler->handlers['header']['area']->options['content']['format'] = filter_default_format();
|
||||||
$build = $view->display_handler->handlers['header']['area']->render();
|
$build = $view->display_handler->handlers['header']['area']->render();
|
||||||
$this->assertEqual(check_markup($string), drupal_render($build), 'Existent format should return something');
|
$this->assertEqual(check_markup($string), drupal_render($build), 'Existent format should return something');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue