]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - plugins/qrcode/qrcode.php
5db409291c772e3ad811ed26eb9c199163e14b76
[github/shaarli/Shaarli.git] / plugins / qrcode / qrcode.php
1 <?php
2
3 // TODO: Can't be tested in localhost
4
5 /**
6 * Add qrcode icon to link_plugin when rendering linklist.
7 *
8 * @param $data - linklist data.
9 * @return mixed - linklist data with qrcode plugin.
10 */
11 function hook_qrcode_render_linklist($data)
12 {
13 $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
14
15 foreach ($data['links'] as &$value) {
16 $qrcode = sprintf($qrcode_html, $value['url'], $value['url'], PluginManager::$PLUGINS_PATH);
17 $value['link_plugin'][] = $qrcode;
18 }
19
20 return $data;
21 }
22
23 /**
24 * When linklist is displayed, include qrcode JS files.
25 *
26 * @param array $data - footer data.
27 * @return mixed - footer data with qrcode JS files added.
28 */
29 function hook_qrcode_render_footer($data)
30 {
31 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
32 $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
33 }
34
35 return $data;
36 }