From 11b66abd17b6d9694c916c2f425dfcb0eef7e7f8 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Fri, 31 Oct 2014 20:48:49 +0400 Subject: [PATCH] Fixed piwik-analytics plugin --- plugins/piwik-analytics/index.php | 71 ++++++++++++++------------- plugins/piwik-analytics/js/include.js | 4 +- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/plugins/piwik-analytics/index.php b/plugins/piwik-analytics/index.php index 11368a99a..1932a0717 100644 --- a/plugins/piwik-analytics/index.php +++ b/plugins/piwik-analytics/index.php @@ -1,35 +1,36 @@ -Config()->Get('plugin', 'account', '')) - { - $this->addJs('js/include.js'); - } - } - - /** - * @return array - */ - public function configMapping() - { - $oUrl = \RainLoop\Plugins\Property::NewInstance('piwik_url')->SetLabel('Piwik URL') - ->SetAllowedInJs(true); - - $oSiteID = \RainLoop\Plugins\Property::NewInstance('site_id')->SetLabel('Site ID') - ->SetAllowedInJs(true); - - if (\method_exists($oUrl, 'SetPlaceholder')) - { - $oUrl->SetPlaceholder('http://'); - $oSiteID->SetPlaceholder(''); - } - - return array($oUrl, $oSiteID); - } -} +Config()->Get('plugin', 'piwik_url', '') && + '' !== $this->Config()->Get('plugin', 'site_id', '')) + { + $this->addJs('js/include.js'); + } + } + + /** + * @return array + */ + public function configMapping() + { + $oUrl = \RainLoop\Plugins\Property::NewInstance('piwik_url')->SetLabel('Piwik URL') + ->SetAllowedInJs(true); + + $oSiteID = \RainLoop\Plugins\Property::NewInstance('site_id')->SetLabel('Site ID') + ->SetAllowedInJs(true); + + if (\method_exists($oUrl, 'SetPlaceholder')) + { + $oUrl->SetPlaceholder('http://'); + $oSiteID->SetPlaceholder(''); + } + + return array($oUrl, $oSiteID); + } +} diff --git a/plugins/piwik-analytics/js/include.js b/plugins/piwik-analytics/js/include.js index 26afba6ff..df4b4dc6d 100644 --- a/plugins/piwik-analytics/js/include.js +++ b/plugins/piwik-analytics/js/include.js @@ -1,6 +1,6 @@ $(function () { - + var sPiwikURL = '' + window.rl.pluginSettingsGet('piwik-analytics', 'piwik_url'), sSiteID = '' + window.rl.pluginSettingsGet('piwik-analytics', 'site_id') @@ -9,7 +9,7 @@ $(function () { if ('' !== sPiwikURL && '' !== sSiteID) { sPiwikURL = sPiwikURL.replace(/[\\\/\s]+$/, '') + '/'; - if (/^https?:/i.test(sPiwikURL)) + if (!/^https?:/i.test(sPiwikURL)) { sPiwikURL = 'http://' + sPiwikURL; }