You are here

function cacheflush_list_preset_form in CacheFlush 7

Same name and namespace in other branches
  1. 7.2 cacheflush.admin.inc \cacheflush_list_preset_form()

Callback function after drupal_get_form().

1 string reference to 'cacheflush_list_preset_form'
cacheflush_menu in ./cacheflush.module
Implements hook_menu().

File

./cacheflush.admin.inc, line 11
Cacheflush admin for list presets.

Code

function cacheflush_list_preset_form($form, &$form_state) {

  // Get the preset list.
  $form_state['cacheflush_preset_list'] = $cache_presets = variable_get('cacheflush_preset_list', array());

  // Table header.
  $rows = $default_value = array();
  $header = array(
    'title' => array(
      'data' => t('Title'),
      'style' => 'width:100%;',
    ),
    'operations' => t('Operations'),
  );

  // Table rows.
  foreach ($cache_presets as $key => $value) {
    $operations = '';
    if (!isset($value['#editable'])) {
      $operations = l(t('Edit'), "admin/config/development/cacheflush/preset/{$key}") . ' | ' . l(t('Delete'), "admin/config/development/cacheflush/preset/delete/{$key}");
    }
    $rows[$key] = array(
      'title' => $value['#name'],
      'operations' => $operations,
    );
    $default_value[$key] = $value['#enabled'];
  }

  // The table form element.
  $form['preset_list'] = array(
    '#type' => 'tableselect',
    '#title' => t('Preset List'),
    '#header' => $header,
    '#options' => $rows,
    '#multiple' => TRUE,
    '#default_value' => $default_value,
    '#empty' => t('No content available.'),
    '#js_select' => FALSE,
    '#attributes' => array(
      'id' => 'cachefulsher_preset_list',
    ),
  );

  // Submit button.
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}