function _background_batch_page_progress_js in Background Process 7.2
Same name and namespace in other branches
- 6 background_batch/background_batch.pages.inc \_background_batch_page_progress_js()
- 7 background_batch/background_batch.pages.inc \_background_batch_page_progress_js()
Batch processing page with JavaScript support.
1 call to _background_batch_page_progress_js()
- _background_batch_page_start in background_batch/
background_batch.pages.inc
File
- background_batch/
background_batch.pages.inc, line 163 - Pages for background batch.
Code
function _background_batch_page_progress_js() {
require_once 'includes/batch.inc';
$batch = batch_get();
$id = $batch['id'];
$delay = variable_get('background_batch_delay', BACKGROUND_BATCH_DELAY) * 1000000;
$handle = 'background_batch:' . $id;
$process = BackgroundProcess::loadByHandle($handle);
if ($process && $process
->getDispatcher() == 'foreground') {
drupal_set_message(t('Batch is using the "foreground" dispatcher. If you leave this page, the batch processing will stop/pause.'), 'warning');
$delay = 1;
}
$current_set = _batch_current_set();
drupal_set_title($current_set['title'], PASS_THROUGH);
// Merge required query parameters for batch processing into those provided by
// batch_set() or hook_batch_alter().
$batch['url_options']['query']['id'] = $batch['id'];
$js_setting['batch'] = array();
$js_setting['batch']['errorMessage'] = $current_set['error_message'] . '<br />' . $batch['error_message'];
// Check wether ETA information should be shown.
if (variable_get('background_batch_show_eta', BACKGROUND_BATCH_PROCESS_ETA)) {
$js_setting['batch']['initMessage'] = 'ETA: ' . t('N/A') . '<br/>' . $current_set['init_message'];
}
else {
$js_setting['batch']['initMessage'] = $current_set['init_message'];
}
$js_setting['batch']['uri'] = url($batch['url'], $batch['url_options']);
$js_setting['batch']['delay'] = variable_get('background_batch_delay', BACKGROUND_BATCH_DELAY) * 1000000;
drupal_add_js($js_setting, 'setting');
drupal_add_library('background_batch', 'background-process.batch');
return '<div id="progress"></div>';
}