-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSystemSettings.php
58 lines (51 loc) · 1.9 KB
/
SystemSettings.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
53
54
55
56
57
58
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\IPtoCompany;
use Piwik\Piwik;
use Piwik\Settings\Setting;
use Piwik\Settings\FieldConfig;
use Piwik\Validators\NotEmpty;
/**
* Defines Settings for IPtoCompany.
*
* Usage like this:
* $settings = new SystemSettings();
* $settings->metric->getValue();
* $settings->description->getValue();
*/
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
{
/** @var Setting */
public $ipInfoAccessToken;
/** @var Setting */
public $cacheLifeTimeForResults;
protected function init()
{
// Create a setting to store the IPInfo API token
$this->ipInfoAccessToken = $this->createIpInfoAccessTokenSetting();
$this->cacheLifeTimeForResults = $this->createCacheLifeTimeForResultsSetting();
}
private function createIpInfoAccessTokenSetting()
{
return $this->makeSetting('ipInfoAccessToken', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = Piwik::translate('IPtoCompany_YourIPInfoAccessToken');
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->description = Piwik::translate('IPtoCompany_PasteYourAccessToken');
// $field->validators[] = new NotEmpty();
});
}
private function createCacheLifeTimeForResultsSetting()
{
return $this->makeSetting('cacheLifeTimeForResults', $default = 2, FieldConfig::TYPE_INT, function (FieldConfig $field) {
$field->title = Piwik::translate('IPtoCompany_LifeTimeOfCacheForResultsInWeeks');
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->description = Piwik::translate('IPtoCompany_PasteYourAccessToken');
// $field->validators[] = new NotEmpty();
});
}
}