You are here

function cacheflush_ui_preset_form_options in CacheFlush 7.3

Callback: cacheflush_ui_preset_form().

1 call to cacheflush_ui_preset_form_options()
cacheflush_form in modules/cacheflush_ui/includes/cacheflush_ui.forms.inc
Cacheflush preset edit form.

File

modules/cacheflush_ui/includes/cacheflush_ui.presets.inc, line 11
Contains the CacheflushUI forms function.

Code

function cacheflush_ui_preset_form_options(&$form, &$form_state) {

  // Form element, vertical tab parent.
  $form['cacheflush_vertical_tabs'] = array(
    '#type' => 'vertical_tabs',
    '#weight' => 50,
    '#attached' => array(
      'js' => array(
        'vertical-tabs' => drupal_get_path('module', 'cacheflush_ui') . '/js/cacheflush_ui_vertical_tabs.js',
      ),
    ),
  );

  // Add vertical tabs.
  $form_state['#cacheflush_tabs'] = module_invoke_all('cacheflush_ui_tabs');
  $original_tabs = cacheflush_ui_cacheflush_ui_tabs();
  foreach ($form_state['#cacheflush_tabs'] as $key => $value) {
    $form[$key] = array(
      '#type' => 'fieldset',
      '#title' => check_plain($value['name']),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#group' => 'cacheflush_vertical_tabs',
      '#tree' => TRUE,
      '#weight' => isset($value['weight']) ? $value['weight'] : NULL,
      '#attributes' => isset($original_tabs[$key]) ? array(
        'class' => array(
          'original_tabs',
        ),
      ) : array(),
    );
  }
  $form_state['cacheflush']->data = unserialize(isset($form_state['cacheflush']->data) ? $form_state['cacheflush']->data : NULL);

  // Adding table elemnts to tabs.
  $form_state['#preset_options'] = _cacheflush_get_option_list();
  foreach ($form_state['#preset_options'] as $key => $value) {

    // Special tab element added only if there module are instaled.
    if ($value['category'] == 'vertical_tabs_often' && !module_exists($key)) {
      continue;
    }
    $form[$value['category']][$key] = array(
      '#type' => 'checkbox',
      '#title' => check_plain($key),
      '#default_value' => isset($form_state['cacheflush']->data[$key]) ? 1 : 0,
      '#description' => check_plain($value['description']),
    );
  }
  _cacheflush_ui_tabs_description($form);
}