Commit 92e520db authored by tim.plunkett's avatar tim.plunkett

Issue #1754322 by tim.plunkett, dawehner: Remove export and localization code.

parent 595b233e
......@@ -2,7 +2,6 @@ debug:
output: '0'
region: 'footer'
display_extenders: { }
localization_plugin: ''
no_javascript: '0'
skip_cache: '0'
sql_signature: '0'
......
......@@ -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();
......
......@@ -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';
......
......@@ -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.
......
......@@ -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.
......
......@@ -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.
*/
......
......@@ -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'));
}
......
......@@ -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) {
}
}