You are here

function sheetnode_phpexcel_batch_import in Sheetnode 6

Same name and namespace in other branches
  1. 7.2 modules/sheetnode_phpexcel/sheetnode_phpexcel.module \sheetnode_phpexcel_batch_import()
  2. 7 modules/sheetnode_phpexcel/sheetnode_phpexcel.module \sheetnode_phpexcel_batch_import()

API function to batch import several files using Batch API.

1 call to sheetnode_phpexcel_batch_import()
_sheetnode_phpexcel_import_form_submit in modules/sheetnode_phpexcel/sheetnode_phpexcel.import.inc

File

modules/sheetnode_phpexcel/sheetnode_phpexcel.module, line 84

Code

function sheetnode_phpexcel_batch_import($files, $destination = NULL, $callback = NULL, $params = array(), $batch = array()) {
  $batch += array(
    'finished' => '_sheetnode_phpexcel_batch_import_finished',
    'title' => t('Importing spreadsheets'),
    'init_message' => t('Import process is starting.'),
    'progress_message' => t('Imported @current out of @total files.'),
    'error_message' => t('Import process has encountered an error.'),
    'file' => drupal_get_path('module', 'sheetnode_phpexcel') . '/sheetnode_phpexcel.import.inc',
  );
  foreach ($files as $filename) {
    $batch['operations'][] = array(
      '_sheetnode_phpexcel_batch_import_file',
      array(
        $filename,
        $callback,
        $params,
      ),
    );
  }
  batch_set($batch);
  batch_process($destination);
}