mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +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
|
|
@ -1 +1 @@
|
|||
1.4
|
||||
1.5
|
||||
|
|
@ -18,11 +18,17 @@ class GoogleAnalyticsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
*/
|
||||
public function configMapping()
|
||||
{
|
||||
return array(
|
||||
\RainLoop\Plugins\Property::NewInstance('account')->SetLabel('Account')
|
||||
->SetAllowedInJs(true)
|
||||
->SetDescription('UA-XXXXXXXX-X')
|
||||
->SetDefaultValue(''),
|
||||
$oAccount = \RainLoop\Plugins\Property::NewInstance('account')->SetLabel('Account')
|
||||
->SetAllowedInJs(true)
|
||||
->SetDefaultValue('')
|
||||
;
|
||||
|
||||
if (\method_exists($oAccount, 'SetPlaceholder'))
|
||||
{
|
||||
$oAccount->SetPlaceholder('UA-XXXXXXXX-X');
|
||||
}
|
||||
|
||||
return array($oAccount,
|
||||
\RainLoop\Plugins\Property::NewInstance('domain_name')->SetLabel('Domain Name')
|
||||
->SetAllowedInJs(true)
|
||||
->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));
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue