4 * Add QRCode containing URL for each links.
5 * Display a QRCode icon in link list.
8 use Shaarli\Plugin\PluginManager
;
9 use Shaarli\Render\TemplatePage
;
12 * Add qrcode icon to link_plugin when rendering linklist.
14 * @param array $data - linklist data.
16 * @return mixed - linklist data with qrcode plugin.
18 function hook_qrcode_render_linklist($data)
20 $qrcode_html = file_get_contents(PluginManager
::$PLUGINS_PATH . '/qrcode/qrcode.html');
22 $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager
::$PLUGINS_PATH;
23 foreach ($data['links'] as &$value) {
29 $value['link_plugin'][] = $qrcode;
36 * When linklist is displayed, include qrcode JS files.
38 * @param array $data - footer data.
40 * @return mixed - footer data with qrcode JS files added.
42 function hook_qrcode_render_footer($data)
44 if ($data['_PAGE_'] == TemplatePage
::LINKLIST
) {
45 $data['js_files'][] = PluginManager
::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
52 * When linklist is displayed, include qrcode CSS file.
54 * @param array $data - header data.
56 * @return mixed - header data with qrcode CSS file added.
58 function hook_qrcode_render_includes($data)
60 if ($data['_PAGE_'] == TemplatePage
::LINKLIST
) {
61 $data['css_files'][] = PluginManager
::$PLUGINS_PATH . '/qrcode/qrcode.css';
68 * This function is never called, but contains translation calls for GNU gettext extraction.
70 function qrcode_dummy_translation()
73 t('For each link, add a QRCode icon.');