You are here

public static function LingotekSync::insertTargetEntriesForAllNodes in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.4 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::insertTargetEntriesForAllNodes()
1 call to LingotekSync::insertTargetEntriesForAllNodes()
LingotekSync::insertTargetEntriesForAllDocs in lib/Drupal/lingotek/LingotekSync.php

File

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

Class

LingotekSync
A utility class for Lingotek Syncing.

Code

public static function insertTargetEntriesForAllNodes($lingotek_locale) {

  // select all nids where the node's source is the locale provided
  $drupal_language_code = Lingotek::convertLingotek2Drupal($lingotek_locale);
  $subquery = db_select('node', 'n')
    ->fields('n', array(
    'nid',
  ));
  $subquery
    ->condition('language', $drupal_language_code);
  $query = db_select('lingotek', 'l')
    ->fields('l');
  $query
    ->condition('lingokey', 'node_sync_status');
  $query
    ->condition('nid', $subquery, 'NOT IN');

  // exclude adding to nodes where this locale is the source
  $result = $query
    ->execute();
  while ($record = $result
    ->fetchAssoc()) {
    $node_id = $record['nid'];

    // If the Node is CURRENT or PENDING, then we just need to pull down the new translation (because the source will have been uploaded), so set the Node and Target to PENDING.
    if ($record['lingovalue'] == self::STATUS_CURRENT) {
      self::setTargetStatus($node_id, $lingotek_locale, self::STATUS_PENDING);
    }
    else {

      // Otherwise, set it to EDITED
      self::setNodeStatus($node_id, self::STATUS_EDITED);
      self::setTargetStatus($node_id, $lingotek_locale, self::STATUS_EDITED);
    }
  }
}