function spaces_preset_default_form in Spaces 5.2
Same name and namespace in other branches
- 6 spaces_admin.inc \spaces_preset_default_form()
- 6.2 spaces_admin.inc \spaces_preset_default_form()
Page callback for generating a list of spaces presets. (admin/build/spaces)
1 string reference to 'spaces_preset_default_form'
- spaces_menu in ./
spaces.module - Implementation of hook_menu().
File
- ./
spaces_admin.inc, line 7
Code
function spaces_preset_default_form() {
$default_presets = variable_get('spaces_default_presets', array());
$form = array(
'#theme' => 'spaces_preset_default_form',
'types' => array(
'#tree' => TRUE,
),
);
foreach (spaces_types() as $type => $info) {
$form['types'][$type] = array(
'#tree' => TRUE,
'#title' => $info['title'],
);
// Button for adding new preset
$form['types'][$type]['add'] = array(
'#type' => 'markup',
'#value' => l(t('Add preset'), 'admin/build/spaces/presets/add/' . $type, array(
'class' => 'button',
)),
);
$presets = spaces_presets($type, TRUE);
if (count($presets)) {
$form['types'][$type]['default'] = array(
'#type' => 'radios',
'#options' => array(),
);
foreach ($presets as $id => $preset) {
// Add radio for use when choosing default
if (!$preset['disabled']) {
$form['types'][$type]['default']['#options'][$id] = $preset['name'];
// Set as default if it is
if ($id == $default_presets[$type]) {
$form['types'][$type]['default']['#default_value'] = $id;
}
}
// Build links for each preset
$links = array();
if (isset($preset['module'])) {
$links[] = $preset['disabled'] ? l(t('Enable'), 'admin/build/spaces/presets/enable/' . $type . '/' . $id) : l(t('Disable'), 'admin/build/spaces/presets/disable/' . $type . '/' . $id);
}
else {
$links[] = l(t('Edit'), 'admin/build/spaces/presets/edit/' . $type . '/' . $id);
$links[] = $preset['disabled'] ? l(t('Enable'), 'admin/build/spaces/presets/enable/' . $type . '/' . $id) : l(t('Disable'), 'admin/build/spaces/presets/disable/' . $type . '/' . $id);
$links[] = l(t('Delete'), 'admin/build/spaces/presets/delete/' . $type . '/' . $id);
}
$links = implode(' | ', $links);
// Store preset information to be passed to theme function
$form['types'][$type]['info'][$id] = array(
'#type' => 'value',
'#value' => array(
'name' => $preset['name'],
'description' => $preset['description'],
'links' => $links,
'disabled' => $preset['disabled'],
),
);
}
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save defaults'),
);
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Clear defaults'),
);
return $form;
}