Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
230cdaf1
Commit
230cdaf1
authored
Sep 23, 2012
by
Daniel Wehner
Committed by
Tim Plunkett
Oct 21, 2012
Browse files
Issue
#1781934
by dawehner: Unify plugin_options() on the display.
parent
78e75789
Changes
65
Hide whitespace changes
Inline
Side-by-side
config/views.view.archive.yml
View file @
230cdaf1
...
...
@@ -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
...
...
config/views.view.backlinks.yml
View file @
230cdaf1
...
...
@@ -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
config/views.view.comments_recent.yml
View file @
230cdaf1
...
...
@@ -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
...
...
config/views.view.frontpage.yml
View file @
230cdaf1
...
...
@@ -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
...
...
config/views.view.glossary.yml
View file @
230cdaf1
...
...
@@ -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
...
...
config/views.view.taxonomy_term.yml
View file @
230cdaf1
...
...
@@ -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
config/views.view.tracker.yml
View file @
230cdaf1
...
...
@@ -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
:
'
'
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
:
'
'
name
:
sortable
:
1
separator
:
'
'
comment_count
:
sortable
:
1
separator
:
'
<br
/>'
last_comment_timestamp
:
sortable
:
1
separator
:
'
'
timestamp
:
separator
:
'
'
new_comments
:
separator
:
'
'
override
:
1
order
:
desc
page
:
id
:
page
display_title
:
Page
...
...
includes/admin.inc
View file @
230cdaf1
...
...
@@ -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.
$
nam
e
=
$view
->
displayHandlers
[
$display
[
'id'
]]
->
getOption
(
'style
_plugin
'
);
$style_plugin
=
$view
->
displayHandlers
[
$display
[
'id'
]]
->
getPlugin
(
'style'
,
$
name
);
$
styl
e
=
$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
);
}
...
...
lib/Drupal/views/Plugin/views/access/AccessPluginBase.php
View file @
230cdaf1
...
...
@@ -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
);
}
/**
...
...
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
View file @
230cdaf1
...
...
@@ -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
);
}
/**
...
...
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
230cdaf1
...
...
@@ -352,10 +352,8 @@ public function attachTo($display_id) { }
*/
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 @@ public function defaultableSections($section = NULL) {
'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 @@ protected function defineOptions() {
'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 @@ protected function defineOptions() {
'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 @@ protected function defineOptions() {
'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 @@ protected function defineOptions() {
'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_options'
=>
array
(
'default'
=>
array
(),
),
'row_plugin'
=>
array
(
'default'
=>
'fields'
,
'style'
=>
array
(
'contains'
=>
array
(
'type'
=>
array
(
'default'
=>
'default'
),
'options'
=>
array
(
'default'
=>
array
()),
),
),
'row_options'
=>
array
(
'default'
=>
array
(),
'row'
=>
array
(
'contains'
=>
array
(
'type'
=>
array
(
'default'
=>
'fields'
),
'options'
=>
array
(
'default'
=>
array
()),
),
),
'exposed_block'
=>
array
(
...
...
@@ -738,8 +722,8 @@ public function getOption($option) {
* @return bool
*/
public
function
usesFields
()
{
$
nam
e
=
$this
->
getOption
(
'style
_plugin
'
);
$plugin
=
$this
->
getPlugin
(
'style'
,
$
name
);
$
styl
e
=
$this
->
getOption
(
'style'
);
$plugin
=
$this
->
getPlugin
(
'style'
,
$
style
[
'type'
]
);
if
(
$plugin
)
{
return
$plugin
->
usesFields
();
}
...
...
@@ -759,15 +743,6 @@ public function getPlugin($type = 'style', $name = NULL) {
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 @@ public function getPlugin($type = 'style', $name = NULL) {
$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 @@ public function optionsSummary(&$categories, &$options) {
'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 @@ public function optionsSummary(&$categories, &$options) {
// 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 @@ public function optionsSummary(&$categories, &$options) {
);
// 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 @@ public function buildOptionsForm(&$form, &$form_state) {
break
;
case
'access_options'
:
$access
=
$this
->
getOption
(
'access'
);
$plugin
=
$this
->
getPlugin
(
'access'
);
$form
[
'#title'
]
.
=
t
(
'Access options'
);
if
(
$plugin
)
{