-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSystemSettings.php
More file actions
53 lines (47 loc) · 1.69 KB
/
Copy pathSystemSettings.php
File metadata and controls
53 lines (47 loc) · 1.69 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
<?php
namespace Piwik\Plugins\VipDetector;
use Piwik\Settings\FieldConfig;
use Piwik\Validators\NotEmpty;
use Piwik\Validators\UrlLike;
use Piwik\Settings\Plugin\SystemSetting;
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
{
public SystemSetting $importUrl;
public SystemSetting $importViaScheduler;
protected function init(): void
{
$this->title = "VIP Ranges Detector";
$this->importUrl = $this->createImportUrlSetting();
$this->importViaScheduler = $this->importViaSchedulerSetting();
}
// Source URL Setting
private function createImportUrlSetting(): SystemSetting
{
return $this->makeSetting(
'importUrl',
'https://ranges.vikoe.eu/all.json',
FieldConfig::TYPE_STRING,
function (FieldConfig $field) {
$field->title = 'Json Source File Download URL';
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->description = 'The URL where the range file is located';
$field->validators[] = new NotEmpty();
$field->validators[] = new UrlLike();
}
);
}
// Import via CLI or Scheduler?
private function importViaSchedulerSetting(): SystemSetting
{
return $this->makeSetting(
'importViaScheduler',
false,
FieldConfig::TYPE_BOOL,
function (FieldConfig $field) {
$field->title = 'Use Scheduler';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'If enabled, this URL will be used. If disabled, use the CLI importer.';
}
);
}
}