ajax_test.module

You are here

  1. 7 modules/simpletest/tests/ajax_test.module
  2. 8 core/modules/system/tests/modules/ajax_test/ajax_test.module

Helper module for Ajax framework tests.

Functions

Namesort descending Description
ajax_test_error Menu callback; Returns Ajax element with #error property set.
ajax_test_link Menu callback; Renders a #type link with #ajax.
ajax_test_menu Implements hook_menu().
ajax_test_render Menu callback; Return an element suitable for use by ajax_deliver().
ajax_test_system_theme_info Implements hook_system_theme_info().

File

modules/simpletest/tests/ajax_test.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Helper module for Ajax framework tests.
  5. */
  6. /**
  7. * Implements hook_menu().
  8. */
  9. function ajax_test_menu() {
  10. $items['ajax-test/render'] = array(
  11. 'title' => 'ajax_render',
  12. 'page callback' => 'ajax_test_render',
  13. 'delivery callback' => 'ajax_deliver',
  14. 'access callback' => TRUE,
  15. 'type' => MENU_CALLBACK,
  16. );
  17. $items['ajax-test/render-error'] = array(
  18. 'title' => 'ajax_render_error',
  19. 'page callback' => 'ajax_test_error',
  20. 'delivery callback' => 'ajax_deliver',
  21. 'access callback' => TRUE,
  22. 'type' => MENU_CALLBACK,
  23. );
  24. $items['ajax-test/link'] = array(
  25. 'title' => 'AJAX Link',
  26. 'page callback' => 'ajax_test_link',
  27. 'access callback' => TRUE,
  28. );
  29. return $items;
  30. }
  31. /**
  32. * Implements hook_system_theme_info().
  33. */
  34. function ajax_test_system_theme_info() {
  35. $themes['test_theme'] = drupal_get_path('module', 'ajax_test') . '/themes/test_theme/test_theme.info';
  36. return $themes;
  37. }
  38. /**
  39. * Menu callback; Return an element suitable for use by ajax_deliver().
  40. *
  41. * Additionally ensures that ajax_render() incorporates JavaScript settings
  42. * generated during the page request by invoking drupal_add_js() with a dummy
  43. * setting.
  44. */
  45. function ajax_test_render() {
  46. drupal_add_js(array('ajax' => 'test'), 'setting');
  47. return array('#type' => 'ajax', '#commands' => array());
  48. }
  49. /**
  50. * Menu callback; Returns Ajax element with #error property set.
  51. */
  52. function ajax_test_error() {
  53. $message = '';
  54. if (!empty($_GET['message'])) {
  55. $message = $_GET['message'];
  56. }
  57. return array('#type' => 'ajax', '#error' => $message);
  58. }
  59. /**
  60. * Menu callback; Renders a #type link with #ajax.
  61. */
  62. function ajax_test_link() {
  63. $build['link'] = array(
  64. '#type' => 'link',
  65. '#title' => 'Show help',
  66. '#href' => 'filter/tips',
  67. '#ajax' => array(
  68. 'wrapper' => 'block-system-main',
  69. ),
  70. );
  71. return $build;
  72. }