function vefl_views_exposed_form_preprocess in Views exposed form layout 7
A theme preprocess function for views_exposed_form.
Adds $region_widgets array with separated by regions widgets.
2 string references to 'vefl_views_exposed_form_preprocess'
- vefl_theme in ./
vefl.module - Implements hook_theme().
- vefl_theme_registry_alter in ./
vefl.module - Implements hook_theme_registry_alter().
File
- includes/
vefl.inc, line 45 - Provides default layouts for views exposed form.
Code
function vefl_views_exposed_form_preprocess(&$vars) {
if (empty($vars['form']['#layout'])) {
return;
}
$layout = $vars['form']['#layout'];
$actions = array_keys(vefl_form_actions());
// Adds additional action for BEF combined sort.
if (!empty($vars['widgets']['sort-sort_bef_combine'])) {
$actions[] = 'sort-sort_bef_combine';
}
// Ensure each region has an empty value.
foreach ($layout['region_widgets'] as $region => $fields) {
$vars['region_widgets'][$region] = array();
}
// Put fields to regions.
foreach ($layout['region_widgets'] as $region => $fields) {
foreach ($fields as $id) {
if (!in_array($id, $actions) && !empty($vars['widgets'][$id]->widget)) {
$vars['region_widgets'][$region][$id] = $vars['widgets'][$id];
}
}
}
// Put form actions to regions.
foreach ($layout['region_widgets'] as $region => $fields) {
foreach ($fields as $id) {
if (in_array($id, $actions) && (!empty($vars['widgets'][$id]->widget) || !empty($vars[$id]))) {
$widget = !empty($vars['widgets'][$id]->widget) ? $vars['widgets'][$id] : array(
'widget' => $vars[$id],
'id' => $id,
);
$vars['region_widgets'][$region][$id] = (object) $widget;
}
}
}
$vars['classes_array'][] = 'vefl-layout';
$vars['classes_array'][] = str_replace('_', '-', $layout['layout_id']);
if (vefl_layout_module($layout['layout_id']) == 'vefl') {
drupal_add_css(drupal_get_path('module', 'vefl') . '/css/vefl-layouts.css');
}
}