You are here

function _l10n_update_prepare_updates in Localization update 7

Same name and namespace in other branches
  1. 6 l10n_update.check.inc \_l10n_update_prepare_updates()

Prepare update list.

Parameters

$updates: Array of update sources that may be indexed in multiple ways.

$projects: Array of project names to be included, others will be filtered out.

$languages: Array of language codes to be included, others will be filtered out.

Return value

array Plain array of filtered updates with directory applied.

4 calls to _l10n_update_prepare_updates()
drush_l10n_update in ./l10n_update.drush.inc
Callback for command l10n-update.
l10n_update_admin_import_form_submit in ./l10n_update.admin.inc
Submit handler for Update form.
l10n_update_language_refresh in ./l10n_update.check.inc
Language refresh. Runs a batch for loading the selected languages.
l10n_update_project_refresh in ./l10n_update.project.inc
Refresh projects after enabling modules

File

./l10n_update.check.inc, line 450
Reusable API for l10n remote updates using $source objects

Code

function _l10n_update_prepare_updates($updates, $projects = NULL, $languages = NULL) {
  $result = array();
  foreach ($updates as $key => $update) {
    if (is_array($update)) {

      // It is a sub array of updates yet, process and merge
      $result = array_merge($result, _l10n_update_prepare_updates($update, $projects, $languages));
    }
    elseif ((!$projects || in_array($update->project, $projects)) && (!$languages || in_array($update->language, $languages))) {
      $directory = variable_get('l10n_update_download_store', '');
      if ($directory && empty($update->uri)) {

        // If we have a destination folder set just if we have no uri
        if (empty($update->uri)) {
          $update->uri = $directory . '/' . $update->filename;
          $update->keep = TRUE;
        }
      }
      $result[] = $update;
    }
  }
  return $result;
}