You are here

private function PurgePurgerBundleUI::get_select in Purge 7.2

Get an item selection form.

Parameters

$pointer_type string:

1 call to PurgePurgerBundleUI::get_select()
PurgePurgerBundleUI::get_form_edit_purger in includes/purge_ui.class.inc
Generate the purger form elements.

File

includes/purge_ui.class.inc, line 374
Provides administrative interface for the Purge module.

Class

PurgePurgerBundleUI
Generates UI elements for the Purge UI module.

Code

private function get_select($pointer_type) {

  // Check if we select a single or multiple values.
  $multiple = true;
  if ($pointer_type == 'handler' || $pointer_type == 'queue') {
    $multiple = false;
  }
  $form = array();

  // Common header
  $table_header = array(
    'name' => t('Name'),
    'description' => t('Description'),
  );
  $default_value = array();
  foreach ($this->{$pointer_type} as $pointer_name => $pointer) {

    // Get name and description from the item object.
    $rows[$pointer_name] = array(
      'name' => $this->{$pointer_type}[$pointer_name]->name,
      'description' => $this->{$pointer_type}[$pointer_name]->description,
    );

    // Add to the default value if selected.
    if (in_array($pointer_name, $this->form_item->pointers[$pointer_type])) {
      if ($multiple) {
        $default_value[$pointer_name] = $pointer_name;
      }
      else {
        $default_value = $pointer_name;
      }
    }
  }

  // Now lets build the form.
  $form[$pointer_type] = array(
    '#type' => 'fieldset',
    '#title' => $this->type[$pointer_type]->name,
    '#description' => $this->type[$pointer_type]->description,
  );
  $form[$pointer_type][$pointer_type . '_selection'] = array(
    '#type' => 'tableselect',
    '#header' => $table_header,
    '#options' => $rows,
    '#default_value' => $default_value,
    '#multiple' => $multiple,
  );
  return $form;
}