Commit afb01e60 authored by xjm's avatar xjm Committed by tim.plunkett

Issue #1754536 by dawehner, xjm: Fixed the comment wizard doesn't use the...

Issue #1754536 by dawehner, xjm: Fixed the comment wizard doesn't use the right row plugin by default.
parent 7e972b3e
......@@ -425,16 +425,23 @@ function build_form($form, &$form_state) {
}
/**
* Builds the part of the form that builds the display format options.
* Adds the style options to the wizard form.
*
* @param array $form
* The full wizard form array.
* @param array $form_state
* The current state of the wizard form.
* @param string $type
* The display ID (e.g. 'page' or 'block').
*/
protected function build_form_style(&$form, &$form_state, $type) {
protected function build_form_style(array &$form, array &$form_state, $type) {
$style_form =& $form['displays'][$type]['options']['style'];
$style = $style_form['style_plugin']['#default_value'];
// @fixme
$style_plugin = views_get_plugin('style', $style);
if (isset($style_plugin) && $style_plugin->usesRowPlugin()) {
$options = $this->row_style_options($type);
$options = $this->row_style_options();
$style_form['row_plugin'] = array(
'#type' => 'select',
'#title' => t('of'),
......@@ -461,10 +468,12 @@ protected function build_form_style(&$form, &$form_state, $type) {
}
/**
* Adds possible row style options to the form.
* Retrieves row style plugin names.
*
* @return array
* Returns the plugin names available for the base table of the wizard.
*/
protected function row_style_options($type) {
$data = views_fetch_data($this->base_table);
protected function row_style_options() {
// Get all available row plugins by default.
$options = views_fetch_plugin_names('row', 'normal', array($this->base_table));
return $options;
......
......@@ -15,7 +15,7 @@
* Plugin which performs a comment_view on the resulting object.
*
* @Plugin(
* id = "comment_view",
* id = "comment",
* module = "comment",
* title = @Translation("Comment"),
* help = @Translation("Display the comment with standard comment view."),
......
......@@ -64,14 +64,17 @@ class Comment extends WizardPluginBase {
)
);
protected function row_style_options($type) {
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::row_style_options().
*/
protected function row_style_options() {
$options = array();
$options['comment'] = t('comments');
$options['fields'] = t('fields');
return $options;
}
protected function build_form_style(&$form, &$form_state, $type) {
protected function build_form_style(array &$form, array &$form_state, $type) {
parent::build_form_style($form, $form_state, $type);
$style_form =& $form['displays'][$type]['options']['style'];
// Some style plugins don't support row plugins so stop here if that's the
......
......@@ -71,7 +71,10 @@ public function getAvailableSorts() {
);
}
protected function row_style_options($type) {
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::row_style_options().
*/
protected function row_style_options() {
$options = array();
$options['teasers'] = t('teasers');
$options['full_posts'] = t('full posts');
......@@ -81,7 +84,17 @@ protected function row_style_options($type) {
return $options;
}
protected function build_form_style(&$form, &$form_state, $type) {
/**
* Adds the style options to the wizard form.
*
* @param array $form
* The full wizard form array.
* @param array $form_state
* The current state of the wizard form.
* @param string $type
* The display ID (e.g. 'page' or 'block').
*/
protected function build_form_style(array &$form, array &$form_state, $type) {
parent::build_form_style($form, $form_state, $type);
$style_form =& $form['displays'][$type]['options']['style'];
// Some style plugins don't support row plugins so stop here if that's the
......
......@@ -71,10 +71,12 @@ class NodeRevision extends WizardPluginBase {
);
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::row_style_options().
*
* Node revisions do not support full posts or teasers, so remove them.
*/
protected function row_style_options($type) {
$options = parent::row_style_options($type);
protected function row_style_options() {
$options = parent::row_style_options();
unset($options['teasers']);
unset($options['full_posts']);
return $options;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment