You are here

function devel_generate_content in Devel 5

Same name and namespace in other branches
  1. 6 devel_generate.inc \devel_generate_content()
  2. 7 devel_generate/devel_generate.inc \devel_generate_content()
1 call to devel_generate_content()
devel_generate_content_form_submit in ./devel_generate.module

File

./devel_generate.inc, line 33

Code

function devel_generate_content($num_nodes, $num_comments, $title_length, $kill, $node_types = array()) {
  if ($kill) {
    $sql = 'SELECT nid FROM {node} WHERE type IN (' . implode(', ', array_fill(0, count($node_types), "'%s'")) . ')';
    $result = db_query($sql, $node_types);
    while ($row = db_fetch_object($result)) {
      node_delete($row->nid);
    }
  }

  // Get user id.
  $users = devel_get_users();

  // Create $num_nodes pseudo-random nodes.
  devel_create_nodes($num_nodes, $users, $title_length, $node_types);
  drupal_set_message(t('%num nodes created.', array(
    '%num' => $num_nodes,
  )));
  $nodes = devel_get_nodes($next_nid);
  $comments = devel_get_comments();
  devel_create_comments($num_comments, $users, $nodes, $comments);
  drupal_set_message(t('%num comments created.', array(
    '%num' => $num_comments,
  )));
}