link.devel_generate.inc 899 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Devel Generate support for Link module.
  5. */
  6. /**
  7. * Implements hook_devel_generate().
  8. */
  9. function link_devel_generate($object, $field, $instance, $bundle) {
  10. if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
  11. return devel_generate_multiple('_link_devel_generate', $object, $field, $instance, $bundle);
  12. }
  13. else {
  14. return _link_devel_generate($object, $field, $instance, $bundle);
  15. }
  16. }
  17. /**
  18. * Callback for hook_devel_generate().
  19. */
  20. function _link_devel_generate($object, $field, $instance, $bundle) {
  21. $url = 'http://example.com/' . devel_generate_word(mt_rand(6, 12));
  22. $link = array(
  23. 'url' => url($url, array('absolute' => TRUE)),
  24. 'attributes' => _link_default_attributes(),
  25. );
  26. if ($instance['settings']['title'] != 'none') {
  27. $link['title'] = devel_create_greeking(mt_rand(1, 3), TRUE);
  28. }
  29. return $link;
  30. }