mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
Plugin system improvements
+ piwik analytics plugin (not tested)
This commit is contained in:
parent
4c38993c26
commit
085095b717
11 changed files with 137 additions and 11 deletions
|
|
@ -124,6 +124,7 @@
|
||||||
this.configures(_.map(aConfig, function (aItem) {
|
this.configures(_.map(aConfig, function (aItem) {
|
||||||
return {
|
return {
|
||||||
'value': ko.observable(aItem[0]),
|
'value': ko.observable(aItem[0]),
|
||||||
|
'placeholder': ko.observable(aItem[6]),
|
||||||
'Name': aItem[1],
|
'Name': aItem[1],
|
||||||
'Type': aItem[2],
|
'Type': aItem[2],
|
||||||
'Label': aItem[3],
|
'Label': aItem[3],
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
1.4
|
1.5
|
||||||
|
|
@ -18,11 +18,17 @@ class GoogleAnalyticsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
*/
|
*/
|
||||||
public function configMapping()
|
public function configMapping()
|
||||||
{
|
{
|
||||||
return array(
|
$oAccount = \RainLoop\Plugins\Property::NewInstance('account')->SetLabel('Account')
|
||||||
\RainLoop\Plugins\Property::NewInstance('account')->SetLabel('Account')
|
->SetAllowedInJs(true)
|
||||||
->SetAllowedInJs(true)
|
->SetDefaultValue('')
|
||||||
->SetDescription('UA-XXXXXXXX-X')
|
;
|
||||||
->SetDefaultValue(''),
|
|
||||||
|
if (\method_exists($oAccount, 'SetPlaceholder'))
|
||||||
|
{
|
||||||
|
$oAccount->SetPlaceholder('UA-XXXXXXXX-X');
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($oAccount,
|
||||||
\RainLoop\Plugins\Property::NewInstance('domain_name')->SetLabel('Domain Name')
|
\RainLoop\Plugins\Property::NewInstance('domain_name')->SetLabel('Domain Name')
|
||||||
->SetAllowedInJs(true)
|
->SetAllowedInJs(true)
|
||||||
->SetDefaultValue(''),
|
->SetDefaultValue(''),
|
||||||
|
|
|
||||||
20
plugins/piwik-analytics/LICENSE
Normal file
20
plugins/piwik-analytics/LICENSE
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 RainLoop Team
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
1
plugins/piwik-analytics/README
Normal file
1
plugins/piwik-analytics/README
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Embed Piwik Analytics (Open source web analytics platform) code into your webmail installation pages.
|
||||||
1
plugins/piwik-analytics/VERSION
Normal file
1
plugins/piwik-analytics/VERSION
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
1.0
|
||||||
35
plugins/piwik-analytics/index.php
Normal file
35
plugins/piwik-analytics/index.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
plugins/piwik-analytics/js/include.js
Normal file
32
plugins/piwik-analytics/js/include.js
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
var
|
||||||
|
sPiwikURL = '' + window.rl.pluginSettingsGet('piwik-analytics', 'piwik_url'),
|
||||||
|
sSiteID = '' + window.rl.pluginSettingsGet('piwik-analytics', 'site_id')
|
||||||
|
;
|
||||||
|
|
||||||
|
if ('' !== sPiwikURL && '' !== sSiteID)
|
||||||
|
{
|
||||||
|
sPiwikURL = sPiwikURL.replace(/[\\\/\s]+$/, '') + '/';
|
||||||
|
if (/^https?:/i.test(sPiwikURL))
|
||||||
|
{
|
||||||
|
sPiwikURL = 'http://' + sPiwikURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
window._paq = window._paq || [];
|
||||||
|
(function(window){
|
||||||
|
window._paq.push(['setSiteId', sSiteID]);
|
||||||
|
window._paq.push(['setTrackerUrl', sPiwikURL + 'piwik.php']);
|
||||||
|
window._paq.push(['trackPageView']);
|
||||||
|
window.setInterval(function () {
|
||||||
|
window._paq.push(['trackPageView']);
|
||||||
|
}, 1000 * 60 * 2);
|
||||||
|
var d = window.document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||||
|
g.type = 'text/javascript'; g.defer = true; g.async = true; g.src = sPiwikURL + 'piwik.js';
|
||||||
|
if (s && s.parentNode) {
|
||||||
|
s.parentNode.insertBefore(g, s);
|
||||||
|
}
|
||||||
|
}(window));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -295,7 +295,7 @@ class Manager
|
||||||
$aMap = $oPlugin->ConfigMap();
|
$aMap = $oPlugin->ConfigMap();
|
||||||
if (\is_array($aMap))
|
if (\is_array($aMap))
|
||||||
{
|
{
|
||||||
foreach ($aMap as /* @var $oPluginProperty \RainLoop\Plugins\Property */$oPluginProperty)
|
foreach ($aMap as /* @var $oPluginProperty \RainLoop\Plugins\Property */ $oPluginProperty)
|
||||||
{
|
{
|
||||||
if ($oPluginProperty && $oPluginProperty->AllowedInJs())
|
if ($oPluginProperty && $oPluginProperty->AllowedInJs())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,11 @@ class Property
|
||||||
* @var mixed
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
private $mDefaultValue;
|
private $mDefaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $sPlaceholder;
|
||||||
|
|
||||||
private function __construct($sName)
|
private function __construct($sName)
|
||||||
{
|
{
|
||||||
|
|
@ -42,6 +47,7 @@ class Property
|
||||||
$this->sLabel = '';
|
$this->sLabel = '';
|
||||||
$this->sDesc = '';
|
$this->sDesc = '';
|
||||||
$this->bAllowedInJs = false;
|
$this->bAllowedInJs = false;
|
||||||
|
$this->sPlaceholder = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,6 +83,18 @@ class Property
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sPlaceholder
|
||||||
|
*
|
||||||
|
* @return \RainLoop\Plugins\Property
|
||||||
|
*/
|
||||||
|
public function SetPlaceholder($sPlaceholder)
|
||||||
|
{
|
||||||
|
$this->sPlaceholder = $sPlaceholder;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sLabel
|
* @param string $sLabel
|
||||||
|
|
@ -160,6 +178,14 @@ class Property
|
||||||
{
|
{
|
||||||
return $this->mDefaultValue;
|
return $this->mDefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function Placeholder()
|
||||||
|
{
|
||||||
|
return $this->sPlaceholder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
|
|
@ -172,7 +198,8 @@ class Property
|
||||||
$this->iType,
|
$this->iType,
|
||||||
$this->sLabel,
|
$this->sLabel,
|
||||||
$this->mDefaultValue,
|
$this->mDefaultValue,
|
||||||
$this->sDesc
|
$this->sDesc,
|
||||||
|
$this->sPlaceholder
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,16 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<!-- ko if: 0 === Type || 1 === Type -->
|
<!-- ko if: 0 === Type || 1 === Type -->
|
||||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="value: value" />
|
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
|
data-bind="value: value, attr: {placeholder: placeholder}" />
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: 3 === Type -->
|
<!-- ko if: 3 === Type -->
|
||||||
<input type="password" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="value: value" />
|
<input type="password" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
|
data-bind="value: value, attr: {placeholder: placeholder}" />
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: 2 === Type -->
|
<!-- ko if: 2 === Type -->
|
||||||
<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="value: value"></textarea>
|
<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
|
data-bind="value: value, attr: {placeholder: placeholder}"></textarea>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: 4 === Type -->
|
<!-- ko if: 4 === Type -->
|
||||||
<select data-bind="options: Default, value: value"></select>
|
<select data-bind="options: Default, value: value"></select>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue