You are here

public static function LingotekConfigChunk::getSegmentIdsById in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.3 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::getSegmentIdsById()
  2. 7.4 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::getSegmentIdsById()

Return the segments by lid (from locales source) for a given chunk ID

Parameters

int: the ID of a chunk of configuration segments

Return value

array an array of lids from locales_source

File

lib/Drupal/lingotek/LingotekConfigChunk.php, line 170
Defines LingotekConfigChunk.

Class

LingotekConfigChunk
A class wrapper for Lingotek-specific behavior on ConfigChunks.

Code

public static function getSegmentIdsById($chunk_id) {
  $max_length = variable_get('lingotek_config_max_source_length', LINGOTEK_CONFIG_MAX_SOURCE_LENGTH);
  $include_misc_textgroups = FALSE;
  $textgroups_array = self::getTextgroupsForTranslation();
  if (in_array('misc', $textgroups_array)) {
    $include_misc_textgroups = TRUE;
  }
  $textgroups = "-1,'" . implode("','", $textgroups_array) . "'";
  $result = db_query(" SELECT ls.lid\n                        FROM {locales_source} ls\n                        WHERE ls.lid >= :minLid\n                        AND ls.lid <= :maxLid\n                        AND LENGTH(ls.source) < :maxLen\n                        AND (ls.textgroup IN ({$textgroups})\n                        " . $include_misc ? "OR ls.textgroup NOT IN ('default','blocks','taxonomy','menu','views','field'))" : ")", array(
    ':minLid' => self::minLid($chunk_id),
    ':maxLid' => self::maxLid($chunk_id),
    ':maxLen' => $max_length,
  ));
  return $result
    ->fetchCol();
}