Skip to content
Snippets Groups Projects
Commit 7c94e489 authored by Daniel Wehner's avatar Daniel Wehner Committed by Tim Plunkett
Browse files

Issue #1783018 by dawehner: Fixed some of locale.views.inc and remove textgroup support.

parent 771925c2
No related merge requests found
<?php
/**
* @file
* Definition of views_handler_argument_locale_group.
*/
namespace Views\locale\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a language.
*
* @ingroup views_argument_handlers
*
* @Plugin(
* id = "locale_group",
* module = "locale"
* )
*/
class Group extends ArgumentPluginBase {
public function construct() {
parent::construct('group');
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the group.
*/
function summary_name($data) {
return $this->locale_group($data->{$this->name_alias});
}
/**
* Override the behavior of title(). Get the user friendly version
* of the language.
*/
function title() {
return $this->locale_group($this->argument);
}
function locale_group($group) {
$groups = module_invoke_all('locale', 'groups');
// Sort the list.
asort($groups);
return isset($groups[$group]) ? $groups[$group] : t('Unknown group');
}
}
<?php
/**
* @file
* Definition of views_handler_field_locale_group.
*/
namespace Views\locale\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to translate a group into its readable form.
*
* @ingroup views_field_handlers
*
* @Plugin(
* id = "locale_group",
* module = "locale"
* )
*/
class Group extends FieldPluginBase {
function render($values) {
$groups = module_invoke_all('locale', 'groups');
// Sort the list.
asort($groups);
$value = $this->get_value($values);
return isset($groups[$value]) ? $groups[$value] : '';
}
}
<?php
/**
* @file
* Definition of views_handler_filter_locale_group.
*/
namespace Views\locale\Plugin\views\filter;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\InOperator;
/**
* Filter by locale group.
*
* @ingroup views_filter_handlers
*
* @Plugin(
* id = "locale_group",
* module = "locale"
* )
*/
class Group extends InOperator {
function get_value_options() {
if (!isset($this->value_options)) {
$this->value_title = t('Group');
$groups = module_invoke_all('locale', 'groups');
// Sort the list.
asort($groups);
$this->value_options = $groups;
}
}
}
......@@ -64,28 +64,24 @@ function locale_views_data() {
),
);
// Group field
$data['locales_source']['textgroup'] = array(
// Source field
$data['locales_source']['source'] = array(
'group' => t('Locale source'),
'title' => t('Group'),
'help' => t('The group the translation is in.'),
'title' => t('Source'),
'help' => t('The full original string.'),
'field' => array(
'id' => 'locale_group',
'click sortable' => TRUE,
'id' => 'standard',
),
'filter' => array(
'id' => 'locale_group',
),
'argument' => array(
'id' => 'locale_group',
'id' => 'string',
),
);
// Source field
$data['locales_source']['source'] = array(
$data['locales_source']['context'] = array(
'group' => t('Locale source'),
'title' => t('Source'),
'help' => t('The full original string.'),
'title' => t('Context'),
'help' => t('The context this string applies to.'),
'field' => array(
'id' => 'standard',
),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment