]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - plugins/qrcode/qrcode.php
Fixes QRCode style
[github/shaarli/Shaarli.git] / plugins / qrcode / qrcode.php
CommitLineData
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
A
7
8/**
9 * Add qrcode icon to link_plugin when rendering linklist.
10 *
abb3ff38
A
11 * @param array $data - linklist data.
12 *
14c8efbe
A
13 * @return mixed - linklist data with qrcode plugin.
14 */
15function 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) {
90e5bd65 20 $qrcode = sprintf($qrcode_html, $value['real_url'], $value['real_url'], PluginManager::$PLUGINS_PATH);
14c8efbe
A
21 $value['link_plugin'][] = $qrcode;
22 }
23
24 return $data;
25}
26
27/**
28 * When linklist is displayed, include qrcode JS files.
29 *
30 * @param array $data - footer data.
abb3ff38 31 *
14c8efbe
A
32 * @return mixed - footer data with qrcode JS files added.
33 */
34function hook_qrcode_render_footer($data)
35{
36 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
37 $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
38 }
39
40 return $data;
abb3ff38 41}
28a4fc54
A
42
43/**
44 * When linklist is displayed, include qrcode CSS file.
45 *
46 * @param array $data - header data.
47 *
48 * @return mixed - header data with qrcode CSS file added.
49 */
50function hook_qrcode_render_includes($data)
51{
52 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
53 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css';
54 }
55
56 return $data;
57}