Commit eb3e8563 authored by dawehner's avatar dawehner Committed by tim.plunkett

convert contact, field filter plugins

parent d6fc9251
......@@ -5,7 +5,10 @@
* Definition of views_handler_argument_field_list.
*/
namespace Drupal\field\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler for list field to show the human readable name in the
......@@ -13,7 +16,13 @@
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_field_list extends Numeric {
/**
* @Plugin(
* plugin_id = "field_list"
* )
*/
class FieldList extends Numeric {
/**
* Stores the allowed values of this field.
*
......
......@@ -5,7 +5,10 @@
* Definition of views_handler_argument_field_list_text.
*/
namespace Drupal\field\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\String;
use Drupal\Core\Annotation\Plugin;
/**
......@@ -14,7 +17,13 @@
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_field_list_string extends String {
/**
* @Plugin(
* plugin_id = "field_list_string"
* )
*/
class ListString extends String {
/**
* Stores the allowed values of this field.
*
......
......@@ -5,7 +5,10 @@
* Definition of views_handler_field_field.
*/
namespace Drupal\field\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Helper function: Return an array of formatter options for a field type.
......@@ -39,7 +42,13 @@ function _field_view_formatter_options($field_type = NULL) {
*
* @ingroup views_field_handlers
*/
class views_handler_field_field extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "field"
* )
*/
class Field extends FieldPluginBase {
/**
* An array to store field renderable arrays for use by render_items.
* @var array
......
......@@ -5,14 +5,23 @@
* Definition of views_handler_filter_field_list.
*/
namespace Drupal\field\Plugin\views\filter;
use Drupal\views\Plugins\views\filter\InOperator;
use Drupal\Core\Annotation\Plugin;
/**
* Filter handler which uses list-fields as options.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_field_list extends InOperator {
/**
* @Plugin(
* plugin_id = "field_list"
* )
*/
class FieldList extends InOperator {
function get_value_options() {
$field = field_info_field($this->definition['field_name']);
$this->value_options = list_allowed_values($field);
......
......@@ -5,15 +5,24 @@
* Definition of views_handler_relationship_entity_reverse.
*/
namespace Drupal\field\Plugin\views\relationship;
use Drupal\views\Join;
use Drupal\views\Plugins\views\relationship\RelationshipPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* A relationship handlers which reverse entity references.
*
* @ingroup views_relationship_handlers
*/
class views_handler_relationship_entity_reverse extends RelationshipPluginBase {
/**
* @Plugin(
* plugin_id = "entity_reverse"
* )
*/
class EntityReverse extends RelationshipPluginBase {
function init(&$view, &$options) {
parent::init($view, $options);
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_filter_format_name.
*/
namespace Drupal\filter\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to output the name of an input format.
*
* @ingroup views_field_handlers
*/
class views_handler_field_filter_format_name extends views_handler_field {
/**
* @Plugin(
* plugin_id = "filter_format_name"
* )
*/
class FormatName extends FieldPluginBase {
function construct() {
parent::construct();
// Be explicit about the table we are using.
......
......@@ -37,7 +37,7 @@ function init(&$view, &$display, $options = NULL) {
}
function uses_fields() {
return !empty($this->definition['uses fields']);
return !empty($this->definition['uses_fields']);
}
......
......@@ -106,7 +106,7 @@ function uses_fields() {
$row_uses_fields = $this->row_plugin->uses_fields();
}
// Otherwise, check the definition or the option.
return $row_uses_fields || !empty($this->definition['uses fields']) || !empty($this->options['uses_fields']);
return $row_uses_fields || !empty($this->definition['uses_fields']) || !empty($this->options['uses_fields']);
}
/**
......
......@@ -234,7 +234,7 @@ function field_views_field_default_views_data($field) {
$real_field = reset($keys);
$data[$table][$column]['field'] = array(
'table' => $table,
'handler' => 'views_handler_field_field',
'plugin_id' => 'field',
'click sortable' => TRUE,
'field_name' => $field['field_name'],
// Provide a real field for group by.
......@@ -259,18 +259,18 @@ function field_views_field_default_views_data($field) {
case 'serial':
case 'numeric':
case 'float':
$filter = 'views_handler_filter_numeric';
$argument = 'views_handler_argument_numeric';
$sort = 'views_handler_sort';
$filter = 'numeric';
$argument = 'numeric';
$sort = 'standard';
break;
case 'text':
case 'blob':
// It does not make sense to sort by blob or text.
$allow_sort = FALSE;
default:
$filter = 'views_handler_filter_string';
$argument = 'views_handler_argument_string';
$sort = 'views_handler_sort';
$filter = 'string';
$argument = 'string';
$sort = 'standard';
break;
}
......@@ -335,7 +335,7 @@ function field_views_field_default_views_data($field) {
$data[$table][$column_real_name]['argument'] = array(
'field' => $column_real_name,
'table' => $table,
'handler' => $argument,
'plugin_id' => $argument,
'additional fields' => $additional_fields,
'field_name' => $field['field_name'],
'empty field name' => t('- No value -'),
......@@ -343,7 +343,7 @@ function field_views_field_default_views_data($field) {
$data[$table][$column_real_name]['filter'] = array(
'field' => $column_real_name,
'table' => $table,
'handler' => $filter,
'plugin_id' => $filter,
'additional fields' => $additional_fields,
'field_name' => $field['field_name'],
'allow empty' => TRUE,
......@@ -352,7 +352,7 @@ function field_views_field_default_views_data($field) {
$data[$table][$column_real_name]['sort'] = array(
'field' => $column_real_name,
'table' => $table,
'handler' => $sort,
'plugin_id' => $sort,
'additional fields' => $additional_fields,
'field_name' => $field['field_name'],
);
......@@ -410,14 +410,14 @@ function list_field_views_data($field) {
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (isset($field_data['filter']) && $field_name != 'delta') {
$data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list';
$data[$table_name][$field_name]['filter']['plugin_id'] = 'field_list';
}
if (isset($field_data['argument']) && $field_name != 'delta') {
if ($field['type'] == 'list_text') {
$data[$table_name][$field_name]['argument']['handler'] = 'views_handler_argument_field_list_string';
$data[$table_name][$field_name]['argument']['plugin_id'] = 'field_list_string';
}
else {
$data[$table_name][$field_name]['argument']['handler'] = 'views_handler_argument_field_list';
$data[$table_name][$field_name]['argument']['plugin_id'] = 'field_list';
}
}
}
......
......@@ -578,14 +578,14 @@ function hook_views_data_alter(&$data) {
* - Used by style plugins:
* - uses_row_plugin: Set to TRUE to allow row plugins for this style.
* - uses_row_class: Set to TRUE to allow the CSS class settings for rows.
* - uses fields: Set to TRUE to have the style plugin accept field
* - uses_fields: Set to TRUE to have the style plugin accept field
* handlers.
* - uses grouping: Set to TRUE to allow the grouping settings for rows.
* - even empty: May have the value 'even empty' to tell Views that the style
* should be rendered even if there are no results.
*
* - Used by row plugins:
* - uses fields: Set to TRUE to have the row plugin accept field handlers.
* - uses_fields: Set to TRUE to have the row plugin accept field handlers.
*/
function hook_views_plugins() {
$plugins = array();
......
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