diff --git a/better_exposed_filters_exposed_form_plugin.inc b/better_exposed_filters_exposed_form_plugin.inc index 33de3ab..b1a9e22 100644 --- a/better_exposed_filters_exposed_form_plugin.inc +++ b/better_exposed_filters_exposed_form_plugin.inc @@ -16,6 +16,9 @@ class better_exposed_filters_exposed_form_plugin extends views_plugin_exposed_fo // Add Better Exposed Filters options to those saved by Views. $options['bef'] = array('default' => array()); + // Options to exclude token substitution details. + $options['token_details'] = array('default' => FALSE); + return $options; } @@ -167,6 +170,13 @@ Title Desc|Z -> A Leave the replacement value blank to remove an option al ); } + $form['token_details'] = array( + '#type' => 'checkbox', + '#default_value' => isset($this->options['token_details']) ? $this->options['token_details'] : FALSE, + '#title' => t('Show token substitution information for each field'), + '#description' => t('Make an exhaustive list of token substitutions available for each field. Enabling this can cause excessive load times on the BEF Settings form and Input variables (max_input_vars) PHP warnings when submitting the form.') + ); + // Only add the description text once -- it was getting a little long to be // added to each filter. $bef_filter_intro = FALSE; @@ -451,38 +461,42 @@ Title Desc|Z -> A Leave the replacement value blank to remove an option al '#description' => t('Adds descriptive text to the exposed filter. This is usually rendered in smaller print under the label or the options.'), ); - // Add token support to the description field. - $bef_options[$label]['more_options']['tokens'] = array( - '#title' => t('Replacement patterns'), - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - - if (!module_exists('token')) { - $bef_options[$label]['more_options']['tokens']['no_tokens'] = array( - '#markup' => '

' - . t('Enable the !token module to use replacement values.', array('!token' => l(t('Token'), 'http://drupal.org/project/token'))) - . '

', + // Only add token info if explicitly requested. + // @see https://drupal.org/node/1891612 + if (!empty($this->options['token_details'])) { + // Add token support to the description field. + $bef_options[$label]['more_options']['tokens'] = array( + '#title' => t('Replacement patterns'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, ); - } - // Collect a list of token types that make sense for this filter. - $available = array('global_types'); - if (!empty($filter->options['vid'])) { - $available[] = 'vocabulary'; - } - /* @TODO: Other token types? */ + if (!module_exists('token')) { + $bef_options[$label]['more_options']['tokens']['no_tokens'] = array( + '#markup' => '

' + . t('Enable the !token module to use replacement values.', array('!token' => l(t('Token'), 'http://drupal.org/project/token'))) + . '

', + ); + } - $bef_options[$label]['more_options']['tokens']['list'] = array( - '#theme' => 'token_tree', - '#token_types' => $available, - ); - $bef_options[$label]['more_options']['tokens']['available'] = array( - // Save us from parsing available tokens again. - '#type' => 'value', - '#value' => $available, - ); + // Collect a list of token types that make sense for this filter. + $available = array('global_types'); + if (!empty($filter->options['vid'])) { + $available[] = 'vocabulary'; + } + /* @TODO: Other token types? */ + + $bef_options[$label]['more_options']['tokens']['list'] = array( + '#theme' => 'token_tree', + '#token_types' => $available, + ); + $bef_options[$label]['more_options']['tokens']['available'] = array( + // Save us from parsing available tokens again. + '#type' => 'value', + '#value' => $available, + ); + } // token_details // Allow rewriting of filter options for any filter. $bef_options[$label]['more_options']['rewrite'] = array(