metatag_test.module 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Implements hook_ctools_plugin_api().
  4. */
  5. function metatag_test_ctools_plugin_api($owner, $api) {
  6. if ($owner == 'metatag' && $api == 'metatag') {
  7. return array('version' => 1);
  8. }
  9. }
  10. /**
  11. * Implements hook_menu().
  12. *
  13. * Provides simple pages to test against.
  14. */
  15. function metatag_test_menu() {
  16. $string = 'moosqueakoinkmeow';
  17. $defaults = array(
  18. 'page callback' => 'metatag_test_page_callback',
  19. 'access callback' => TRUE,
  20. 'type' => MENU_NORMAL_ITEM,
  21. );
  22. $items[$string] = array(
  23. 'title' => 'Test page',
  24. 'description' => 'An average page.',
  25. ) + $defaults;
  26. // 255 / 19 chars = 13.
  27. $long_path = implode('/', array_pad(array(), 13, $string));
  28. $items[$long_path . '/%'] = array(
  29. 'title' => 'Test page with really long URL',
  30. 'description' => 'The URL is really, really, really long.',
  31. 'page arguments' => array(13),
  32. ) + $defaults;
  33. // User-specific meta tags.
  34. $items['account-test-page'] = array(
  35. 'title' => 'User test page',
  36. 'description' => 'Test how user tokens are handled.',
  37. 'page callback' => 'metatag_test_user_page_callback',
  38. ) + $defaults;
  39. return $items;
  40. }
  41. /**
  42. * Simple page callback for test pages.
  43. */
  44. function metatag_test_page_callback() {
  45. return t('Test page.');
  46. }
  47. /**
  48. * Simple page callback for the user test page.
  49. */
  50. function metatag_test_user_page_callback() {
  51. global $user;
  52. $username = 'Anonymous visitor';
  53. if (isset($user->name)) {
  54. $username = $user->name;
  55. }
  56. drupal_set_title('Hello ' . $username);
  57. return t('Test page for user tokens.');
  58. }