Commit 61de3bdd authored by alexpott's avatar alexpott

Issue #2320743 by jhodgdon: Taxonomy views needs filter/field on original language.

parent 5385c228
...@@ -7,27 +7,21 @@ ...@@ -7,27 +7,21 @@
namespace Drupal\taxonomy; namespace Drupal\taxonomy;
use Drupal\views\EntityViewsDataInterface; use Drupal\views\EntityViewsData;
/** /**
* Provides the views data for the taxonomy entity type. * Provides the views data for the taxonomy entity type.
*/ */
class TermViewsData implements EntityViewsDataInterface { class TermViewsData extends EntityViewsData {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getViewsData() { public function getViewsData() {
$data = array(); $data = parent::getViewsData();
$data['taxonomy_term_data']['table']['group'] = t('Taxonomy term'); $data['taxonomy_term_data']['table']['base']['help'] = t('Taxonomy terms are attached to nodes.');
$data['taxonomy_term_data']['table']['base'] = array( $data['taxonomy_term_data']['table']['base']['access query tag'] = 'term_access';
'field' => 'tid',
'title' => t('Term'),
'help' => t('Taxonomy terms are attached to nodes.'),
'access query tag' => 'term_access',
);
$data['taxonomy_term_data']['table']['entity type'] = 'taxonomy_term';
$data['taxonomy_term_data']['table']['wizard_id'] = 'taxonomy_term'; $data['taxonomy_term_data']['table']['wizard_id'] = 'taxonomy_term';
$data['taxonomy_term_data']['table']['join'] = array( $data['taxonomy_term_data']['table']['join'] = array(
...@@ -38,36 +32,17 @@ public function getViewsData() { ...@@ -38,36 +32,17 @@ public function getViewsData() {
), ),
); );
$data['taxonomy_term_field_data']['table']['group'] = t('Taxonomy term'); $data['taxonomy_term_data']['tid']['help'] = t('The tid of a taxonomy term.');
$data['taxonomy_term_field_data']['table']['entity type'] = 'taxonomy_term';
$data['taxonomy_term_field_data']['table']['join']['taxonomy_term_data'] = array(
'type' => 'INNER',
'left_field' => 'tid',
'field' => 'tid',
);
$data['taxonomy_term_data']['tid'] = array( $data['taxonomy_term_data']['tid']['argument']['id'] = 'taxonomy';
'title' => t('Term ID'), $data['taxonomy_term_data']['tid']['argument']['name field'] = 'name';
'help' => t('The tid of a taxonomy term.'), $data['taxonomy_term_data']['tid']['argument']['zero is null'] = TRUE;
'field' => array(
'id' => 'numeric', $data['taxonomy_term_data']['tid']['filter']['id'] = 'taxonomy_index_tid';
), $data['taxonomy_term_data']['tid']['filter']['title'] = t('Term');
'sort' => array( $data['taxonomy_term_data']['tid']['filter']['help'] = t('Taxonomy term chosen from autocomplete or select widget.');
'id' => 'standard', $data['taxonomy_term_data']['tid']['filter']['hierarchy table'] = 'taxonomy_term_hierarchy';
), $data['taxonomy_term_data']['tid']['filter']['numeric'] = TRUE;
'argument' => array(
'id' => 'taxonomy',
'name field' => 'name',
'zero is null' => TRUE,
),
'filter' => array(
'title' => t('Term'),
'help' => t('Taxonomy term chosen from autocomplete or select widget.'),
'id' => 'taxonomy_index_tid',
'hierarchy table' => 'taxonomy_term_hierarchy',
'numeric' => TRUE,
),
);
$data['taxonomy_term_data']['tid_raw'] = array( $data['taxonomy_term_data']['tid_raw'] = array(
'title' => t('Term ID'), 'title' => t('Term ID'),
...@@ -86,7 +61,7 @@ public function getViewsData() { ...@@ -86,7 +61,7 @@ public function getViewsData() {
'help' => t('Obtains a single representative node for each term, according to a chosen sort criterion.'), 'help' => t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
'id' => 'groupwise_max', 'id' => 'groupwise_max',
'relationship field' => 'tid', 'relationship field' => 'tid',
'outer field' => 'taxonomy_term_data.tid', 'outer field' => 'taxonomy_term_field_data.tid',
'argument table' => 'taxonomy_term_field_data', 'argument table' => 'taxonomy_term_field_data',
'argument field' => 'tid', 'argument field' => 'tid',
'base' => 'node', 'base' => 'node',
...@@ -95,81 +70,10 @@ public function getViewsData() { ...@@ -95,81 +70,10 @@ public function getViewsData() {
), ),
); );
$data['taxonomy_term_field_data']['name'] = array( $data['taxonomy_term_data']['vid']['help'] = t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
'title' => t('Name'), unset($data['taxonomy_term_data']['vid']['field']);
'help' => t('The taxonomy term name.'), unset($data['taxonomy_term_data']['vid']['argument']);
'field' => array( unset($data['taxonomy_term_data']['vid']['sort']);
'id' => 'taxonomy',
),
'sort' => array(
'id' => 'standard',
),
'filter' => array(
'id' => 'string',
'help' => t('Taxonomy term name.'),
),
'argument' => array(
'id' => 'string',
'help' => t('Taxonomy term name.'),
'many to one' => TRUE,
'empty field name' => t('Uncategorized'),
),
);
$data['taxonomy_term_field_data']['weight'] = array(
'title' => t('Weight'),
'help' => t('The term weight field'),
'field' => array(
'id' => 'numeric',
),
'sort' => array(
'id' => 'standard',
),
'filter' => array(
'id' => 'numeric',
),
'argument' => array(
'id' => 'numeric',
),
);
$data['taxonomy_term_field_data']['description__value'] = array(
'title' => t('Term description'),
'help' => t('The description associated with a taxonomy term.'),
'field' => array(
'id' => 'markup',
'format' => array('field' => 'description__format'),
'click sortable' => FALSE,
),
'filter' => array(
'id' => 'string',
),
);
$data['taxonomy_term_data']['vid'] = array(
'title' => t('Vocabulary'),
'help' => t('Filter the results of "Taxonomy: Term" to a particular vocabulary.'),
'filter' => array(
'id' => 'bundle',
),
);
$data['taxonomy_term_field_data']['langcode'] = array(
'title' => t('Language'), // The item it appears as on the UI,
'help' => t('Language of the term'),
'field' => array(
'id' => 'taxonomy_term_language',
),
'sort' => array(
'id' => 'standard',
),
'filter' => array(
'id' => 'language',
),
'argument' => array(
'id' => 'language',
),
);
$data['taxonomy_term_data']['edit_term'] = array( $data['taxonomy_term_data']['edit_term'] = array(
'field' => array( 'field' => array(
...@@ -180,19 +84,26 @@ public function getViewsData() { ...@@ -180,19 +84,26 @@ public function getViewsData() {
), ),
); );
$data['taxonomy_term_field_data']['changed'] = array( if (\Drupal::moduleHandler()->moduleExists('content_translation')) {
'title' => t('Updated date'), $data['taxonomy_term_data']['translation_link'] = array(
'help' => t('The date the term was last updated.'), 'title' => t('Translation link'),
'field' => array( 'help' => t('Provide a link to the translations overview for taxonomy terms.'),
'id' => 'date', 'field' => array(
), 'id' => 'content_translation_link',
'sort' => array( ),
'id' => 'date' );
), }
'filter' => array(
'id' => 'date', $data['taxonomy_term_field_data']['name']['field']['id'] = 'taxonomy';
), $data['taxonomy_term_field_data']['name']['argument']['many to one'] = TRUE;
); $data['taxonomy_term_field_data']['name']['argument']['empty field name'] = t('Uncategorized');
$data['taxonomy_term_field_data']['description__value']['field']['click sortable'] = FALSE;
$data['taxonomy_term_field_data']['langcode']['field']['id'] = 'taxonomy_term_language';
$data['taxonomy_term_field_data']['changed']['title'] = t('Updated date');
$data['taxonomy_term_field_data']['changed']['help'] = t('The date the term was last updated.');
$data['taxonomy_term_field_data']['changed_fulldate'] = array( $data['taxonomy_term_field_data']['changed_fulldate'] = array(
'title' => t('Updated date'), 'title' => t('Updated date'),
...@@ -248,16 +159,6 @@ public function getViewsData() { ...@@ -248,16 +159,6 @@ public function getViewsData() {
), ),
); );
if (\Drupal::moduleHandler()->moduleExists('content_translation')) {
$data['taxonomy_term_data']['translation_link'] = array(
'title' => t('Translation link'),
'help' => t('Provide a link to the translations overview for taxonomy terms.'),
'field' => array(
'id' => 'content_translation_link',
),
);
}
$data['taxonomy_index']['table']['group'] = t('Taxonomy term'); $data['taxonomy_index']['table']['group'] = t('Taxonomy term');
$data['taxonomy_index']['table']['join'] = array( $data['taxonomy_index']['table']['join'] = array(
...@@ -314,30 +215,30 @@ public function getViewsData() { ...@@ -314,30 +215,30 @@ public function getViewsData() {
); );
$data['taxonomy_index']['sticky'] = [ $data['taxonomy_index']['sticky'] = [
'title' => t('Sticky status'), 'title' => t('Sticky status'),
'help' => t('Whether or not the content related to a term is sticky.'), 'help' => t('Whether or not the content related to a term is sticky.'),
'filter' => [ 'filter' => [
'id' => 'boolean', 'id' => 'boolean',
'label' => t('Sticky status'), 'label' => t('Sticky status'),
'type' => 'yes-no', 'type' => 'yes-no',
], ],
'sort' => [ 'sort' => [
'id' => 'standard', 'id' => 'standard',
'help' => t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'), 'help' => t('Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.'),
], ],
]; ];
$data['taxonomy_index']['created'] = [ $data['taxonomy_index']['created'] = [
'title' => t('Post date'), 'title' => t('Post date'),
'help' => t('The date the content related to a term was posted.'), 'help' => t('The date the content related to a term was posted.'),
'sort' => [ 'sort' => [
'id' => 'date' 'id' => 'date'
], ],
'filter' => [ 'filter' => [
'id' => 'date', 'id' => 'date',
], ],
]; ];
$data['taxonomy_term_hierarchy']['table']['group'] = t('Taxonomy term'); $data['taxonomy_term_hierarchy']['table']['group'] = t('Taxonomy term');
...@@ -377,4 +278,3 @@ public function getViewsData() { ...@@ -377,4 +278,3 @@ public function getViewsData() {
} }
} }
This diff is collapsed.
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