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