/** * Get all lids marked as current or not, in the lingotek_config_map table * * @param int $current * 1 to get lids of all current segments, 0 to get lids for segments that are not current * @param array $lids * a subset of lids to check, defaults to look for all current segments */ public static function getLidsToUpdate($current = 0, $lids = 'all') { $textgroups = array_merge(array(-1), LingotekConfigSet::getTextgroupsForTranslation()); $query = db_select('lingotek_config_map', 'lcm')->fields('lcm', array('lid')); if ($lids !== 'all') { $query->condition('lcm.lid', $lids, 'IN'); } $query->join('locales_source', 'ls', "lcm.lid = ls.lid"); $query->condition('ls.textgroup', $textgroups, 'IN'); $query->join('locales_target', 'lt', "lcm.lid = lt.lid"); $or = db_or(); $or->condition('lcm.current', $current); $or->condition('lt.i18n_status', 1); $query->condition($or); $lids = $query->execute()->fetchCol(); return array_unique($lids); }
public static function getDirtySetLids() { // 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), LingotekConfigSet::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(); }