diff options
author | Arthur <arthur@hoa.ro> | 2015-11-07 16:52:53 +0100 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2015-11-07 16:52:53 +0100 |
commit | c536c98ae134191108171d266b73326d6b851f93 (patch) | |
tree | b6f43bc921f1a1f7b08ecfd368fe6aa9e3ffc748 /plugins/qrcode/qrcode.php | |
parent | 1b4ea59f93386594a6e6f35e581244b65c2db57f (diff) | |
parent | abb3ff38f5aea6231f981fd2e6d417f09de7a6e6 (diff) | |
download | Shaarli-c536c98ae134191108171d266b73326d6b851f93.tar.gz Shaarli-c536c98ae134191108171d266b73326d6b851f93.tar.zst Shaarli-c536c98ae134191108171d266b73326d6b851f93.zip |
Merge pull request #285 from ArthurHoaro/plugin-qrcode
PLUGIN QRCode
Diffstat (limited to 'plugins/qrcode/qrcode.php')
-rw-r--r-- | plugins/qrcode/qrcode.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php new file mode 100644 index 00000000..1080c964 --- /dev/null +++ b/plugins/qrcode/qrcode.php | |||
@@ -0,0 +1,41 @@ | |||
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($qrcode_html, $value['url'], $value['url'], PluginManager::$PLUGINS_PATH); | ||
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. | ||
31 | * | ||
32 | * @return mixed - footer data with qrcode JS files added. | ||
33 | */ | ||
34 | function 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; | ||
41 | } | ||