function lingotek_grid_download_ready in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.bulk_grid.inc \lingotek_grid_download_ready()
- 7.4 lingotek.bulk_grid.inc \lingotek_grid_download_ready()
- 7.5 lingotek.bulk_grid.inc \lingotek_grid_download_ready()
1 string reference to 'lingotek_grid_download_ready'
- lingotek_menu in ./
lingotek.module - Implements hook_menu().
File
- ./
lingotek.bulk_grid.inc, line 835
Code
function lingotek_grid_download_ready($entity_type) {
if ($entity_type === 'config') {
// Looks clean but actually gets set_ids, convert those to lids, then the next function converts back to set_ids.
$lids = LingotekConfigSet::getLidsByStatus(LingotekSync::STATUS_READY);
lingotek_config_download_selected('download_all', $lids);
return;
}
$targets = LingotekSync::getTargetsByStatus($entity_type, LingotekSync::STATUS_READY);
if (!empty($targets)) {
$entity_ids = array();
foreach ($targets as $target) {
$entity_ids[] = $target['id'];
}
$entities = entity_load($entity_type, $entity_ids);
$operations = array();
foreach ($targets as $target) {
if ($entities[$target['id']]->lingotek['profile'] != LingotekSync::PROFILE_DISABLED) {
// exclude nodes with PROFILE_DISABLED
$operations[] = array(
'lingotek_entity_download',
array(
$target['id'],
$entity_type,
$target['locale'],
),
);
}
}
$redirect = 'admin/settings/lingotek/manage/' . $entity_type;
$batch = array(
'title' => t('Downloading Translations'),
'finished' => 'lingotek_sync_download_target_finished',
);
$batch['operations'] = $operations;
batch_set($batch);
batch_process($redirect);
}
else {
drupal_set_message(t('There are no translations ready for download.'));
drupal_goto('admin/settings/lingotek/manage/' . $entity_type);
}
}