You are here

public static function LingotekSync::getDirtyChunkLids in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.3 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDirtyChunkLids()
  2. 7.4 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDirtyChunkLids()
2 calls to LingotekSync::getDirtyChunkLids()
LingotekSync::getChunkCountByStatus in lib/Drupal/lingotek/LingotekSync.php
LingotekSync::getDirtyConfigChunks in lib/Drupal/lingotek/LingotekSync.php

File

lib/Drupal/lingotek/LingotekSync.php, line 555
LingotekSync

Class

LingotekSync
A utility class for Lingotek Syncing.

Code

public static function getDirtyChunkLids() {

  // return the list of all lids from the locale_source table *not* fully translated
  $source_language = language_default();
  if (!isset($source_language->lingotek_locale)) {
    $source_language->lingotek_locale = Lingotek::convertDrupal2Lingotek($source_language->language);
  }
  $lingotek_codes = Lingotek::getLanguagesWithoutSource($source_language->lingotek_locale);
  if (!count($lingotek_codes)) {
    LingotekLog::error('No languages configured for this Lingotek account.', array());
    return array();
  }

  // get the drupal language for each associated lingotek locale
  $drupal_codes = array();
  foreach ($lingotek_codes as $lc) {
    $drupal_codes[] = Lingotek::convertLingotek2Drupal($lc);
  }

  // get the list of all segments that need updating
  // that belong to the textgroups the user wants translated
  $textgroups = array_merge(array(
    -1,
  ), LingotekConfigChunk::getTextgroupsForTranslation());
  $max_length = variable_get('lingotek_config_max_source_length', LINGOTEK_CONFIG_MAX_SOURCE_LENGTH);
  $query = db_select('{locales_source}', 'ls');
  $query
    ->fields('ls', array(
    'lid',
  ))
    ->condition('ls.source', '', '!=')
    ->condition('ls.lid', self::getQueryCompletedConfigTranslations($drupal_codes), 'NOT IN')
    ->where('length(ls.source) < ' . (int) $max_length);
  if (in_array('misc', $textgroups)) {
    $or = db_or();
    $or
      ->condition('ls.textgroup', $textgroups, 'IN');
    $or
      ->where("ls.textgroup NOT IN ('default','menu','taxonomy','views','blocks','field')");
    $query
      ->condition($or);
  }
  else {
    $query
      ->condition('ls.textgroup', $textgroups, 'IN');
  }
  return $query
    ->execute()
    ->fetchCol();
}