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