You are here

function global_filter_block_configure in Views Global Filter 8

Same name and namespace in other branches
  1. 6 global_filter.blocks.inc \global_filter_block_configure()
  2. 7 global_filter.blocks.inc \global_filter_block_configure()

Implements hook_block_configure().

Note that this hook cannot easily be used with dynamic forms adding additional fields at the press of a button, because form_state is not passed as its argument. See drupal.org/node/690828. Therefore the actions of adding or removing a fieldset (filter) is not easily communicated back to this function.

$param string $delta Example: 'global_filter_2'

File

./global_filter.blocks.inc, line 64
global_filter.block.inc

Code

function global_filter_block_configure($delta) {

  // Container for the table, its id is used in the AJAX callback.
  $form['all-filters'] = array(
    '#title' => t('Global filters in this block'),
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#prefix' => '<div id="all-filters">',
    '#suffix' => '</div>',
  );
  $block_number = empty($delta) ? 1 : drupal_substr($delta, -1);
  $filter_parameters = global_filter_get_parameter(NULL);

  // Generate forms for existing filters.
  $fieldset = 0;
  $keys = array();
  for ($key = 1; $key < 10; $key++) {
    if (empty($filter_parameters[$key])) {
      if (!isset($first_free_key)) {
        $first_free_key = $key;
      }
    }
    elseif (drupal_substr($filter_parameters[$key]['block'], -1) == $block_number) {
      $form['all-filters'][$key] = _global_filter_configure_form($block_number, $key, $fieldset);
      $keys[] = $key;
      $fieldset++;
    }
  }

  // Generate empty form for optional extra filter.
  if (isset($first_free_key)) {
    $form['all-filters'][$first_free_key] = _global_filter_configure_form($block_number, $first_free_key, $fieldset);
    $keys[] = $first_free_key;
  }
  return $form;
}