-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.php
52 lines (44 loc) · 1.67 KB
/
Settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\LiveEngagement;
use Piwik\Settings\SystemSetting;
use Piwik\Settings\UserSetting;
use Piwik\Piwik;
/**
* Defines Settings for LiveEngagementPlugin.
*
*/
class Settings extends \Piwik\Plugin\Settings
{
/** @var SystemSetting */
public $refreshInterval;
protected function init()
{
$this->setIntroduction(Piwik::translate('LiveEngagement_SettingsIntroduction'));
// System setting --> textbox converted to int defining a validator and filter
$this->createRefreshIntervalSetting();
}
private function createRefreshIntervalSetting()
{
$this->refreshInterval = new SystemSetting('refreshInterval', Piwik::translate('LiveEngagement_SettingsRefreshInterval'));
$this->refreshInterval->readableByCurrentUser = true;
$this->refreshInterval->type = static::TYPE_INT;
$this->refreshInterval->uiControlType = static::CONTROL_TEXT;
$this->refreshInterval->uiControlAttributes = array('size' => 3);
$this->refreshInterval->description = Piwik::translate('LiveEngagement_SettingsRefreshIntervalDescription');
$this->refreshInterval->inlineHelp = Piwik::translate('LiveEngagement_SettingsRefreshIntervalHelp');
$this->refreshInterval->defaultValue = '5';
$this->refreshInterval->validate = function ($value, $setting) {
if ($value < 1) {
throw new \Exception('Value is invalid');
}
};
$this->addSetting($this->refreshInterval);
}
}