You are here

function template_preprocess_spaces_dashboard_admin_form in Spaces 7.3

Same name and namespace in other branches
  1. 7 spaces_dashboard/theme/theme.inc \template_preprocess_spaces_dashboard_admin_form()

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

File

spaces_dashboard/theme/theme.inc, line 6

Code

function template_preprocess_spaces_dashboard_admin_form(&$variables) {
  drupal_add_css(drupal_get_path('module', 'spaces_dashboard') . '/spaces_dashboard.admin.css');
  drupal_add_js(drupal_get_path('module', 'spaces_dashboard') . '/spaces_dashboard.admin.js');
  drupal_add_js('misc/tableselect.js');
  $form =& $variables['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' => array(
            "dashboard-blocks-{$grouping_id}",
          ),
        ),
      );
      $tables[$grouping_id] = array();
      $headers[$grouping_id] = array(
        array(
          'class' => array(
            'select-all',
          ),
        ),
        array(
          'data' => t('Block'),
        ),
      );
    }
    $title = $form[$i]['#title'];
    unset($form[$i]['#title']);
    $row = array(
      array(
        'data' => $form[$i],
      ),
      array(
        'data' => check_plain($title),
      ),
    );
    $tables[$grouping_id][] = $row;
    unset($form[$i]);
  }
  ksort($links);
  ksort($tables);
  ksort($headers);
  $variables['tables'] = '';
  foreach ($tables as $grouping_id => $rows) {
    $variables['tables'] .= theme('table', array(
      'header' => $headers[$grouping_id],
      'rows' => $tables[$grouping_id],
      'attributes' => array(
        'id' => "dashboard-blocks-{$grouping_id}",
      ),
    ));
  }
  $variables['links'] = theme('links', array(
    'links' => $links,
    'attributes' => array(
      'id' => 'dashboard-blocks-links',
    ),
  ));
}