-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSystemSettings.php
More file actions
62 lines (56 loc) · 1.91 KB
/
SystemSettings.php
File metadata and controls
62 lines (56 loc) · 1.91 KB
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
59
60
61
62
<?php
/**
* Piwik - free/libre analytics platform.
*
* @see https://matomo.org
*
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\IP2Proxy;
use Piwik\Piwik;
use Piwik\Settings\FieldConfig;
use Piwik\Settings\Setting;
use Piwik\Validators\NotEmpty;
/**
* Defines Settings for IP2Proxy.
*
* Usage like this:
* $settings = new SystemSettings();
* $settings->metric->getValue();
* $settings->description->getValue();
*/
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
{
/** @var Setting */
public $database;
public $ioApiKey;
protected function init()
{
// Create a setting to store the IPInfo API token
$this->database = $this->createDatabaseSetting();
$this->ioApiKey = $this->createIP2LocationIoSetting();
}
private function createDatabaseSetting()
{
return $this->makeSetting('database', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = Piwik::translate('IP2Proxy_IP2ProxyBinDatabase');
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->inlineHelp = Piwik::translate('IP2Proxy_DownloadYourBinDatabase', [
'<a target="_blank" rel="noreferrer noopener" href="https://lite.ip2location.com/ip2proxy-lite">', '</a>',
'<a target="_blank" rel="noreferrer noopener" href="https://www.ip2location.com/database/ip2proxy">', '</a>',
]);
// $field->validators[] = new NotEmpty();
});
}
private function createIP2LocationIoSetting()
{
return $this->makeSetting('ioApiKey', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = Piwik::translate('IP2Proxy_IoApiKey');
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->inlineHelp = Piwik::translate('IP2Proxy_SignUpFreeIP2LocationIo', [
'<a target="_blank" rel="noreferrer noopener" href="https://www.ip2location.io/">', '</a>',
]);
// $field->validators[] = new NotEmpty();
});
}
}