root / drupal7 / sites / all / modules / print / print_epub / print_epub.api.php @ 76bdcd04
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Hooks provided by the EPUB version module.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* @addtogroup hooks
|
10 |
* @{
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Generate a EPUB version of the provided HTML.
|
15 |
*
|
16 |
* @param string $html
|
17 |
* HTML content of the EPUB.
|
18 |
* @param array $meta
|
19 |
* Meta information to be used in the EPUB
|
20 |
* - url: original URL
|
21 |
* - name: author's name
|
22 |
* - title: Page title
|
23 |
* - node: node object.
|
24 |
* @param string $filename
|
25 |
* (optional) Filename of the generated EPUB.
|
26 |
*
|
27 |
* @return string|null
|
28 |
* generated EPUB page, or NULL in case of error
|
29 |
*
|
30 |
* @see print_epub_controller_html()
|
31 |
* @ingroup print_hooks
|
32 |
*/
|
33 |
function hook_print_epub_generate($html, $meta, $filename = NULL) { |
34 |
$epub = new EPUB(); |
35 |
$epub->writeHTML($html); |
36 |
if ($filename) { |
37 |
$epub->Output($filename); |
38 |
return TRUE; |
39 |
} |
40 |
else {
|
41 |
return $epub->Output(); |
42 |
} |
43 |
} |
44 |
|
45 |
/**
|
46 |
* Alters the list of available EPUB libraries.
|
47 |
*
|
48 |
* During the configuration of the EPUB library to be used, the module needs
|
49 |
* to discover and display the available libraries. This function should use
|
50 |
* the internal _print_scan_libs() function which will scan both the module
|
51 |
* and the libraries directory in search of the unique file pattern that can
|
52 |
* be used to identify the library location.
|
53 |
*
|
54 |
* @param array $epub_tools
|
55 |
* An associative array using as key the format 'module|path', and as value
|
56 |
* a string describing the discovered library, where:
|
57 |
* - module: the machine name of the module that handles this library.
|
58 |
* - path: the path where the library is installed, relative to DRUPAL_ROOT.
|
59 |
* If the recommended path is used, it begins with sites/all/libraries.
|
60 |
* As a recommendation, the value should contain in parantheses the path
|
61 |
* where the library was found, to allow the user to distinguish between
|
62 |
* multiple install paths of the same library version.
|
63 |
*
|
64 |
* @ingroup print_hooks
|
65 |
*/
|
66 |
function hook_print_epub_available_libs_alter(&$epub_tools) { |
67 |
module_load_include('inc', 'print', 'includes/print'); |
68 |
$tools = _print_scan_libs('foo', '!^foo.php$!'); |
69 |
|
70 |
foreach ($tools as $tool) { |
71 |
$epub_tools['print_epub_foo|' . $tool] = 'foo (' . dirname($tool) . ')'; |
72 |
} |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Alters the EPUB filename.
|
77 |
*
|
78 |
* Changes the value of the EPUB filename variable, just before it is used to
|
79 |
* create the file. When altering the variable, do not suffix it with the
|
80 |
* '.epub' extension, as the module will do that automatically.
|
81 |
*
|
82 |
* @param string $epub_filename
|
83 |
* Current value of the epub_filename variable, after processing tokens and
|
84 |
* any transliteration steps.
|
85 |
* @param string $path
|
86 |
* original alias/system path of the page being converted to EPUB.
|
87 |
*
|
88 |
* @ingroup print_hooks
|
89 |
*/
|
90 |
function hook_print_epub_filename_alter(&$epub_filename, &$path) { |
91 |
$epub_filename = $path . '/foo'; |
92 |
} |
93 |
|
94 |
/**
|
95 |
* @} End of "addtogroup hooks".
|
96 |
*/
|