You are here

function spaces_overrides_form in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces.admin.inc \spaces_overrides_form()
  2. 7.3 spaces.admin.inc \spaces_overrides_form()

Form for managing space override values.

2 string references to 'spaces_overrides_form'
spaces_menu_alter in ./spaces.module
Implements hook_menu_alter().
spaces_preset_editor in spaces_ui/export_ui/spaces_presets_export_ui.class.php
Preset editor form.

File

./spaces.admin.inc, line 140

Code

function spaces_overrides_form($form_state) {
  $space = spaces_get_space();
  $stack = array(
    'space',
    'preset',
  );
  $form = array();
  if ($space) {
    foreach (array_keys(spaces_controllers()) as $controller) {
      foreach ($stack as $env) {
        foreach ($space->controllers->{$controller}
          ->get(NULL, $env) as $key => $value) {
          if (!isset($form[$controller][$key])) {
            $form[$controller][$key] = array(
              '#type' => 'checkbox',
              '#title' => $key,
              '#disabled' => $env !== 'space',
              '#description' => $space->controllers->{$controller}
                ->summary($key, $value),
              '#default_value' => NULL,
            );
          }
        }
      }
    }
    if (element_children($form)) {
      $form['#tree'] = TRUE;
      $form['#theme'] = 'spaces_overrides_form';
      $form['space'] = array(
        '#type' => 'value',
        '#value' => $space,
      );
      $presets = spaces_preset_load(NULL, $space->type);
      $default_preset = variable_get('spaces_preset_' . $space->type, NULL);
      if (isset($presets, $default_preset) && array_key_exists($default_preset, $presets) && spaces_access_admin_perms(array(
        'administer spaces',
      ))) {
        $preset_name = t($presets[$default_preset]->title);
        $form['preset'] = array(
          '#tree' => FALSE,
          '#type' => 'item',
          '#title' => t('Save'),
          '#description' => t('Save selected overrides from this space to the current preset <strong>@preset</strong>.', array(
            '@preset' => $preset_name,
          )),
        );
        $form['preset']['preset_save'] = array(
          '#type' => 'submit',
          '#value' => t('Save to preset'),
          '#submit' => array(
            'spaces_overrides_preset_save',
          ),
        );
      }
      $form['revert'] = array(
        '#tree' => FALSE,
        '#type' => 'item',
        '#title' => t('Revert'),
        '#description' => t('Revert the selected overrides for this space.'),
      );
      $form['revert']['revert'] = array(
        '#type' => 'submit',
        '#value' => t('Revert overrides'),
        '#submit' => array(
          'spaces_overrides_revert',
        ),
      );
    }
  }
  return $form;
}