From 6a491db3e0fa0471725bcc875e8c393bc0f6ffdb Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 23 Jun 2011 20:47:24 +0200 Subject: [PATCH 1/2] admin interface stuff for the piwik addon --- addon/piwik/admin.tpl | 4 ++++ addon/piwik/piwik.php | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 addon/piwik/admin.tpl diff --git a/addon/piwik/admin.tpl b/addon/piwik/admin.tpl new file mode 100644 index 0000000000..e7a281e3a5 --- /dev/null +++ b/addon/piwik/admin.tpl @@ -0,0 +1,4 @@ +{{ inc field_input.tpl with $field=$baseurl }}{{ endinc }} +{{ inc field_input.tpl with $field=$sideid }}{{ endinc }} +{{ inc field_checkbox.tpl with $field=$optout }}{{ endinc }} +
diff --git a/addon/piwik/piwik.php b/addon/piwik/piwik.php index 032f84f4bb..94aa9b55c0 100644 --- a/addon/piwik/piwik.php +++ b/addon/piwik/piwik.php @@ -70,4 +70,21 @@ function piwik_analytics($a,&$b) { } } - +function piwik_plugin_admin (&$a, &$o) { + $t = file_get_contents( dirname(__file__)."/admin.tpl"); + $o = replace_macros( $t, array( + '$submit' => t('Submit'), + '$baseurl' => array('baseurl', t('Piwik Base URL'), get_config('piwik','baseurl' ), ''), + '$sideid' => array('sideid', t('Side ID'), get_config('piwik','sideid' ), ''), + '$optout' => array('optout', t('Show opt-out cookie link?'), get_config('piwik','optout' ), ''), + )); +} +function piwik_plugin_admin_post (&$a) { + $url = ((x($_POST, 'baseurl')) ? notags(trim($_POST['baseurl'])) : ''); + $id = ((x($_POST, 'sideid')) ? trim($_POST['sideid']) : ''); + $optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); + set_config('piwik', 'baseurl', $url); + set_config('piwik', 'sideid', $id); + set_config('piwik', 'optout', $optout); + info( t('Settings updated.'). EOL); +} From cb319c68249bc02da6e41d9e907d08439f57895d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 23 Jun 2011 21:44:25 +0200 Subject: [PATCH 2/2] fixed a typo --- addon/piwik/admin.tpl | 2 +- addon/piwik/piwik.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addon/piwik/admin.tpl b/addon/piwik/admin.tpl index e7a281e3a5..0edd062104 100644 --- a/addon/piwik/admin.tpl +++ b/addon/piwik/admin.tpl @@ -1,4 +1,4 @@ {{ inc field_input.tpl with $field=$baseurl }}{{ endinc }} -{{ inc field_input.tpl with $field=$sideid }}{{ endinc }} +{{ inc field_input.tpl with $field=$siteid }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$optout }}{{ endinc }}
diff --git a/addon/piwik/piwik.php b/addon/piwik/piwik.php index 94aa9b55c0..3cc136d299 100644 --- a/addon/piwik/piwik.php +++ b/addon/piwik/piwik.php @@ -18,10 +18,10 @@ * Add the following two lines to your .htconfig.php file: * * $a->config['piwik']['baseurl'] = 'www.example.com/piwik/'; - * $a->config['piwik']['sideid'] = '1'; + * $a->config['piwik']['siteid'] = '1'; * $a->config['piwik']['optout'] = true; // set to false to disable * - * Change the sideid to the ID that the Piwik tracker for your Friendika + * Change the siteid to the ID that the Piwik tracker for your Friendika * installation has. Alter the baseurl to fit your needs, don't care * about http/https but beware to put the trailing / at the end of your * setting. @@ -54,13 +54,13 @@ function piwik_analytics($a,&$b) { * Get the configuration variables from the .htconfig file. */ $baseurl = get_config('piwik','baseurl'); - $sideod = get_config('piwik','sideid'); + $siteid = get_config('piwik','siteid'); $optout = get_config('piwik','optout'); /* - * Add the Piwik code for the side. + * Add the Piwik code for the site. */ - $b .= "
\r\n \r\n\r\n\r\n
"; + $b .= "
\r\n \r\n\r\n\r\n
"; /* * If the optout variable is set to true then display the notice * otherwise just include the above code into the page. @@ -75,16 +75,16 @@ function piwik_plugin_admin (&$a, &$o) { $o = replace_macros( $t, array( '$submit' => t('Submit'), '$baseurl' => array('baseurl', t('Piwik Base URL'), get_config('piwik','baseurl' ), ''), - '$sideid' => array('sideid', t('Side ID'), get_config('piwik','sideid' ), ''), + '$siteid' => array('siteid', t('Site ID'), get_config('piwik','siteid' ), ''), '$optout' => array('optout', t('Show opt-out cookie link?'), get_config('piwik','optout' ), ''), )); } function piwik_plugin_admin_post (&$a) { $url = ((x($_POST, 'baseurl')) ? notags(trim($_POST['baseurl'])) : ''); - $id = ((x($_POST, 'sideid')) ? trim($_POST['sideid']) : ''); + $id = ((x($_POST, 'siteid')) ? trim($_POST['siteid']) : ''); $optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); set_config('piwik', 'baseurl', $url); - set_config('piwik', 'sideid', $id); + set_config('piwik', 'siteid', $id); set_config('piwik', 'optout', $optout); info( t('Settings updated.'). EOL); }