From 92e520db558e04c2aae4ad8457fb9abdf77045a0 Mon Sep 17 00:00:00 2001 From: Tim Plunkett <git@plnktt.com> Date: Sat, 8 Sep 2012 13:17:32 -0400 Subject: [PATCH] Issue #1754322 by tim.plunkett, dawehner: Remove export and localization code. --- config/views.settings.yml | 1 - includes/admin.inc | 18 -- .../views/Plugin/ctools/export_ui/ViewsUI.php | 2 - lib/Drupal/views/Plugin/views/HandlerBase.php | 7 - lib/Drupal/views/Plugin/views/PluginBase.php | 207 +------------- .../views/argument/ArgumentPluginBase.php | 87 +----- .../views/Plugin/views/argument/Date.php | 25 -- .../views/display/DisplayPluginBase.php | 267 +----------------- .../views/Plugin/views/filter/InOperator.php | 2 +- .../views/Plugin/views/localization/Core.php | 123 -------- .../localization/LocalizationPluginBase.php | 179 ------------ .../views/Plugin/views/localization/None.php | 49 ---- lib/Drupal/views/Tests/PluginInstanceTest.php | 1 - lib/Drupal/views/Tests/TranslatableTest.php | 152 ---------- lib/Drupal/views/Tests/Wizard/BasicTest.php | 7 - lib/Drupal/views/View.php | 60 ---- ...ews.view.test_view_unpack_translatable.yml | 80 ------ .../views/localization/LocalizationTest.php | 55 ---- views.install | 2 - views.module | 78 +---- 20 files changed, 18 insertions(+), 1384 deletions(-) delete mode 100644 lib/Drupal/views/Plugin/views/localization/Core.php delete mode 100644 lib/Drupal/views/Plugin/views/localization/LocalizationPluginBase.php delete mode 100644 lib/Drupal/views/Plugin/views/localization/None.php delete mode 100644 lib/Drupal/views/Tests/TranslatableTest.php delete mode 100644 tests/views_test_config/config/views.view.test_view_unpack_translatable.yml delete mode 100644 tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/localization/LocalizationTest.php diff --git a/config/views.settings.yml b/config/views.settings.yml index ed24ed57bcb7..b655c401740c 100644 --- a/config/views.settings.yml +++ b/config/views.settings.yml @@ -2,7 +2,6 @@ debug: output: '0' region: 'footer' display_extenders: { } -localization_plugin: '' no_javascript: '0' skip_cache: '0' sql_signature: '0' diff --git a/includes/admin.inc b/includes/admin.inc index 5a35d7f448d6..d8e8932b4971 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -1210,10 +1210,6 @@ function views_ui_render_display_top($view, $display_id) { 'title' => t('clone view'), 'href' => "admin/structure/views/view/$view->name/clone", ), - 'export' => array( - 'title' => t('export view'), - 'href' => "admin/structure/views/view/$view->name/export", - ), 'reorder' => array( 'title' => t('reorder displays'), 'href' => "admin/structure/views/nojs/reorder-displays/$view->name/$display_id", @@ -4895,19 +4891,6 @@ function views_ui_admin_settings_advanced() { '#default_value' => $config->get('debug.output'), ); - $form['locale'] = array( - '#type' => 'fieldset', - '#title' => t('Localization'), - ); - - $form['locale']['localization_plugin'] = array( - '#type' => 'radios', - '#title' => t('Translation method'), - '#options' => views_fetch_plugin_names('localization', NULL, array()), - '#default_value' => views_get_localization_plugin(), - '#description' => t('Select a translation method to use for Views data like header, footer, and empty text.'), - ); - $regions = array(); $regions['watchdog'] = t('Watchdog'); if (module_exists('devel')) { @@ -4963,7 +4946,6 @@ function views_ui_admin_settings_advanced_submit(&$form, &$form_state) { ->set('sql_signature', $form_state['values']['sql_signature']) ->set('no_javascript', $form_state['values']['no_javascript']) ->set('debug.output', $form_state['values']['debug_output']) - ->set('localization_plugin', $form_state['values']['localization_plugin']) ->set('debug.region', $form_state['values']['debug_region']) ->set('display_extenders', isset($form_state['values']['display_extenders']) ? $form_state['values']['display_extenders'] : array()) ->save(); diff --git a/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php b/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php index aa4fdfdbed7e..23cdd7de4845 100644 --- a/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php +++ b/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php @@ -55,8 +55,6 @@ function init($plugin) { $plugin['menu']['items']['edit']['path'] = 'view/%ctools_export_ui/edit'; $plugin['menu']['items']['clone']['path'] = 'view/%ctools_export_ui/clone'; $plugin['menu']['items']['clone']['type'] = MENU_VISIBLE_IN_BREADCRUMB; - $plugin['menu']['items']['export']['path'] = 'view/%ctools_export_ui/export'; - $plugin['menu']['items']['export']['type'] = MENU_VISIBLE_IN_BREADCRUMB; $plugin['menu']['items']['enable']['path'] = 'view/%ctools_export_ui/enable'; $plugin['menu']['items']['disable']['path'] = 'view/%ctools_export_ui/disable'; $plugin['menu']['items']['delete']['path'] = 'view/%ctools_export_ui/delete'; diff --git a/lib/Drupal/views/Plugin/views/HandlerBase.php b/lib/Drupal/views/Plugin/views/HandlerBase.php index c8ad094bce28..4fe16a035790 100644 --- a/lib/Drupal/views/Plugin/views/HandlerBase.php +++ b/lib/Drupal/views/Plugin/views/HandlerBase.php @@ -113,13 +113,6 @@ public function init(&$view, &$options) { $display_id = 'default'; } - $this->localization_keys = array( - $display_id, - $this->plugin_type, - $options['table'], - $options['id'] - ); - $this->unpackOptions($this->options, $options); // This exist on most handlers, but not all. So they are still optional. diff --git a/lib/Drupal/views/Plugin/views/PluginBase.php b/lib/Drupal/views/Plugin/views/PluginBase.php index d84fb9bfee5c..b3ad926136e5 100644 --- a/lib/Drupal/views/Plugin/views/PluginBase.php +++ b/lib/Drupal/views/Plugin/views/PluginBase.php @@ -38,15 +38,6 @@ abstract class PluginBase extends ComponentPluginBase { */ public $plugin_type = NULL; - /** - * An array which identifies the instance in the views plugin hierarchy. - * - * For handlers this is for example display_id, type, table, id. - * - * @var array - */ - public $localization_keys; - /** * Denotes whether the plugin has an additional options form. * @@ -84,17 +75,10 @@ public function __construct(array $configuration, $plugin_id, DiscoveryInterface * assumed to be array(). * - 'bool' => (optional) TRUE/FALSE Is the value a boolean value. This will * change the export format to TRUE/FALSE instead of 1/0. - * - 'export' => (optional) FALSE or a callback for special export handling - * if necessary. - * - 'unpack_translatable' => (optional) callback for special handling for - * translating data within the option, if necessary. * ), * * @return array * Returns the options of this handler/plugin. - * - * @see Drupal\views\Plugin\views\PluginBase::exportOption() - * @see Drupal\views\Plugin\views\PluginBase::unpackTranslatable() */ protected function defineOptions() { return array(); } @@ -124,7 +108,7 @@ protected function setOptionDefaults(&$storage, $options, $level = 0) { * Unpack options over our existing defaults, drilling down into arrays * so that defaults don't get totally blown away. */ - public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) { + public function unpackOptions(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE) { if ($check && !is_array($options)) { return; } @@ -133,23 +117,6 @@ public function unpackOptions(&$storage, $options, $definition = NULL, $all = TR $definition = $this->defineOptions(); } - if (!empty($this->view)) { - // Ensure we have a localization plugin. - $this->view->initLocalization(); - - // Set up default localization keys. Handlers and such set this for us - if (empty($localization_keys) && isset($this->localization_keys)) { - $localization_keys = $this->localization_keys; - } - // but plugins don't because there isn't a common init() these days. - else if (empty($this->is_handler)) { - if ($this->plugin_type != 'display') { - $localization_keys = array($this->view->current_display); - $localization_keys[] = $this->plugin_type; - } - } - } - foreach ($options as $key => $value) { if (is_array($value)) { // Ignore arrays with no definition. @@ -169,31 +136,7 @@ public function unpackOptions(&$storage, $options, $definition = NULL, $all = TR continue; } - $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE, array_merge($localization_keys, array($key))); - } - // Don't localize strings during editing. When editing, we need to work with - // the original data, not the translated version. - else if (empty($this->view->editing) && !empty($definition[$key]['translatable']) && !empty($value) || !empty($definition['contains'][$key]['translatable']) && !empty($value)) { - if (!empty($this->view) && $this->view->isTranslatable()) { - // Allow other modules to make changes to the string before it's - // sent for translation. - // The $keys array is built from the view name, any localization keys - // sent in, and the name of the property being processed. - $format = NULL; - if (isset($definition[$key]['format_key']) && isset($options[$definition[$key]['format_key']])) { - $format = $options[$definition[$key]['format_key']]; - } - $translation_data = array( - 'value' => $value, - 'format' => $format, - 'keys' => array_merge(array($this->view->name), $localization_keys, array($key)), - ); - $storage[$key] = $this->view->localization_plugin->translate($translation_data); - } - // Otherwise, this is a code-based string, so we can use t(). - else { - $storage[$key] = t($value); - } + $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE); } else if ($all || !empty($definition[$key])) { $storage[$key] = $value; @@ -215,152 +158,6 @@ public function destroy() { } } - public function exportOptions($indent, $prefix) { - $output = ''; - foreach ($this->defineOptions() as $option => $definition) { - $output .= $this->exportOption($indent, $prefix, $this->options, $option, $definition, array()); - } - - return $output; - } - - protected function exportOption($indent, $prefix, $storage, $option, $definition, $parents) { - // Do not export options for which we have no settings. - if (!isset($storage[$option])) { - return; - } - - if (isset($definition['export'])) { - if ($definition['export'] === FALSE) { - return; - } - - // Special handling for some items - if (method_exists($this, $definition['export'])) { - return $this->{$definition['export']}($indent, $prefix, $storage, $option, $definition, $parents); - } - } - - // Add the current option to the parents tree. - $parents[] = $option; - $output = ''; - - // If it has child items, export those separately. - if (isset($definition['contains'])) { - foreach ($definition['contains'] as $sub_option => $sub_definition) { - $output .= $this->exportOption($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents); - } - } - // Otherwise export just this item. - else { - $default = isset($definition['default']) ? $definition['default'] : NULL; - $value = $storage[$option]; - if (isset($definition['bool'])) { - $value = (bool) $value; - } - - if ($value !== $default) { - $output .= $indent . $prefix . "['" . implode("']['", $parents) . "'] = "; - if (isset($definition['bool'])) { - $output .= empty($storage[$option]) ? 'FALSE' : 'TRUE'; - } - else { - $output .= views_var_export($storage[$option], $indent); - } - - $output .= ";\n"; - } - } - return $output; - } - - /** - * Unpacks each handler to store translatable texts. - */ - public function unpackTranslatables(&$translatable, $parents = array()) { - foreach ($this->defineOptions() as $option => $definition) { - $this->unpackTranslatable($translatable, $this->options, $option, $definition, $parents, array()); - } - } - - /** - * Unpack a single option definition. - * - * This function run's through all suboptions recursive. - * - * @param $translatable - * Stores all available translatable items. - * @param $storage - * @param $option - * @param $definition - * @param $parents - * @param $keys - */ - protected function unpackTranslatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) { - // Do not export options for which we have no settings. - if (!isset($storage[$option])) { - return; - } - - // Special handling for some items - if (isset($definition['unpack_translatable']) && method_exists($this, $definition['unpack_translatable'])) { - return $this->{$definition['unpack_translatable']}($translatable, $storage, $option, $definition, $parents, $keys); - } - - if (isset($definition['translatable'])) { - if ($definition['translatable'] === FALSE) { - return; - } - } - - // Add the current option to the parents tree. - $parents[] = $option; - - // If it has child items, unpack those separately. - if (isset($definition['contains'])) { - foreach ($definition['contains'] as $sub_option => $sub_definition) { - $translation_keys = array_merge($keys, array($sub_option)); - $this->unpackTranslatable($translatable, $storage[$option], $sub_option, $sub_definition, $parents, $translation_keys); - } - } - - // @todo Figure out this double definition stuff. - $options = $storage[$option]; - if (is_array($options)) { - foreach ($options as $key => $value) { - $translation_keys = array_merge($keys, array($key)); - if (is_array($value)) { - $this->unpackTranslatable($translatable, $options, $key, $definition, $parents, $translation_keys); - } - else if (!empty($definition[$key]['translatable']) && !empty($value)) { - // Build source data and add to the array - $format = NULL; - if (isset($definition['format_key']) && isset($options[$definition['format_key']])) { - $format = $options[$definition['format_key']]; - } - $translatable[] = array( - 'value' => $value, - 'keys' => $translation_keys, - 'format' => $format, - ); - } - } - } - else if (!empty($definition['translatable']) && !empty($options)) { - $value = $options; - // Build source data and add to the array - $format = NULL; - if (isset($definition['format_key']) && isset($options[$definition['format_key']])) { - $format = $options[$definition['format_key']]; - } - $translatable[] = array( - 'value' => $value, - 'keys' => isset($translation_keys) ? $translation_keys : $parents, - 'format' => $format, - ); - } - } - /** * Init will be called after construct, when the plugin is attached to a * view and a display. diff --git a/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php b/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php index cb2f7876d9cf..cc3423a4de12 100644 --- a/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php +++ b/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php @@ -134,25 +134,25 @@ protected function defineOptions() { $options['title'] = array('default' => '', 'translatable' => TRUE); $options['breadcrumb_enable'] = array('default' => FALSE, 'bool' => TRUE); $options['breadcrumb'] = array('default' => '', 'translatable' => TRUE); - $options['default_argument_type'] = array('default' => 'fixed', 'export' => 'export_plugin'); - $options['default_argument_options'] = array('default' => array(), 'export' => FALSE); + $options['default_argument_type'] = array('default' => 'fixed'); + $options['default_argument_options'] = array('default' => array()); $options['default_argument_skip_url'] = array('default' => FALSE, 'bool' => TRUE); - $options['summary_options'] = array('default' => array(), 'export' => FALSE); + $options['summary_options'] = array('default' => array()); $options['summary'] = array( 'contains' => array( 'sort_order' => array('default' => 'asc'), 'number_of_records' => array('default' => 0), - 'format' => array('default' => 'default_summary', 'export' => 'export_summary'), + 'format' => array('default' => 'default_summary'), ), ); $options['specify_validation'] = array('default' => FALSE, 'bool' => TRUE); $options['validate'] = array( 'contains' => array( - 'type' => array('default' => 'none', 'export' => 'export_validation'), + 'type' => array('default' => 'none'), 'fail' => array('default' => 'not found'), ), ); - $options['validate_options'] = array('default' => array(), 'export' => FALSE); + $options['validate_options'] = array('default' => array()); return $options; } @@ -1054,81 +1054,6 @@ function get_value() { return $value; } - /** - * Export handler for summary export. - * - * Arguments can have styles for the summary view. This special export - * handler makes sure this works properly. - */ - function export_summary($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - $name = $this->options['summary'][$option]; - $options = $this->options['summary_options']; - - $plugin = views_get_plugin('style', $name); - if ($plugin) { - $plugin->init($this->view, $this->view->display_handler->display, $options); - // Write which plugin to use. - $output .= $indent . $prefix . "['summary']['$option'] = '$name';\n"; - - // Pass off to the plugin to export itself. - $output .= $plugin->exportOptions($indent, $prefix . "['summary_options']"); - } - - return $output; - } - - /** - * Export handler for validation export. - * - * Arguments use validation plugins. This special export handler makes sure - * this works properly. - */ - function export_validation($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - $name = $this->options['validate'][$option]; - $options = $this->options['validate_options']; - - $plugin = views_get_plugin('argument_validator', $name); - if ($plugin) { - $plugin->init($this->view, $this->display, $options); - // Write which plugin to use. - $output .= $indent . $prefix . "['validate']['$option'] = '$name';\n"; - - // Pass off to the plugin to export itself. - $output .= $plugin->exportOptions($indent, $prefix . "['validate_options']"); - } - - return $output; - } - - /** - * Generic plugin export handler. - * - * Since style and validation plugins have their own export handlers, this - * one is currently only used for default argument plugins. - */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - if ($option == 'default_argument_type') { - $type = 'argument_default'; - $option_name = 'default_argument_options'; - } - - $plugin = $this->get_plugin($type); - $name = $this->options[$option]; - - if ($plugin) { - // Write which plugin to use. - $output .= $indent . $prefix . "['$option'] = '$name';\n"; - - // Pass off to the plugin to export itself. - $output .= $plugin->exportOptions($indent, $prefix . "['$option_name']"); - } - - return $output; - } - /** * Get the display or row plugin, if it exists. */ diff --git a/lib/Drupal/views/Plugin/views/argument/Date.php b/lib/Drupal/views/Plugin/views/argument/Date.php index cc4aaa35ab51..e136b2c230c0 100644 --- a/lib/Drupal/views/Plugin/views/argument/Date.php +++ b/lib/Drupal/views/Plugin/views/argument/Date.php @@ -79,31 +79,6 @@ function get_default_argument($raw = FALSE) { return parent::get_default_argument($raw); } - /** - * The date handler provides some default argument types, which aren't argument default plugins, - * so addapt the export mechanism. - */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { - - // Only use a special behaviour for the special argument types, else just - // use the default behaviour. - if ($option == 'default_argument_type') { - $type = 'argument default'; - $option_name = 'default_argument_options'; - - $plugin = $this->get_plugin($type); - $name = $this->options[$option]; - if (in_array($name, array('date', 'node_created', 'node_changed'))) { - - // Write which plugin to use. - $output = $indent . $prefix . "['$option'] = '$name';\n"; - return $output; - } - } - return parent::export_plugin($indent, $prefix, $storage, $option, $definition, $parents); - } - - function get_sort_name() { return t('Date', array(), array('context' => 'Sort order')); } diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 2891b6d15c3f..03618c9a35bc 100644 --- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -454,7 +454,6 @@ protected function defineOptions() { 'filters' => TRUE, 'filter_groups' => TRUE, ), - 'export' => FALSE, ), 'title' => array( @@ -496,7 +495,6 @@ protected function defineOptions() { 'use_more_always' => array( 'default' => FALSE, 'bool' => TRUE, - 'export' => 'export_option_always', ), 'use_more_text' => array( 'default' => 'more', @@ -524,18 +522,18 @@ protected function defineOptions() { // and therefore need special handling. 'access' => array( 'contains' => array( - 'type' => array('default' => 'none', 'export' => 'exportPlugin', 'unpack_translatable' => 'unpackPlugin'), + 'type' => array('default' => 'none'), ), ), 'cache' => array( 'contains' => array( - 'type' => array('default' => 'none', 'export' => 'exportPlugin', 'unpack_translatable' => 'unpackPlugin'), + 'type' => array('default' => 'none'), ), ), 'query' => array( 'contains' => array( - 'type' => array('default' => 'views_query', 'export' => 'exportPlugin'), - 'options' => array('default' => array(), 'export' => FALSE), + 'type' => array('default' => 'views_query'), + 'options' => array('default' => array()), ), ), // Note that exposed_form plugin has options in a separate array, @@ -546,14 +544,14 @@ protected function defineOptions() { // should be copied. 'exposed_form' => array( 'contains' => array( - 'type' => array('default' => 'basic', 'export' => 'exportPlugin', 'unpack_translatable' => 'unpackPlugin'), - 'options' => array('default' => array(), 'export' => FALSE), + 'type' => array('default' => 'basic'), + 'options' => array('default' => array()), ), ), 'pager' => array( 'contains' => array( - 'type' => array('default' => 'full', 'export' => 'exportPlugin', 'unpack_translatable' => 'unpackPlugin'), - 'options' => array('default' => array(), 'export' => FALSE), + 'type' => array('default' => 'full'), + 'options' => array('default' => array()), ), ), @@ -562,21 +560,15 @@ protected function defineOptions() { // should not be repeated. 'style_plugin' => array( 'default' => 'default', - 'export' => 'exportStyle', - 'unpack_translatable' => 'unpackStyle', ), 'style_options' => array( 'default' => array(), - 'export' => FALSE, ), 'row_plugin' => array( 'default' => 'fields', - 'export' => 'exportStyle', - 'unpack_translatable' => 'unpackStyle', ), 'row_options' => array( 'default' => array(), - 'export' => FALSE, ), 'exposed_block' => array( @@ -585,42 +577,27 @@ protected function defineOptions() { 'header' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), 'footer' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), 'empty' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), // We want these to export last. // These are the 5 handler types. 'relationships' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', - ), 'fields' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), 'sorts' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), 'arguments' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), 'filter_groups' => array( 'contains' => array( @@ -630,8 +607,6 @@ protected function defineOptions() { ), 'filters' => array( 'default' => array(), - 'export' => 'exportHandler', - 'unpack_translatable' => 'unpackHandler', ), ); @@ -829,7 +804,6 @@ public function getPlugin($type = 'style', $name = NULL) { } else { $display_id = $this->isDefaulted($option_name) ? $this->display->id : 'default'; - $plugin->localization_keys = array($display_id, $type); if (!isset($this->base_field)) { $views_data = views_fetch_data($this->view->base_table); @@ -2748,231 +2722,6 @@ public function viewSpecialBlocks($type) { } } - /** - * Override of exportOption() - * - * Because displays do not want to export options that are NOT overridden from the - * default display, we need some special handling during the export process. - */ - public function exportOption($indent, $prefix, $storage, $option, $definition, $parents) { - // The $prefix is wrong because we store our actual options a little differently: - $prefix = '$handler->display->display_options'; - $output = ''; - if (!$parents && !$this->isDefaultDisplay()) { - // Do not export items that are not overridden. - if ($this->isDefaulted($option)) { - return; - } - - // If this is not defaulted and is overrideable, flip the switch to say this - // is overridden. - if ($this->defaultableSections($option)) { - $output .= $indent . $prefix . "['defaults']['$option'] = FALSE;\n"; - } - } - - $output .= parent::exportOption($indent, $prefix, $storage, $option, $definition, $parents); - return $output; - } - - /** - * Special method to export items that have handlers. - * - * This method was specified in the defineOptions() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. - */ - public function exportHandler($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - - // cut the 's' off because the data is stored as the plural form but we need - // the singular form. Who designed that anyway? Oh yeah, I did. :( - if ($option != 'header' && $option != 'footer' && $option != 'empty') { - $type = substr($option, 0, -1); - } - else { - $type = $option; - } - $types = View::viewsHandlerTypes(); - foreach ($storage[$option] as $id => $info) { - if (!empty($types[$type]['type'])) { - $handler_type = $types[$type]['type']; - } - else { - $handler_type = $type; - } - // If aggregation is on, the group type might override the actual - // handler that is in use. This piece of code checks that and, - // if necessary, sets the override handler. - $override = NULL; - if ($this->useGroupBy() && !empty($info['group_type'])) { - if (empty($this->view->query)) { - $this->view->initQuery(); - } - $aggregate = $this->view->query->get_aggregation_info(); - if (!empty($aggregate[$info['group_type']]['handler'][$type])) { - $override = $aggregate[$info['group_type']]['handler'][$type]; - } - } - $handler = views_get_handler($info['table'], $info['field'], $handler_type, $override); - if ($handler) { - $handler->init($this->view, $info); - $output .= $indent . '/* ' . $types[$type]['stitle'] . ': ' . $handler->adminLabel() . " */\n"; - $output .= $handler->exportOptions($indent, $prefix . "['$option']['$id']"); - } - - // Prevent reference problems. - unset($handler); - } - - return $output; - } - - /** - * Special handling for the style export. - * - * Styles are stored as style_plugin and style_options or row_plugin and - * row_options accordingly. The options are told not to export, and the - * export for the plugin should export both. - */ - public function exportStyle($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - $name = $this->getOption('style_plugin'); - $style_plugin = $this->getPlugin('style', $name); - if ($option == 'style_plugin') { - $type = 'style'; - $options_field = 'style_options'; - $plugin = $style_plugin; - } - else { - if (!$style_plugin || !$style_plugin->usesRowPlugin()) { - return; - } - - $type = 'row'; - $options_field = 'row_options'; - $name = $this->getOption('row_plugin'); - $plugin = $this->getPlugin('row', $name); - // If the style plugin doesn't use row plugins, don't even bother. - } - - if ($plugin) { - // Write which plugin to use. - $value = $this->getOption($option); - $output .= $indent . $prefix . "['$option'] = '$value';\n"; - - // Pass off to the plugin to export itself. - $output .= $plugin->exportOptions($indent, $prefix . "['$options_field']"); - } - - return $output; - } - - /** - * Special handling for plugin export - * - * Plugins other than styles are stored in array with 'type' being the key - * to the plugin. For modern plugins, the options are stored in the 'options' - * array, but for legacy plugins (access and cache) options are stored as - * siblings to the type. - */ - public function exportPlugin($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - $plugin_type = end($parents); - $plugin = $this->getPlugin($plugin_type); - if ($plugin) { - // Write which plugin to use. - $value = $storage[$option]; - $new_prefix = $prefix . "['$plugin_type']"; - - $output .= $indent . $new_prefix . "['$option'] = '$value';\n"; - - if ($plugin_type != 'access' && $plugin_type!= 'cache') { - $new_prefix .= "['options']"; - } - - // Pass off to the plugin to export itself. - $output .= $plugin->exportOptions($indent, $new_prefix); - } - - return $output; - } - - public function unpackStyle($indent, $prefix, $storage, $option, $definition, $parents) { - $output = ''; - $name = $this->getOption('style_plugin'); - $style_plugin = $this->getPlugin('style', $name); - if ($option == 'style_plugin') { - $plugin = $style_plugin; - } - else { - if (!$style_plugin || !$style_plugin->usesRowPlugin()) { - return; - } - - $name = $this->getOption('row_plugin'); - $plugin = $this->getPlugin('row', $name); - // If the style plugin doesn't use row plugins, don't even bother. - } - - if ($plugin) { - return $plugin->unpackTranslatables($translatable, $parents); - } - } - - /** - * Special handling for plugin unpacking. - */ - public function unpackPlugin(&$translatable, $storage, $option, $definition, $parents) { - $plugin_type = end($parents); - $plugin = $this->getPlugin($plugin_type); - if ($plugin) { - // Write which plugin to use. - return $plugin->unpackTranslatables($translatable, $parents); - } - } - - /** - * Special method to unpack items that have handlers. - * - * This method was specified in the defineOptions() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. - */ - public function unpackHandler(&$translatable, $storage, $option, $definition, $parents) { - $output = ''; - - // cut the 's' off because the data is stored as the plural form but we need - // the singular form. Who designed that anyway? Oh yeah, I did. :( - if ($option != 'header' && $option != 'footer' && $option != 'empty') { - $type = substr($option, 0, -1); - } - else { - $type = $option; - } - $types = View::viewsHandlerTypes(); - foreach ($storage[$option] as $id => $info) { - if (!empty($types[$type]['type'])) { - $handler_type = $types[$type]['type']; - } - else { - $handler_type = $type; - } - $handler = views_get_handler($info['table'], $info['field'], $handler_type); - if ($handler) { - $handler->init($this->view, $info); - $handler->unpackTranslatables($translatable, array_merge($parents, array($type, $info['table'], $info['id']))); - } - - // Prevent reference problems. - unset($handler); - } - - return $output; - } - /** * Provide some helpful text for the arguments. * The result should contain of an array with diff --git a/lib/Drupal/views/Plugin/views/filter/InOperator.php b/lib/Drupal/views/Plugin/views/filter/InOperator.php index 139b0286f817..3d100d0dd674 100644 --- a/lib/Drupal/views/Plugin/views/filter/InOperator.php +++ b/lib/Drupal/views/Plugin/views/filter/InOperator.php @@ -433,7 +433,7 @@ public function validate() { } } elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) { - $errors[] = t('The value @value is not an array for @operator on filter: @filter', array('@value' => views_var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE))); + $errors[] = t('The value @value is not an array for @operator on filter: @filter', array('@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE))); } return $errors; } diff --git a/lib/Drupal/views/Plugin/views/localization/Core.php b/lib/Drupal/views/Plugin/views/localization/Core.php deleted file mode 100644 index 7befb7c42d3e..000000000000 --- a/lib/Drupal/views/Plugin/views/localization/Core.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\Plugin\views\localization\Core. - */ - -namespace Drupal\views\Plugin\views\localization; - -use Drupal\Core\Annotation\Plugin; -use Drupal\Core\Annotation\Translation; - -/** - * Localization plugin to pass translatable strings through t(). - * - * @ingroup views_localization_plugins - * - * @Plugin( - * id = "core", - * title = @Translation("Core"), - * help = @Translation("Use Drupal core t() function. Not recommended, as it doesn't support updates to existing strings.") - * ) - */ -class Core extends LocalizationPluginBase { - - /** - * Translate a string. - * - * @param $string - * The string to be translated. - * @param $keys - * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format - * The input format of the string. This is optional. - */ - function translate_string($string, $keys = array(), $format = '') { - return t($string); - } - - /** - * Save a string for translation. - * - * @param $string - * The string to be translated. - * @param $keys - * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format - * The input format of the string. This is optional. - */ - function save_string($string, $keys = array(), $format = '') { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); - - // If the current language is 'en', we need to reset the language - // in order to trigger an update. - // TODO: add test for number of languages. - if ($language_interface->langcode == 'en') { - $changed = TRUE; - $languages = language_list(); - $cached_language = $language_interface; - unset($languages['en']); - if (!empty($languages)) { - // @todo Rewrite this code. - //drupal_container()->set(LANGUAGE_TYPE_INTERFACE, current($languages)); - } - } - - t($string); - - if (isset($cached_language)) { - // @todo Rewrite this code. - //drupal_container()->set(LANGUAGE_TYPE_INTERFACE, $cached_language); - } - return TRUE; - } - - /** - * Delete a string. - * - * Deletion is not supported. - * - * @param $source - * Full data for the string to be translated. - */ - function delete($source) { - return FALSE; - } - - /** - * Collect strings to be exported to code. - * - * String identifiers are not supported so strings are anonymously in an array. - * - * @param $source - * Full data for the string to be translated. - */ - function export($source) { - if (!empty($source['value'])) { - $this->export_strings[] = $source['value']; - } - } - - /** - * Render any collected exported strings to code. - * - * @param $indent - * An optional indentation for prettifying nested code. - */ - function export_render($indent = ' ') { - $output = ''; - if (!empty($this->export_strings)) { - $this->export_strings = array_unique($this->export_strings); - $output = $indent . '$translatables[\'' . $this->view->name . '\'] = array(' . "\n"; - foreach ($this->export_strings as $string) { - $output .= $indent . " t('" . str_replace("'", "\'", $string) . "'),\n"; - } - $output .= $indent . ");\n"; - } - return $output; - } - -} diff --git a/lib/Drupal/views/Plugin/views/localization/LocalizationPluginBase.php b/lib/Drupal/views/Plugin/views/localization/LocalizationPluginBase.php deleted file mode 100644 index 0283afd5700e..000000000000 --- a/lib/Drupal/views/Plugin/views/localization/LocalizationPluginBase.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\Plugin\views\localization\LocalizationPluginBase. - */ - -namespace Drupal\views\Plugin\views\localization; - -use Drupal\views\Plugin\views\PluginBase; - -/** - * @defgroup views_localization_plugins Views localization plugins - * @{ - * @todo. - * - * @see hook_views_plugins() - */ - -/** - * The base plugin to handle localization of Views strings. - */ -abstract class LocalizationPluginBase extends PluginBase { - - // Store for exported strings - var $export_strings = array(); - - var $translate = TRUE; - - /** - * Initialize the plugin. - * - * @param $view - * The view object. - */ - public function init(&$view) { - $this->setOptionDefaults($this->options, $this->defineOptions()); - $this->view = &$view; - } - - /** - * Translate a string / text with format - * - * The $source parameter is an array with the following elements: - * - value, source string - * - format, input format in case the text has some format to be applied - * - keys. An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * - * @param $source - * Full data for the string to be translated. - * - * @return string - * Translated string / text - */ - function translate($source) { - // Allow other modules to make changes to the string before and after translation - $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); - $source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']); - $source['post_process'] = $this->invoke_translation_process($source, 'post'); - return $source['translation']; - } - - /** - * Translate a string. - * - * @param $string - * The string to be translated. - * @param $keys - * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format - * The input format of the string. This is optional. - */ - function translate_string($string, $keys = array(), $format = '') {} - - /** - * Save string source for translation. - * - * @param $source - * Full data for the string to be translated. - */ - function save($source) { - // Allow other modules to make changes to the string before saving - $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); - $this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : ''); - } - - /** - * Save a string for translation - * - * @param $string - * The string to be translated. - * @param $keys - * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format - * The input format of the string. This is optional. - */ - function save_string($string, $keys = array(), $format = '') {} - - /** - * Delete a string. - * - * @param $source - * Full data for the string to be translated. - */ - function delete($source) { } - - /** - * Collect strings to be exported to code. - * - * @param $source - * Full data for the string to be translated. - */ - function export($source) { } - - /** - * Render any collected exported strings to code. - * - * @param $indent - * An optional indentation for prettifying nested code. - */ - function export_render($indent = ' ') { } - - /** - * Invoke hook_translation_pre_process() or hook_translation_post_process(). - * - * Like node_invoke_nodeapi(), this function is needed to enable both passing - * by reference and fetching return values. - */ - function invoke_translation_process(&$value, $op) { - $return = array(); - $hook = 'translation_' . $op . '_process'; - foreach (module_implements($hook) as $module) { - $function = $module . '_' . $hook; - $result = $function($value); - if (isset($result)) { - $return[$module] = $result; - } - } - return $return; - } - - function process_locale_strings($op) { - $this->view->initDisplay(); - - foreach ($this->view->display as $display_id => $display) { - $translatable = array(); - // Special handling for display title. - if (isset($display->display_title)) { - $translatable[] = array('value' => $display->display_title, 'keys' => array('display_title')); - } - // Unpack handlers. - if (is_object($this->view->display[$display_id]->handler)) { - $this->view->display[$display_id]->handler->unpackTranslatables($translatable); - } - foreach ($translatable as $data) { - $data['keys'] = array_merge(array($this->view->name, $display_id), $data['keys']); - switch ($op) { - case 'save': - $this->save($data); - break; - case 'delete': - $this->delete($data); - break; - case 'export': - $this->export($data); - break; - } - } - } - } - -} - -/** - * @} - */ diff --git a/lib/Drupal/views/Plugin/views/localization/None.php b/lib/Drupal/views/Plugin/views/localization/None.php deleted file mode 100644 index da5696c396e7..000000000000 --- a/lib/Drupal/views/Plugin/views/localization/None.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\Plugin\views\localization\None. - */ - -namespace Drupal\views\Plugin\views\localization; - -use Drupal\Core\Annotation\Plugin; -use Drupal\Core\Annotation\Translation; - -/** - * Localization plugin for no localization. - * - * @ingroup views_localization_plugins - * - * @Plugin( - * id = "none", - * title = @Translation("None"), - * help = @Translation("Do not pass admin strings for translation.") - * ) - */ -class None extends LocalizationPluginBase { - - var $translate = FALSE; - - /** - * Translate a string; simply return the string. - */ - function translate($source) { - return $source['value']; - } - - /** - * Save a string for translation; not supported. - */ - function save($source) { - return FALSE; - } - - /** - * Delete a string; not supported. - */ - function delete($source) { - return FALSE; - } - -} diff --git a/lib/Drupal/views/Tests/PluginInstanceTest.php b/lib/Drupal/views/Tests/PluginInstanceTest.php index 019245571ae1..7ee50d24c642 100644 --- a/lib/Drupal/views/Tests/PluginInstanceTest.php +++ b/lib/Drupal/views/Tests/PluginInstanceTest.php @@ -33,7 +33,6 @@ class PluginInstanceTest extends ViewTestBase { 'field', 'filter', 'join', - 'localization', 'pager', 'query', 'relationship', diff --git a/lib/Drupal/views/Tests/TranslatableTest.php b/lib/Drupal/views/Tests/TranslatableTest.php deleted file mode 100644 index 8c8e2f8c3825..000000000000 --- a/lib/Drupal/views/Tests/TranslatableTest.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\Tests\TranslatableTest. - */ - -namespace Drupal\views\Tests; - -/** - * Tests Views pluggable translations. - */ -class TranslatableTest extends ViewTestBase { - - /** - * Stores the strings, which are tested by this test. - * - * @var array - */ - protected $strings; - - public static function getInfo() { - return array( - 'name' => 'Translatable tests', - 'description' => 'Tests the pluggable translations.', - 'group' => 'Views', - ); - } - - protected function setUp() { - parent::setUp(); - - config('views.settings')->set('localization_plugin', 'test_localization')->save(); - // Reset the plugin data. - // @todo when all the plugin information is cached make a reset function and - // call it here. - $this->strings = array( - 'Master1', - 'Apply1', - 'Sort By1', - 'Asc1', - 'Desc1', - 'more1', - 'Reset1', - 'Offset1', - 'Master1', - 'title1', - 'Items per page1', - 'fieldlabel1', - 'filterlabel1' - ); - - $this->view = $this->getBasicView(); - } - - /** - * Overrides Drupal\views\Tests\ViewTestBase::getBasicView(). - */ - protected function getBasicView() { - return $this->createViewFromConfig('test_view_unpack_translatable'); - } - - /** - * Tests the unpack translation funtionality. - */ - public function testUnpackTranslatable() { - $view = $this->getView(); - $view->initLocalization(); - - $this->assertEqual('Drupal\views_test_data\Plugin\views\localization\LocalizationTest', get_class($view->localization_plugin), 'Make sure that init_localization initializes the right translation plugin'); - - $view->exportLocaleStrings(); - - $expected_strings = $this->strings; - $result_strings = $view->localization_plugin->get_export_strings(); - $this->assertEqual(sort($expected_strings), sort($result_strings), 'Make sure that the localization plugin got every translatable string.'); - } - - public function testUi() { - // Make sure that the string is not translated in the UI. - $view = $this->getView(); - $view->save(); - views_invalidate_cache(); - - $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); - $this->drupalLogin($admin_user); - - $this->drupalGet("admin/structure/views/view/$view->name/edit"); - $this->assertNoText('-translated', 'Make sure that no strings get translated in the UI.'); - } - - /** - * Make sure that the translations get into the loaded view. - */ - public function testTranslation() { - $view = $this->getView(); - $this->executeView($view); - - $expected_strings = array(); - foreach ($this->strings as $string) { - $expected_strings[] = $string . '-translated'; - } - - sort($expected_strings); - sort($view->localization_plugin->translated_strings); - - // @todo The plugin::unpackOptions() method is missing some keys of the - // display, but calls the translate method two times per item. - //$this->assertEqual($expected_strings, $view->localization_plugin->translated_strings, 'Make sure that every string got loaded translated'); - } - - /** - * Make sure that the different things have the right translation keys. - */ - public function testTranslationKey() { - $view = $this->getView(); - $view->editing = TRUE; - $view->initDisplay(); - - // Don't run translation. We just want to get the right keys. - - foreach ($view->display as $display_id => $display) { - $translatables = array(); - $display->handler->unpackTranslatables($translatables); - - $this->string_keys = array( - 'Master1' => array('title'), - 'Apply1' => array('exposed_form', 'submit_button'), - 'Sort By1' => array('exposed_form', 'exposed_sorts_label'), - 'Asc1' => array('exposed_form', 'sort_asc_label'), - 'Desc1' => array('exposed_form', 'sort_desc_label'), - 'more1' => array('use_more_text'), - 'Reset1' => array('exposed_form', 'reset_button_label'), - 'Offset1' => array('pager', 'expose', 'offset_label'), - 'Master1' => array('title'), - 'title1' => array('title'), - 'Tag first1' => array('pager', 'tags', 'first'), - 'Tag prev1' => array('pager', 'tags', 'previous'), - 'Tag next1' => array('pager', 'tags', 'next'), - 'Tag last1' => array('pager', 'tags', 'last'), - 'Items per page1' => array('pager', 'expose', 'items_per_page_label'), - 'fieldlabel1' => array('field', 'node', 'nid', 'label'), - 'filterlabel1' => array('filter', 'node', 'nid', 'expose', 'label'), - '- All -' => array('pager', 'expose', 'items_per_page_options_all_label'), - ); - foreach ($translatables as $translatable) { - $this->assertEqual($translatable['keys'], $this->string_keys[$translatable['value']]); - } - } - } - -} diff --git a/lib/Drupal/views/Tests/Wizard/BasicTest.php b/lib/Drupal/views/Tests/Wizard/BasicTest.php index 3460aa627e90..41ebdce85732 100644 --- a/lib/Drupal/views/Tests/Wizard/BasicTest.php +++ b/lib/Drupal/views/Tests/Wizard/BasicTest.php @@ -129,13 +129,6 @@ function testViewsWizardAndListing() { $this->assertText($node1->label()); $this->assertNoText($node2->label()); - // Check if the export screen works. - // @todo Remove this once the export is gone. - // $this->drupalGet('admin/structure/views/view/' . $view3['name'] . '/export'); - // $this->assertRaw('$view = new Drupal\views\View(array(), "view");'); - // $this->assertRaw($view3['human_name']); - // $this->assertRaw($view3['description']); - // Make sure the listing page doesn't show disabled default views. $this->assertNoText('tracker', t('Default tracker view does not show on the listing page.')); } diff --git a/lib/Drupal/views/View.php b/lib/Drupal/views/View.php index 1d9aadbcb9a9..4da2da810c88 100644 --- a/lib/Drupal/views/View.php +++ b/lib/Drupal/views/View.php @@ -592,7 +592,6 @@ public function initDisplay($reset = FALSE) { } $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin); if (!empty($this->display[$id]->handler)) { - $this->display[$id]->handler->localization_keys = array($id); // Initialize the new display handler with data. $this->display[$id]->handler->init($this, $this->display[$id]); // If this is NOT the default display handler, let it know which is @@ -2059,32 +2058,6 @@ public function validate() { return $errors ? $errors : TRUE; } - /** - * Find and initialize the localizer plugin. - */ - public function initLocalization() { - // @todo The check for the view was added to ensure that - // $this->localization_plugin->init() is run. - if (isset($this->localization_plugin) && is_object($this->localization_plugin) && isset($this->localization_plugin->view)) { - return TRUE; - } - - $this->localization_plugin = views_get_plugin('localization', views_get_localization_plugin()); - - if (empty($this->localization_plugin)) { - $this->localization_plugin = views_get_plugin('localization', 'none'); - $this->localization_plugin->init($this); - return FALSE; - } - - /** - * Figure out whether there should be options. - */ - $this->localization_plugin->init($this); - - return $this->localization_plugin->translate; - } - /** * Determine whether a view supports admin string translation. */ @@ -2094,39 +2067,6 @@ public function isTranslatable() { return (!isset($this->type) || in_array($this->type, array(t('Normal'), t('Overridden')))) ? TRUE : FALSE; } - /** - * Send strings for localization. - */ - public function saveLocaleStrings() { - $this->processLocaleStrings('save'); - } - - /** - * Delete localized strings. - */ - public function deleteLocaleStrings() { - $this->processLocaleStrings('delete'); - } - - /** - * Export localized strings. - */ - public function exportLocaleStrings() { - $this->processLocaleStrings('export'); - } - - /** - * Process strings for localization, deletion or export to code. - */ - public function processLocaleStrings($op) { - // Ensure this view supports translation, we have a display, and we - // have a localization plugin. - // @fixme Export does not init every handler. - if (($this->isTranslatable() || $op == 'export') && $this->initDisplay() && $this->initLocalization()) { - $this->localization_plugin->process_locale_strings($op); - } - } - /** * Provide a list of views handler types used in a view, with some information * about them. diff --git a/tests/views_test_config/config/views.view.test_view_unpack_translatable.yml b/tests/views_test_config/config/views.view.test_view_unpack_translatable.yml deleted file mode 100644 index 94357876b4a5..000000000000 --- a/tests/views_test_config/config/views.view.test_view_unpack_translatable.yml +++ /dev/null @@ -1,80 +0,0 @@ -api_version: '3.0' -base_table: node -core: '8' -description: '' -disabled: '0' -display: - default: - display_options: - access: - type: none - cache: - type: none - exposed_form: - options: - exposed_sorts_label: 'Sort By1' - reset_button: '1' - reset_button_label: Reset1 - sort_asc_label: Asc1 - sort_desc_label: Desc1 - submit_button: Apply1 - type: basic - fields: - nid: - alter: - alter_text: '0' - ellipsis: '1' - html: '0' - make_link: '0' - strip_tags: '0' - trim: '0' - word_boundary: '1' - empty_zero: '0' - field: nid - hide_empty: '0' - id: nid - label: fieldlabel1 - link_to_node: '0' - table: node - filters: - nid: - expose: - identifier: nid - label: filterlabel1 - multiple: '1' - operator_id: nid_op - reduce: '0' - exposed: '1' - field: nid - id: nid - table: node - pager: - options: - expose: - items_per_page: '1' - items_per_page_label: 'Items per page1' - offset: '1' - offset_label: Offset1 - id: '0' - items_per_page: '10' - offset: '0' - quantity: '9' - tags: - first: 'Tag first1' - last: 'Tag last1' - next: 'Tag next1' - previous: 'Tag prev1' - type: full - query: - type: views_query - row_plugin: fields - style_plugin: default - title: title1 - use_more_text: more1 - display_plugin: default - display_title: Master1 - id: default - position: '0' -human_name: '' -name: test_view_unpack_translatable -tag: '' diff --git a/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/localization/LocalizationTest.php b/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/localization/LocalizationTest.php deleted file mode 100644 index ce427dda95d0..000000000000 --- a/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/localization/LocalizationTest.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views_test_data\Plugin\views\localization\LocalizationTest. - */ - -namespace Drupal\views_test_data\Plugin\views\localization; - -use Drupal\Core\Annotation\Plugin; -use Drupal\Core\Annotation\Translation; -use Drupal\views\Plugin\views\localization\LocalizationPluginBase; - -/** - * A stump localisation plugin which has static variables to cache the input. - * - * @Plugin( - * id = "test_localization", - * title = @Translation("Test."), - * help = @Translation("This is a test description."), - * no_uid = TRUE - * ) - */ -class LocalizationTest extends LocalizationPluginBase { - - /** - * Store the strings which was translated. - */ - var $translated_strings = array(); - /** - * Return the string and take sure that the test can find out whether the - * string got translated. - */ - function translate_string($string, $keys = array(), $format = '') { - $this->translated_strings[] = $string . "-translated"; - return $string . "-translated"; - } - - /** - * Store the export strings. - */ - function export($source) { - if (!empty($source['value'])) { - $this->export_strings[] = $source['value']; - } - } - - /** - * Return the stored strings for the simpletest. - */ - function get_export_strings() { - return $this->export_strings; - } - -} diff --git a/views.install b/views.install index 369c1ab8ed47..9f5355e8415b 100644 --- a/views.install +++ b/views.install @@ -35,7 +35,6 @@ function views_schema() { 'create callback' => 'views_new_view', 'save callback' => 'views_save_view', 'delete callback' => 'views_delete_view', - 'export callback' => 'views_export_view', ), 'fields' => array( 'vid' => array( @@ -213,7 +212,6 @@ function views_update_8000() { 'views_sql_signature' => 'sql_signature', 'views_no_javascript' => 'no_javascript', 'views_devel_output' => 'debug.output', - 'views_localization_plugin' => 'localization_plugin', 'views_devel_region' => 'debug.region', 'views_display_extenders' => 'display_extenders', )); diff --git a/views.module b/views.module index 35c24c5e9b92..69cfde617f15 100644 --- a/views.module +++ b/views.module @@ -1448,7 +1448,7 @@ function views_get_plugin($type, $plugin_id) { */ function views_get_plugin_definitions($type = FALSE) { $plugins = array(); - $plugin_types = $type ? array($type) : array('access', 'area', 'argument', 'argument_default', 'argument_validator', 'cache', 'display_extender', 'display', 'exposed_form', 'field', 'filter', 'join', 'localization', 'pager', 'query', 'relationship', 'row', 'sort', 'style', 'wizard'); + $plugin_types = $type ? array($type) : array('access', 'area', 'argument', 'argument_default', 'argument_validator', 'cache', 'display_extender', 'display', 'exposed_form', 'field', 'filter', 'join', 'pager', 'query', 'relationship', 'row', 'sort', 'style', 'wizard'); foreach ($plugin_types as $plugin_type) { $manager = new ViewsPluginManager($plugin_type); $plugins[$plugin_type] = $manager->getDefinitions(); @@ -1475,26 +1475,6 @@ function views_get_plugin_definition($type, $plugin_id) { return $manager->getDefinition($plugin_id); } -/** - * Load the current enabled localization plugin. - * - * @return The name of the localization plugin. - */ -function views_get_localization_plugin() { - $plugin = config('views.settings')->get('localization_plugin'); - // Provide sane default values for the localization plugin. - if (empty($plugin)) { - if (module_exists('locale')) { - $plugin = 'core'; - } - else { - $plugin = 'none'; - } - } - - return $plugin; -} - /** * Get enabled display extenders. */ @@ -1816,21 +1796,6 @@ function views_delete_view(&$view) { return $view->delete(TRUE); } -/** - * Export CRUD callback to export a view. - */ -function views_export_view(&$view, $indent = '') { - return $view->export($indent); -} - -/** - * Export callback to change view status. - */ -function views_export_status($view, $status) { - ctools_export_set_object_status($view, $status); - views_invalidate_cache(); -} - // ------------------------------------------------------------------ // Views form (View with form elements) @@ -2334,47 +2299,6 @@ function views_get_view_result($name, $display_id = NULL) { } } -/** - * Export a field. - */ -function views_var_export($var, $prefix = '', $init = TRUE) { - if (is_array($var)) { - if (empty($var)) { - $output = 'array()'; - } - else { - $output = "array(\n"; - foreach ($var as $key => $value) { - $output .= " " . views_var_export($key, '', FALSE) . " => " . views_var_export($value, ' ', FALSE) . ",\n"; - } - $output .= ')'; - } - } - elseif (is_bool($var)) { - $output = $var ? 'TRUE' : 'FALSE'; - } - elseif (is_string($var) && strpos($var, "\n") !== FALSE) { - // Replace line breaks in strings with a token for replacement - // at the very end. This protects multi-line strings from - // unintentional indentation. - $var = str_replace("\n", "***BREAK***", $var); - $output = var_export($var, TRUE); - } - else { - $output = var_export($var, TRUE); - } - - if ($prefix) { - $output = str_replace("\n", "\n$prefix", $output); - } - - if ($init) { - $output = str_replace("***BREAK***", "\n", $output); - } - - return $output; -} - /** * Prepare a string for use as a valid CSS identifier (element, class or ID name). * This function is similar to a core version but with more sane filter values. -- GitLab