You are here

function devel_generate_content_form in Devel 5

Same name and namespace in other branches
  1. 6 devel_generate.module \devel_generate_content_form()
  2. 7 devel_generate/devel_generate.module \devel_generate_content_form()
1 string reference to 'devel_generate_content_form'
devel_generate_menu in ./devel_generate.module
Implementation of hook_menu().

File

./devel_generate.module, line 80

Code

function devel_generate_content_form() {
  if (module_exists('content')) {
    $types = content_types();
    $warn = '';
    foreach ($types as $type) {
      if (count($type['fields'])) {
        $warn = t('. <strong>Warning</strong>. This type contains CCK fields which won\'t be populated. See !url', array(
          '!url' => l(t('this CCK issue.'), 'http://drupal.org/node/187599'),
        ));
      }
      $options[$type['type']] = t($type['name']) . $warn;
      unset($warn);
    }
  }
  else {
    $types = node_get_types();
    foreach ($types as $type) {
      $options[$type->type] = t($type->name);
    }
  }

  // we cannot currently generate valid polls.
  unset($options['poll']);
  $form['node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which node types do you want to create?'),
    '#options' => $options,
    '#default_value' => array_keys($options),
  );
  $form['kill_content'] = array(
    '#type' => 'checkbox',
    '#title' => t('<strong>Delete existing content</strong> before generating new content.'),
    '#default_value' => FALSE,
  );
  $form['num_nodes'] = array(
    '#type' => 'textfield',
    '#title' => t('How many nodes would you like to generate?'),
    '#default_value' => 50,
    '#size' => 10,
  );
  $form['num_comments'] = array(
    '#type' => 'textfield',
    '#title' => t('How many comments would you like to generate?'),
    '#default_value' => 0,
    '#size' => 10,
  );
  $form['title_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Max word length of titles'),
    '#default_value' => 8,
    '#size' => 10,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Do it!'),
  );
  return $form;
}