print_ui.api.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Print UI module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Provides the format-specific info to be used by the print_ui module.
  12. *
  13. * The print_ui module manages all the generic link management of the print
  14. * package sub-modules. In order to keep the code as generic as possible, all
  15. * the identified information necessary to build the link is provided as an
  16. * array, from which each of the print_ui functions can access the necessary
  17. * details. The print_ui module will iterate over all modules that implement
  18. * this hook and build a link pointing to the indicated path + node id (or url
  19. * alias). For convenience, this function should be called directly inside the
  20. * hook_menu call for each module, and the returned path value used as the
  21. * main entry point of the specific functionality.
  22. *
  23. * @return array
  24. * An associative array containing:
  25. * - format: The format identifier, must be unique among all modules.
  26. * Examples: 'html', 'mail, 'pdf'.
  27. * - text: The default string used in the link text. Overridable by the user
  28. * configuration settings in the sub-module page.
  29. * - description: The text shown when hovering over the link.
  30. * - path: The unique path used to call the main handler.
  31. * - class: The default value of the CSS class used in the 'a' tag of the
  32. * link. Overridable by the user configuration settings in the sub-module
  33. * page.
  34. * - icon: the filename of the image used as the link icon.
  35. * - module: the name of the module. Used to call common functions or access
  36. * tables, as not all module names follow the 'print_format' template (e.g.
  37. * print.module and not print_html.module).
  38. *
  39. * @ingroup print_hooks
  40. */
  41. function hook_print_link() {
  42. return array(
  43. 'format' => 'foo',
  44. 'text' => t('Foo version'),
  45. 'description' => t('Display the foo version of this page.'),
  46. 'path' => 'printfoo',
  47. 'class' => 'print-foo',
  48. 'icon' => 'foo_icon.png',
  49. 'module' => 'print_foo',
  50. );
  51. }
  52. /**
  53. * Checks if the link is allowed according to the appropriate sub-module.
  54. *
  55. * Normally checks if the user holds the required access permission, but can
  56. * be used for extra checks, such as the proper module configuration, etc.
  57. *
  58. * @param array $args
  59. * An associative array containing:
  60. * - path: path to the non-node page being displayed.
  61. * - node: path to the node beign displayed.
  62. * - view_mode: current view mode of the node being displayed.
  63. * - type: 'node' or 'comment'.
  64. *
  65. * @return bool
  66. * FALSE if not allowed, TRUE otherwise
  67. *
  68. * @ingroup print_hooks
  69. */
  70. function hook_link_allowed($args) {
  71. return (user_access('access foo'));
  72. }
  73. /**
  74. * Allows the user to change the new window behaviour.
  75. *
  76. * @param string $new_window
  77. * New window status.
  78. * @param string $format
  79. * Format being processed.
  80. *
  81. * @ingroup print_hooks
  82. */
  83. function hook_print_new_window_alter(&$new_window, $format) {
  84. if ($format == 'foo') {
  85. $new_window = variable_get('print_foo_new_window', FALSE);
  86. }
  87. }
  88. /**
  89. * @} End of "addtogroup hooks".
  90. */