views_exposed_groups.module in Views exposed groups 7.2
Same filename and directory in other branches
Views Exposed Groups module functions.
File
views_exposed_groups.moduleView source
<?php
/**
* @file
* Views Exposed Groups module functions.
*/
/**
* Implements hook_views_api().
*/
function views_exposed_groups_views_api() {
return array(
'api' => 3.0,
);
}
/**
* Implements hook_theme().
*/
function views_exposed_groups_theme() {
return array(
'views_exposed_groups_reorder_filter_form' => array(
'render element' => 'form',
),
);
}
/**
* Theme callback to render the option form as a draggable table.
*/
function theme_views_exposed_groups_reorder_filter_form($vars) {
$form = $vars['form'];
$rows = array();
foreach (element_children($form) as $key) {
if (isset($form[$key]['weight'])) {
$group = is_numeric($form[$key]['group']['#default_value']) ? $form[$key]['group']['#default_value'] : 'no-group';
$row = array();
$row[] = $form[$key]['weight']['#title'];
$form[$key]['weight']['#attributes']['class'] = array(
'weight',
'weight-' . $group,
);
$form[$key]['group']['#attributes']['class'] = array(
'group-select',
'field-group-' . $group,
);
$row[] = drupal_render($form[$key]['group']);
$row[] = drupal_render($form[$key]['weight']);
$class = array(
'draggable',
);
$rows[$group][] = array(
'data' => $row,
'class' => $class,
'id' => 'display-row-' . $key,
);
}
}
$groups = $form['#groups'];
$table_rows = array();
foreach ($groups as $k => $group) {
$table_rows[] = array(
array(
'data' => '<strong>' . $group . '</strong>',
'colspan' => 3,
'class' => array(
'field-group-header',
),
),
);
if (isset($rows[$k])) {
foreach ($rows[$k] as $row) {
$table_rows[] = $row;
}
}
}
foreach ($groups as $k => $group) {
drupal_add_tabledrag('reorder-group-filters', 'match', 'sibling', 'group-select', 'field-group-' . $k, NULL, FALSE);
drupal_add_tabledrag('reorder-group-filters', 'order', 'sibling', 'weight', 'weight-' . $k);
}
$header = array(
t('Filter'),
t('Group'),
t('Weight'),
);
$output = drupal_render($form['override']);
$output .= theme('table', array(
'header' => $header,
'rows' => $table_rows,
'attributes' => array(
'id' => 'reorder-group-filters',
),
));
$output .= drupal_render_children($form);
return $output;
}
Functions
Name | Description |
---|---|
theme_views_exposed_groups_reorder_filter_form | Theme callback to render the option form as a draggable table. |
views_exposed_groups_theme | Implements hook_theme(). |
views_exposed_groups_views_api | Implements hook_views_api(). |