You are here

function spaces_features_form in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \spaces_features_form()
  2. 5 spaces_admin.inc \spaces_features_form()
  3. 6.3 spaces.admin.inc \spaces_features_form()
  4. 6.2 spaces_admin.inc \spaces_features_form()
  5. 7.3 spaces.admin.inc \spaces_features_form()
  6. 7 spaces.admin.inc \spaces_features_form()
2 string references to 'spaces_features_form'
spaces_features_page in ./spaces_admin.inc
FEATURE SETTINGS ===================================================
spaces_preset_form in ./spaces_admin.inc
Form for adding or editing a spaces preset.

File

./spaces_admin.inc, line 556

Code

function spaces_features_form(&$form_state, $space = NULL) {

  // Attempt to get current space if not provided
  $space = !isset($space) ? spaces_get_space() : $space;

  // Set a wide layout for themes that support it
  context_set('theme', 'layout', 'wide');
  spaces_preset_enforce($space);
  $form = _spaces_features_form($space);

  // Generate base path for the given space
  $types = spaces_types();
  $type = $types[$space->type];
  $base_path = '';
  if (isset($type['base path'])) {
    $base_path = str_replace('%sid', $space->sid, $type['base path']) . '/';
  }

  // Add customization and/or settings link if feature is not disabled
  $form['customize'] = array(
    '#tree' => TRUE,
  );
  foreach (element_children($form['features']) as $id) {
    if (isset($space->features[$id]) && $space->features[$id] != SPACES_FEATURE_DISABLED) {
      $form['customize'][$id] = array(
        '#type' => 'markup',
        '#value' => l(t('Customize'), $base_path . 'spaces/features/' . $id),
      );
    }
  }

  // Lock features and settings.
  if ($space->preset) {
    $presets = spaces_presets($space->type);
    $preset = $presets[$space->preset];
    foreach (array(
      'features',
      'settings',
    ) as $item) {
      if (isset($preset['preset']['locked'][$item])) {
        foreach ($preset['preset']['locked'][$item] as $id => $value) {
          if ($value && isset($form[$item][$id])) {
            $form[$item][$id]['#disabled'] = true;
            $form[$item][$id]['#locked'] = true;

            // attribute used in theme layer
          }
        }
      }
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#weight' => 10,
  );
  return $form;
}