You are here

function lingotek_sync_download_config_target in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.batch.inc \lingotek_sync_download_config_target()
1 string reference to 'lingotek_sync_download_config_target'
lingotek_get_sync_download_batch_elements in ./lingotek.batch.inc
Sync - Download Batch Elements: Creates the batch elements for nodes/documents that need to be downloaded.

File

./lingotek.batch.inc, line 330
Central location for batch create functions, before control is handed off to individual batch command files.

Code

function lingotek_sync_download_config_target($set_id, $lingotek_locale, $sync_success_status, &$context) {
  if ($context) {
    $context['message'] = t('Downloading "@locale" translation for configuration set #@set_id', array(
      '@locale' => $lingotek_locale,
      '@set_id' => $set_id,
    ));
  }
  LingotekLog::trace('download chunk: @set_id (@language)', array(
    '@set_id' => $set_id,
    '@language' => $lingotek_locale,
  ));
  $config_set = LingotekConfigSet::loadById($set_id);
  if ($config_set) {
    $result = $config_set
      ->downloadTriggered($lingotek_locale);
  }
  if ($result) {
    $context['results']['downloads'] = isset($context['results']['downloads']) && is_numeric($context['results']['downloads']) ? $context['results']['downloads'] + 1 : 1;
    if (!isset($context['results']['downloaded_chunk_targets']) || !is_array($context['results']['downloaded_chunk_targets'])) {
      $context['results']['downloaded_chunk_targets'] = array();
    }
    $context['results']['downloaded_chunk_targets'][] = array(
      "cid" => $set_id,
      "locale" => $lingotek_locale,
    );
  }
  else {
    $context['results']['download_fails'] = isset($context['results']['download_fails']) && is_numeric($context['results']['download_fails']) ? $context['results']['download_fails'] + 1 : 1;
    if (!isset($context['results']['download_fail_chunk_targets']) || !is_array($context['results']['download_fail_chunk_targets'])) {
      $context['results']['download_fail_chunk_targets'] = array();
    }
    $context['results']['download_fail_chunk_targets'][] = array(
      "cid" => $set_id,
      "locale" => $lingotek_locale,
    );
  }
}