function lingotek_node_sync in Lingotek Translation 7.2
Synchronize the node's content with current translations as stored on the Lingotek platform.
Parameters
object $node: A Drupal node object.
1 call to lingotek_node_sync()
- lingotek_node_view in ./
lingotek.module - Implements hook_node_view().
File
- ./
lingotek.util.inc, line 155 - Utility functions.
Code
function lingotek_node_sync(&$node) {
// Keep synchronized?
$sync_method = lingotek_variable_get(lingotek_lingonode($node->nid, 'sync_method'), 'lingotek_sync', 100);
$lingotek_document_id = lingotek_lingonode($node->nid, 'document_id');
lingotek_trace("lingotek_node_sync", array(
"nid" => $node->nid,
'sync_method' => $sync_method,
));
if ($sync_method != "0" && $lingotek_document_id) {
$progress = lingotek_get_document_targets(lingotek_lingonode($node->nid, 'document_id'));
// Check for changes in % complete.
foreach ($progress as $lingotek_locale => $target) {
$key = 'percent_complete_' . $lingotek_locale;
$before = lingotek_lingonode($node->nid, $key);
if ($before == "") {
$before = "0";
}
$after = $target->percentComplete;
if ($sync_method == "1" && $before !== (string) $after || $sync_method == "100" && $after == "100" && $before !== (string) $after) {
lingotek_trace("lingotek_node_sync percent complete changed", array(
'target_locale' => $lingotek_locale,
'nid' => $node->nid,
'percent' => $after,
));
lingotek_lingonode($node->nid, $key, $after);
lingotek_download_document($node, $lingotek_locale);
}
else {
lingotek_trace("lingotek_node_sync percent complete stayed the same", array(
'target_locale' => $lingotek_locale,
'nid' => $node->nid,
'percent' => $after,
));
}
}
}
}