From 5e4b5ff6f8a32b68296b94e6b521677e9bd8f4cf Mon Sep 17 00:00:00 2001 From: damiankloip <damiankloip@1037976.no-reply.drupal.org> Date: Sat, 18 Aug 2012 22:53:41 +0200 Subject: [PATCH] Issue #1732672 by damiankloip, dawehner: Added description option to exposed filters. --- css/views-admin.seven.css | 6 ++++-- css/views-admin.theme.css | 3 ++- includes/admin.inc | 2 ++ .../Plugin/views/filter/FilterPluginBase.php | 19 +++++++++++++++++++ theme/theme.inc | 9 ++++++++- theme/views-exposed-form.tpl.php | 5 +++++ 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/css/views-admin.seven.css b/css/views-admin.seven.css index 6ebdbf1fd3e6..d58bb1be5f4f 100644 --- a/css/views-admin.seven.css +++ b/css/views-admin.seven.css @@ -127,7 +127,8 @@ fieldset.fieldset-no-legend { .dependent-options, .dependent-options.form-item, .form-item-options-expose-required, -.form-item-options-expose-label { +.form-item-options-expose-label, +.form-item-options-expose-description { margin-left: 1.5em; } @@ -139,7 +140,8 @@ fieldset.fieldset-no-legend { .views-admin-dependent .dependent-options .form-type-select, .views-admin-dependent .dependent-options .form-type-textfield, .form-item-options-expose-required, -.form-item-options-expose-label { +.form-item-options-expose-label, +.form-item-options-expose-description { margin-bottom: 6px; margin-top: 6px; } diff --git a/css/views-admin.theme.css b/css/views-admin.theme.css index ee52fd2d9426..8611783f7e5d 100644 --- a/css/views-admin.theme.css +++ b/css/views-admin.theme.css @@ -933,7 +933,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @group Expose filter form items */ .form-item-options-expose-required, -.form-item-options-expose-label { +.form-item-options-expose-label, +.form-item-options-expose-description { margin-bottom: 6px; margin-left: 18px; margin-top: 6px; diff --git a/includes/admin.inc b/includes/admin.inc index e9b9e061c381..6dff0ba88b41 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -3508,6 +3508,7 @@ function theme_views_ui_expose_filter_form($variables) { $output .= drupal_render($form['required']); } $output .= drupal_render($form['label']); + $output .= drupal_render($form['description']); $output .= drupal_render($form['operator']); $output .= drupal_render($form['value']); @@ -3558,6 +3559,7 @@ function theme_views_ui_build_group_filter_form($variables) { $output .= '<div class="views-right-60">'; $output .= drupal_render($form['widget']); $output .= drupal_render($form['label']); + $output .= drupal_render($form['description']); $output .= '</div>'; $header = array( diff --git a/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php b/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php index ca1759e18b61..ab230edfe417 100644 --- a/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php +++ b/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php @@ -120,6 +120,7 @@ function option_definition() { 'contains' => array( 'operator_id' => array('default' => FALSE), 'label' => array('default' => '', 'translatable' => TRUE), + 'description' => array('default' => '', 'translatable' => TRUE), 'use_operator' => array('default' => FALSE, 'bool' => TRUE), 'operator' => array('default' => ''), 'identifier' => array('default' => ''), @@ -144,6 +145,7 @@ function option_definition() { $options['group_info'] = array( 'contains' => array( 'label' => array('default' => '', 'translatable' => TRUE), + 'description' => array('default' => '', 'translatable' => TRUE), 'identifier' => array('default' => ''), 'optional' => array('default' => TRUE, 'bool' => TRUE), 'widget' => array('default' => 'select'), @@ -494,6 +496,13 @@ function expose_form(&$form, &$form_state) { '#size' => 40, ); + $form['expose']['description'] = array( + '#type' => 'textfield', + '#default_value' => $this->options['expose']['description'], + '#title' => t('Description'), + '#size' => 60, + ); + if (!empty($form['operator']['#type'])) { // Increase the width of the left (operator) column. $form['operator']['#prefix'] = '<div class="views-group-box views-left-40">'; @@ -668,6 +677,7 @@ function expose_options() { 'operator' => $this->options['id'] . '_op', 'identifier' => $this->options['id'], 'label' => $this->definition['title'], + 'description' => NULL, 'remember' => FALSE, 'multiple' => FALSE, 'required' => FALSE, @@ -680,6 +690,7 @@ function expose_options() { function build_group_options() { $this->options['group_info'] = array( 'label' => $this->definition['title'], + 'description' => NULL, 'identifier' => $this->options['id'], 'optional' => TRUE, 'widget' => 'select', @@ -824,6 +835,12 @@ function build_group_form(&$form, &$form_state) { '#title' => t('Label'), '#size' => 40, ); + $form['group_info']['description'] = array( + '#type' => 'textfield', + '#default_value' => $this->options['group_info']['description'], + '#title' => t('Description'), + '#size' => 60, + ); $form['group_info']['optional'] = array( '#type' => 'checkbox', '#title' => t('Optional'), @@ -1116,6 +1133,7 @@ function exposed_info() { return array( 'value' => $this->options['group_info']['identifier'], 'label' => $this->options['group_info']['label'], + 'description' => $this->options['group_info']['description'], ); } @@ -1123,6 +1141,7 @@ function exposed_info() { 'operator' => $this->options['expose']['operator_id'], 'value' => $this->options['expose']['identifier'], 'label' => $this->options['expose']['label'], + 'description' => $this->options['expose']['description'], ); } diff --git a/theme/theme.inc b/theme/theme.inc index e781683fb0ff..613f1b9bbacd 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -934,16 +934,23 @@ function template_preprocess_views_exposed_form(&$vars) { } $widget = new stdClass; // set up defaults so that there's always something there. - $widget->label = $widget->operator = $widget->widget = NULL; + $widget->label = $widget->operator = $widget->widget = $widget->description = NULL; $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : ''; + if (!empty($info['label'])) { $widget->label = check_plain($info['label']); } if (!empty($info['operator'])) { $widget->operator = drupal_render($form[$info['operator']]); } + $widget->widget = drupal_render($form[$info['value']]); + + if (!empty($info['description'])) { + $widget->description = check_plain($info['description']); + } + $vars['widgets'][$id] = $widget; } diff --git a/theme/views-exposed-form.tpl.php b/theme/views-exposed-form.tpl.php index c0861f2fe463..bdd570c228a8 100644 --- a/theme/views-exposed-form.tpl.php +++ b/theme/views-exposed-form.tpl.php @@ -43,6 +43,11 @@ <div class="views-widget"> <?php print $widget->widget; ?> </div> + <?php if (!empty($widget->description)): ?> + <div class="description"> + <?php print $widget->description; ?> + </div> + <?php endif; ?> </div> <?php endforeach; ?> <?php if (!empty($sort_by)): ?> -- GitLab