function devel_generate_taxonomy_data in Devel 6
Same name and namespace in other branches
- 5 devel_generate.inc \devel_generate_taxonomy_data()
1 call to devel_generate_taxonomy_data()
- devel_generate_taxonomy_form_submit in ./
devel_generate.module - FormAPI submission to generate taxonomy vocabularies and terms.
1 string reference to 'devel_generate_taxonomy_data'
- drush_devel_generate_generate_taxonomy in ./
devel_generate.drush.inc - Command callback. Generate a number of taxonomy.
File
- ./
devel_generate.inc, line 173
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("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),
)));
}
}