You are here

function theme_spaces_dashboard_admin_form in Spaces 6.3

Theme function to display the dashboar block selector as a table.

1 theme call to theme_spaces_dashboard_admin_form()
spaces_dashboard_admin_form in spaces_dashboard/spaces_dashboard.admin.inc
Provide a form that allows administrators to select which blcoks are available in which dashboards.

File

spaces_dashboard/spaces_dashboard.admin.inc, line 126

Code

function theme_spaces_dashboard_admin_form($form) {
  $links = array();
  $headers = array();
  $tables = array();
  foreach (element_children($form) as $i) {
    $grouping = $form[$i]['#grouping'];
    $grouping_id = $form[$i]['#grouping_id'];
    if (!isset($links[$grouping_id])) {
      $links[$grouping_id] = array(
        'title' => $grouping,
        'href' => '',
        'attributes' => array(
          'class' => "dashboard-blocks-{$grouping_id}",
        ),
      );
      $tables[$grouping_id] = array();
      $headers[$grouping_id] = array(
        theme('table_select_header_cell'),
        t('Block'),
      );
    }
    $row = array();
    $title = $form[$i]['#title'];
    unset($form[$i]['#title']);
    $row[] = drupal_render($form[$i]);
    $row[] = check_plain($title);
    $tables[$grouping_id][] = $row;
  }
  ksort($links);
  ksort($tables);
  ksort($headers);
  foreach ($tables as $grouping_id => $rows) {
    $output .= theme('table', $headers[$grouping_id], $tables[$grouping_id], array(
      'id' => "dashboard-blocks-{$grouping_id}",
    ));
  }
  $output = '<div id="dashboard-form-content"><div class="table-wrapper">' . $output . '</div></div>';
  $output .= '<div id="dashboard-form-links">' . theme('links', $links, array(
    'id' => 'dashboard-blocks-links',
  )) . '</div><div class="clear-block"></div>';
  drupal_add_js(drupal_get_path('module', 'spaces_dashboard') . '/spaces_dashboard.admin.js');
  drupal_add_css(drupal_get_path('module', 'spaces_dashboard') . '/spaces_dashboard.admin.css');
  return $output;
}