You are here

function devel_generate_content in Devel 6

Same name and namespace in other branches
  1. 5 devel_generate.inc \devel_generate_content()
  2. 7 devel_generate/devel_generate.inc \devel_generate_content()

The main API function for creating content.

See devel_generate_content_form() for the supported keys in $form_state['values']. Other modules may participate by form_alter() on that form and then handling their data during hook_nodeapi('pre_save') or in own submit handler for the form.

Parameters

string $form_state:

Return value

void

1 call to devel_generate_content()
devel_generate_content_form_submit in ./devel_generate.module
FormAPI submission to generate nodes.
1 string reference to 'devel_generate_content'
drush_devel_generate_generate_content in ./devel_generate.drush.inc
Command callback. Generate a number of content.

File

./devel_generate.inc, line 50

Code

function devel_generate_content($form_state) {

  // Set defaults.
  $form_state['values'] += array(
    'time_range' => 0,
    'add_alias' => FALSE,
    'add_statistics' => FALSE,
  );
  if ($form_state['values']['kill_content']) {
    devel_generate_content_kill($form_state['values']);
  }
  if (count($form_state['values']['node_types'])) {

    // Generate nodes.
    devel_generate_content_pre_node($form_state['values']);
    for ($i = 1; $i <= $form_state['values']['num_nodes']; $i++) {
      devel_generate_content_add_node($form_state['values']);
    }
  }
  drupal_set_message(format_plural($form_state['values']['num_nodes'], '1 node created.', '@count nodes created'));
}