]>
Commit | Line | Data |
---|---|---|
14c8efbe | 1 | <?php |
abb3ff38 A |
2 | /** |
3 | * Plugin qrcode | |
4 | * Add QRCode containing URL for each links. | |
5 | * Display a QRCode icon in link list. | |
6 | */ | |
14c8efbe | 7 | |
e1850388 | 8 | use Shaarli\Plugin\PluginManager; |
a932f486 V |
9 | use Shaarli\Router; |
10 | ||
14c8efbe A |
11 | /** |
12 | * Add qrcode icon to link_plugin when rendering linklist. | |
13 | * | |
abb3ff38 A |
14 | * @param array $data - linklist data. |
15 | * | |
14c8efbe A |
16 | * @return mixed - linklist data with qrcode plugin. |
17 | */ | |
18 | function hook_qrcode_render_linklist($data) | |
19 | { | |
20 | $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); | |
21 | ||
22 | foreach ($data['links'] as &$value) { | |
a0ab3c3f V |
23 | $qrcode = sprintf( |
24 | $qrcode_html, | |
49e62f22 A |
25 | $value['url'], |
26 | PluginManager::$PLUGINS_PATH | |
27 | ); | |
14c8efbe A |
28 | $value['link_plugin'][] = $qrcode; |
29 | } | |
30 | ||
31 | return $data; | |
32 | } | |
33 | ||
34 | /** | |
35 | * When linklist is displayed, include qrcode JS files. | |
36 | * | |
37 | * @param array $data - footer data. | |
abb3ff38 | 38 | * |
14c8efbe A |
39 | * @return mixed - footer data with qrcode JS files added. |
40 | */ | |
41 | function hook_qrcode_render_footer($data) | |
42 | { | |
43 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | |
44 | $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js'; | |
45 | } | |
46 | ||
47 | return $data; | |
abb3ff38 | 48 | } |
28a4fc54 A |
49 | |
50 | /** | |
51 | * When linklist is displayed, include qrcode CSS file. | |
52 | * | |
53 | * @param array $data - header data. | |
54 | * | |
55 | * @return mixed - header data with qrcode CSS file added. | |
56 | */ | |
57 | function hook_qrcode_render_includes($data) | |
58 | { | |
59 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | |
60 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css'; | |
61 | } | |
62 | ||
63 | return $data; | |
64 | } | |
12266213 A |
65 | |
66 | /** | |
67 | * This function is never called, but contains translation calls for GNU gettext extraction. | |
68 | */ | |
69 | function qrcode_dummy_translation() | |
70 | { | |
71 | // meta | |
72 | t('For each link, add a QRCode icon.'); | |
73 | } |