Commit 5f987ee0 authored by alexpott's avatar alexpott

Issue #2455149 by k4v, jhodgdon, dawehner, Berdir: Aggregator xss fields...

Issue #2455149 by k4v, jhodgdon, dawehner, Berdir: Aggregator xss fields should be using Field/Entity formatters
parent 1731cd48
......@@ -16,10 +16,6 @@ views.field.aggregator_title_link:
type: boolean
label: 'Display as link'
views.field.aggregator_xss:
type: views.field.xss
label: 'Aggregator XSS'
views.row.aggregator_rss:
type: views_row
label: 'Aggregator item row'
......
......@@ -34,12 +34,13 @@ public function getViewsData() {
$data['aggregator_item']['link']['help'] = $this->t('The link to the original source URL of the item.');
$data['aggregator_item']['author']['help'] = $this->t('The author of the original imported item.');
$data['aggregator_item']['author']['field']['id'] = 'aggregator_xss';
$data['aggregator_item']['author']['field']['default_formatter'] = 'aggregator_xss';
$data['aggregator_item']['guid']['help'] = $this->t('The guid of the original imported item.');
$data['aggregator_item']['description']['help'] = $this->t('The actual content of the imported item.');
$data['aggregator_item']['description']['field']['id'] = 'aggregator_xss';
$data['aggregator_item']['description']['field']['default_formatter'] = 'aggregator_xss';
$data['aggregator_item']['description']['field']['click sortable'] = FALSE;
$data['aggregator_item']['timestamp']['help'] = $this->t('The date the original feed item was posted. (With some feeds, this will be the date it was imported.)');
......
<?php
/**
* @file
* Contains \Drupal\aggregator\Plugin\Field\FieldFormatter\AggregatorXSSFormatter.
*/
namespace Drupal\aggregator\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Plugin implementation of the 'aggregator_xss' formatter.
*
* @FieldFormatter(
* id = "aggregator_xss",
* label = @Translation("Aggregator XSS"),
* description = @Translation("Filter output for aggregator items"),
* field_types = {
* "string",
* "string_long",
* }
* )
*/
class AggregatorXSSFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items) {
$elements = [];
foreach ($items as $delta => $item) {
$elements[$delta] = [
'#type' => 'markup',
'#markup' => aggregator_filter_xss($item->value),
];
}
return $elements;
}
}
<?php
/**
* @file
* Contains \Drupal\aggregator\Plugin\views\field\Xss.
*/
namespace Drupal\aggregator\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Filters HTML tags from item.
*
* @ingroup views_field_handlers
*
* @ViewsField("aggregator_xss")
*/
class Xss extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
return aggregator_filter_xss($this->getValue($values));
}
}
......@@ -85,7 +85,7 @@ display:
table: aggregator_item
field: author
id: author
plugin_id: aggregator_xss
plugin_id: field
alter:
alter_text: false
text: ''
......@@ -163,7 +163,7 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: aggregator_xss
plugin_id: field
entity_type: aggregator_item
entity_field: description
filters: { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment