forked from friendica/friendica-addons
[piwik] Add addon config
- Update mentions of .htconfig.php
This commit is contained in:
parent
d9808fecdf
commit
e20f30888f
3 changed files with 57 additions and 18 deletions
|
@ -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
|
||||
---------------------
|
||||
|
|
29
piwik/config/piwik.ini.php
Normal file
29
piwik/config/piwik.ini.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php return <<<INI
|
||||
|
||||
; Warning: Don't change this file! It only holds the default config values for this addon.
|
||||
; Instead overwrite these config values in config/local.ini.php in your Friendica directory
|
||||
|
||||
[piwik]
|
||||
; baseurl (String)
|
||||
; This URL points to your Piwik installation.
|
||||
; Use the absolute path, remember trailing slashes but ignore the protocol (http/s) part of the URL.
|
||||
; Example: baseurl = example.com/piwik/
|
||||
baseurl =
|
||||
|
||||
; siteid (Integer)
|
||||
; Change the *sideid* parameter to whatever ID you want to use for tracking your Friendica installation.
|
||||
sideid =
|
||||
|
||||
; optout (Boolean)
|
||||
; This defines whether or not a short notice about the utilization of Piwik will be displayed on every
|
||||
; page of your Friendica site (at the bottom of the page with some spacing to the other content).
|
||||
; Part of the note is a link that allows the visitor to set an opt-out cookie which will prevent visits
|
||||
; from that user be tracked by Piwik.
|
||||
optout = true
|
||||
|
||||
; async (Boolean)
|
||||
; This defines whether or not to use asynchronous tracking so pages load (or appear to load) faster.
|
||||
async = false
|
||||
|
||||
INI;
|
||||
//Keep this line
|
|
@ -16,13 +16,14 @@
|
|||
*
|
||||
* Configuration:
|
||||
* Use the administration panel to configure the Piwik tracking addon, or
|
||||
* in case you don't use this add the following lines to your .htconfig.php
|
||||
* in case you don't use this add the following lines to your config/local.ini.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
|
||||
|
@ -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'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/piwik/piwik.css' . '" media="all" />';
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
|
Loading…
Reference in a new issue