public static function LingotekSync::insertTargetEntriesForAllEntities in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::insertTargetEntriesForAllEntities()
- 7.6 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::insertTargetEntriesForAllEntities()
1 call to LingotekSync::insertTargetEntriesForAllEntities()
- lingotek_set_target_language in ./
lingotek.util.inc - Sets the extended target language locale in the languages table and whether or not it is enabled
File
- lib/
Drupal/ lingotek/ LingotekSync.php, line 218 - LingotekSync
Class
- LingotekSync
- A utility class for Lingotek Syncing.
Code
public static function insertTargetEntriesForAllEntities($lingotek_locale) {
//this prevents a target from being added to the same source
$locale = strtolower(str_replace("_", "-", $lingotek_locale));
$node_source_check = db_select('node', 'n');
$node_source_check
->addField('n', 'nid');
$or = db_or()
->condition('n.tnid', '0')
->where('n.tnid = n.nid');
$node_source_check
->condition($or);
$node_source_check
->condition('n.language', $locale);
$taxonomy_source_check = db_select('taxonomy_term_data', 't');
$taxonomy_source_check
->addField('t', 'tid');
$taxonomy_source_check
->condition('t.language', $locale);
// insert/update a target language for all entities
$query = db_select('lingotek_entity_metadata', 'meta')
->fields('meta', array(
'entity_id',
'entity_type',
))
->condition('meta.entity_key', 'document_id')
->condition('entity_id', $node_source_check, "NOT IN")
->condition('entity_id', $taxonomy_source_check, "NOT IN");
if (module_exists('comment')) {
$comment_source_check = db_select('comment', 'c');
$comment_source_check
->addField('c', 'cid');
$comment_source_check
->condition('c.language', $locale);
$query
->condition('entity_id', $comment_source_check, "NOT IN");
}
if (module_exists('bean') && variable_get('lingotek_translate_beans')) {
$bean_source_check = db_select('bean', 'b');
$bean_source_check
->addField('b', 'bid');
$bean_source_check
->condition('b.language', $locale);
$query
->condition('entity_id', $bean_source_check, "NOT IN");
}
if (module_exists('group') && variable_get('lingotek_translate_groups')) {
$group_source_check = db_select('groups', 'g');
$group_source_check
->addField('g', 'gid');
$group_source_check
->condition('g.language', $locale);
$query
->condition('entity_id', $group_source_check, "NOT IN");
}
if (module_exists('file_entity') && variable_get('lingotek_translate_files')) {
$file_source_check = db_select('file_managed', 'fm');
$file_source_check
->addField('fm', 'fid');
$file_source_check
->condition('fm.language', $locale);
$query
->condition('entity_id', $file_source_check, "NOT IN");
}
$entities = $query
->execute()
->fetchAll();
foreach ($entities as $e) {
self::setTargetStatus($e->entity_type, $e->entity_id, $lingotek_locale, self::STATUS_PENDING);
}
}