You are here

function spaces_features_form in Spaces 7

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

Spaces features form.

2 string references to 'spaces_features_form'
spaces_menu in ./spaces.module
Implements hook_menu().
spaces_menu_alter in ./spaces.module
Implements hook_menu_alter().

File

./spaces.admin.inc, line 6

Code

function spaces_features_form(&$form, &$form_state) {
  $spaces_features = variable_get('spaces_features', array());
  $form['spaces_features'] = array(
    '#tree' => TRUE,
  );
  $form['labels'] = array(
    '#tree' => FALSE,
  );
  $form['settings'] = array(
    '#tree' => FALSE,
  );
  $space = spaces_get_space();
  $parent = menu_get_item();
  $features = spaces_features($space ? $space->type : 'site');
  ksort($features);
  foreach ($features as $feature => $info) {
    $label = "<strong>" . t($info->info['name']) . "</strong>";
    $label .= "<div class='description'>" . t($info->info['description']) . "</div>";
    $form['labels'][$feature] = array(
      '#type' => 'markup',
      '#markup' => $label,
    );
    $form['spaces_features'][$feature] = array(
      '#type' => 'select',
      '#options' => $space ? $space
        ->feature_options() : array(
        0 => t('Disabled'),
        1 => t('Enabled'),
      ),
      '#default_value' => isset($spaces_features[$feature]) ? $spaces_features[$feature] : 0,
    );

    // By convention, features can provide settings pages at features/[feature].
    // This will detect the items that have been grafted from features/* onto the
    // portion of the menu tree that relates to this pace.
    $item = menu_get_item("{$parent['href']}/{$feature}");
    if ($item && $item['href'] != $parent['href'] && $item['access']) {
      $settings = l($item['title'], $item['href'], array(
        'query' => array(
          'destination' => $_GET['q'],
        ),
      ));
    }
    else {
      $settings = '';
    }
    $form['settings'][$feature] = array(
      '#type' => 'markup',
      '#markup' => $settings,
    );
  }
  $options = $space ? array(
    'spaces-frontpage' => '<' . t('Default page') . '>',
  ) : array();
  $links = menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'));
  if (!empty($links)) {
    foreach ($links as $link) {
      $options[$link['href']] = $link['title'];
    }
  }
  $options['spaces-other'] = '<' . t('Other...') . '>';
  $front_page = variable_get('site_frontpage', 'node');
  ctools_include('dependent');
  $form['site_frontpage'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('Default front page'),
    '#default_value' => isset($options[$front_page]) ? $front_page : 'spaces-other',
    '#description' => t('The home page displays content from this menu item.'),
    '#element_validate' => array(
      'spaces_site_frontpage_validate',
    ),
  );
  $form['site_frontpage_path'] = array(
    '#type' => 'textfield',
    '#description' => t('A relative path to use as the front page.'),
    '#default_value' => $front_page,
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'edit-site-frontpage' => array(
        'spaces-other',
      ),
    ),
  );
  $form = system_settings_form($form);
  $form['#theme'] = 'spaces_features_form';
  $form['buttons']['#weight'] = 100;
  return $form;
}