Issue #1781934 by dawehner: Unify plugin_options() on the display.

8.0.x
dereine 2012-09-23 22:53:04 +02:00 committed by Tim Plunkett
parent 78e7578921
commit 230cdaf1c2
65 changed files with 547 additions and 379 deletions

View File

@ -27,8 +27,6 @@ display:
type: basic
pager:
type: full
style_plugin: default
row_plugin: node
sorts:
created:
id: created
@ -62,6 +60,10 @@ display:
group: 0
expose:
operator: false
style:
type: default
row:
type: node
page:
id: page
display_title: Page

View File

@ -28,10 +28,6 @@ display:
type: full
options:
items_per_page: 30
style_plugin: html_list
style_options:
type: ol
row_plugin: fields
empty:
text:
id: area
@ -70,6 +66,12 @@ display:
group: 0
expose:
operator: false
style:
type: html_list
options:
type: ol
row:
type: fields
page:
id: page
display_title: Page
@ -101,8 +103,6 @@ display:
row_options: false
arguments: false
use_more: true
style_plugin: html_list
row_plugin: fields
arguments:
nid:
id: nid
@ -117,3 +117,7 @@ display:
specify_validation: 1
validate:
type: node
style:
type: html_list
row:
type: fields

View File

@ -30,8 +30,6 @@ display:
type: some
options:
items_per_page: 5
style_plugin: html_list
row_plugin: fields
relationships:
nid:
id: nid
@ -63,6 +61,10 @@ display:
field: status_extra
relationship: nid
group: 0
style:
type: html_list
row:
type: fields
page:
id: page
display_title: Page
@ -78,13 +80,6 @@ display:
row_plugin: false
row_options: false
fields: false
style_plugin: html_list
row_plugin: fields
row_options:
inline:
title: title
timestamp: timestamp
separator: ' '
fields:
title:
id: title
@ -111,6 +106,15 @@ display:
field: comment_body
label: ''
path: comments/recent
style:
type: html_list
row:
type: fields
options:
inline:
title: title
timestamp: timestamp
separator: ' '
block:
id: block
display_title: Block

View File

@ -26,10 +26,12 @@ display:
type: basic
pager:
type: full
style_plugin: default
row_plugin: node
row_options:
links: 1
style:
type: default
row:
type: node
options:
links: 1
sorts:
sticky:
id: sticky
@ -82,8 +84,10 @@ display:
title: 'Front page feed'
pager:
type: some
style_plugin: rss
row_plugin: node_rss
style:
type: rss
row:
type: node_rss
path: rss.xml
displays:
default: default

View File

@ -29,25 +29,6 @@ display:
type: full
options:
items_per_page: 36
style_plugin: table
style_options:
columns:
title: title
name: name
changed: changed
default: title
info:
title:
sortable: 1
separator: ''
name:
sortable: 1
separator: ''
changed:
sortable: 1
separator: ''
override: 1
sticky: 0
fields:
title:
id: title
@ -91,6 +72,26 @@ display:
id: uid
table: node
field: uid
style:
type: table
options:
columns:
title: title
name: name
changed: changed
default: title
info:
title:
sortable: 1
separator: ''
name:
sortable: 1
separator: ''
changed:
sortable: 1
separator: ''
override: 1
sticky: 0
page:
id: page
display_title: Page

View File

@ -26,8 +26,6 @@ display:
type: basic
pager:
type: full
style_plugin: default
row_plugin: node
sorts:
sticky:
id: sticky
@ -75,6 +73,10 @@ display:
group: 0
expose:
operator: false
style:
type: default
row:
type: node
page:
id: page
display_title: Page
@ -98,9 +100,11 @@ display:
type: full
options:
items_per_page: 15
style_plugin: rss
row_plugin: node_rss
path: taxonomy/term/%/%/feed
displays:
page: page
default: 0
style:
type: rss
row:
type: node_rss

View File

@ -29,39 +29,6 @@ display:
type: full
options:
items_per_page: '25'
style_plugin: table
style_options:
columns:
type: type
title: title
name: name
comment_count: comment_count
last_comment_timestamp: last_comment_timestamp
timestamp: title
new_comments: comment_count
default: last_comment_timestamp
info:
type:
sortable: 1
separator: ''
title:
sortable: 1
separator: ' '
name:
sortable: 1
separator: ''
comment_count:
sortable: 1
separator: '<br />'
last_comment_timestamp:
sortable: 1
separator: '&nbsp;'
timestamp:
separator: ''
new_comments:
separator: ''
override: 1
order: desc
relationships:
uid:
id: uid
@ -134,6 +101,40 @@ display:
group: 0
expose:
operator: false
style:
type: table
options:
columns:
type: type
title: title
name: name
comment_count: comment_count
last_comment_timestamp: last_comment_timestamp
timestamp: title
new_comments: comment_count
default: last_comment_timestamp
info:
type:
sortable: 1
separator: ''
title:
sortable: 1
separator: '&nbsp;'
name:
sortable: 1
separator: ''
comment_count:
sortable: 1
separator: '<br />'
last_comment_timestamp:
sortable: 1
separator: '&nbsp;'
timestamp:
separator: ''
new_comments:
separator: ''
override: 1
order: desc
page:
id: page
display_title: Page

View File

@ -1963,15 +1963,17 @@ function views_ui_import_validate($form, &$form_state) {
continue;
}
$plugin = views_get_plugin('style', $display->getOption('style_plugin'));
$style = $display->getOption('style');
$plugin = views_get_plugin('style', $style['type']);
if (!$plugin) {
drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $display->getOption('style_plugin'))), 'error');
drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $style['type'])), 'error');
$broken = TRUE;
}
elseif ($plugin->usesRowPlugin()) {
$plugin = views_get_plugin('row', $display->getOption('row_plugin'));
$row = $display->getOption('row');
$plugin = views_get_plugin('row', $row['type']);
if (!$plugin) {
drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $display->getOption('row_plugin'))), 'error');
drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $row['type'])), 'error');
$broken = TRUE;
}
}
@ -2122,8 +2124,8 @@ function views_ui_edit_form_get_bucket($type, ViewExecutable $view, $display) {
break;
case 'field':
// Fetch the style plugin info so we know whether to list fields or not.
$name = $view->displayHandlers[$display['id']]->getOption('style_plugin');
$style_plugin = $view->displayHandlers[$display['id']]->getPlugin('style', $name);
$style = $view->displayHandlers[$display['id']]->getOption('style');
$style_plugin = $view->displayHandlers[$display['id']]->getPlugin('style', $style['type']);
$uses_fields = $style_plugin && $style_plugin->usesFields();
if (!$uses_fields) {
$build['fields'][] = array(
@ -3139,6 +3141,7 @@ function views_ui_edit_display_form($form, &$form_state) {
if (!$view->setDisplay($display_id)) {
views_ajax_error(t('Invalid display id @display', array('@display' => $display_id)));
}
$display = &$view->display[$display_id];
// Get form from the handler.
$form['options'] = array(
@ -4582,12 +4585,12 @@ function views_ui_config_style_form($form, &$form_state) {
$form['#section'] = $display_id . '-' . $type . '-style-options';
$plugin = views_get_plugin('style', $handler->options['style_plugin']);
$plugin = views_get_plugin('style', $handler->options['style']['type']);
if ($plugin) {
$form['style_options'] = array(
'#tree' => TRUE,
);
$plugin->init($view, $view->display[$display_id], $handler->options['style_options']);
$plugin->init($view, $view->display[$display_id], $handler->options['style']['options']);
$plugin->buildOptionsForm($form['style_options'], $form_state);
}

View File

@ -34,16 +34,12 @@ abstract class AccessPluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display) {
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
if (is_object($display)) {
$options = $display->getOption('access');
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
$this->unpackOptions($this->options, $options);
}
/**

View File

@ -63,16 +63,12 @@ abstract class CachePluginBase extends PluginBase {
* @param $display
* The display handler.
*/
public function init(ViewExecutable $view, &$display) {
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
$this->displayHandler = &$display;
if (is_object($display)) {
$options = $display->getOption('cache');
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
$this->unpackOptions($this->options, $options);
}
/**

View File

@ -352,10 +352,8 @@ abstract class DisplayPluginBase extends PluginBase {
*/
public function defaultableSections($section = NULL) {
$sections = array(
'access' => array('access', 'access_options'),
'access_options' => array('access', 'access_options'),
'cache' => array('cache', 'cache_options'),
'cache_options' => array('cache', 'cache_options'),
'access' => array('access'),
'cache' => array('cache'),
'title' => array('title'),
'css_class' => array('css_class'),
'use_ajax' => array('use_ajax'),
@ -369,10 +367,8 @@ abstract class DisplayPluginBase extends PluginBase {
'link_display' => array('link_display', 'link_url'),
// Force these to cascade properly.
'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'style_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'row_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'row_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'style' => array('style', 'row'),
'row' => array('style', 'row'),
'pager' => array('pager', 'pager_options'),
'pager_options' => array('pager', 'pager_options'),
@ -427,21 +423,17 @@ abstract class DisplayPluginBase extends PluginBase {
'hide_attachment_summary' => TRUE,
'hide_admin_links' => FALSE,
'pager' => TRUE,
'pager_options' => TRUE,
'use_more' => TRUE,
'use_more_always' => TRUE,
'use_more_text' => TRUE,
'exposed_form' => TRUE,
'exposed_form_options' => TRUE,
'link_display' => TRUE,
'link_url' => '',
'group_by' => TRUE,
'style_plugin' => TRUE,
'style_options' => TRUE,
'row_plugin' => TRUE,
'row_options' => TRUE,
'style' => TRUE,
'row' => TRUE,
'header' => TRUE,
'footer' => TRUE,
@ -523,12 +515,14 @@ abstract class DisplayPluginBase extends PluginBase {
'access' => array(
'contains' => array(
'type' => array('default' => 'none'),
),
'options' => array('default' => array()),
),
),
'cache' => array(
'contains' => array(
'type' => array('default' => 'none'),
),
'options' => array('default' => array()),
),
),
'query' => array(
'contains' => array(
@ -536,12 +530,6 @@ abstract class DisplayPluginBase extends PluginBase {
'options' => array('default' => array()),
),
),
// Note that exposed_form plugin has options in a separate array,
// while access and cache do not. access and cache are legacy and
// that pattern should not be repeated, but it is left as is to
// reduce the need to modify older views. Let's consider the
// pattern used here to be the template from which future plugins
// should be copied.
'exposed_form' => array(
'contains' => array(
'type' => array('default' => 'basic'),
@ -554,21 +542,17 @@ abstract class DisplayPluginBase extends PluginBase {
'options' => array('default' => array()),
),
),
// Note that the styles have their options completely independent.
// Like access and cache above, this is a legacy pattern and
// should not be repeated.
'style_plugin' => array(
'default' => 'default',
'style' => array(
'contains' => array(
'type' => array('default' => 'default'),
'options' => array('default' => array()),
),
),
'style_options' => array(
'default' => array(),
),
'row_plugin' => array(
'default' => 'fields',
),
'row_options' => array(
'default' => array(),
'row' => array(
'contains' => array(
'type' => array('default' => 'fields'),
'options' => array('default' => array()),
),
),
'exposed_block' => array(
@ -738,8 +722,8 @@ abstract class DisplayPluginBase extends PluginBase {
* @return bool
*/
public function usesFields() {
$name = $this->getOption('style_plugin');
$plugin = $this->getPlugin('style', $name);
$style = $this->getOption('style');
$plugin = $this->getPlugin('style', $style['type']);
if ($plugin) {
return $plugin->usesFields();
}
@ -759,15 +743,6 @@ abstract class DisplayPluginBase extends PluginBase {
static $cache = array();
if (!isset($cache[$type][$name])) {
switch ($type) {
case 'style':
case 'row':
$option_name = $type . '_plugin';
$options = $this->getOption($type . '_options');
if (!$name) {
$name = $this->getOption($option_name);
}
break;
case 'query':
$views_data = views_fetch_data($this->view->storage->base_table);
$name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
@ -778,15 +753,7 @@ abstract class DisplayPluginBase extends PluginBase {
$name = $options['type'];
}
// access & cache store their options as siblings with the
// type; all others use an 'options' array.
if ($type != 'access' && $type != 'cache') {
if (!isset($options['options'])) {
// debug($type);
// debug($options);
}
$options = $options['options'];
}
$options = $options['options'];
}
if ($type != 'query') {
@ -1089,15 +1056,16 @@ abstract class DisplayPluginBase extends PluginBase {
'desc' => t('Change the title that this display will use.'),
);
$name = $this->getOption('style_plugin');
$style_options = $this->getOption('style');
$name = $style_options['type'];
$style_plugin = views_get_plugin_definition('style', $name);
$style_plugin_instance = $this->getPlugin('style', $name);
$style_plugin_instance = $this->getPlugin('style');
$style_summary = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->summaryTitle();
$style_title = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->pluginTitle();
$style = '';
$options['style_plugin'] = array(
$options['style'] = array(
'category' => 'format',
'title' => t('Format'),
'value' => $style_title,
@ -1107,17 +1075,18 @@ abstract class DisplayPluginBase extends PluginBase {
// This adds a 'Settings' link to the style_options setting if the style has options.
if ($style_plugin_instance->usesOptions()) {
$options['style_plugin']['links']['style_options'] = t('Change settings for this format');
$options['style']['links']['style_options'] = t('Change settings for this format');
}
if ($style_plugin_instance->usesRowPlugin()) {
$name = $this->getOption('row_plugin');
$row_options = $this->getOption('row');
$name = $row_options['type'];
$row_plugin = views_get_plugin_definition('row', $name);
$row_plugin_instance = $this->getPlugin('row', $name);
$row_summary = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->summaryTitle();
$row_title = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->pluginTitle();
$options['row_plugin'] = array(
$options['row'] = array(
'category' => 'format',
'title' => t('Show'),
'value' => $row_title,
@ -1126,7 +1095,7 @@ abstract class DisplayPluginBase extends PluginBase {
);
// This adds a 'Settings' link to the row_options setting if the row style has options.
if ($row_plugin_instance->usesOptions()) {
$options['row_plugin']['links']['row_options'] = t('Change settings for this style');
$options['row']['links']['row_options'] = t('Change settings for this style');
}
}
if ($this->usesAJAX()) {
@ -1493,17 +1462,12 @@ abstract class DisplayPluginBase extends PluginBase {
break;
case 'access_options':
$access = $this->getOption('access');
$plugin = $this->getPlugin('access');
$form['#title'] .= t('Access options');
if ($plugin) {
$form['access_options'] = array(
'#tree' => TRUE,
);
$form['access_options']['type'] = array(
'#type' => 'value',
'#value' => $access['type'],
);
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
@ -1532,17 +1496,12 @@ abstract class DisplayPluginBase extends PluginBase {
}
break;
case 'cache_options':
$cache = $this->getOption('cache');
$plugin = $this->getPlugin('cache');
$form['#title'] .= t('Caching options');
if ($plugin) {
$form['cache_options'] = array(
'#tree' => TRUE,
);
$form['cache_options']['type'] = array(
'#type' => 'value',
'#value' => $cache['type'],
);
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
@ -1609,20 +1568,21 @@ abstract class DisplayPluginBase extends PluginBase {
$form['field_language']['#markup'] = t("You don't have translatable entity types.");
}
break;
case 'style_plugin':
case 'style':
$form['#title'] .= t('How should this view be styled');
$form['style_plugin'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('style', $this->getStyleType(), array($this->view->storage->base_table)),
'#default_value' => $this->getOption('style_plugin'),
'#default_value' => $style['type'],
'#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'),
);
$name = $this->getOption('style_plugin');
$style_plugin = $this->getPlugin('style', $name);
$style_plugin = $this->getPlugin('style', $style['type']);
if ($style_plugin->usesOptions()) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->optionLink(t('settings'), 'style_options'))) . '</div>',
'#prefix' => '<div class="form-item description">',
'#suffix' => '</div>',
'#markup' => t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->optionLink(t('settings'), 'style_options'))),
);
}
@ -1630,19 +1590,19 @@ abstract class DisplayPluginBase extends PluginBase {
case 'style_options':
$form['#title'] .= t('Style options');
$style = TRUE;
$type = 'style_plugin';
$name = $this->getOption('style_plugin');
$style_plugin = $this->getOption('style');
$name = $style_plugin['type'];
case 'row_options':
if (!isset($name)) {
$name = $this->getOption('row_plugin');
$row_plugin = $this->getOption('row');
$name = $row_plugin['type'];
}
// if row, $style will be empty.
if (empty($style)) {
$form['#title'] .= t('Row style options');
$type = 'row_plugin';
}
$plugin = $this->getPlugin(empty($style) ? 'row' : 'style');
$plugin = $this->getPlugin(empty($style) ? 'row' : 'style', $name);
if ($plugin) {
$form[$form_state['section']] = array(
'#tree' => TRUE,
@ -1650,19 +1610,20 @@ abstract class DisplayPluginBase extends PluginBase {
$plugin->buildOptionsForm($form[$form_state['section']], $form_state);
}
break;
case 'row_plugin':
case 'row':
$form['#title'] .= t('How should each row in this view be styled');
$form['row_plugin'] = array(
'#type' => 'radios',
'#options' => views_fetch_plugin_names('row', $this->getStyleType(), array($this->view->storage->base_table)),
'#default_value' => $this->getOption('row_plugin'),
'#default_value' => $row['type'],
);
$name = $this->getOption('row_plugin');
$row_plugin = $this->getPlugin('row', $name);
if ($row_plugin->usesOptions()) {
$row_plugin_instance = $this->getPlugin('row', $row['type']);
if ($row_plugin_instance->usesOptions()) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->optionLink(t('settings'), 'row_options'))) . '</div>',
'#prefix' => '<div class="form-item description">',
'#suffix' => '</div>',
'#markup' => t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->optionLink(t('settings'), 'row_options'))),
);
}
@ -2128,7 +2089,7 @@ abstract class DisplayPluginBase extends PluginBase {
}
foreach ($this->view->display as $id => $display) {
if ($id != $this->view->current_display && ($form_state['values']['display_id'] == $id || (isset($display['new_id']) && $form_state['values']['display_id'] == $display['new_id']))) {
if ($id != $this->view->current_display && ($form_state['values']['display_id'] == $id || (isset($display->new_id) && $form_state['values']['display_id'] == $display->new_id))) {
form_error($form['display_id'], t('Display id should be unique.'));
}
}
@ -2216,10 +2177,12 @@ abstract class DisplayPluginBase extends PluginBase {
break;
case 'access_options':
$plugin = views_get_plugin('access', $form_state['values'][$section]['type']);
$plugin = $this->getPlugin('access');
if ($plugin) {
$access = $this->getOption('access');
$plugin->submitOptionsForm($form['access_options'], $form_state);
$this->setOption('access', $form_state['values'][$section]);
$access['options'] = $form_state['values'][$section];
$this->setOption('access', $access);
}
break;
case 'cache':
@ -2237,10 +2200,12 @@ abstract class DisplayPluginBase extends PluginBase {
break;
case 'cache_options':
$plugin = views_get_plugin('cache', $form_state['values'][$section]['type']);
$plugin = $this->getPlugin('cache');
if ($plugin) {
$cache = $this->getOption('cache');
$plugin->submitOptionsForm($form['cache_options'], $form_state);
$this->setOption('cache', $form_state['values'][$section]);
$cache['options'] = $form_state['values'][$section];
$this->setOption('cache', $cache);
}
break;
case 'query':
@ -2277,14 +2242,15 @@ abstract class DisplayPluginBase extends PluginBase {
case 'group_by':
$this->setOption($section, $form_state['values'][$section]);
break;
case 'row_plugin':
case 'row':
// This if prevents resetting options to default if they don't change
// the plugin.
if ($this->getOption($section) != $form_state['values'][$section]) {
$plugin = views_get_plugin('row', $form_state['values'][$section]);
$row = $this->getOption('row');
if ($row['type'] != $form_state['values'][$section]['type']) {
$plugin = views_get_plugin('row', $form_state['values'][$section]['type']);
if ($plugin) {
$this->setOption($section, $form_state['values'][$section]);
$this->setOption('row_options', array());
$row = array('type' => $form_state['values'][$section]['type']);
$this->setOption($section, $row);
// send ajax form to options page if we use it.
if ($plugin->usesOptions()) {
@ -2293,14 +2259,15 @@ abstract class DisplayPluginBase extends PluginBase {
}
}
break;
case 'style_plugin':
case 'style':
// This if prevents resetting options to default if they don't change
// the plugin.
if ($this->getOption($section) != $form_state['values'][$section]) {
$plugin = views_get_plugin('style', $form_state['values'][$section]);
$style = $this->getOption('style');
if ($style['type'] != $form_state['values'][$section]['type']) {
$plugin = views_get_plugin('style', $form_state['values'][$section]['type']);
if ($plugin) {
$this->setOption($section, $form_state['values'][$section]);
$this->setOption('style_options', array());
$row = array('type' => $form_state['values'][$section]['type']);
$this->setOption($section, $row);
// send ajax form to options page if we use it.
if ($plugin->usesOptions()) {
views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('style_options'));
@ -2309,14 +2276,22 @@ abstract class DisplayPluginBase extends PluginBase {
}
break;
case 'style_options':
$style = TRUE;
case 'row_options':
// if row, $style will be empty.
$plugin = $this->getPlugin(empty($style) ? 'row' : 'style');
$plugin = $this->getPlugin('style');
if ($plugin) {
$plugin->submitOptionsForm($form['options'][$section], $form_state);
$style = $this->getOption('style');
$plugin->submitOptionsForm($form['style_options'], $form_state);
$style['options'] = $form_state['values'][$section];
$this->setOption('style', $style);
}
break;
case 'row_options':
$plugin = $this->getPlugin('row');
if ($plugin) {
$row = $this->getOption('row');
$plugin->submitOptionsForm($form['row_options'], $form_state);
$row['options'] = $form_state['values'][$section];
$this->setOption('row', $row);
}
$this->setOption($section, $form_state['values'][$section]);
break;
case 'exposed_block':
$this->setOption($section, (bool) $form_state['values'][$section]);

View File

@ -52,8 +52,8 @@ class Feed extends Page {
// which we don't know until init().
$row_plugins = views_fetch_plugin_names('row', $this->getStyleType(), array($view->storage->base_table));
$default_row_plugin = key($row_plugins);
if ($this->options['row_plugin'] == '') {
$this->options['row_plugin'] = $default_row_plugin;
if (empty($this->options['row']['type'])) {
$this->options['row']['type'] = $default_row_plugin;
}
}
@ -92,7 +92,7 @@ class Feed extends Page {
}
public function defaultableSections($section = NULL) {
if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin'))) {
if (in_array($section, array('style', 'row'))) {
return FALSE;
}
@ -114,14 +114,12 @@ class Feed extends Page {
$options['displays'] = array('default' => array());
// Overrides for standard stuff:
$options['style_plugin']['default'] = 'rss';
$options['style_options']['default'] = array('description' => '');
$options['style']['contains']['type']['default'] = 'rss';
$options['style']['contains']['options']['default'] = array('description' => '');
$options['sitename_title']['default'] = FALSE;
$options['row_plugin']['default'] = '';
$options['defaults']['default']['style_plugin'] = FALSE;
$options['defaults']['default']['style_options'] = FALSE;
$options['defaults']['default']['row_plugin'] = FALSE;
$options['defaults']['default']['row_options'] = FALSE;
$options['row']['contains']['type']['default'] = '';
$options['defaults']['default']['style'] = FALSE;
$options['defaults']['default']['row'] = FALSE;
return $options;
}

View File

@ -47,8 +47,8 @@ abstract class RowPluginBase extends PluginBase {
$this->view = &$view;
$this->displayHandler = &$display;
// Overlay incoming options on top of defaults.
$this->unpackOptions($this->options, isset($options) ? $options : $display->getOption('row_options'));
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
/**

View File

@ -95,10 +95,9 @@ abstract class StylePluginBase extends PluginBase {
$this->view = &$view;
$this->displayHandler = &$display;
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, isset($options) ? $options : $display->getOption('style_options'));
$this->unpackOptions($this->options, $options);
if ($this->usesRowPlugin() && $display->getOption('row_plugin')) {
if ($this->usesRowPlugin() && $display->getOption('row')) {
$this->row_plugin = $display->getPlugin('row');
}

View File

@ -609,7 +609,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
protected function alter_display_options(&$display_options, $form, $form_state) {
foreach ($display_options as $display_type => $options) {
// Allow style plugins to hook in and provide some settings.
$style_plugin = views_get_plugin('style', $options['style_plugin']);
$style_plugin = views_get_plugin('style', $options['style']['type']);
$style_plugin->wizard_submit($form, $form_state, $this, $display_options, $display_type);
}
}
@ -669,8 +669,8 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$display_options['query']['type'] = 'views_query';
$display_options['exposed_form']['type'] = 'basic';
$display_options['pager']['type'] = 'full';
$display_options['style_plugin'] = 'default';
$display_options['row_plugin'] = 'fields';
$display_options['style']['type'] = 'default';
$display_options['row']['type'] = 'fields';
// Add a least one field so the view validates and the user has a preview.
// The base field can provide a default in its base settings; otherwise,
@ -856,7 +856,6 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
return $sorts;
}
/**
* Retrieves the page display options.
*
@ -873,11 +872,11 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$page = $form_state['values']['page'];
$display_options['title'] = $page['title'];
$display_options['path'] = $page['path'];
$display_options['style_plugin'] = $page['style']['style_plugin'];
$display_options['style'] = array('type' => $page['style']['style_plugin']);
// Not every style plugin supports row style plugins.
// Make sure that the selected row plugin is a valid one.
$options = $this->row_style_options();
$display_options['row_plugin'] = (isset($page['style']['row_plugin']) && isset($options[$page['style']['row_plugin']])) ? $page['style']['row_plugin'] : 'fields';
$display_options['row'] = array('type' => (isset($page['style']['row_plugin']) && isset($options[$page['style']['row_plugin']])) ? $page['style']['row_plugin'] : 'fields');
// If the specific 0 items per page, use no pager.
if (empty($page['items_per_page'])) {
@ -918,8 +917,8 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$display_options = array();
$block = $form_state['values']['block'];
$display_options['title'] = $block['title'];
$display_options['style_plugin'] = $block['style']['style_plugin'];
$display_options['row_plugin'] = isset($block['style']['row_plugin']) ? $block['style']['row_plugin'] : 'fields';
$display_options['style'] = array('type' => $block['style']['style_plugin']);
$display_options['row'] = array('type' => isset($block['style']['row_plugin']) ? $block['style']['row_plugin'] : 'fields');
$display_options['pager']['type'] = $block['pager'] ? 'full' : (empty($block['items_per_page']) ? 'none' : 'some');
$display_options['pager']['options']['items_per_page'] = $block['items_per_page'];
return $display_options;
@ -939,8 +938,8 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
protected function page_feed_display_options($form, $form_state) {
$display_options = array();
$display_options['pager']['type'] = 'some';
$display_options['style_plugin'] = 'rss';
$display_options['row_plugin'] = $form_state['values']['page']['feed_properties']['row_plugin'];
$display_options['style'] = array('type' => 'rss');
$display_options['row'] = array('type' => $form_state['values']['page']['feed_properties']['row_plugin']);
$display_options['path'] = $form_state['values']['page']['feed_properties']['path'];
$display_options['title'] = $form_state['values']['page']['title'];
$display_options['displays'] = array(
@ -971,8 +970,6 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
*/
protected function setDefaultOptions($options, DisplayPluginBase $display, DisplayPluginBase $default_display) {
foreach ($options as $option => $value) {
// @todo: Wouldn't it be possible to call set_override and set_option
// instead.
// If the default display supports this option, set the value there.
// Otherwise, set it on the provided display.
$default_value = $default_display->getOption($option);

View File

@ -72,7 +72,8 @@ class WizardTest extends WizardTestBase {
$view = views_get_view($view['name']);
$view->initDisplay();
$view->initHandlers();
$this->assertEqual($view->display_handler->getOption('row_plugin'), 'comment');
$row = $view->display_handler->getOption('row');
$this->assertEqual($row['type'], 'comment');
// Check for the default filters.
$this->assertEqual($view->filter['status']->table, 'comment');

View File

@ -69,7 +69,7 @@ class AccessTest extends PluginTestBase {
function testAccessRole() {
$view = $this->createViewFromConfig('test_access_role');
$view->displayHandlers['default']->options['access']['role'] = array(
$view->displayHandlers['default']->options['access']['options']['role'] = array(
$this->normal_role => $this->normal_role,
);

View File

@ -88,8 +88,10 @@ class CacheTest extends PluginTestBase {
$view = $this->getView();
$view->display_handler->overrideOption('cache', array(
'type' => 'time',
'results_lifespan' => '3600',
'output_lifespan' => '3600',
'options' => array(
'results_lifespan' => '3600',
'output_lifespan' => '3600'
)
));
$this->executeView($view);
@ -108,8 +110,10 @@ class CacheTest extends PluginTestBase {
$view = $this->getView();
$view->display_handler->overrideOption('cache', array(
'type' => 'time',
'results_lifespan' => '3600',
'output_lifespan' => '3600',
'options' => array(
'results_lifespan' => '3600',
'output_lifespan' => '3600'
)
));
$this->executeView($view);
@ -127,6 +131,7 @@ class CacheTest extends PluginTestBase {
$view = $this->getView();
$view->display_handler->overrideOption('cache', array(
'type' => 'none',
'options' => array()
));
$this->executeView($view);
@ -146,6 +151,7 @@ class CacheTest extends PluginTestBase {
$view = $this->getView();
$view->display_handler->overrideOption('cache', array(
'type' => 'none',
'options' => array()
));
$this->executeView($view);
@ -164,7 +170,9 @@ class CacheTest extends PluginTestBase {
$view->storage->name = 'test_cache_header_storage';
$view->display_handler->overrideOption('cache', array(
'type' => 'time',
'output_lifespan' => '3600',
'options' => array(
'output_lifespan' => '3600'
)
));
$view->preview();

View File

@ -36,7 +36,7 @@ class StyleMappingTest extends StyleTestBase {
$this->assertTrue(strpos($output, 'job') === FALSE, 'The job field is added to the view but not in the mapping.');
$view = $this->getView();
$view->displayHandlers['default']->options['style_options']['mapping']['name_field'] = 'job';
$view->displayHandlers['default']->options['style']['options']['mapping']['name_field'] = 'job';
$output = $this->mappedOutputHelper($view);
$this->assertTrue(strpos($output, 'job') !== FALSE, 'The job field is added to the view and is in the mapping.');
}

View File

@ -29,7 +29,9 @@ class StyleTest extends StyleTestBase {
*/
public function testStyle() {
$view = $this->getView();
$view->display_handler->setOption('style_plugin', 'test_style');
$style = $view->display_handler->getOption('style');
$style['type'] = 'test_style';
$view->display_handler->setOption('style', $style);
$view->initDisplay();
$view->initStyle();
$this->assertTrue($view->style_plugin instanceof \Drupal\views_test_data\Plugin\views\style\StyleTest, 'Make sure the right style plugin class is loaded.');
@ -43,8 +45,12 @@ class StyleTest extends StyleTestBase {
// This run use the test row plugin and render with it.
$view = $this->getView();
$view->display_handler->setOption('style_plugin', 'test_style');
$view->display_handler->setOption('row_plugin', 'test_row');
$style = $view->display_handler->getOption('style');
$style['type'] = 'test_style';
$view->display_handler->setOption('style', $style);
$row = $view->display_handler->getOption('row');
$row['type'] = 'test_row';
$view->display_handler->setOption('row', $row);
$view->initDisplay();
$view->initStyle();
$view->style_plugin->setUsesRowPlugin(TRUE);

View File

@ -787,8 +787,9 @@ class ViewExecutable {
}
if (!isset($this->plugin_name)) {
$this->plugin_name = $this->display_handler->getOption('style_plugin');
$this->style_options = $this->display_handler->getOption('style_options');
$style = $this->display_handler->getOption('style');
$this->plugin_name = $style['type'];
$this->style_options = $style['options'];
}
$this->style_plugin = views_get_plugin('style', $this->plugin_name);

View File

@ -127,8 +127,8 @@ class Comment extends WizardPluginBase {
protected function display_options_row(&$display_options, $row_plugin, $row_options) {
switch ($row_plugin) {
case 'comment':
$display_options['row_plugin'] = 'comment';
$display_options['row_options']['links'] = !empty($row_options['links']);
$display_options['row']['type'] = 'comment';
$display_options['row']['options']['links'] = !empty($row_options['links']);
break;
}
}

View File

@ -219,23 +219,23 @@ class Node extends WizardPluginBase {
protected function display_options_row(&$display_options, $row_plugin, $row_options) {
switch ($row_plugin) {
case 'full_posts':
$display_options['row_plugin'] = 'node';
$display_options['row_options']['build_mode'] = 'full';
$display_options['row_options']['links'] = !empty($row_options['links']);
$display_options['row_options']['comments'] = !empty($row_options['comments']);
$display_options['row']['type'] = 'node';
$display_options['row']['options']['build_mode'] = 'full';
$display_options['row']['options']['links'] = !empty($row_options['links']);
$display_options['row']['options']['comments'] = !empty($row_options['comments']);
break;
case 'teasers':
$display_options['row_plugin'] = 'node';
$display_options['row_options']['build_mode'] = 'teaser';
$display_options['row_options']['links'] = !empty($row_options['links']);
$display_options['row_options']['comments'] = !empty($row_options['comments']);
$display_options['row']['type'] = 'node';
$display_options['row']['options']['build_mode'] = 'teaser';
$display_options['row']['options']['links'] = !empty($row_options['links']);
$display_options['row']['options']['comments'] = !empty($row_options['comments']);
break;
case 'titles_linked':
$display_options['row_plugin'] = 'fields';
$display_options['row']['type'] = 'fields';
$display_options['field']['title']['link_to_node'] = 1;
break;
case 'titles':
$display_options['row_plugin'] = 'fields';
$display_options['row']['type'] = 'fields';
$display_options['field']['title']['link_to_node'] = 0;
break;
}

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -7,16 +7,19 @@ display:
default:
display_options:
access:
perm: 'views_test_data test permission'
type: perm
options:
perm: 'views_test_data test permission'
cache:
type: none
exposed_form:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -44,8 +44,10 @@ display:
options:
query_comment: '0'
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -43,8 +43,10 @@ display:
items_per_page: '10'
offset: '0'
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -35,8 +35,10 @@ display:
options:
query_comment: '0'
type: views_query
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -131,7 +131,6 @@ display:
id: uid
table: comment
relationship: cid
row_plugin: fields
sorts:
last_comment_name:
field: last_comment_name
@ -141,7 +140,10 @@ display:
field: last_comment_timestamp
id: last_comment_timestamp
table: node_comment_statistics
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -50,9 +50,11 @@ display:
relationship: nid
required: '0'
table: node
row_plugin: fields
sorts: { }
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default
@ -60,4 +62,3 @@ display:
human_name: test_field_get_entity
name: test_field_get_entity
tag: default

View File

@ -16,8 +16,6 @@ display:
type: full
query:
type: views_query
row_plugin: fields
style_plugin: default
fields:
name:
id: name
@ -35,6 +33,10 @@ display:
id: job
table: views_test_data
field: job
style:
type: default
row:
type: fields
display_plugin: default
display_title: Defaults
id: default

View File

@ -28,8 +28,10 @@ display:
options:
query_comment: '0'
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -34,8 +34,10 @@ display:
type: full
query:
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -54,15 +54,17 @@ display:
type: full
query:
type: views_query
row_plugin: node
sorts:
created:
field: created
id: created
order: DESC
table: node
style_plugin: default
title: test_filter_groups
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -32,19 +32,15 @@ display:
table: node
value:
- '1'
sorts:
nid:
id: nid
table: node
field: nid
order: asc
sorts: { }
pager:
type: full
query:
type: views_query
row_plugin: fields
sorts: { }
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -35,8 +35,10 @@ display:
type: full
query:
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -47,8 +47,10 @@ display:
group_by: '1'
pager:
type: some
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -40,8 +40,10 @@ display:
group_by: '1'
pager:
type: some
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -18,8 +18,10 @@ display:
items_per_page: '5'
offset: '0'
type: full
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: none
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -17,8 +17,10 @@ display:
items_per_page: '5'
offset: '0'
type: some
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -43,8 +43,10 @@ display:
items_per_page: '10'
offset: '0'
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: none
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -54,8 +54,10 @@ display:
table: node
vocabularies:
tags: '0'
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
display_plugin: default
display_title: Master
id: default

View File

@ -0,0 +1,102 @@
api_version: '3.0'
base_table: node
core: '8'
description: ''
disabled: '0'
display:
default:
display_options:
access:
type: perm
cache:
type: none
exposed_form:
type: basic
fields:
name:
alter:
absolute: '0'
alter_text: '0'
ellipsis: '1'
external: '0'
html: '0'
make_link: '0'
nl2br: '0'
replace_spaces: '0'
strip_tags: '0'
trim: '0'
trim_whitespace: '0'
word_boundary: '1'
element_default_classes: '1'
element_label_colon: '1'
empty_zero: '0'
field: name
hide_alter_empty: '0'
hide_empty: '0'
id: name
link_to_user: '1'
overwrite_anonymous: '0'
table: users
title:
alter:
absolute: '0'
alter_text: '0'
ellipsis: '0'
html: '0'
make_link: '0'
strip_tags: '0'
trim: '0'
word_boundary: '0'
empty_zero: '0'
field: title
hide_empty: '0'
id: title
label: ''
link_to_node: '1'
table: node
uid:
alter:
absolute: '0'
alter_text: '0'
ellipsis: '1'
external: '0'
html: '0'
make_link: '0'
nl2br: '0'
replace_spaces: '0'
strip_tags: '0'
trim: '0'
trim_whitespace: '0'
word_boundary: '1'
element_default_classes: '1'
element_label_colon: '1'
empty_zero: '0'
field: uid
hide_alter_empty: '0'
hide_empty: '0'
id: uid
link_to_user: '1'
table: users
pager:
options:
items_per_page: '10'
type: full
query:
options:
query_comment: '0'
type: views_query
title: test_user_relationship
style:
type: default
row:
type: fields
options:
default_field_elements: '1'
hide_empty: '0'
display_plugin: default
display_title: Master
id: default
position: '0'
human_name: test_user_relationship
name: test_user_relationship
tag: default

View File

@ -24,8 +24,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -24,8 +24,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -24,8 +24,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -16,8 +16,10 @@ display:
type: full
query:
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Defaults
id: default

View File

@ -17,17 +17,14 @@ display:
type: none
exposed_form:
type: basic
fields:
nid:
field: nid
id: nid
table: node
pager:
type: full
query:
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default
@ -35,4 +32,3 @@ display:
human_name: test_view_fieldapi
name: test_view_fieldapi
tag: default

View File

@ -34,8 +34,10 @@ display:
items_per_page: '0'
offset: '0'
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -37,8 +37,10 @@ display:
options:
query_comment: '0'
type: views_query
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -40,8 +40,10 @@ display:
items_per_page: '10'
offset: '0'
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -24,17 +24,18 @@ display:
type: none
cache:
type: none
style_plugin: table
style_options:
info:
id:
sortable: 1
default_sort_order: asc
name:
sortable: 1
default_sort_order: desc
created:
sortable: 0
style:
type: table
options:
info:
id:
sortable: 1
default_sort_order: asc
name:
sortable: 1
default_sort_order: desc
created:
sortable: 0
display_plugin: default
display_title: Master
id: default

View File

@ -25,16 +25,18 @@ display:
table: node
pager:
type: full
row_options:
comments: '0'
links: '1'
row_plugin: node
sorts:
created:
field: created
id: created
table: node
style_plugin: default
style:
type: default
row:
type: node
options:
comments: '0'
links: '1'
display_plugin: default
display_title: Master
id: default

View File

@ -15,7 +15,8 @@ display:
id: id
table: views_test_data
field: id
style_plugin: html_list
style:
type: html_list
display_plugin: default
display_title: Master
id: default

View File

@ -15,11 +15,12 @@ display:
id: name
table: views_test_data
field: name
style_plugin: html_list
style:
type: html_list
display_plugin: default
display_title: Master
id: default
position: '0'
human_name: ""
human_name: ''
name: test_field_output
tag: ''

View File

@ -27,9 +27,11 @@ display:
table: views_test_data
query:
type: views_query
row_plugin: fields
style_plugin: default
use_more_always: '0'
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -26,8 +26,10 @@ display:
table: node
pager:
type: full
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default

View File

@ -31,11 +31,13 @@ display:
options:
query_comment: '0'
type: views_query
row_options:
comments: '0'
links: '1'
row_plugin: node
style_plugin: default
style:
type: default
row:
type: node
options:
comments: '0'
links: '1'
display_plugin: default
display_title: Master
id: default

View File

@ -39,15 +39,16 @@ display:
order: ASC
relationship: none
table: views_test_data
style_options:
mapping:
name_field: name
numeric_field:
age: age
title_field: name
toggle_numeric_field: '1'
toggle_title_field: '1'
style_plugin: mapping_test
style:
type: mapping_test
options:
mapping:
name_field: name
numeric_field:
age: age
title_field: name
toggle_numeric_field: '1'
toggle_title_field: '1'
display_plugin: default
display_title: Master
id: default

View File

@ -14,8 +14,10 @@ display:
type: basic
pager:
type: none
row_plugin: fields
style_plugin: default
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default