You are here

function theme_l10n_update_project_status in Localization update 6

Same name and namespace in other branches
  1. 7 l10n_update.admin.inc \theme_l10n_update_project_status()

Format project update status.

@params array $projects Projects listed. @params array $languages Languages listed. @params array $history Project translation history. @params array $available Available translation releases. @params array $updates Applicable translation updates.

Return value

string HTML output.

1 theme call to theme_l10n_update_project_status()
l10n_update_admin_overview in ./l10n_update.admin.inc
Page callback: Admin overview page.

File

./l10n_update.admin.inc, line 255
Admin settings and update page.

Code

function theme_l10n_update_project_status($projects, $languages, $history, $available, $updates) {

  // We use the core update module CSS
  drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
  $output = '';

  //$header = array(t('Project'), t('Current version'), t('Available update'), '');
  $header = $rows = array();
  foreach ($projects as $name => $project) {
    $row = '<div class="version-status">';
    if (empty($available[$name])) {

      // Remote information not checked
      $status = 'unknown';
      $class = 'unknown';
    }
    elseif (empty($updates[$name])) {

      // No updates available
      $status = 'ok';
      $class = 'ok';
    }
    else {

      // Update available
      $status = 'update';
      $class = 'warning';
    }
    $row = theme('l10n_update_version_status', $status);
    $row .= "<div class=\"project {$class}\">";
    $title = isset($project->title) ? $project->title : $project->name;
    $row .= check_plain($title);
    $row .= ' ' . check_plain(isset($project->info['version']) ? $project->info['version'] : $project->version);
    if ($server = l10n_update_server($project->l10n_server)) {
      $row .= ' ' . l($server['name'], $server['link']);
    }
    $row .= "</div>\n";
    $row .= "<div class=\"versions\">\n";
    $versions = array();
    foreach ($languages as $lang => $language) {
      $current = isset($history[$name][$lang]) ? $history[$name][$lang] : NULL;

      //$installed = isset($history[$name][$lang]) ? $history[$name][$lang] : NULL;
      $update = isset($updates[$name][$lang]) ? $updates[$name][$lang] : NULL;
      if ($update) {
        $status = 'update';
        $class = 'warning';
      }
      elseif ($current) {
        $status = $class = 'ok';
      }
      else {
        $status = $class = 'unknown';
      }
      $version = array(
        array(
          'data' => $language,
          'class' => 'version-title',
        ),
        $current ? theme('l10n_update_release', $current) : '',
        $update ? theme('l10n_update_release', $update) : '',
        theme('l10n_update_version_status', $status, $update ? $update->type : NULL),
      );
      $versions[] = array(
        'data' => $version,
        'class' => $class,
      );
    }
    $row .= theme('table', array(), $versions);
    $row .= "</div>\n";
    $rows[] = array(
      $row,
    );
  }
  $output .= theme('table', $header, $rows, array(
    'class' => 'update',
  ));
  return $output;
}