openlayers_test.module 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * @file
  4. * Main OpenLayers Test Module file
  5. *
  6. * This file contains a test module to help with automated
  7. * testing.
  8. *
  9. * @ingroup openlayers
  10. */
  11. /**
  12. * Implements hook_menu().
  13. */
  14. function openlayers_test_menu() {
  15. $items = array();
  16. $items['admin/structure/openlayers/test'] = array(
  17. 'title' => 'Tests',
  18. 'description' => 'Test Pages for OpenLayers.',
  19. 'page callback' => 'openlayers_test_show_maps',
  20. 'access arguments' => array('administer openlayers'),
  21. 'file' => 'includes/openlayers_test.pages.inc',
  22. 'type' => MENU_LOCAL_TASK,
  23. 'weight' => 9999,
  24. );
  25. $items['admin/structure/openlayers/test/list'] = array(
  26. 'title' => 'Show Maps',
  27. 'type' => MENU_DEFAULT_LOCAL_TASK,
  28. 'weight' => -20,
  29. );
  30. $items['admin/structure/openlayers/test/js'] = array(
  31. 'title' => 'JS Tests',
  32. 'description' => 'Test Pages for OpenLayers Javascript.',
  33. 'page callback' => 'openlayers_test_js',
  34. 'access arguments' => array('administer openlayers'),
  35. 'file' => 'includes/openlayers_test.pages.inc',
  36. 'type' => MENU_LOCAL_TASK,
  37. 'weight' => -10,
  38. );
  39. return $items;
  40. }
  41. /**
  42. * Implements hook_ctools_plugin_api().
  43. */
  44. function openlayers_test_ctools_plugin_api($module, $api) {
  45. // Define plugins for OpenLayers plugins api
  46. if ($module == "openlayers") {
  47. switch ($api) {
  48. case 'openlayers_maps':
  49. return array('version' => 1);
  50. case 'openlayers_layers':
  51. return array('version' => 1);
  52. }
  53. }
  54. }
  55. /**
  56. * Implements hook_views_api().
  57. */
  58. function openlayers_test_views_api() {
  59. return array(
  60. 'api' => 2,
  61. );
  62. }
  63. /**
  64. * Implements hook_openlayers_maps().
  65. */
  66. function openlayers_test_openlayers_maps() {
  67. module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.maps');
  68. return _openlayers_test_openlayers_maps();
  69. }
  70. /**
  71. * Implements hook_openlayers_layers().
  72. */
  73. function openlayers_test_openlayers_layers() {
  74. module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.layers');
  75. return _openlayers_test_openlayers_layers();
  76. }
  77. /**
  78. * Implements hook_views_default_views().
  79. */
  80. function openlayers_test_views_default_views() {
  81. module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.views');
  82. return _openlayers_test_views_default_views();
  83. }
  84. /**
  85. * Impements hook_openlayers_map_preprocess_alter().
  86. */
  87. function openlayers_test_openlayers_map_preprocess_alter(&$map) {
  88. // For testing purposes, display a message on the only the Test
  89. // page, and only once.
  90. static $performed = FALSE;
  91. if (!$performed && $_GET['q'] == 'admin/structure/openlayers/test') {
  92. drupal_set_message(t('OpenLayers preprocess map alter hook fired.'));
  93. $performed = TRUE;
  94. }
  95. // Add stop render for JS testing
  96. if ($_GET['q'] == 'admin/structure/openlayers/test/js') {
  97. $map['stop_render'] = TRUE;
  98. }
  99. }
  100. /**
  101. * Impements hook_openlayers_map_alter().
  102. */
  103. function openlayers_test_openlayers_map_alter(&$map) {
  104. // For testing purposes, display a message on the only the Test
  105. // page, and only once.
  106. static $performed = FALSE;
  107. if (!$performed && $_GET['q'] == 'admin/structure/openlayers/test') {
  108. drupal_set_message(t('OpenLayers map alter hook fired.'));
  109. $performed = TRUE;
  110. }
  111. }