node.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @file
  4. * Node module integration.
  5. */
  6. /**
  7. * Implements hook_custom_formatters_devel_generate_info() on behalf of
  8. * node.module.
  9. */
  10. function node_custom_formatters_devel_generate_info() {
  11. return array(
  12. 'node' => array(
  13. 'process callback' => 'custom_formatters_node_devel_generate_process',
  14. ),
  15. );
  16. }
  17. /**
  18. * Process callback for Node Devel Generate integration.
  19. */
  20. function custom_formatters_node_devel_generate_process($form_state) {
  21. module_load_include('inc', 'devel_generate', 'devel_generate');
  22. $object = new stdClass();
  23. $object->nid = mt_rand(1, 100);
  24. $object->type = $form_state['values']['preview']['bundle'];
  25. $object->uid = $GLOBALS['user']->uid;
  26. $type = node_type_get_type($object);
  27. $object->title = $type->has_title ? devel_create_greeking(mt_rand(2, rand(4, 10)), TRUE) : '';
  28. $object->revision = mt_rand(0, 1);
  29. $object->promote = mt_rand(0, 1);
  30. devel_generate_set_language(array(), $object);
  31. $object->created = REQUEST_TIME;
  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, $form_state['values']['preview']['entity_type'], $object->type);
  35. return $object;
  36. }