class views_exposed_groups_plugin in Views exposed groups 7
Same name and namespace in other branches
- 7.2 views/views_exposed_groups_plugin.inc \views_exposed_groups_plugin
@file Provides a grouped form exposed form plugin for View 3.x.
Hierarchy
- class \views_object
- class \views_plugin
- class \views_plugin_exposed_form
- class \views_plugin
Expanded class hierarchy of views_exposed_groups_plugin
1 string reference to 'views_exposed_groups_plugin'
- views_exposed_groups_views_plugins in ./
views_exposed_groups.views.inc - Implements hook_views_plugins().
File
- views/
views_exposed_groups_plugin.inc, line 6 - Provides a grouped form exposed form plugin for View 3.x.
View source
class views_exposed_groups_plugin extends views_plugin_exposed_form_basic {
function summary_title() {
return t('Grouped form');
}
function option_definition() {
$options = parent::option_definition();
$options['views_exposed_groups'] = array(
'default' => array(),
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$groups = explode("\n", $this->options['views_exposed_groups']['groups']);
array_walk($groups, 'trim');
$form['views_exposed_groups']['format_groups'] = array(
'#type' => 'select',
'#title' => 'Render groups as',
'#options' => array(
'vertical_tabs' => 'Vertical tabs',
'fieldsets_collapsed' => 'Fieldset (collapsed)',
'fieldsets' => 'Fieldsets(not collapsed)',
),
'#default_value' => $this->options['views_exposed_groups']['format_groups'],
);
$form['views_exposed_groups']['groups'] = array(
'#type' => 'textarea',
'#title' => 'Groups',
'#description' => 'Enter a list of groups to include in this form',
'#default_value' => $this->options['views_exposed_groups']['groups'],
);
$weight_delta = count($this->display->handler
->get_handlers('filter'));
foreach ($this->display->handler
->get_handlers('filter') as $filter_name => $filter) {
if (!$filter->options['exposed']) {
continue;
}
$label = $filter->options['expose']['identifier'];
$field_label = $filter->options['expose']['label'] ? $filter->options['expose']['label'] : $label;
$form['views_exposed_groups']['group-' . $label]['group'] = array(
'#type' => 'select',
'#title' => 'Group for ' . $field_label,
'#filter_field' => $filter,
'#options' => $groups,
'#title_display' => 'invisible',
'#default_value' => $this->options['views_exposed_groups']['group-' . $label]['group'],
);
$form['views_exposed_groups']['group-' . $label]['filter_name'] = array(
'#type' => 'value',
'#value' => $filter_name,
);
$form['views_exposed_groups']['group-' . $label]['weight'] = array(
'#type' => 'weight',
'#title' => $field_label,
'#filter_field' => $filter,
'#delta' => $weight_delta,
'#title_display' => 'invisible',
'#default_value' => $this->options['views_exposed_groups']['group-' . $label]['weight'],
);
}
$form['views_exposed_groups']['#theme'][] = 'views_exposed_groups_reorder_filter_form';
}
/*
* Tweak the exposed filter form to show grouped form options.
*/
function exposed_form_alter(&$form, &$form_state) {
drupal_add_js(drupal_get_path('module', 'views_exposed_groups') . '/js/views_exposed_groups.js');
$form['#theme'] = array();
if ($this->options['views_exposed_groups']['format_groups'] == 'vertical_tabs') {
$form['filters'] = array(
'#type' => 'vertical_tabs',
'#weight' => -10,
);
}
else {
$form['filters'] = array(
'#weight' => -10,
);
}
$groups = explode("\n", $this->options['views_exposed_groups']['groups']);
array_walk($groups, 'trim');
foreach ($groups as $key => $group) {
$form['filters'][$key] = array(
'#type' => 'fieldset',
'#title' => $group,
'#collapsible' => TRUE,
'#collapsed' => $this->options['views_exposed_groups']['format_groups'] == 'fieldsets_collapsed' ? TRUE : FALSE,
);
}
$fields = $this->options['views_exposed_groups'];
unset($fields['groups']);
foreach ($fields as $field => $group) {
$field = str_replace('group-', '', $field);
if (isset($form[$field]) && is_array($form[$field])) {
$title = !is_array($form[$field . '_op']) ? $form['#info']['filter-' . $group['filter_name']]['label'] : null;
$form['filters'][$group['group']][$field] = $form[$field] + array(
'#weight' => $group['weight'],
'#title' => $title,
);
unset($form[$field]);
}
if (isset($form[$field . '_op']) && is_array($form[$field . '_op'])) {
$form['filters'][$group['group']][$field . '_op'] = $form[$field . '_op'] + array(
'#weight' => $group['weight'],
'#title' => $form['#info']['filter-' . $group['filter_name']]['label'],
);
unset($form[$field . '_op']);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
views_exposed_groups_plugin:: |
function |
Overrides views_plugin_exposed_form:: |
||
views_exposed_groups_plugin:: |
function |
Provide a form to edit options for this plugin. Overrides views_plugin_exposed_form:: |
||
views_exposed_groups_plugin:: |
function |
Information about options for all kinds of purposes will be held here. Overrides views_plugin_exposed_form:: |
||
views_exposed_groups_plugin:: |
function |
Returns the summary of the settings in the display. Overrides views_plugin:: |
||
views_object:: |
public | property | Handler's definition. | |
views_object:: |
public | property | Except for displays, options for the object will be held here. | 1 |
views_object:: |
function | Collect this handler's option definition and alter them, ready for use. | ||
views_object:: |
public | function | Views handlers use a special construct function. | 4 |
views_object:: |
public | function | Destructor. | 2 |
views_object:: |
public | function | 1 | |
views_object:: |
public | function | ||
views_object:: |
public | function | Always exports the option, regardless of the default value. | |
views_object:: |
public | function | Set default options on this object. | 1 |
views_object:: |
public | function | Set default options. | |
views_object:: |
public | function | Let the handler know what its full definition is. | |
views_object:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
public | function | Unpack a single option definition. | |
views_object:: |
public | function | Unpacks each handler to store translatable texts. | |
views_object:: |
public | function | ||
views_plugin:: |
public | property | The current used views display. | |
views_plugin:: |
public | property | The plugin name of this plugin, for example table or full. | |
views_plugin:: |
public | property | The plugin type of this plugin, for example style or query. | |
views_plugin:: |
public | property |
The top object of a view. Overrides views_object:: |
1 |
views_plugin:: |
public | function | Provide a list of additional theme functions for the theme info page. | |
views_plugin:: |
public | function | Handle any special handling on the validate form. | 9 |
views_plugin:: |
public | function | Validate the options form. | 10 |
views_plugin:: |
public | function | Return the human readable name of the display. | |
views_plugin:: |
public | function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
public | function | Validate that the plugin is correct and can be saved. | 3 |
views_plugin_exposed_form:: |
public | function | This function is executed when exposed form is submited. | |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | Initialize the plugin. | |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | 1 | |
views_plugin_exposed_form:: |
public | function |
Add anything to the query that we might need to. Overrides views_plugin:: |
1 |
views_plugin_exposed_form:: |
public | function | Render the exposed filter form. | |
views_plugin_exposed_form:: |
public | function |