You are here

function spaces_customize_form in Spaces 6.2

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_customize_form()
  2. 6 spaces_admin.inc \spaces_customize_form()

Feature customization form.

2 string references to 'spaces_customize_form'
spaces_active_space_menu in ./spaces.module
A mild abstraction of hook_menu() items that can be used by implementing modules to embed/graft relevant spaces items into the menu tree.
spaces_og_menu in spaces_og/spaces_og.module
Implementation of hook_menu().

File

./spaces_admin.inc, line 691

Code

function spaces_customize_form(&$form_state, $space = NULL, $feature) {

  // Attempt to get current space if not provided
  $space = !isset($space) ? spaces_get_space() : $space;
  $form = array();
  $form['space'] = array(
    '#type' => 'value',
    '#value' => $space,
  );
  $form['feature'] = array(
    '#type' => 'value',
    '#value' => $feature,
  );
  $form['settings'] = array(
    '#tree' => TRUE,
  );
  $form['customizers'] = array(
    '#tree' => TRUE,
  );
  $customizable = FALSE;
  $features = spaces_features();
  $f = $features[$feature];
  drupal_set_title(t('Customize: !feature', array(
    '!feature' => $f->info['name'],
  )));

  // Generate feature-specific settings form
  $settings = spaces_feature_settings($feature);
  if (!empty($settings)) {
    $form['settings']['#title'] = t('Settings');
    $form['settings']['#type'] = 'fieldset';
    $form['settings']['#collapsible'] = TRUE;
    foreach ($settings as $id => $setting) {
      $setting_value = isset($space->settings[$id]) ? $space->settings[$id] : NULL;
      $form['settings'][$id] = $setting
        ->form($space, $setting_value);
    }
    $customizable = TRUE;
  }

  // Create a fieldset per customizer
  $customizers = spaces_customizers();
  foreach ($customizers as $id => $customizer) {
    $form['customizers'][$id] = array(
      '#title' => t($customizer->name),
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#theme' => 'spaces_customize_item',
      '#collapsible' => TRUE,
    );
    $customizer_form = $customizer
      ->form($space, $feature);
    if ($customizer_form) {
      $form['customizers'][$id] = array_merge($form['customizers'][$id], $customizer_form);
      $customizable = TRUE;
    }
  }

  // If we have customizers and/or settings, add submit buttons
  if ($customizable) {
    $form['buttons'] = array(
      '#tree' => FALSE,
      '#theme' => 'features_form_buttons',
    );
    $form['buttons']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save settings'),
      '#submit' => array(
        'spaces_customize_form_submit',
      ),
    );
  }
  else {
    drupal_set_message(t('This feature does not have any customizations or settings available.'));
  }
  return $form;
}