function lingotek_sync_batch_create in Lingotek Translation 7.2
Same name and namespace in other branches
- 7.7 lingotek.batch.inc \lingotek_sync_batch_create()
- 7.3 lingotek.batch.inc \lingotek_sync_batch_create()
- 7.4 lingotek.batch.inc \lingotek_sync_batch_create()
- 7.5 lingotek.batch.inc \lingotek_sync_batch_create()
- 7.6 lingotek.batch.inc \lingotek_sync_batch_create()
Batch Create - Sync: Uploads new and changed documents for translation and Downloads translated documents.
Creates the batch operations array. Downloads first, then uploads.
File
- ./
lingotek.batch.inc, line 71
Code
function lingotek_sync_batch_create($upload = true, $download = true, $download_locales = array(), $upload_et = false, $download_incomplete = false) {
// Grab the Nodes that need to be Downloaded & Uploaded. These are batch operation arrays.
$download_commands = $download ? lingotek_get_sync_download_batch_elements($download_locales, $download_incomplete) : array();
$upload_commands = $upload ? lingotek_get_sync_upload_batch_elements($upload_et) : array();
// Important: Until we add the call to get target statuses, and can work off that, do the upload SECOND. (so we dont try to download what we just uploaded.)
$operations = array();
$operations[] = array(
'lingotek_mt_sync_set_status',
array(
'set',
),
);
$operations = array_merge($operations, $download_commands, $upload_commands);
$operations[] = array(
'lingotek_mt_sync_set_status',
array(
'clear',
),
);
// Where to send the user after the batch has processed. If redirect_url GET param exists, then use it
$redirect = isset($_GET['redirect_url']) && strlen($_GET['redirect_url']) ? $_GET['redirect_url'] : LINGOTEK_BASE_URL;
if (count($operations) > 0) {
// Note, the first step of the batch process sets a session variable that tracks that we are in a sync state.
// The Node update hook uses that so it knows NOT to reupload the content we just recieved.
// The last step of the sync process clears the sync flag. $_SESSION['lingotek_sync_in_progress']
// As a backup (in case there is an error and the batch doesnt complete successfully) there is a backup on the lingotek_dashboard() that clears the sync status flag.
$batch = array(
'title' => t('Syncing Content Translations with Lingotek'),
'operations' => $operations,
'file' => 'lingotek.batch.inc',
);
batch_set($batch);
batch_process($redirect);
// Needed if not inside a form _submit handler. Setting redirect in batch_process.
}
else {
$options = strpos($redirect, '//') !== FALSE ? array(
'external' => TRUE,
) : array();
drupal_goto($redirect, $options);
}
}