block_test.module

Provide test blocks.

File

drupal-7.x/modules/block/tests/block_test.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide test blocks.
  5. */
  6. /**
  7. * Implements hook_system_theme_info().
  8. */
  9. function block_test_system_theme_info() {
  10. $themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info';
  11. return $themes;
  12. }
  13. /**
  14. * Implements hook_block_info().
  15. */
  16. function block_test_block_info() {
  17. $blocks['test_cache'] = array(
  18. 'info' => t('Test block caching'),
  19. 'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE),
  20. );
  21. $blocks['test_underscore'] = array(
  22. 'info' => t('Test underscore'),
  23. );
  24. $blocks['test-hyphen'] = array(
  25. 'info' => t('Test hyphen'),
  26. );
  27. $blocks['test_html_id'] = array(
  28. 'info' => t('Test block html id'),
  29. );
  30. return $blocks;
  31. }
  32. /**
  33. * Implements hook_block_view().
  34. */
  35. function block_test_block_view($delta = 0) {
  36. return array('content' => variable_get('block_test_content', ''));
  37. }
  38. /**
  39. * Implements hook_block_view_MODULE_DELTA_alter().
  40. */
  41. function block_test_block_view_block_test_test_underscore_alter(&$data, $block) {
  42. $data['content'] = 'hook_block_view_MODULE_DELTA_alter';
  43. }
  44. /**
  45. * Implements hook_block_view_MODULE_DELTA_alter().
  46. */
  47. function block_test_block_view_block_test_test_hyphen_alter(&$data, $block) {
  48. $data['content'] = 'hook_block_view_MODULE_DELTA_alter';
  49. }
  50. /**
  51. * Implements hook_block_info_alter().
  52. */
  53. function block_test_block_info_alter(&$blocks) {
  54. if (variable_get('block_test_info_alter')) {
  55. $blocks['block_test']['test_html_id']['weight'] = 10000;
  56. }
  57. }