protected static function LingotekConfigSet::getAllSegments in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lib/Drupal/lingotek/LingotekConfigSet.php \LingotekConfigSet::getAllSegments()
Return all segments from the database that belong to a given set ID
Parameters
int $set_id:
Return value
array An array containing the translation sources from the locales_source table
1 call to LingotekConfigSet::getAllSegments()
- LingotekConfigSet::__construct in lib/
Drupal/ lingotek/ LingotekConfigSet.php - Constructor.
File
- lib/
Drupal/ lingotek/ LingotekConfigSet.php, line 420 - Defines LingotekConfigSet.
Class
- LingotekConfigSet
- A class wrapper for Lingotek-specific behavior on ConfigSets.
Code
protected static function getAllSegments($set_id) {
$max_length = variable_get('lingotek_config_max_source_length', LINGOTEK_CONFIG_MAX_SOURCE_LENGTH);
//is this just to make sure there are no enormous config items or is there another reason? How often does this come into play?
$lids = self::getLidsFromSets($set_id);
if (empty($lids)) {
return $lids;
}
$results = db_select('locales_source', 'ls')
->fields('ls', array(
'lid',
'source',
))
->condition('lid', $lids, 'IN')
->orderBy('lid')
->execute();
$response = array();
while ($r = $results
->fetchAssoc()) {
if (strlen($r['source']) < $max_length) {
$response[$r['lid']] = $r['source'];
}
else {
LingotekLog::warning("Config item @id was not sent to Lingotek for translation because it exceeds the max length of 4096 characters.", array(
'@id' => $r['lid'],
));
// Remove it from the set in the config_map table so it doesn't get marked as uploaded or translated.
self::disassociateSegments($r['lid']);
}
}
return $response;
}