]>
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 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 | */ | |
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) { | |
49e62f22 A |
20 | $qrcode = sprintf($qrcode_html, |
21 | urlencode($value['url']), | |
22 | $value['url'], | |
23 | PluginManager::$PLUGINS_PATH | |
24 | ); | |
14c8efbe A |
25 | $value['link_plugin'][] = $qrcode; |
26 | } | |
27 | ||
28 | return $data; | |
29 | } | |
30 | ||
31 | /** | |
32 | * When linklist is displayed, include qrcode JS files. | |
33 | * | |
34 | * @param array $data - footer data. | |
abb3ff38 | 35 | * |
14c8efbe A |
36 | * @return mixed - footer data with qrcode JS files added. |
37 | */ | |
38 | function hook_qrcode_render_footer($data) | |
39 | { | |
40 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | |
41 | $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js'; | |
42 | } | |
43 | ||
44 | return $data; | |
abb3ff38 | 45 | } |
28a4fc54 A |
46 | |
47 | /** | |
48 | * When linklist is displayed, include qrcode CSS file. | |
49 | * | |
50 | * @param array $data - header data. | |
51 | * | |
52 | * @return mixed - header data with qrcode CSS file added. | |
53 | */ | |
54 | function hook_qrcode_render_includes($data) | |
55 | { | |
56 | if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { | |
57 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css'; | |
58 | } | |
59 | ||
60 | return $data; | |
61 | } |