2 // $Id: devel_generate_batch.inc,v 1.1.2.5 2009/02/02 21:00:52 drewish Exp $
5 * Devel Generate batch handling functions using the BatchAPI
6 * included by devel_generate.module
10 * Functions called from FAPI:
13 function devel_batch_generate_content($form_state) {
14 $operations = array();
16 // Setup the batch operations and save the variables.
17 $operations[] = array('devel_generate_batch_content_pre_node', array($form_state['values']));
19 // add the kill operation
20 if ($form_state['values']['kill_content']) {
21 $operations[] = array('devel_generate_batch_content_kill', array());
24 // add the operations to create the nodes
25 for ($num = 0; $num < $form_state['values']['num_nodes']; $num ++) {
26 $operations[] = array('devel_generate_batch_content_add_node', array());
31 'title' => t('Generating Content'),
32 'operations' => $operations,
33 'finished' => 'devel_generate_batch_finished',
34 'file' => drupal_get_path('module', 'devel_generate') . '/devel_generate_batch.inc',
40 * Create Content Batch Functions:
43 function devel_generate_batch_content_kill(&$context) {
44 require_once('devel_generate.inc');
45 devel_generate_content_kill($context['results']);
48 function devel_generate_batch_content_pre_node($vars, &$context) {
49 $context['results'] = $vars;
50 $context['results']['num_nids'] = 0;
51 require_once('devel_generate.inc');
52 devel_generate_content_pre_node($context['results']);
55 function devel_generate_batch_content_add_node(&$context) {
56 require_once('devel_generate.inc');
57 devel_generate_content_add_node($context['results']);
58 $context['results']['num_nids'] ++;
61 function devel_generate_batch_finished($success, $results, $operations) {
63 $message = t('Finished @num_nids nodes created successfully.', array('@num_nids' => $results['num_nids']));
66 $message = t('Finished with an error.');
68 drupal_set_message($message);