You are here

function spaces_features_labels in Spaces 5

Menu customization form.

1 string reference to 'spaces_features_labels'
spaces_menu in ./spaces.module

File

./spaces_admin.inc, line 183

Code

function spaces_features_labels($nid) {
  drupal_set_title(t('Menu Labels'));
  $form = array();
  $weights = array();
  for ($i = -10; $i <= 10; $i++) {
    $weights[$i] = $i;
  }
  $spaces_features = spaces_features();
  $active_features = spaces_features($nid);

  // Check for active features
  if ($active_features != false) {
    $form['help'] = array(
      '#type' => 'item',
      '#value' => "<p>" . t("You can customize this group's menu by entering custom labels and weights. Any changes you make will only affect this group and can be undone using the <strong>Reset</strong> button.") . "</p>",
    );
    $form['nid'] = array(
      '#type' => 'hidden',
      '#value' => $nid,
    );
    foreach ($active_features as $feature => $active) {
      if ($active && isset($spaces_features[$feature]->menu) && ($menu = _spaces_feature_menu_tree($spaces_features[$feature], null, $nid))) {
        $path = $menu['href'];
        $form[$feature] = array(
          '#title' => $spaces_features[$feature]->spaces['label'],
          '#description' => $spaces_features[$feature]->spaces['description'],
          '#tree' => TRUE,
        );
        $form[$feature][$path]['label'] = array(
          '#type' => 'textfield',
          '#title' => $menu['title'],
          '#description' => $menu['href'],
          '#default_value' => $menu['title'],
          '#size' => 30,
          '#required' => true,
        );
        $form[$feature][$path]['weight'] = array(
          '#type' => 'select',
          '#default_value' => $menu['#weight'] ? $menu['#weight'] : 0,
          '#options' => $weights,
          '#required' => true,
        );
        if (isset($menu['children'])) {
          $form[$feature]['#title'] = $spaces_features[$feature]->spaces['label'];
          foreach ($menu['children'] as $child) {
            $form[$feature][$child['href']]['label'] = array(
              '#type' => 'textfield',
              '#title' => $child['title'],
              '#description' => $child['href'],
              '#default_value' => $child['title'],
              '#size' => 30,
              '#required' => true,
            );
            $form[$feature][$child['href']]['weight'] = array(
              '#type' => 'select',
              '#default_value' => $child['#weight'] ? $child['#weight'] : 0,
              '#options' => $weights,
              '#required' => true,
            );
          }
        }
      }
    }
    $form['#theme'] = 'spaces_features_labels';
    $form['save'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
    );
    $form['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset'),
    );
  }
  else {
    $form['error'] = array(
      '#value' => t('No active features in this group. You must enable features before customizing labels.'),
    );
  }
  return $form;
}