You are here

function lingotek_sync_download_node_target in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.4 lingotek.batch.inc \lingotek_sync_download_node_target()

Download Batch Worker Function: Download Translated Node Content

1 call to lingotek_sync_download_node_target()
lingotek_notifications in ./lingotek.sync.inc
Registers the site translation notfication callback.
1 string reference to 'lingotek_sync_download_node_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 418
Central location for batch create functions, before control is handed off to individual batch command files.

Code

function lingotek_sync_download_node_target($nid, $lingotek_locale, $sync_success_status, &$context) {
  LingotekLog::trace('download node: @node_id (@language)', array(
    '@node_id' => $nid,
    '@language' => $lingotek_locale,
  ));
  $node = lingotek_node_load_default($nid);
  lingotek_download_document($node, $lingotek_locale, $sync_success_status);
  cache_clear_all('field:node:' . $nid, 'cache_field');
  $result = TRUE;

  // assume TRUE until the above lingotek_download_document call is updated to return the result
  if ($result) {
    $context['results']['downloads'] = isset($context['results']['downloads']) && is_numeric($context['results']['downloads']) ? $context['results']['downloads'] + 1 : 1;
    if (!isset($context['results']['downloaded_node_targets']) || !is_array($context['results']['downloaded_node_targets'])) {
      $context['results']['downloaded_node_targets'] = array();
    }
    $context['results']['downloaded_node_targets'][] = array(
      "nid" => $nid,
      "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_node_targets']) || !is_array($context['results']['download_fail_node_targets'])) {
      $context['results']['download_fail_node_targets'] = array();
    }
    $context['results']['download_fail_node_targets'][] = array(
      "nid" => $nid,
      "locale" => $lingotek_locale,
    );
  }
}