Commit 230cdaf1 authored by dawehner's avatar dawehner Committed by tim.plunkett

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

parent 78e75789
...@@ -27,8 +27,6 @@ display: ...@@ -27,8 +27,6 @@ display:
type: basic type: basic
pager: pager:
type: full type: full
style_plugin: default
row_plugin: node
sorts: sorts:
created: created:
id: created id: created
...@@ -62,6 +60,10 @@ display: ...@@ -62,6 +60,10 @@ display:
group: 0 group: 0
expose: expose:
operator: false operator: false
style:
type: default
row:
type: node
page: page:
id: page id: page
display_title: Page display_title: Page
......
...@@ -28,10 +28,6 @@ display: ...@@ -28,10 +28,6 @@ display:
type: full type: full
options: options:
items_per_page: 30 items_per_page: 30
style_plugin: html_list
style_options:
type: ol
row_plugin: fields
empty: empty:
text: text:
id: area id: area
...@@ -70,6 +66,12 @@ display: ...@@ -70,6 +66,12 @@ display:
group: 0 group: 0
expose: expose:
operator: false operator: false
style:
type: html_list
options:
type: ol
row:
type: fields
page: page:
id: page id: page
display_title: Page display_title: Page
...@@ -101,8 +103,6 @@ display: ...@@ -101,8 +103,6 @@ display:
row_options: false row_options: false
arguments: false arguments: false
use_more: true use_more: true
style_plugin: html_list
row_plugin: fields
arguments: arguments:
nid: nid:
id: nid id: nid
...@@ -117,3 +117,7 @@ display: ...@@ -117,3 +117,7 @@ display:
specify_validation: 1 specify_validation: 1
validate: validate:
type: node type: node
style:
type: html_list
row:
type: fields
...@@ -30,8 +30,6 @@ display: ...@@ -30,8 +30,6 @@ display:
type: some type: some
options: options:
items_per_page: 5 items_per_page: 5
style_plugin: html_list
row_plugin: fields
relationships: relationships:
nid: nid:
id: nid id: nid
...@@ -63,6 +61,10 @@ display: ...@@ -63,6 +61,10 @@ display:
field: status_extra field: status_extra
relationship: nid relationship: nid
group: 0 group: 0
style:
type: html_list
row:
type: fields
page: page:
id: page id: page
display_title: Page display_title: Page
...@@ -78,13 +80,6 @@ display: ...@@ -78,13 +80,6 @@ display:
row_plugin: false row_plugin: false
row_options: false row_options: false
fields: false fields: false
style_plugin: html_list
row_plugin: fields
row_options:
inline:
title: title
timestamp: timestamp
separator: ' '
fields: fields:
title: title:
id: title id: title
...@@ -111,6 +106,15 @@ display: ...@@ -111,6 +106,15 @@ display:
field: comment_body field: comment_body
label: '' label: ''
path: comments/recent path: comments/recent
style:
type: html_list
row:
type: fields
options:
inline:
title: title
timestamp: timestamp
separator: ' '
block: block:
id: block id: block
display_title: Block display_title: Block
......
...@@ -26,10 +26,12 @@ display: ...@@ -26,10 +26,12 @@ display:
type: basic type: basic
pager: pager:
type: full type: full
style_plugin: default style:
row_plugin: node type: default
row_options: row:
links: 1 type: node
options:
links: 1
sorts: sorts:
sticky: sticky:
id: sticky id: sticky
...@@ -82,8 +84,10 @@ display: ...@@ -82,8 +84,10 @@ display:
title: 'Front page feed' title: 'Front page feed'
pager: pager:
type: some type: some
style_plugin: rss style:
row_plugin: node_rss type: rss
row:
type: node_rss
path: rss.xml path: rss.xml
displays: displays:
default: default default: default
......
...@@ -29,25 +29,6 @@ display: ...@@ -29,25 +29,6 @@ display:
type: full type: full
options: options:
items_per_page: 36 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: fields:
title: title:
id: title id: title
...@@ -91,6 +72,26 @@ display: ...@@ -91,6 +72,26 @@ display:
id: uid id: uid
table: node table: node
field: uid 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: page:
id: page id: page
display_title: Page display_title: Page
......
...@@ -26,8 +26,6 @@ display: ...@@ -26,8 +26,6 @@ display:
type: basic type: basic
pager: pager:
type: full type: full
style_plugin: default
row_plugin: node
sorts: sorts:
sticky: sticky:
id: sticky id: sticky
...@@ -75,6 +73,10 @@ display: ...@@ -75,6 +73,10 @@ display:
group: 0 group: 0
expose: expose:
operator: false operator: false
style:
type: default
row:
type: node
page: page:
id: page id: page
display_title: Page display_title: Page
...@@ -98,9 +100,11 @@ display: ...@@ -98,9 +100,11 @@ display:
type: full type: full
options: options:
items_per_page: 15 items_per_page: 15
style_plugin: rss
row_plugin: node_rss
path: taxonomy/term/%/%/feed path: taxonomy/term/%/%/feed
displays: displays:
page: page page: page
default: 0 default: 0
style:
type: rss
row:
type: node_rss
...@@ -29,39 +29,6 @@ display: ...@@ -29,39 +29,6 @@ display:
type: full type: full
options: options:
items_per_page: '25' 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: relationships:
uid: uid:
id: uid id: uid
...@@ -134,6 +101,40 @@ display: ...@@ -134,6 +101,40 @@ display:
group: 0 group: 0
expose: expose:
operator: false 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: page:
id: page id: page
display_title: Page display_title: Page
......
...@@ -1963,15 +1963,17 @@ function views_ui_import_validate($form, &$form_state) { ...@@ -1963,15 +1963,17 @@ function views_ui_import_validate($form, &$form_state) {
continue; continue;
} }
$plugin = views_get_plugin('style', $display->getOption('style_plugin')); $style = $display->getOption('style');
$plugin = views_get_plugin('style', $style['type']);
if (!$plugin) { 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; $broken = TRUE;
} }
elseif ($plugin->usesRowPlugin()) { 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) { 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; $broken = TRUE;
} }
} }
...@@ -2122,8 +2124,8 @@ function views_ui_edit_form_get_bucket($type, ViewExecutable $view, $display) { ...@@ -2122,8 +2124,8 @@ function views_ui_edit_form_get_bucket($type, ViewExecutable $view, $display) {
break; break;
case 'field': case 'field':
// Fetch the style plugin info so we know whether to list fields or not. // Fetch the style plugin info so we know whether to list fields or not.
$name = $view->displayHandlers[$display['id']]->getOption('style_plugin'); $style = $view->displayHandlers[$display['id']]->getOption('style');
$style_plugin = $view->displayHandlers[$display['id']]->getPlugin('style', $name); $style_plugin = $view->displayHandlers[$display['id']]->getPlugin('style', $style['type']);
$uses_fields = $style_plugin && $style_plugin->usesFields(); $uses_fields = $style_plugin && $style_plugin->usesFields();
if (!$uses_fields) { if (!$uses_fields) {
$build['fields'][] = array( $build['fields'][] = array(
...@@ -3139,6 +3141,7 @@ function views_ui_edit_display_form($form, &$form_state) { ...@@ -3139,6 +3141,7 @@ function views_ui_edit_display_form($form, &$form_state) {
if (!$view->setDisplay($display_id)) { if (!$view->setDisplay($display_id)) {
views_ajax_error(t('Invalid display id @display', array('@display' => $display_id))); views_ajax_error(t('Invalid display id @display', array('@display' => $display_id)));
} }
$display = &$view->display[$display_id];
// Get form from the handler. // Get form from the handler.
$form['options'] = array( $form['options'] = array(
...@@ -4582,12 +4585,12 @@ function views_ui_config_style_form($form, &$form_state) { ...@@ -4582,12 +4585,12 @@ function views_ui_config_style_form($form, &$form_state) {
$form['#section'] = $display_id . '-' . $type . '-style-options'; $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) { if ($plugin) {
$form['style_options'] = array( $form['style_options'] = array(
'#tree' => TRUE, '#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); $plugin->buildOptionsForm($form['style_options'], $form_state);
} }
......
...@@ -34,16 +34,12 @@ abstract class AccessPluginBase extends PluginBase { ...@@ -34,16 +34,12 @@ abstract class AccessPluginBase extends PluginBase {
* @param $display * @param $display
* The display handler. * The display handler.
*/ */
public function init(ViewExecutable $view, &$display) { public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); $this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view; $this->view = &$view;
$this->displayHandler = &$display; $this->displayHandler = &$display;
if (is_object($display)) { $this->unpackOptions($this->options, $options);
$options = $display->getOption('access');
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
} }
/** /**
......
...@@ -63,16 +63,12 @@ abstract class CachePluginBase extends PluginBase { ...@@ -63,16 +63,12 @@ abstract class CachePluginBase extends PluginBase {
* @param $display * @param $display
* The display handler. * The display handler.
*/ */
public function init(ViewExecutable $view, &$display) { public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions()); $this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view; $this->view = &$view;
$this->displayHandler = &$display; $this->displayHandler = &$display;
if (is_object($display)) { $this->unpackOptions($this->options, $options);
$options = $display->getOption('cache');
// Overlay incoming options on top of defaults
$this->unpackOptions($this->options, $options);
}
} }
/** /**
......
...@@ -352,10 +352,8 @@ public function attachTo($display_id) { } ...@@ -352,10 +352,8 @@ public function attachTo($display_id) { }
*/ */
public function defaultableSections($section = NULL) { public function defaultableSections($section = NULL) {
$sections = array( $sections = array(
'access' => array('access', 'access_options'), 'access' => array('access'),
'access_options' => array('access', 'access_options'), 'cache' => array('cache'),
'cache' => array('cache', 'cache_options'),
'cache_options' => array('cache', 'cache_options'),
'title' => array('title'), 'title' => array('title'),
'css_class' => array('css_class'), 'css_class' => array('css_class'),
'use_ajax' => array('use_ajax'), 'use_ajax' => array('use_ajax'),
...@@ -369,10 +367,8 @@ public function defaultableSections($section = NULL) { ...@@ -369,10 +367,8 @@ public function defaultableSections($section = NULL) {
'link_display' => array('link_display', 'link_url'), 'link_display' => array('link_display', 'link_url'),
// Force these to cascade properly. // Force these to cascade properly.
'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), 'style' => array('style', 'row'),
'style_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), 'row' => array('style', 'row'),
'row_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'row_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'pager' => array('pager', 'pager_options'), 'pager' => array('pager', 'pager_options'),
'pager_options' => array('pager', 'pager_options'), 'pager_options' => array('pager', 'pager_options'),
...@@ -427,21 +423,17 @@ protected function defineOptions() { ...@@ -427,21 +423,17 @@ protected function defineOptions() {
'hide_attachment_summary' => TRUE, 'hide_attachment_summary' => TRUE,
'hide_admin_links' => FALSE, 'hide_admin_links' => FALSE,
'pager' => TRUE, 'pager' => TRUE,
'pager_options' => TRUE,
'use_more' => TRUE, 'use_more' => TRUE,
'use_more_always' => TRUE, 'use_more_always' => TRUE,
'use_more_text' => TRUE, 'use_more_text' => TRUE,
'exposed_form' => TRUE, 'exposed_form' => TRUE,
'exposed_form_options' => TRUE,
'link_display' => TRUE, 'link_display' => TRUE,
'link_url' => '', 'link_url' => '',
'group_by' => TRUE, 'group_by' => TRUE,
'style_plugin' => TRUE, 'style' => TRUE,
'style_options' => TRUE, 'row' => TRUE,
'row_plugin' => TRUE,
'row_options' => TRUE,
'header' => TRUE, 'header' => TRUE,
'footer' => TRUE, 'footer' => TRUE,
...@@ -523,12 +515,14 @@ protected function defineOptions() { ...@@ -523,12 +515,14 @@ protected function defineOptions() {
'access' => array( 'access' => array(
'contains' => array( 'contains' => array(
'type' => array('default' => 'none'), 'type' => array('default' => 'none'),
), 'options' => array('default' => array()),
),
), ),