You are here

function theme_hosting_site_list in Hostmaster (Aegir) 6

Build the site list form.

File

modules/hosting/site/hosting_site.module, line 700

Code

function theme_hosting_site_list($form) {

  // If there are rows in this form, then $form['site'] contains a list of
  // the title form elements.
  $has_posts = isset($form['site']) && is_array($form['site']);
  $select_header = $has_posts ? theme('table_select_header_cell') : '';
  $header = array(
    $select_header,
    array(
      'data' => t('Site'),
      'field' => 'title',
    ),
    array(
      'data' => t('Profile'),
      'field' => 'profile',
    ),
    array(
      'data' => t('Language'),
      'field' => 'site_language',
    ),
    array(
      'data' => t('Created'),
      'field' => 'created',
      'sort' => 'desc',
    ),
  );
  if (isset($form['platform'])) {
    $header[] = array(
      'data' => t('Platform'),
      'field' => 'platform',
    );
  }
  $output = '';
  $output .= drupal_render($form['options']);
  if ($has_posts) {
    foreach (element_children($form['site']) as $key) {
      $row = array();
      $row[] = drupal_render($form['sites'][$key]);
      $row[] = array(
        'data' => drupal_render($form['site'][$key]),
        'class' => 'hosting-status',
      );
      $row[] = drupal_render($form['profile'][$key]);
      $row[] = drupal_render($form['language'][$key]);
      $row[] = drupal_render($form['created'][$key]);
      if (isset($form['platform'])) {
        $row[] = drupal_render($form['platform'][$key]);
      }
      $rows[] = array(
        'data' => $row,
        'class' => drupal_render($form['site_class'][$key]),
      );
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No sites available.'),
        'colspan' => sizeof($header),
      ),
    );
  }
  $output .= theme('table', $header, $rows, array(
    'class' => 'hosting-table',
  ));
  if ($form['pager']['#value']) {
    $output .= drupal_render($form['pager']);
  }
  $output .= drupal_render($form);
  return $output;
}