aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/qrcode/qrcode.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-07-15 12:02:56 +0200
committerArthurHoaro <arthur@hoa.ro>2015-11-07 15:32:28 +0100
commit14c8efbe312696bde56466af114385b70c159bc1 (patch)
tree1ac2267852f8f82f0f748d7c7733eb269ae8d1ba /plugins/qrcode/qrcode.php
parenta52e8435939c641f964939f1df55cf7ceddcc0fd (diff)
downloadShaarli-14c8efbe312696bde56466af114385b70c159bc1.tar.gz
Shaarli-14c8efbe312696bde56466af114385b70c159bc1.tar.zst
Shaarli-14c8efbe312696bde56466af114385b70c159bc1.zip
PLUGIN QRCode
Add an icon in linklist to display links QRCode
Diffstat (limited to 'plugins/qrcode/qrcode.php')
-rw-r--r--plugins/qrcode/qrcode.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php
new file mode 100644
index 00000000..5db40929
--- /dev/null
+++ b/plugins/qrcode/qrcode.php
@@ -0,0 +1,36 @@
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 */
11function 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 */
29function 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} \ No newline at end of file