You are here

function spaces_features_form in Spaces 6.2

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 spaces_admin.inc \spaces_features_form()
  5. 7.3 spaces.admin.inc \spaces_features_form()
  6. 7 spaces.admin.inc \spaces_features_form()

FEATURE SETTINGS ===================================================

3 string references to 'spaces_features_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().
spaces_preset_form in ./spaces_admin.inc
Form for adding or editing a spaces preset.

File

./spaces_admin.inc, line 485

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['buttons'] = array(
    '#tree' => FALSE,
    '#theme' => 'features_form_buttons',
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  $form['buttons']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
    '#submit' => array(
      'spaces_features_form_reset',
    ),
  );
  return $form;
}