function _spaces_features_form in Spaces 6.2
Same name and namespace in other branches
- 5.2 spaces_admin.inc \_spaces_features_form()
- 6 spaces_admin.inc \_spaces_features_form()
Core form for controlling features / settings
2 calls to _spaces_features_form()
- spaces_features_form 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 548
Code
function _spaces_features_form($space) {
$form = array();
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
);
$form['space'] = array(
'#type' => 'value',
'#value' => $space,
);
$form['features'] = array(
'#type' => 'fieldset',
'#title' => t('Features'),
'#tree' => TRUE,
);
$form['weights'] = array(
'#tree' => TRUE,
);
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#tree' => TRUE,
);
// Generate features form
// Grab an ordered list of features from the current space.
// Add any additional features that this space is missing to the end.
$features = spaces_features($space->type, TRUE);
$ordered = array();
if (isset($space->features)) {
$ordered = array_keys($space->features);
// Sometimes the feature array can contain stale data --
// we intersect it with the spaces_features() to make sure it
// doesn't contain any dead features.
$ordered = array_intersect($ordered, array_keys($features));
}
foreach (array_keys($features) as $feature) {
if (!in_array($feature, $ordered)) {
$ordered[] = $feature;
}
}
// Iterate a second time to build the form. We assign weights in a
// strictly ascending fashion.
$weight = -10;
foreach ($ordered as $id) {
$options = $space
->feature_options() ? $space
->feature_options() : array();
if (count($options) > 0) {
$form['weights'][$id] = array(
'#type' => 'weight',
'#delta' => 10,
'#default_value' => $weight,
);
$form['features'][$id] = array(
'#type' => 'select',
'#title' => $features[$id]->info['name'],
'#description' => $features[$id]->info['description'],
'#options' => $options,
'#default_value' => isset($space->features[$id]) ? $space->features[$id] : SPACES_FEATURE_DISABLED,
);
$weight++;
}
}
// Generate settings form
foreach (spaces_settings($space->type, TRUE) as $setting) {
$setting_value = isset($space->settings[$setting->id]) ? $space->settings[$setting->id] : NULL;
$setting_form = $setting
->form($space, $setting_value);
if (!empty($setting_form)) {
$form['settings'][$setting->id] = $setting_form;
}
}
return $form;
}