You are here

function devel_generate_taxonomy_data in Devel 5

Same name and namespace in other branches
  1. 6 devel_generate.inc \devel_generate_taxonomy_data()
1 call to devel_generate_taxonomy_data()
devel_generate_taxonomy_form_submit in ./devel_generate.module

File

./devel_generate.inc, line 227

Code

function devel_generate_taxonomy_data($num_vocab, $num_terms, $title_length, $kill) {
  if ($kill) {
    db_query("DELETE FROM {term_data}");
    db_query("DELETE FROM {term_node}");
    db_query("DELETE FROM {term_hierarchy}");
    db_query("DELETE FROM {term_relation}");
    db_query("DELETE FROM {term_synonym}");
    db_query("DELETE FROM {vocabulary}");
    db_query("DELETE FROM {vocabulary_node_types}");
    switch ($GLOBALS['db_type']) {
      case 'mysql':
      case 'mysqli':
        db_query("UPDATE {sequences} SET id = '0' WHERE name = '{vocabulary}_vid'");
        db_query("UPDATE {sequences} SET id = '0' WHERE name = '{term_data}_tid'");
        db_query("ALTER TABLE {vocabulary} AUTO_INCREMENT = 1");
        db_query("ALTER TABLE {term_data} AUTO_INCREMENT = 1");
        break;
      case 'pgsql':
        db_query("SELECT setval('{vocabulary}_vid_seq', 1, false)");
        db_query("SELECT setval('{term_data}_tid_seq', 1, false)");
        break;
    }
    drupal_set_message(t('Deleted taxonomy.'));
  }
  $new_vocs = devel_generate_vocabs($num_vocab, $title_length);
  if (!empty($new_vocs)) {
    drupal_set_message(t('Created the following new vocabularies: !vocs', array(
      '!vocs' => theme('item_list', $new_vocs),
    )));
  }
  $vocs = devel_generate_get_vocabs();
  $new_terms = devel_generate_terms($num_terms, $vocs, $title_length);
  if (!empty($new_terms)) {
    drupal_set_message(t('Created the following new terms: !terms', array(
      '!terms' => theme('item_list', $new_terms),
    )));
  }
}