X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=piwik%2Fpiwik.php;h=1487f370e363d0dd89b3ee7dfd98370725a3f031;hb=101d3603245b17bd2e6d4880e94bb27887257238;hp=a2086bdcbdc6b20a6e0fe3337989c77d8cb82ef8;hpb=1b250fad733200f28752d1b0bf9c148d95686af1;p=friendica-addons.git diff --git a/piwik/piwik.php b/piwik/piwik.php old mode 100755 new mode 100644 index a2086bdc..1487f370 --- a/piwik/piwik.php +++ b/piwik/piwik.php @@ -1,13 +1,13 @@ * Author: Klaus Weidenbach */ -/* Piwik Analytics Plugin for Friendica +/* Piwik Analytics Addon for Friendica * * Author: Tobias Diekershoff * tobias.diekershoff@gmx.net @@ -15,12 +15,15 @@ * License: 3-clause BSD license * * Configuration: - * Add the following lines to your .htconfig.php file: + * Use the administration panel to configure the Piwik tracking addon, or + * in case you don't use this add the following lines to your config/addon.config.php + * file: * - * $a->config['piwik']['baseurl'] = 'www.example.com/piwik/'; - * $a->config['piwik']['siteid'] = '1'; - * $a->config['piwik']['optout'] = true; // set to false to disable - * $a->config['piwik']['async'] = false; // set to true to enable + * [piwik] + * baseurl = example.com/piwik/ + * sideid = 1 + * optout = true ;set to false to disable + * async = false ;set to true to enable * * Change the siteid to the ID that the Piwik tracker for your Friendica * installation has. Alter the baseurl to fit your needs, don't care @@ -28,44 +31,59 @@ * setting. */ +use Friendica\Core\Config; +use Friendica\Core\Hook; +use Friendica\Core\L10n; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; +use Friendica\Util\Config\ConfigFileLoader; +use Friendica\Util\Strings; + function piwik_install() { - register_hook('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); + Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config'); + Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); - logger("installed piwik plugin"); + Logger::log("installed piwik addon"); } function piwik_uninstall() { - unregister_hook('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); + Hook::unregister('load_config', 'addon/piwik/piwik.php', 'piwik_load_config'); + Hook::unregister('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); + + Logger::log("uninstalled piwik addon"); +} - logger("uninstalled piwik plugin"); +function piwik_load_config(\Friendica\App $a, ConfigFileLoader $loader) +{ + $a->getConfigCache()->load($loader->loadAddonConfig('piwik')); } function piwik_analytics($a,&$b) { /* - * styling of every HTML block added by this plugin is done in the + * styling of every HTML block added by this addon is done in the * associated CSS file. We just have to tell Friendica to get it * into the page header. */ - $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= ''; /* - * Get the configuration variables from the .htconfig file. + * Get the configuration variables from the config/addon.config.php file. */ - $baseurl = get_config('piwik','baseurl'); - $siteid = get_config('piwik','siteid'); - $optout = get_config('piwik','optout'); - $async = get_config('piwik','async'); + $baseurl = Config::get('piwik', 'baseurl'); + $siteid = Config::get('piwik', 'siteid'); + $optout = Config::get('piwik', 'optout'); + $async = Config::get('piwik', 'async'); /* * Add the Piwik tracking code for the site. * If async is set to true use asynchronous tracking */ if ($async) { - $a->page['htmlhead'] .= " \r\n\r\n"; + $b .= " \r\n"; $b .= "