You are here

function devel_generate_vocabs in Devel 5

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

File

./devel_generate.inc, line 159

Code

function devel_generate_vocabs($records, $maxlength = 12, $types = array(
  'story',
  'blog',
  'forum',
  'page',
)) {
  $vocs = array();

  // Insert new data:
  for ($i = 1; $i <= $records; $i++) {
    $voc = array();
    $voc['name'] = devel_generate_word(rand(2, $maxlength));
    $voc['description'] = "description of " . $voc['name'];
    $voc['nodes'] = array_flip(array(
      $types[array_rand($types)],
    ));
    foreach ($voc['nodes'] as $key => $value) {
      $voc['nodes'][$key] = $key;
    }
    $voc['multiple'] = 1;
    $voc['required'] = 0;
    $voc['relations'] = 1;
    $voc['hierarchy'] = 1;
    $voc['weight'] = rand(0, 10);
    taxonomy_save_vocabulary($voc);
    $vocs[] = $voc['name'];
  }
  return $vocs;
}