You are here

function lingotek_grid_query_status in Lingotek Translation 7.7

1 string reference to 'lingotek_grid_query_status'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.bulk_grid.inc, line 1165

Code

function lingotek_grid_query_status($entity_type, $comma_separated_ids = '') {
  if (strlen($comma_separated_ids) == 0) {
    return;
  }
  $ids = explode(',', $comma_separated_ids);
  $information = array();
  foreach ($ids as $id) {
    $source_status = LingotekSync::getUploadStatus($entity_type, $id);
    $target_statuses = LingotekSync::getAllTargetStatusForEntity($entity_type, $id);
    $profile = LingotekSync::getProfileByEntityId($entity_type, $id);
    $last_sync_error = LingotekSync::getLastSyncError($entity_type, $id);
    $existing_translations = lingotek_get_languages($entity_type, $id);
    $existing_translations_converted = array();
    foreach ($existing_translations as $language) {
      $locale = Lingotek::convertDrupal2Lingotek($language);
      $existing_translations_converted[] = $locale;
    }
    $information[$id] = $target_statuses;
    $information[$id]['existing_translations'] = $existing_translations_converted;
    $information[$id]['source_status'] = $source_status;
    $information[$id]['profile'] = $profile;
    if ($last_sync_error) {
      $information[$id]['last_upload_error'] = $last_sync_error;
    }
    if ($entity_type === 'node') {
      $query = db_select('node', 'n')
        ->fields('n', array(
        'changed',
      ))
        ->condition('n.nid', $id);
      $timestamp = $query
        ->execute()
        ->fetch();
      $information[$id]['last_modified'] = lingotek_human_readable_timestamp($timestamp->changed) . ' ago';
    }
  }
  echo json_encode($information);
}