Commit 0884e7b7 authored by alexpott's avatar alexpott
Browse files

Issue #2455153 by damiankloip: Switch revision log views fields to use 'field' formatter

parent 841e4a9a
......@@ -45,7 +45,6 @@ public function getViewsData() {
$data['aggregator_feed']['checked']['help'] = $this->t('The date the feed was last checked for new content.');
$data['aggregator_feed']['description']['help'] = $this->t('The description of the aggregator feed.');
$data['aggregator_feed']['description']['field']['id'] = 'xss';
$data['aggregator_feed']['description']['field']['click sortable'] = FALSE;
$data['aggregator_feed']['modified']['help'] = $this->t('The date of the most recent new content on the feed.');
......
......@@ -7,7 +7,8 @@
namespace Drupal\aggregator\Plugin\views\field;
use Drupal\views\Plugin\views\field\Xss as XssBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Filters htmls tags from item.
......@@ -16,13 +17,13 @@
*
* @ViewsField("aggregator_xss")
*/
class Xss extends XssBase {
class Xss extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function sanitizeValue($value, $type = NULL) {
return aggregator_filter_xss($value);
public function render(ResultRow $values) {
return aggregator_filter_xss($this->getValue($values));
}
}
......@@ -58,8 +58,6 @@ public function getViewsData() {
$data['block_content_revision']['revision_id']['relationship']['title'] = $this->t('Block Content');
$data['block_content_revision']['revision_id']['relationship']['label'] = $this->t('Get the actual block content from a block content revision.');
$data['block_content_revision']['revision_log']['field']['id'] = 'xss';
return $data;
}
......
......@@ -280,8 +280,6 @@ public function getViewsData() {
$data['node_field_revision']['langcode']['help'] = t('The language the original content is in.');
$data['node_revision']['revision_log']['field']['id'] = 'xss';
$data['node_revision']['revision_uid']['help'] = t('Relate a content revision to the user who created the revision.');
$data['node_revision']['revision_uid']['relationship']['label'] = t('revision user');
......
......@@ -171,10 +171,6 @@ views.field.url:
type: boolean
label: 'Display as link'
views.field.xss:
type: views_field
label: 'Xss'
views.field.language:
type: views_field
label: 'Language'
......
<?php
/**
* @file
* Definition of Drupal\views\Plugin\views\field\Xss
*/
namespace Drupal\views\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* A handler to run a field through simple XSS filtering.
*
* @ingroup views_field_handlers
*
* @ViewsField("xss")
*/
class Xss extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->sanitizeValue($value, 'xss');
}
}
<?php
/**
* @file
* Definition of Drupal\views\Tests\Handler\FieldXssTest.
*/
namespace Drupal\views\Tests\Handler;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Views;
/**
* Tests the core Drupal\views\Plugin\views\field\Xss handler.
*
* @group views
* @see CommonXssUnitTest
*/
class FieldXssTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
function dataHelper() {
$map = array(
'John' => 'John',
"Foo\xC0barbaz" => '',
'Fooÿñ' => 'Fooÿñ'
);
return $map;
}
function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['name']['field']['id'] = 'xss';
return $data;
}
public function testFieldXss() {
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('fields', array(
'name' => array(
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
),
));
$this->executeView($view);
$counter = 0;
foreach ($this->dataHelper() as $input => $expected_result) {
$view->result[$counter]->views_test_data_name = $input;
$this->assertEqual($view->field['name']->advancedRender($view->result[$counter]), $expected_result);
$counter++;
}
}
}
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