You are here

function spaces_preset_editor in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces_ui/export_ui/spaces_presets_export_ui.class.php \spaces_preset_editor()
  2. 7 spaces_ui/export_ui/spaces_presets_export_ui.class.php \spaces_preset_editor()

Preset editor form.

1 string reference to 'spaces_preset_editor'
spaces_presets.inc in spaces_ui/export_ui/spaces_presets.inc

File

spaces_ui/export_ui/spaces_presets_export_ui.class.php, line 136

Code

function spaces_preset_editor(&$form, &$form_state) {
  $preset = $form_state['item'];
  $form['info']['#type'] = 'fieldset';
  $form['info']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $preset->title,
    '#maxlength' => 64,
  );
  $form['info']['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#default_value' => $preset->description,
  );
  $types = array();
  foreach (spaces_types(TRUE) as $type => $info) {
    $types[$type] = $info['title'];
  }
  $form['info']['space_type'] = array(
    '#title' => t('Type'),
    '#type' => 'select',
    '#options' => $types,
    '#default_value' => $preset->space_type,
    '#disabled' => $form_state['op'] === 'edit',
  );
  if (!empty($preset->value) && isset($preset->space_type) && ($space = spaces_load($preset->space_type, 0))) {
    foreach ($preset->value as $controller => $overrides) {
      if (!empty($overrides) && is_array($overrides)) {
        foreach ($overrides as $key => $value) {
          $form['revert'][$controller][$key] = array(
            '#type' => 'checkbox',
            '#title' => $key,
            '#disabled' => FALSE,
            '#description' => $space->controllers->{$controller}
              ->summary($key, $value),
          );
        }
      }
    }
    if (element_children($form['revert'])) {
      $form['revert']['#tree'] = TRUE;
      $form['revert']['#theme'] = 'spaces_overrides_form';
      $form['revert']['revert'] = array(
        '#type' => 'item',
        '#title' => t('Remove'),
        '#description' => t('Remove the selected overrides from this preset.'),
      );
      $form['revert']['revert']['revert'] = array(
        '#type' => 'submit',
        '#value' => t('Remove overrides'),
        '#submit' => array(
          'spaces_preset_editor_remove_overrides',
        ),
      );
    }
  }
  return $form;
}