diff options
Diffstat (limited to 'plugins/qrcode/qrcode.php')
-rw-r--r-- | plugins/qrcode/qrcode.php | 36 |
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 | */ | ||
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 | } \ No newline at end of file | ||