image_effects_text.module 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @file Provide text manipulation effects for image styles.
  4. *
  5. * Ported by dman
  6. * from http://drupal.org/node/264862#comment-865490 by patrickharris
  7. *
  8. * Ported to D7 by fietserwin
  9. * from imagecache_textactions 6.x-1.8.
  10. * - The module has been renamed to follow D7 terminology:
  11. * * imagecache -> image
  12. * * action(s) -> effect(s)
  13. * resulting in image_effects_text.
  14. * - The .module file is kept as small as possible. The real work is done in the
  15. * .inc file.
  16. * - Function and parameter naming has been changed to match the image effects
  17. * in the core image module.
  18. */
  19. /**
  20. * Implements hook_image_effect_info().
  21. *
  22. * Defines information about the supported effects.
  23. */
  24. function image_effects_text_image_effect_info() {
  25. $effects = array();
  26. $effects['image_effects_text'] = array(
  27. 'label' => t('Text'),
  28. 'help' => t('Add static or dynamic (coded) text to an image.'),
  29. 'dimensions passthrough' => TRUE,
  30. 'form callback' => 'image_effects_text_form',
  31. 'effect callback' => 'image_effects_text_effect',
  32. 'summary theme' => 'image_effects_text_summary',
  33. );
  34. return $effects;
  35. }
  36. /**
  37. * Implements hook_help().
  38. */
  39. function image_effects_text_help($path, $arg) {
  40. if ($path === 'admin/advanced_help' && count($arg) >= 3 && $arg[2] === 'image_effects_text'
  41. || $path === 'admin/help/image_effects_text') {
  42. module_load_include('inc', 'image_effects_text', 'image_effects_text');
  43. return image_effects_text_help_inc($path, $arg);
  44. }
  45. else if ($path === 'admin/help#image_effects_text') {
  46. // This path just checks if there is (non-empty) help, so it can place a
  47. // link to it.
  48. return ' ';
  49. }
  50. }
  51. /**
  52. * Implements hook_theme().
  53. *
  54. * We register theme functions for the effect summaries.
  55. */
  56. function image_effects_text_theme() {
  57. return array(
  58. 'image_effects_text_summary' => array(
  59. 'variables' => array('data' => NULL),
  60. 'file' => 'image_effects_text.inc'
  61. ),
  62. );
  63. }
  64. /**
  65. * Builds the form structure for the overlay text image effect.
  66. */
  67. function image_effects_text_form($data) {
  68. module_load_include('inc', 'image_effects_text', 'image_effects_text');
  69. return image_effects_text_form_inc($data);
  70. }
  71. /**
  72. * Callback to perform the image effect on the given image.
  73. */
  74. function image_effects_text_effect($image, $data) {
  75. module_load_include('inc', 'image_effects_text', 'image_effects_text');
  76. return image_effects_text_effect_inc($image, $data);
  77. }