You are here

function theme_spaces_preset_default_form in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces_admin.inc \theme_spaces_preset_default_form()
  2. 6.2 spaces.theme.inc \theme_spaces_preset_default_form()

Theme function for spaces_preset_default_form().

1 theme call to theme_spaces_preset_default_form()
spaces_preset_default_form in ./spaces_admin.inc
Page callback for generating a list of spaces presets. (admin/build/spaces)

File

./spaces_admin.inc, line 107

Code

function theme_spaces_preset_default_form($form) {
  drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
  $output = '';
  foreach (element_children($form['types']) as $type) {

    // Build table rows
    $rows = array();
    if (!empty($form['types'][$type]['info'])) {
      foreach (element_children($form['types'][$type]['info']) as $preset) {

        // Determine if this preset is enabled
        if ($form['types'][$type]['info'][$preset]['#value']['disabled']) {
          $preset_option = $form['types'][$type]['info'][$preset]['#value']['name'];
          $disabled = TRUE;
        }
        else {
          $preset_option = drupal_render($form['types'][$type]['default'][$preset]);
          $disabled = FALSE;
        }

        // Build table row
        $row = array(
          'data' => array(
            $preset_option,
            $preset,
            $form['types'][$type]['info'][$preset]['#value']['description'],
            $form['types'][$type]['info'][$preset]['#value']['links'],
          ),
          'class' => $disabled ? 'disabled' : '',
        );
        $rows[] = $row;
      }
    }
    $rows[] = array(
      array(
        'data' => "<div class='buttons'>" . l(t('Add preset'), 'admin/build/spaces/presets/add/' . $type, array(
          'attributes' => array(
            'class' => 'button',
          ),
        )) . "</div>",
        'colspan' => 4,
      ),
    );

    // Add type heading and preset table to output
    $output .= "<h3>" . $form['types'][$type]['#title'] . "</h3>";
    $output .= theme('table', array(
      t('Default'),
      t('ID'),
      t('Description'),
      '',
    ), $rows, array(
      'class' => 'spaces-admin',
    ));
  }
  $output .= "<div class='buttons'>";
  $output .= drupal_render($form['submit']) . drupal_render($form['reset']);
  $output .= "</div>";
  $output .= drupal_render($form);
  return $output;
}