You are here

function _background_batch_page_progress_js in Background Process 6

Same name and namespace in other branches
  1. 7.2 background_batch/background_batch.pages.inc \_background_batch_page_progress_js()
  2. 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 193
Pages for background batch.

Code

function _background_batch_page_progress_js() {
  $batch = batch_get();

  // The first batch set gets to set the page title
  // and the initialization and error messages.
  $current_set = _batch_current_set();
  drupal_set_title($current_set['title']);
  drupal_add_js('misc/progress.js', 'core', 'header', FALSE, FALSE);
  $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'], array(
    'query' => array(
      'id' => $batch['id'],
    ),
  ));
  $js_setting['batch']['delay'] = variable_get('background_batch_delay', BACKGROUND_BATCH_DELAY);
  drupal_add_js($js_setting, 'setting');
  drupal_add_js(drupal_get_path('module', 'background_batch') . '/js/progress.js', 'module', 'header', FALSE, FALSE);
  drupal_add_js(drupal_get_path('module', 'background_batch') . '/js/batch.js', 'module', 'header', FALSE, FALSE);
  $output = '<div id="progress"></div>';
  return $output;
}