You are here

function lingotek_get_target_status in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.2 lingotek.dashboard.inc \lingotek_get_target_status()
  2. 7.3 lingotek.dashboard.inc \lingotek_get_target_status()

Get the status of the target given by locale

2 calls to lingotek_get_target_status()
lingotek_dashboard_command_ajax in ./lingotek.dashboard.inc
Ajax Command Processing for the Lingotek dashboard.
lingotek_get_dashboard_code in ./lingotek.dashboard.inc
Generates the code for the embedded Javascript dashboard.

File

./lingotek.dashboard.inc, line 311
Lingotek Dashboard.

Code

function lingotek_get_target_status($lingotek_locale_requested = NULL) {
  $response = array();
  $target_languages = Lingotek::availableLanguageTargets(NULL, FALSE);

  // print("locale: ".$lingotek_locale."\n"); print("count: ".  implode(', ',array_keys($target_languages)).' ['.count($target_languages)."]\n");
  // If we get a parameter, only return that language.  Otherwise return all the codes (dont return the source language).
  // Otherwise Return a List of all the Active Languages
  foreach ($target_languages as $target) {
    if (!is_null($lingotek_locale_requested) && $lingotek_locale_requested != $target->lingotek_locale) {
      continue;
    }
    $drupal_language_code = $target->language;
    $lingotek_locale = $target->lingotek_locale;
    $edited = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_EDITED, $lingotek_locale);
    $pending = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_PENDING, $lingotek_locale);
    $ready = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_READY, $lingotek_locale);
    $current = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_CURRENT, $lingotek_locale);
    $total = $edited + $pending + $ready + $current;
    $target_status = array(
      'code' => $lingotek_locale,
      // Return this language code as the Lingotek language code.
      'dcode' => $drupal_language_code,
      'active' => intval($target->lingotek_enabled),
      //lingotek_enabled,
      'enabled' => intval($target->enabled),
      // drupal enabled
      'docs' => $total,
      'pending' => $pending,
      'ready' => $ready,
      'edited' => $edited,
      'current' => $current,
    );
    if ($lingotek_locale_requested == $target->lingotek_locale) {
      $response = $target_status;
    }
    else {
      $response[] = $target_status;
    }
  }
  return $response;
}