filter_test.module

Test module for Filter module hooks and functions not used in core.

File

drupal-7.x/modules/simpletest/tests/filter_test.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Test module for Filter module hooks and functions not used in core.
  5. */
  6. /**
  7. * Implements hook_filter_format_insert().
  8. */
  9. function filter_test_filter_format_insert($format) {
  10. drupal_set_message('hook_filter_format_insert invoked.');
  11. }
  12. /**
  13. * Implements hook_filter_format_update().
  14. */
  15. function filter_test_filter_format_update($format) {
  16. drupal_set_message('hook_filter_format_update invoked.');
  17. }
  18. /**
  19. * Implements hook_filter_format_disable().
  20. */
  21. function filter_test_filter_format_disable($format) {
  22. drupal_set_message('hook_filter_format_disable invoked.');
  23. }
  24. /**
  25. * Implements hook_filter_info().
  26. */
  27. function filter_test_filter_info() {
  28. $filters['filter_test_uncacheable'] = array(
  29. 'title' => 'Uncacheable filter',
  30. 'description' => 'Does nothing, but makes a text format uncacheable.',
  31. 'cache' => FALSE,
  32. );
  33. $filters['filter_test_replace'] = array(
  34. 'title' => 'Testing filter',
  35. 'description' => 'Replaces all content with filter and text format information.',
  36. 'process callback' => 'filter_test_replace',
  37. );
  38. return $filters;
  39. }
  40. /**
  41. * Implements callback_filter_process().
  42. *
  43. * Process handler for filter_test_replace filter.
  44. *
  45. * Replaces all text with filter and text format information.
  46. */
  47. function filter_test_replace($text, $filter, $format, $langcode, $cache, $cache_id) {
  48. $text = array();
  49. $text[] = 'Filter: ' . $filter->title . ' (' . $filter->name . ')';
  50. $text[] = 'Format: ' . $format->name . ' (' . $format->format . ')';
  51. $text[] = 'Language: ' . $langcode;
  52. $text[] = 'Cache: ' . ($cache ? 'Enabled' : 'Disabled');
  53. if ($cache_id) {
  54. $text[] = 'Cache ID: ' . $cache_id;
  55. }
  56. return implode("<br />\n", $text);
  57. }