taxonomy.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Taxonomy module integration.
  5. */
  6. /**
  7. * Implements hook_custom_formatters_devel_generate_info() on behalf of
  8. * taxonomy.module.
  9. */
  10. function taxonomy_custom_formatters_devel_generate_info() {
  11. return array(
  12. 'taxonomy_term' => array(
  13. 'process callback' => 'custom_formatters_taxonomy_term_devel_generate_process',
  14. ),
  15. );
  16. }
  17. /**
  18. * Process callback for Taxonomy term Devel Generate integration.
  19. */
  20. function custom_formatters_taxonomy_term_devel_generate_process($form_state) {
  21. module_load_include('inc', 'devel_generate', 'devel_generate');
  22. $vocab = taxonomy_vocabulary_machine_name_load($form_state['values']['preview']['bundle']);
  23. $object = new stdClass();
  24. $object->tid = mt_rand(1, 100);
  25. $object->vid = $vocab->vid;
  26. $object->name = devel_generate_word(mt_rand(2, 12));
  27. $object->description = "description of {$object->name}";
  28. $object->format = filter_fallback_format();
  29. $object->weight = mt_rand(0, 10);
  30. $object->vocabulary_machine_name = $form_state['values']['preview']['bundle'];
  31. $object->language = LANGUAGE_NONE;
  32. // Populate all core fields on behalf of field.module
  33. module_load_include('inc', 'devel_generate', 'devel_generate.fields');
  34. devel_generate_fields($object, 'taxonomy_term', $object->vocabulary_machine_name);
  35. return $object;
  36. }