Fixed piwik-analytics plugin

This commit is contained in:
RainLoop Team 2014-10-31 20:48:49 +04:00
parent 139f412b6a
commit 11b66abd17
2 changed files with 38 additions and 37 deletions

View file

@ -1,35 +1,36 @@
<?php
class PiwikAnalyticsPlugin extends \RainLoop\Plugins\AbstractPlugin
{
/**
* @return void
*/
public function Init()
{
if ('' !== $this->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);
}
}
<?php
class PiwikAnalyticsPlugin extends \RainLoop\Plugins\AbstractPlugin
{
/**
* @return void
*/
public function Init()
{
if ('' !== $this->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);
}
}

View file

@ -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;
}