You are here

function l10n_update_get_projects in Localization update 7.2

Same name and namespace in other branches
  1. 6 l10n_update.module \l10n_update_get_projects()
  2. 7 l10n_update.module \l10n_update_get_projects()

Get array of projects which are available for interface translation.

This project data contains all projects which will be checked for available interface translations.

For full functionality this function depends on Update module. When Update module is enabled the project data will contain the most recent module status; both in enabled status as in version. When Update module is disabled this function will return the last known module state. The status will only be updated once Update module is enabled.

Parameters

array $project_names: Array of names of the projects to get.

Return value

array Array of project data for translation update.

See also

l10n_update_build_projects()

10 calls to l10n_update_get_projects()
l10n_update_batch_fetch_build in ./l10n_update.fetch.inc
Builds a batch to download and import project translations.
l10n_update_batch_status_build in ./l10n_update.compare.inc
Builds a batch to get the status of remote and local translation files.
l10n_update_batch_update_build in ./l10n_update.fetch.inc
Builds a batch to check, download and import project translations.
l10n_update_build_sources in ./l10n_update.translation.inc
Build translation sources.
l10n_update_check_projects_local in ./l10n_update.compare.inc
Check and store the status and timestamp of local po files.

... See full list

1 string reference to 'l10n_update_get_projects'
l10n_update_clear_cache_projects in ./l10n_update.translation.inc
Clears the projects cache.

File

./l10n_update.translation.inc, line 55
Common API for interface translation.

Code

function l10n_update_get_projects($project_names = array()) {
  $projects =& drupal_static(__FUNCTION__, array());
  if (empty($projects)) {

    // Get project data from the database.
    $result = db_query('SELECT name, project_type, core, version, l10n_path as server_pattern, status FROM {l10n_update_project}');

    // https://www.drupal.org/node/1777106 is a follow-up issue to make the check for
    // possible out-of-date project information more robust.
    if ($result
      ->rowCount() == 0) {
      module_load_include('compare.inc', 'l10n_update');

      // At least the core project should be in the database, so we build the
      // data if none are found.
      l10n_update_build_projects();
      $result = db_query('SELECT name, project_type, core, version, l10n_path as server_pattern, status FROM {l10n_update_project}');
    }
    foreach ($result as $project) {
      $projects[$project->name] = $project;
    }
  }

  // Return the requested project names or all projects.
  if ($project_names) {
    return array_intersect_key($projects, drupal_map_assoc($project_names));
  }
  return $projects;
}