4 * Adds tracking code on each page.
7 use Shaarli\Plugin\PluginManager
;
10 * Initialization function.
11 * It will be called when the plugin is loaded.
12 * This function can be used to return a list of initialization errors.
14 * @param $conf ConfigManager instance.
16 * @return array List of errors (optional).
18 function piwik_init($conf)
20 $piwikUrl = $conf->get('plugins.PIWIK_URL');
21 $piwikSiteid = $conf->get('plugins.PIWIK_SITEID');
22 if (empty($piwikUrl) || empty($piwikSiteid)) {
23 $error = t('Piwik plugin error: ' .
24 'Please define PIWIK_URL and PIWIK_SITEID in the plugin administration page.');
31 * Executed on every page redering.
33 * Template placeholders:
39 * - _PAGE_: current page
40 * - _LOGGEDIN_: true/false
42 * @param array $data data passed to plugin
44 * @return array altered $data.
46 function hook_piwik_render_footer($data, $conf)
48 $piwikUrl = $conf->get('plugins.PIWIK_URL');
49 $piwikSiteid = $conf->get('plugins.PIWIK_SITEID');
50 if (empty($piwikUrl) || empty($piwikSiteid)) {
54 // Free elements at the end of the page.
55 $data['endofpage'][] = sprintf(
56 file_get_contents(PluginManager
::$PLUGINS_PATH . '/piwik/piwik.html'),
67 * This function is never called, but contains translation calls for GNU gettext extraction.
69 function piwik_dummy_translation()
72 t('A plugin that adds Piwik tracking code to Shaarli pages.');