5 * Adds tracking code on each page.
8 use Shaarli\Plugin\PluginManager
;
11 * Initialization function.
12 * It will be called when the plugin is loaded.
13 * This function can be used to return a list of initialization errors.
15 * @param $conf ConfigManager instance.
17 * @return array List of errors (optional).
19 function piwik_init($conf)
21 $piwikUrl = $conf->get('plugins.PIWIK_URL');
22 $piwikSiteid = $conf->get('plugins.PIWIK_SITEID');
23 if (empty($piwikUrl) || empty($piwikSiteid)) {
24 $error = t('Piwik plugin error: ' .
25 'Please define PIWIK_URL and PIWIK_SITEID in the plugin administration page.');
32 * Executed on every page redering.
34 * Template placeholders:
40 * - _PAGE_: current page
41 * - _LOGGEDIN_: true/false
43 * @param array $data data passed to plugin
45 * @return array altered $data.
47 function hook_piwik_render_footer($data, $conf)
49 $piwikUrl = $conf->get('plugins.PIWIK_URL');
50 $piwikSiteid = $conf->get('plugins.PIWIK_SITEID');
51 if (empty($piwikUrl) || empty($piwikSiteid)) {
55 // Free elements at the end of the page.
56 $data['endofpage'][] = sprintf(
57 file_get_contents(PluginManager
::$PLUGINS_PATH . '/piwik/piwik.html'),
68 * This function is never called, but contains translation calls for GNU gettext extraction.
70 function piwik_dummy_translation()
73 t('A plugin that adds Piwik tracking code to Shaarli pages.');