You are here

function theme_l10n_update_project_status in Localization update 7

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

Format project update status.

Parameters

$variables: An associative array containing:

  • projects: An array containing all enabled projects.
  • languages: An array of all enabled languages.
  • history: An array of the current translations per project.
  • available: An array of translation sources per project.
  • updates: An array of available translation updates per project. Only recommended translations are listed.

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 281
Admin settings and update page.

Code

function theme_l10n_update_project_status($variables) {
  $header = $rows = array();

  // Get module and theme data for the project title.
  $projects = system_rebuild_module_data();
  $projects += system_rebuild_theme_data();
  foreach ($variables['projects'] as $name => $project) {
    if (isset($variables['history'][$name])) {
      if (isset($variables['updates'][$name])) {
        $project_status = 'updatable';
        $project_class = 'warning';
      }
      else {
        $project_status = 'uptodate';
        $project_class = 'ok';
      }
    }
    elseif (isset($variables['available'][$name])) {
      $project_status = 'available';
      $project_class = 'warning';
    }
    else {

      // Remote information not checked
      $project_status = 'unknown';
      $project_class = 'unknown';
    }

    // Get the project title and module version.
    $project->title = isset($projects[$name]->info['name']) ? $projects[$name]->info['name'] : '';
    $project->module_version = isset($projects[$name]->info['version']) ? $projects[$name]->info['version'] : $project->version;

    // Project with related language states.
    $row = theme('l10n_update_single_project_wrapper', array(
      'project' => $project,
      'project_status' => $project_status,
      'languages' => $variables['languages'],
      'available' => $variables['available'],
      'history' => $variables['history'],
      'updates' => $variables['updates'],
    ));
    $rows[$project->project_type][] = array(
      'data' => array(
        array(
          'data' => $row,
          'class' => 'l10n-update-wrapper collapsed',
        ),
      ),
      'class' => array(
        $project_class,
      ),
    );
  }

  // Build tables of update states grouped by project type. Similar to the
  // status report by the Update module.
  $output = '';
  $project_types = array(
    'core' => t('Drupal core'),
    'module' => t('Modules'),
    'theme' => t('Themes'),
    'module-disabled' => t('Disabled modules'),
    'theme-disabled' => t('Disabled themes'),
  );
  foreach ($project_types as $type_name => $type_label) {
    if (!empty($rows[$type_name])) {
      ksort($rows[$type_name]);
      $output .= "\n<h3>" . $type_label . "</h3>\n";
      $output .= theme('table', array(
        'header' => $header,
        'rows' => $rows[$type_name],
        'attributes' => array(
          'class' => array(
            'update l10n-update',
          ),
        ),
      ));
    }
  }

  // We use the core update module CSS to re-use the color definitions.
  // Plus add our own css and js.
  drupal_add_css(drupal_get_path('module', 'update') . '/update.css');
  drupal_add_css(drupal_get_path('module', 'l10n_update') . '/css/l10n_update.admin.css');
  drupal_add_js('misc/collapse.js');
  drupal_add_js(drupal_get_path('module', 'l10n_update') . '/js/l10n_update.js');
  return $output;
}