You are here

function theme_update_status_report in Update Status 5

Same name and namespace in other branches
  1. 5.2 update_status.module \theme_update_status_report()

Theme project status report.

2 theme calls to theme_update_status_report()
update_status_settings in ./update_status.module
Menu callback. Show the settings for the update status module.
update_status_status in ./update_status.module
Menu callback. Generate a page of information about the update status of projects.

File

./update_status.module, line 333

Code

function theme_update_status_report($data) {
  $i = 0;
  $last = variable_get('update_status_last', 0);
  $output = '<p>' . t('Last checked: ') . ($last ? format_date($last) : t('Never'));
  $output .= ' ' . l(t('Check manually'), 'admin/logs/updates/force-check') . '</p>';
  if (!is_array($data)) {
    $output .= '<p>' . $data . '</p>';
    return $output;
  }

  // move 'drupal' to the top
  $data = array(
    'drupal' => $data['drupal'],
  ) + $data;
  $header = array(
    array(
      'data' => t('Project'),
      'class' => 'project',
    ),
    array(
      'data' => t('Status'),
      'class' => 'status',
    ),
    array(
      'data' => t('Current version'),
      'class' => 'current-version',
    ),
    array(
      'data' => t('Available version'),
      'class' => 'available-version',
    ),
    array(
      'data' => t('Download latest version'),
      'class' => 'links',
    ),
  );
  foreach ($data as $project) {

    // This protects us from homegrown projects that either aren't
    // configured properly or don't actually have info on drupal.org
    if (!$project['title']) {
      continue;
    }
    switch ($project['status']) {
      case UPDATE_STATUS_NOT_CURRENT:
        $class = 'error';
        break;
      case UPDATE_STATUS_CURRENT:
        $class = 'ok';
        break;
      default:
        $class = 'unknown';
        break;
    }
    $row1 = array(
      'class' => 'top-row ' . $class,
      'data' => array(),
    );
    $row2 = array(
      'class' => 'bottom-row ' . $class,
      'data' => array(),
    );
    $row1['data'][] = array(
      'class' => 'project',
      'data' => l($project['title'], $project['link']),
    );
    switch ($project['status']) {
      case UPDATE_STATUS_CURRENT:
        $row1['data'][] = t('Up to date');
        break;
      case UPDATE_STATUS_NOT_CURRENT:
        $row1['data'][] = t('Update available');
        break;
      case UPDATE_STATUS_NOT_CHECKED:
        $row1['data'][] = t('Ignored');
        break;
      case UPDATE_STATUS_CANT_CHECK:
        $row1['data'][] = t("Ignored (CVS)");
        break;
      default:
        $row1['data'][] = t('Unknown');
    }
    $row1['data'][] = array(
      'class' => 'current-version',
      'data' => $project['existing_version'],
    );
    $row1['data'][] = array(
      'class' => 'new-version',
      'data' => l($project['version'], $project['release']) . ' (' . format_date($project['date'], 'custom', 'Y-M-d') . ')',
    );
    $links = array();
    $links[] = l($project['download']['title'], $project['download']['href']);
    $row1['data'][] = array(
      'class' => 'links',
      'data' => implode(' | ', $links),
    );
    $row2['data'][] = array(
      'class' => 'info',
      'colspan' => 5,
      'data' => t('Includes: %modules', array(
        '%modules' => implode(', ', $project['modules']),
      )),
    );
    $rows[] = $row1;
    $rows[] = $row2;
  }
  $output .= theme('table', $header, $rows, array(
    'class' => 'update-status',
  ));
  drupal_add_css(drupal_get_path('module', 'update_status') . '/' . 'update_status.css');
  return $output;
}