-
Notifications
You must be signed in to change notification settings - Fork 10
/
SystemSettings.php
110 lines (97 loc) · 3.58 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?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\MatomoCustomOptOut;
use Piwik\Piwik;
use Piwik\Settings\FieldConfig;
use Piwik\Settings\Setting;
use Piwik\Settings\Plugin\SystemSettings as BaseSettings;
/**
* Defines Settings for CustomOptOut.
*
* Usage like this:
* $settings = new Settings('CustomOptOut');
* $settings->autoRefresh->getValue();
* $settings->metric->getValue();
*
*/
class SystemSettings extends BaseSettings
{
/**
* @var Setting
*/
public $enableEditor;
/**
* @var Setting
*/
public $editorTheme;
/**
* @var Setting
*/
public $defaultCssStyles;
/**
* @var Setting
*/
public $defaultCssFile;
/**
* @var Setting
*/
public $enableJavascriptInjection;
protected function init()
{
$this->enableEditor = $this->createEnableEditorSetting();
$this->editorTheme = $this->createThemeSetting();
$this->defaultCssStyles = $this->createDefaultCssStylesSetting();
$this->defaultCssFile = $this->createDefaultCssFileSetting();
$this->enableJavascriptInjection = $this->createEnableJavascriptInjectionSetting();
}
private function createEnableEditorSetting()
{
return $this->makeSetting('enableEditor', true, FieldConfig::TYPE_BOOL, function(FieldConfig $field) {
$field->title = Piwik::translate('CustomOptOut_ShowEditorOptionName');
$field->description = Piwik::translate('CustomOptOut_ShowEditorDescription');
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
});
}
private function createThemeSetting()
{
return $this->makeSetting('editorTheme', 'default', FieldConfig::TYPE_STRING, function(FieldConfig $field) {
$field->title = Piwik::translate('CustomOptOut_EditorThemeOptionName');
$field->description = Piwik::translate('CustomOptOut_EditorThemeDescription');
$field->uiControl = FieldConfig::UI_CONTROL_SINGLE_SELECT;
$field->availableValues = array(
'default' => 'Bright Theme',
'blackboard' => 'Dark Theme',
);
});
}
private function createDefaultCssStylesSetting()
{
return $this->makeSetting('defaultCssStyles', 'body { font-family: Arial; }', FieldConfig::TYPE_STRING, function(FieldConfig $field) {
$field->title = Piwik::translate('CustomOptOut_DefaultCssStyles');
$field->description = Piwik::translate('CustomOptOut_DefaultCssStylesDescription');
$field->uiControl = FieldConfig::UI_CONTROL_TEXTAREA;
});
}
private function createDefaultCssFileSetting()
{
return $this->makeSetting('defaultCssFile', null, FieldConfig::TYPE_STRING, function(FieldConfig $field) {
$field->title = Piwik::translate('CustomOptOut_DefaultCssFile');
$field->description = Piwik::translate('CustomOptOut_DefaultCssFileDescription');
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
});
}
private function createEnableJavascriptInjectionSetting()
{
return $this->makeSetting('enableJavascriptInjection', false, FieldConfig::TYPE_BOOL, function(FieldConfig $field) {
$field->title = Piwik::translate('CustomOptOut_EnableJavascriptInjection');
$field->description = Piwik::translate('CustomOptOut_EnableJavascriptInjectionDescription');
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
});
}
}