function _background_batch_page_do_nojs in Background Process 6
Same name and namespace in other branches
- 7.2 background_batch/background_batch.pages.inc \_background_batch_page_do_nojs()
- 7 background_batch/background_batch.pages.inc \_background_batch_page_do_nojs()
Output a batch processing page without JavaScript support.
See also
2 calls to _background_batch_page_do_nojs()
- _background_batch_page in background_batch/
background_batch.pages.inc - State-based dispatcher for the batch processing page.
- _background_batch_page_start in background_batch/
background_batch.pages.inc
File
- background_batch/
background_batch.pages.inc, line 276 - Pages for background batch.
Code
function _background_batch_page_do_nojs() {
$batch =& batch_get();
$id = $batch['id'];
_background_batch_initiate();
$current_set = _batch_current_set();
drupal_set_title($current_set['title']);
$new_op = 'do_nojs';
// This is one of the later requests: do some processing first.
// Error handling: if PHP dies due to a fatal error (e.g. non-existant
// function), it will output whatever is in the output buffer,
// followed by the error message.
ob_start();
$fallback = $current_set['error_message'] . '<br/>' . $batch['error_message'];
drupal_maintenance_theme();
$fallback = theme('maintenance_page', $fallback, FALSE, FALSE);
// We strip the end of the page using a marker in the template, so any
// additional HTML output by PHP shows up inside the page rather than
// below it. While this causes invalid HTML, the same would be true if
// we didn't, as content is not allowed to appear after </html> anyway.
list($fallback) = explode('<!--partial-->', $fallback);
print $fallback;
$percentage = t('N/A');
$message = '';
// Get progress
if ($progress = progress_get_progress('_background_batch:' . $id)) {
$percentage = $progress->progress * 100;
$message = $progress->message;
progress_estimate_completion($progress);
// Check wether ETA information should be shown.
if (variable_get('background_batch_show_eta', BACKGROUND_BATCH_PROCESS_ETA)) {
$message = "ETA: " . ($progress->estimate ? format_date((int) $progress->estimate, 'large') : t('N/A')) . "<br/>{$message}";
}
}
if (count($batch['sets'][$batch['current_set']]['operations']) == 0) {
// The background process has self-destructed, and the batch job is done.
$percentage = 100;
$message = '';
}
elseif ($process = background_process_get_process('background_batch:' . $id)) {
_background_batch_initiate($process);
}
else {
// Not running ... and stale?
_background_batch_initiate();
}
if ($percentage == 100) {
$new_op = 'finished';
}
// PHP did not die : remove the fallback output.
ob_end_clean();
$url = url($batch['url'], array(
'query' => array(
'id' => $batch['id'],
'op' => $new_op,
),
));
drupal_set_html_head('<meta http-equiv="Refresh" content="0; URL=' . $url . '">');
$output = theme('progress_bar', sprintf("%.02f", $percentage), $message);
return $output;
}