You are here

function _lingotek_notification_handle_target_or_phase in Lingotek Translation 7.7

1 call to _lingotek_notification_handle_target_or_phase()
lingotek_notifications in ./lingotek.sync.inc
Registers the site translation notfication callback.

File

./lingotek.sync.inc, line 94
Sync and management

Code

function _lingotek_notification_handle_target_or_phase($trans_obj, $document_id) {
  $locale = "";
  if (isset($_GET['locale'])) {
    $locale = $_GET['locale'];

    // Project Callbacks
  }
  else {
    if (isset($_GET['target_code'])) {
      $locale = $_GET['target_code'];

      // Integration Callback
    }
  }
  $completed = false;
  if (isset($_GET['complete']) && $_GET['complete'] != 'false' || isset($_GET['completed']) && $_GET['completed'] != 'false') {
    $completed = true;
  }
  $project_id = isset($_GET['project_id']) ? $_GET['project_id'] : "";
  $trans_obj
    ->preDownload($locale, $completed);
  $replacements = array(
    '@trans_type' => get_class($trans_obj),
    '@document' => $document_id,
    '@language_code' => $locale,
    '@project_id' => $project_id,
    '@id' => $trans_obj
      ->getId(),
  );
  if ($trans_obj
    ->downloadTriggered($locale)) {
    LingotekLog::trace('Updated local content for <strong>@trans_type</strong> @id based on hit
          from external API for document: @document, language code @language_code, project ID: @project_id', $replacements, 'api');
  }
  else {
    LingotekLog::trace('Unable to update local content for <strong>@trans_type</strong> @id based on hit
          from external API for document: @document, language code @language_code, project ID: @project_id', $replacements, 'api');
  }
  $trans_obj
    ->setStatus(LingotekSync::STATUS_CURRENT);
  $trans_obj
    ->postDownload($locale, $completed);
}