5 * Add QRCode containing URL for each links.
6 * Display a QRCode icon in link list.
9 use Shaarli\Plugin\PluginManager
;
10 use Shaarli\Render\TemplatePage
;
13 * Add qrcode icon to link_plugin when rendering linklist.
15 * @param array $data - linklist data.
17 * @return mixed - linklist data with qrcode plugin.
19 function hook_qrcode_render_linklist($data)
21 $qrcode_html = file_get_contents(PluginManager
::$PLUGINS_PATH . '/qrcode/qrcode.html');
23 $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager
::$PLUGINS_PATH;
24 foreach ($data['links'] as &$value) {
30 $value['link_plugin'][] = $qrcode;
37 * When linklist is displayed, include qrcode JS files.
39 * @param array $data - footer data.
41 * @return mixed - footer data with qrcode JS files added.
43 function hook_qrcode_render_footer($data)
45 if ($data['_PAGE_'] == TemplatePage
::LINKLIST
) {
46 $data['js_files'][] = PluginManager
::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
53 * When linklist is displayed, include qrcode CSS file.
55 * @param array $data - header data.
57 * @return mixed - header data with qrcode CSS file added.
59 function hook_qrcode_render_includes($data)
61 if ($data['_PAGE_'] == TemplatePage
::LINKLIST
) {
62 $data['css_files'][] = PluginManager
::$PLUGINS_PATH . '/qrcode/qrcode.css';
69 * This function is never called, but contains translation calls for GNU gettext extraction.
71 function qrcode_dummy_translation()
74 t('For each link, add a QRCode icon.');