From e20f30888f441dcdf8d84950b27e62bc0f587eb2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 27 Jun 2018 23:18:33 -0400 Subject: [PATCH] [piwik] Add addon config - Update mentions of .htconfig.php --- piwik/README.md | 18 ++++++++++-------- piwik/config/piwik.ini.php | 29 +++++++++++++++++++++++++++++ piwik/piwik.php | 28 ++++++++++++++++++---------- 3 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 piwik/config/piwik.ini.php diff --git a/piwik/README.md b/piwik/README.md index 37ece2f0..eb3dc39d 100644 --- a/piwik/README.md +++ b/piwik/README.md @@ -25,18 +25,20 @@ your ~friendica server and then enter the needed details on the config page for the addon. If you don't want to use the admin panel, you can configure the addon through -the .htconfig file. +the config/local.ini.php file. -Open the .htconfig.php file and add "piwik" to the list of activated addons. +Open the config/local.ini.php file and add "piwik" to the list of activated addons. - $a->config['system']['addon'] = "piwik, ..." + [system] + addon = ...,piwik -You have to add 4 more configuration variables for the addon: +You can change 4 more configuration variables for the addon: - $a->config['piwik']['baseurl'] = 'example.com/piwik/'; - $a->config['piwik']['sideid'] = '1'; - $a->config['piwik']['optout'] = true; - $a->config['piwik']['async'] = false; + [piwik] + baseurl = example.com/piwik/ + sideid = 1 + optout = true + async = false Configuration fields --------------------- diff --git a/piwik/config/piwik.ini.php b/piwik/config/piwik.ini.php new file mode 100644 index 00000000..333d1320 --- /dev/null +++ b/piwik/config/piwik.ini.php @@ -0,0 +1,29 @@ +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 @@ -34,17 +35,24 @@ use Friendica\Core\Config; use Friendica\Core\L10n; function piwik_install() { + Addon::registerHook('load_config', 'addon/piwik/piwik.php', 'piwik_load_config'); Addon::registerHook('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); logger("installed piwik addon"); } function piwik_uninstall() { + Addon::unregisterHook('load_config', 'addon/piwik/piwik.php', 'piwik_load_config'); Addon::unregisterHook('page_end', 'addon/piwik/piwik.php', 'piwik_analytics'); logger("uninstalled piwik addon"); } +function piwik_load_config(\Friendica\App $a) +{ + $a->loadConfigFile(__DIR__. '/config/piwik.ini.php'); +} + function piwik_analytics($a,&$b) { /* @@ -55,12 +63,12 @@ function piwik_analytics($a,&$b) { $a->page['htmlhead'] .= ''; /* - * Get the configuration variables from the .htconfig file. + * Get the configuration variables from the config/local.ini.php file. */ - $baseurl = Config::get('piwik','baseurl'); - $siteid = Config::get('piwik','siteid'); - $optout = Config::get('piwik','optout'); - $async = Config::get('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. -- 2.39.5