function theme_spaces_features_form in Spaces 6
Same name and namespace in other branches
- 5.2 spaces_admin.inc \theme_spaces_features_form()
- 5 spaces_admin.inc \theme_spaces_features_form()
- 6.3 spaces.theme.inc \theme_spaces_features_form()
- 6.2 spaces.theme.inc \theme_spaces_features_form()
Theme for spaces featuers/settings form. @TODO: this could probably live in a preprocess/template file.
File
- ./
spaces_admin.inc, line 735
Code
function theme_spaces_features_form($form) {
drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
drupal_add_js(drupal_get_path('module', 'spaces') . '/spaces.js');
// Add draggable weights
drupal_add_js('misc/tableheader.js');
drupal_add_tabledrag('spaces-features', 'order', 'sibling', 'feature-weight');
$output = '';
foreach (array(
'features',
'settings',
) as $type) {
$header = array(
t('Setting'),
t('Status'),
t('Description'),
!isset($form['space']['#value']->sid) ? t('Locked') : '',
);
if ($type == 'features') {
$header[0] = t('Features');
$header[] = '';
}
$rows = array();
foreach (element_children($form[$type]) as $element) {
// Yank title & description fields off the form element for
// rendering in their own cells.
$feature_name = "<strong>" . $form[$type][$element]['#title'] . "</strong>";
$description = "<div class='description'>" . $form[$type][$element]['#description'] . "</div>";
unset($form[$type][$element]['#title']);
unset($form[$type][$element]['#description']);
$row = array(
'name' => $feature_name,
'option' => drupal_render($form[$type][$element]),
'description' => $description,
'action' => drupal_render($form['customize'][$element]) . drupal_render($form['locked'][$type][$element]),
);
// Determine row classes
$class = $form[$type][$element]['#default_value'] ? 'enabled' : 'disabled';
$class .= !empty($form[$type][$element]['#locked']) ? ' locked' : '';
// Add feature weighting
if ($type == 'features') {
$form['weights'][$element]['#attributes'] = array(
'class' => 'feature-weight',
);
$row['weight'] = drupal_render($form['weights'][$element]);
$class .= ' draggable';
}
// Collect data + classes & add to master array.
foreach ($row as $key => $data) {
$row[$key] = array(
'data' => $data,
'class' => $key,
);
}
$rows[] = array(
'data' => $row,
'class' => $class,
);
}
$output .= "<h3>" . $form[$type]['#title'] . "</h3>";
$output .= "<div class='description'>" . $form[$type]['#description'] . "</div>";
$output .= theme('table', $header, $rows, array(
'id' => 'spaces-' . $type,
'class' => 'spaces-' . $type,
));
// Prevent section from being rendered by drupal_render().
unset($form[$type]);
}
if (isset($form['submit']) && $form['submit']['#type'] == 'submit') {
$output .= "<div class='buttons'>";
$output .= drupal_render($form['submit']);
$output .= "</div>";
}
$output .= drupal_render($form);
return $output;
}