You are here

function theme_update_status_settings in Update Status 5.2

Same name and namespace in other branches
  1. 5 update_status.module \theme_update_status_settings()

File

./update_status.module, line 261

Code

function theme_update_status_settings($form) {
  if (isset($form['error'])) {
    return drupal_render($form);
  }
  $output = '';
  $output .= drupal_render($form['notify_emails']);
  $output .= drupal_render($form['check_frequency']);
  $output .= drupal_render($form['notification_threshold']);
  $output .= drupal_render($form['update_status_check_disabled']);
  $header = array(
    array(
      'data' => t('Project'),
      'class' => 'update-status-project',
    ),
    array(
      'data' => t('Warn if out of date'),
      'class' => 'update-status-status',
    ),
    array(
      'data' => t('Notes'),
      'class' => 'update-status-notes',
    ),
  );
  $data = $form['data']['#value'];
  $available = $form['avail']['#value'];
  $rows = array();
  foreach ($data as $key => $project) {
    if (isset($available[$key])) {
      $row = array();
      $row[] = array(
        'class' => 'update-status-project',
        'data' => check_plain($available[$key]['title']),
      );
      $row[] = array(
        'class' => 'update-status-status',
        'data' => drupal_render($form['projects'][$key]['check']),
      );
      $row[] = array(
        'class' => 'update-status-notes',
        'data' => drupal_render($form['projects'][$key]['notes']),
      );
      if (!isset($rows[$project['project_type']])) {
        $rows[$project['project_type']] = array();
      }
      $row_key = drupal_strtolower($available[$key]['title']);
      $rows[$project['project_type']][$row_key] = $row;
    }
  }
  $split_rows = array();
  $project_types = array(
    'core' => t('Drupal core'),
    'module' => t('Modules'),
    'disabled-module' => t('Disabled modules'),
  );
  foreach ($project_types as $type_name => $type_label) {
    if (!empty($rows[$type_name])) {
      $split_rows[] = array(
        'class' => 'update-status-settings-label',
        'data' => array(
          array(
            'class' => 'update-status-settings-label',
            'data' => $type_label,
            'colspan' => 3,
          ),
        ),
      );
      ksort($rows[$type_name]);
      $split_rows = array_merge($split_rows, $rows[$type_name]);
    }
  }
  $output .= theme('table', $header, $split_rows, array(
    'class' => 'update-status-settings',
  ));
  $output .= '<div class="form-item"><div class="description">';
  $output .= drupal_render($form['project_help']);
  $output .= '</div></div>';
  $output .= drupal_render($form);
  return $output;
}