function lingotek_sync_upload_node in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.4 lingotek.batch.inc \lingotek_sync_upload_node()
Upload Batch Worker Function: Upload Node for Translation
1 string reference to 'lingotek_sync_upload_node'
- lingotek_get_sync_upload_batch_elements in ./
lingotek.batch.inc - Sync - Upload Batch Elements: Creates the batch elements for nodes/documents that need to be uploaded.
File
- ./
lingotek.batch.inc, line 342 - Central location for batch create functions, before control is handed off to individual batch command files.
Code
function lingotek_sync_upload_node($nid, &$context) {
LingotekLog::trace('upload node: @node_id', array(
'@node_id' => $nid,
));
$api = LingotekApi::instance();
$node = lingotek_node_load_default($nid);
// Push this node for translation.
if ($existing_document = lingotek_lingonode($node->nid, 'document_id')) {
// Update an existing Lingotek Document.
$result = $api
->updateContentDocument($node);
}
else {
// Create a new Lingotek Document.
$result = $api
->addContentDocument($node, TRUE);
}
if ($result) {
$context['results']['uploads'] = isset($context['results']['uploads']) && is_numeric($context['results']['uploads']) ? $context['results']['uploads'] + 1 : 1;
if (!isset($context['results']['uploaded_nids']) || !is_array($context['results']['uploaded_nids'])) {
$context['results']['uploaded_nids'] = array();
}
$context['results']['uploaded_nids'][] = $nid;
}
else {
$context['results']['upload_fails'] = isset($context['results']['upload_fails']) && is_numeric($context['results']['upload_fails']) ? $context['results']['upload_fails'] + 1 : 1;
if (!isset($context['results']['upload_fail_nids']) || !is_array($context['results']['upload_fail_nids'])) {
$context['results']['upload_fail_nids'] = array();
}
$context['results']['upload_fail_nids'][] = $nid;
}
//$context['results'][] = t('Uploaded: Node #@nid', array('@nid' => $nid));
}