Subversion Repositories oidplus

Rev

Rev 987 | Rev 1050 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 987 Rev 1033
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
9
 * You may obtain a copy of the License at
10
 *
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
if (!defined('INSIDE_OIDPLUS')) die();
20
if (!defined('INSIDE_OIDPLUS')) die();
21
 
21
 
22
class OIDplusPageAdminColors extends OIDplusPagePluginAdmin {
22
class OIDplusPageAdminColors extends OIDplusPagePluginAdmin {
23
 
23
 
24
        public function htmlHeaderUpdate(&$head_elems) {
24
        public function htmlHeaderUpdate(&$head_elems) {
25
                foreach ($head_elems as &$line) {
25
                foreach ($head_elems as &$line) {
26
                        if (strpos($line,'oidplus.min.css.php') !== false) {
26
                        if (strpos($line,'oidplus.min.css.php') !== false) {
27
                                $add_css_args = array();
27
                                $add_css_args = array();
28
                                $add_css_args[] = 'theme='.urlencode(OIDplus::config()->getValue('design','default'));
28
                                $add_css_args[] = 'theme='.urlencode(OIDplus::config()->getValue('design','default'));
29
                                $add_css_args[] = 'invert='.urlencode(OIDplus::config()->getValue('color_invert',0));
29
                                $add_css_args[] = 'invert='.urlencode(OIDplus::config()->getValue('color_invert',0));
30
                                $add_css_args[] = 'h_shift='.urlencode(number_format(OIDplus::config()->getValue('color_hue_shift',0)/360,5,'.',''));
30
                                $add_css_args[] = 'h_shift='.urlencode(number_format(OIDplus::config()->getValue('color_hue_shift',0)/360,5,'.',''));
31
                                $add_css_args[] = 's_shift='.urlencode(number_format(OIDplus::config()->getValue('color_sat_shift',0)/100,5,'.',''));
31
                                $add_css_args[] = 's_shift='.urlencode(number_format(OIDplus::config()->getValue('color_sat_shift',0)/100,5,'.',''));
32
                                $add_css_args[] = 'v_shift='.urlencode(number_format(OIDplus::config()->getValue('color_val_shift',0)/100,5,'.',''));
32
                                $add_css_args[] = 'v_shift='.urlencode(number_format(OIDplus::config()->getValue('color_val_shift',0)/100,5,'.',''));
33
                                if (count($add_css_args) > 0) {
33
                                if (count($add_css_args) > 0) {
34
                                        $line = str_replace('oidplus.min.css.php?', 'oidplus.min.css.php&', $line);
34
                                        $line = str_replace('oidplus.min.css.php?', 'oidplus.min.css.php&', $line);
35
                                        $line = str_replace('oidplus.min.css.php', 'oidplus.min.css.php?'.htmlentities(implode('&',$add_css_args)), $line);
35
                                        $line = str_replace('oidplus.min.css.php', 'oidplus.min.css.php?'.htmlentities(implode('&',$add_css_args)), $line);
36
                                }
36
                                }
37
                        }
37
                        }
38
 
38
 
39
                        if ((stripos($line,'<meta') !== false) && (stripos($line,'name="theme-color"') !== false)) {
39
                        if ((stripos($line,'<meta') !== false) && (stripos($line,'name="theme-color"') !== false)) {
40
                                if (preg_match('@content="(.+)"@ismU', $line, $m)) {
40
                                if (preg_match('@content="(.+)"@ismU', $line, $m)) {
41
                                        $theme_color = $m[1];
41
                                        $theme_color = $m[1];
42
                                        $hs = OIDplus::config()->getValue('color_hue_shift',0)/360;
42
                                        $hs = OIDplus::config()->getValue('color_hue_shift',0)/360;
43
                                        $ss = OIDplus::config()->getValue('color_sat_shift',0)/100;
43
                                        $ss = OIDplus::config()->getValue('color_sat_shift',0)/100;
44
                                        $vs = OIDplus::config()->getValue('color_val_shift',0)/100;
44
                                        $vs = OIDplus::config()->getValue('color_val_shift',0)/100;
45
                                        $theme_color = changeHueOfCSS($theme_color, $hs, $ss, $vs); // "changeHueOfCSS" can also change a single color value if it has the form #xxyyzz or #xyz
45
                                        $theme_color = changeHueOfCSS($theme_color, $hs, $ss, $vs); // "changeHueOfCSS" can also change a single color value if it has the form #xxyyzz or #xyz
46
                                        if (OIDplus::config()->getValue('color_invert',0)) {
46
                                        if (OIDplus::config()->getValue('color_invert',0)) {
47
                                                $theme_color = invertColorsOfCSS($theme_color);
47
                                                $theme_color = invertColorsOfCSS($theme_color);
48
                                        }
48
                                        }
49
                                        $line = preg_replace('@content="(.+)"@ismU', 'content="'.$theme_color.'"', $line);
49
                                        $line = preg_replace('@content="(.+)"@ismU', 'content="'.$theme_color.'"', $line);
50
 
50
 
51
                                }
51
                                }
52
                        }
52
                        }
53
                }
53
                }
54
        }
54
        }
55
 
55
 
56
        public function action($actionID, $params) {
56
        public function action($actionID, $params) {
57
                if ($actionID == 'color_update') {
57
                if ($actionID == 'color_update') {
58
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
58
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
59
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
59
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
60
                        }
60
                        }
61
 
61
 
62
                        _CheckParamExists($params, 'hue_shift');
62
                        _CheckParamExists($params, 'hue_shift');
63
                        _CheckParamExists($params, 'sat_shift');
63
                        _CheckParamExists($params, 'sat_shift');
64
                        _CheckParamExists($params, 'val_shift');
64
                        _CheckParamExists($params, 'val_shift');
65
                        _CheckParamExists($params, 'invcolors');
65
                        _CheckParamExists($params, 'invcolors');
66
                        _CheckParamExists($params, 'theme');
66
                        _CheckParamExists($params, 'theme');
67
 
67
 
68
                        OIDplus::config()->setValue('color_hue_shift', $params['hue_shift']);
68
                        OIDplus::config()->setValue('color_hue_shift', $params['hue_shift']);
69
                        OIDplus::config()->setValue('color_sat_shift', $params['sat_shift']);
69
                        OIDplus::config()->setValue('color_sat_shift', $params['sat_shift']);
70
                        OIDplus::config()->setValue('color_val_shift', $params['val_shift']);
70
                        OIDplus::config()->setValue('color_val_shift', $params['val_shift']);
71
                        OIDplus::config()->setValue('color_invert',    $params['invcolors']);
71
                        OIDplus::config()->setValue('color_invert',    $params['invcolors']);
72
                        OIDplus::config()->setValue('design',          $params['theme']);
72
                        OIDplus::config()->setValue('design',          $params['theme']);
73
 
73
 
74
                        OIDplus::logger()->log("[OK]A?", "Changed system color theme");
74
                        OIDplus::logger()->log("[OK]A?", "Changed system color theme");
75
 
75
 
76
                        return array("status" => 0);
76
                        return array("status" => 0);
77
                } else {
77
                } else {
78
                        throw new OIDplusException(_L('Unknown action ID'));
78
                        throw new OIDplusException(_L('Unknown action ID'));
79
                }
79
                }
80
        }
80
        }
81
 
81
 
82
        public function init($html=true) {
82
        public function init($html=true) {
83
                OIDplus::config()->prepareConfigKey('color_hue_shift', 'HSV Hue shift of CSS colors (-360..360)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
83
                OIDplus::config()->prepareConfigKey('color_hue_shift', 'HSV Hue shift of CSS colors (-360..360)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
84
                        if (!is_numeric($value) || ($value < -360) || ($value > 360)) {
84
                        if (!is_numeric($value) || ($value < -360) || ($value > 360)) {
85
                                throw new OIDplusException(_L('Please enter a valid value.'));
85
                                throw new OIDplusException(_L('Please enter a valid value.'));
86
                        }
86
                        }
87
                });
87
                });
88
                OIDplus::config()->prepareConfigKey('color_sat_shift', 'HSV Saturation shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
88
                OIDplus::config()->prepareConfigKey('color_sat_shift', 'HSV Saturation shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
89
                        if (!is_numeric($value) || ($value < -100) || ($value > 100)) {
89
                        if (!is_numeric($value) || ($value < -100) || ($value > 100)) {
90
                                throw new OIDplusException(_L('Please enter a valid value.'));
90
                                throw new OIDplusException(_L('Please enter a valid value.'));
91
                        }
91
                        }
92
                });
92
                });
93
                OIDplus::config()->prepareConfigKey('color_val_shift', 'HSV Value shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
93
                OIDplus::config()->prepareConfigKey('color_val_shift', 'HSV Value shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
94
                        if (!is_numeric($value) || ($value < -100) || ($value > 100)) {
94
                        if (!is_numeric($value) || ($value < -100) || ($value > 100)) {
95
                                throw new OIDplusException(_L('Please enter a valid value.'));
95
                                throw new OIDplusException(_L('Please enter a valid value.'));
96
                        }
96
                        }
97
                });
97
                });
98
                OIDplus::config()->prepareConfigKey('color_invert', 'Invert colors? (0=no, 1=yes)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
98
                OIDplus::config()->prepareConfigKey('color_invert', 'Invert colors? (0=no, 1=yes)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
99
                        if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
99
                        if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
100
                                throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).'));
100
                                throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).'));
101
                        }
101
                        }
102
                });
102
                });
103
                OIDplus::config()->prepareConfigKey('design', 'Which design to use (must exist in plugins/[vendorname]/design/)?', 'default', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
103
                OIDplus::config()->prepareConfigKey('design', 'Which design to use (must exist in plugins/[vendorname]/design/)?', 'default', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
104
                        $good = true;
104
                        $good = true;
105
                        if (strpos($value,'/') !== false) $good = false;
105
                        if (strpos($value,'/') !== false) $good = false;
106
                        if (strpos($value,'\\') !== false) $good = false;
106
                        if (strpos($value,'\\') !== false) $good = false;
107
                        if (strpos($value,'..') !== false) $good = false;
107
                        if (strpos($value,'..') !== false) $good = false;
108
                        if (!$good) {
108
                        if (!$good) {
109
                                throw new OIDplusException(_L('Invalid design folder name. Do only enter a folder name, not an absolute or relative path'));
109
                                throw new OIDplusException(_L('Invalid design folder name. Do only enter a folder name, not an absolute or relative path'));
110
                        }
110
                        }
111
 
111
 
112
                        if (!wildcard_is_dir(OIDplus::localpath().'plugins/'.'*'.'/design/'.$value)) {
112
                        if (!wildcard_is_dir(OIDplus::localpath().'plugins/'.'*'.'/design/'.$value)) {
113
                                throw new OIDplusException(_L('The design "%1" does not exist in plugin directory %2',$value,'plugins/[vendorname]/design/'));
113
                                throw new OIDplusException(_L('The design "%1" does not exist in plugin directory %2',$value,'plugins/[vendorname]/design/'));
114
                        }
114
                        }
115
                });
115
                });
116
                OIDplus::config()->prepareConfigKey('oobe_colors_done', '"Out Of Box Experience" wizard for OIDplusPageAdminColors done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
116
                OIDplus::config()->prepareConfigKey('oobe_colors_done', '"Out Of Box Experience" wizard for OIDplusPageAdminColors done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
117
        }
117
        }
118
 
118
 
119
        public function gui($id, &$out, &$handled) {
119
        public function gui($id, &$out, &$handled) {
120
                if ($id === 'oidplus:colors') {
120
                if ($id === 'oidplus:colors') {
121
                        $handled = true;
121
                        $handled = true;
122
                        $out['title'] = _L('Design');
122
                        $out['title'] = _L('Design');
123
                        $out['icon']  = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png';
123
                        $out['icon']  = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png';
124
 
124
 
125
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
125
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
126
                                $out['icon'] = 'img/error.png';
126
                                $out['icon'] = 'img/error.png';
127
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
127
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
128
                                return;
128
                                return;
129
                        }
129
                        }
130
 
130
 
131
                        $out['text']  = '<br><p>';
131
                        $out['text']  = '<br><p>';
132
                        $out['text'] .= '  <label for="theme">'._L('Design').':</label>';
132
                        $out['text'] .= '  <label for="theme">'._L('Design').':</label>';
133
                        $out['text'] .= '  <select name="theme" id="theme">';
133
                        $out['text'] .= '  <select name="theme" id="theme">';
134
                        foreach (OIDplus::getDesignPlugins() as $plugin) {
134
                        foreach (OIDplus::getDesignPlugins() as $plugin) {
135
                                $folder = basename($plugin->getPluginDirectory());
135
                                $folder = basename($plugin->getPluginDirectory());
136
                                $selected = $folder == OIDplus::config()->getValue('design') ? ' selected="true"' : '';
136
                                $selected = $folder == OIDplus::config()->getValue('design') ? ' selected="true"' : '';
137
                                $out['text'] .= '<option value="'.htmlentities($folder).'"'.$selected.'>'.htmlentities($plugin->getManifest()->getName()).'</option>';
137
                                $out['text'] .= '<option value="'.htmlentities($folder).'"'.$selected.'>'.htmlentities($plugin->getManifest()->getName()).'</option>';
138
                        }
138
                        }
139
                        $out['text'] .= '  </select>';
139
                        $out['text'] .= '  </select>';
140
                        $out['text'] .= '</p>';
140
                        $out['text'] .= '</p>';
141
 
141
 
142
                        $out['text'] .= '<br><p>';
142
                        $out['text'] .= '<br><p>';
143
                        $out['text'] .= '  <label for="amount">'._L('Hue shift').':</label>';
143
                        $out['text'] .= '  <label for="amount">'._L('Hue shift').':</label>';
144
                        $out['text'] .= '  <input type="text" id="hshift" readonly style="border:0; background:transparent; font-weight:bold;">';
144
                        $out['text'] .= '  <input type="text" id="hshift" readonly style="border:0; background:transparent; font-weight:bold;">';
145
                        $out['text'] .= '</p>';
145
                        $out['text'] .= '</p>';
146
                        $out['text'] .= '<div id="slider-hshift"></div>';
146
                        $out['text'] .= '<div id="slider-hshift"></div>';
147
 
147
 
148
                        $out['text'] .= '<br><p>';
148
                        $out['text'] .= '<br><p>';
149
                        $out['text'] .= '  <label for="amount">'._L('Saturation shift').':</label>';
149
                        $out['text'] .= '  <label for="amount">'._L('Saturation shift').':</label>';
150
                        $out['text'] .= '  <input type="text" id="sshift" readonly style="border:0; background:transparent; font-weight:bold;">';
150
                        $out['text'] .= '  <input type="text" id="sshift" readonly style="border:0; background:transparent; font-weight:bold;">';
151
                        $out['text'] .= '</p>';
151
                        $out['text'] .= '</p>';
152
                        $out['text'] .= '<div id="slider-sshift"></div>';
152
                        $out['text'] .= '<div id="slider-sshift"></div>';
153
 
153
 
154
                        $out['text'] .= '<br><p>';
154
                        $out['text'] .= '<br><p>';
155
                        $out['text'] .= '  <label for="amount">'._L('Value shift').':</label>';
155
                        $out['text'] .= '  <label for="amount">'._L('Value shift').':</label>';
156
                        $out['text'] .= '  <input type="text" id="vshift" readonly style="border:0; background:transparent; font-weight:bold;">';
156
                        $out['text'] .= '  <input type="text" id="vshift" readonly style="border:0; background:transparent; font-weight:bold;">';
157
                        $out['text'] .= '</p>';
157
                        $out['text'] .= '</p>';
158
                        $out['text'] .= '<div id="slider-vshift"></div>';
158
                        $out['text'] .= '<div id="slider-vshift"></div>';
159
 
159
 
160
                        $out['text'] .= '<p><div><input type="checkbox" id="icolor"> <label for="icolor">'._L('Invert colors').'</label></div></p>';
160
                        $out['text'] .= '<p><div><input type="checkbox" id="icolor"> <label for="icolor">'._L('Invert colors').'</label></div></p>';
161
 
161
 
162
                        $out['text'] .= '<script>';
162
                        $out['text'] .= '<script>';
163
                        $out['text'] .= 'if (OIDplusPageAdminColors.hue_shift == null) OIDplusPageAdminColors.hue_shift = OIDplusPageAdminColors.hue_shift_saved = '.OIDplus::config()->getValue('color_hue_shift').";\n";
163
                        $out['text'] .= 'if (OIDplusPageAdminColors.hue_shift == null) OIDplusPageAdminColors.hue_shift = OIDplusPageAdminColors.hue_shift_saved = '.OIDplus::config()->getValue('color_hue_shift').";\n";
164
                        $out['text'] .= 'if (OIDplusPageAdminColors.sat_shift == null) OIDplusPageAdminColors.sat_shift = OIDplusPageAdminColors.sat_shift_saved = '.OIDplus::config()->getValue('color_sat_shift').";\n";
164
                        $out['text'] .= 'if (OIDplusPageAdminColors.sat_shift == null) OIDplusPageAdminColors.sat_shift = OIDplusPageAdminColors.sat_shift_saved = '.OIDplus::config()->getValue('color_sat_shift').";\n";
165
                        $out['text'] .= 'if (OIDplusPageAdminColors.val_shift == null) OIDplusPageAdminColors.val_shift = OIDplusPageAdminColors.val_shift_saved = '.OIDplus::config()->getValue('color_val_shift').";\n";
165
                        $out['text'] .= 'if (OIDplusPageAdminColors.val_shift == null) OIDplusPageAdminColors.val_shift = OIDplusPageAdminColors.val_shift_saved = '.OIDplus::config()->getValue('color_val_shift').";\n";
166
                        $out['text'] .= 'if (OIDplusPageAdminColors.invcolors == null) OIDplusPageAdminColors.invcolors = OIDplusPageAdminColors.invcolors_saved = '.OIDplus::config()->getValue('color_invert').";\n";
166
                        $out['text'] .= 'if (OIDplusPageAdminColors.invcolors == null) OIDplusPageAdminColors.invcolors = OIDplusPageAdminColors.invcolors_saved = '.OIDplus::config()->getValue('color_invert').";\n";
167
                        $out['text'] .= 'if (OIDplusPageAdminColors.activetheme == null) OIDplusPageAdminColors.activetheme_saved = '.js_escape(OIDplus::config()->getValue('design')).";\n";
167
                        $out['text'] .= 'if (OIDplusPageAdminColors.activetheme == null) OIDplusPageAdminColors.activetheme_saved = '.js_escape(OIDplus::config()->getValue('design')).";\n";
168
                        $out['text'] .= 'OIDplusPageAdminColors.setup_color_sliders();';
168
                        $out['text'] .= 'OIDplusPageAdminColors.setup_color_sliders();';
169
                        $out['text'] .= '</script>';
169
                        $out['text'] .= '</script>';
170
 
170
 
171
                        $out['text'] .= '<br>';
171
                        $out['text'] .= '<br>';
172
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.color_reset_sliders_cfg()" value="'._L('Reset to last saved config').'">'.str_repeat('&nbsp;',5);
172
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.color_reset_sliders_cfg()" value="'._L('Reset to last saved config').'">'.str_repeat('&nbsp;',5);
173
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.color_reset_sliders_factory()" value="'._L('Reset default setting').'">'.str_repeat('&nbsp;',5);
173
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.color_reset_sliders_factory()" value="'._L('Reset default setting').'">'.str_repeat('&nbsp;',5);
174
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.test_color_theme()" value="'._L('Test').'">'.str_repeat('&nbsp;',5);
174
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.test_color_theme()" value="'._L('Test').'">'.str_repeat('&nbsp;',5);
175
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.crudActionColorUpdate()" value="'._L('Set permanently').'">';
175
                        $out['text'] .= '<input type="button" onclick="OIDplusPageAdminColors.crudActionColorUpdate()" value="'._L('Set permanently').'">';
176
                }
176
                }
177
        }
177
        }
178
 
178
 
179
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
179
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
180
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
180
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
181
 
181
 
182
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
182
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
183
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
183
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
184
                } else {
184
                } else {
185
                        $tree_icon = null; // default icon (folder)
185
                        $tree_icon = null; // default icon (folder)
186
                }
186
                }
187
 
187
 
188
                $json[] = array(
188
                $json[] = array(
189
                        'id' => 'oidplus:colors',
189
                        'id' => 'oidplus:colors',
190
                        'icon' => $tree_icon,
190
                        'icon' => $tree_icon,
191
                        'text' => _L('Design')
191
                        'text' => _L('Design')
192
                );
192
                );
193
 
193
 
194
                return true;
194
                return true;
195
        }
195
        }
196
 
196
 
197
        public function tree_search($request) {
197
        public function tree_search($request) {
198
                return false;
198
                return false;
199
        }
199
        }
200
 
200
 
201
        public function implementsFeature($id) {
201
        public function implementsFeature($id) {
202
                if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested
202
                if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested
203
                return false;
203
                return false;
204
        }
204
        }
205
 
205
 
206
        public function oobeRequested(): bool {
206
        public function oobeRequested(): bool {
207
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.1
207
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.1
208
 
208
 
209
                return OIDplus::config()->getValue('oobe_colors_done') == '0';
209
                return OIDplus::config()->getValue('oobe_colors_done') == '0';
210
        }
210
        }
211
 
211
 
212
        public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
212
        public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
213
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.1
213
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.1
214
 
214
 
215
                echo '<p><u>'._L('Step %1: Color Theme',$step).'</u></p>';
215
                echo '<p><u>'._L('Step %1: Color Theme',$step).'</u></p>';
216
 
216
 
217
                echo '<input type="checkbox" name="color_invert" id="color_invert"';
217
                echo '<input type="checkbox" name="color_invert" id="color_invert"';
218
                if (isset($_REQUEST['sent'])) {
218
                if (isset($_POST['sent'])) {
219
                        if ($set_value = isset($_REQUEST['color_invert'])) {
219
                        if ($set_value = isset($_POST['color_invert'])) {
220
                                echo ' checked';
220
                                echo ' checked';
221
                        }
221
                        }
222
                } else {
222
                } else {
223
                        if ($set_value = (OIDplus::config()->getValue('color_invert') == 1)) {
223
                        if ($set_value = (OIDplus::config()->getValue('color_invert') == 1)) {
224
                                echo ' checked';
224
                                echo ' checked';
225
                        }
225
                        }
226
                }
226
                }
227
                echo '> <label for="color_invert">'._L('Dark Theme (inverted colors)').'</label><br>';
227
                echo '> <label for="color_invert">'._L('Dark Theme (inverted colors)').'</label><br>';
228
 
228
 
229
                $msg = '';
229
                $msg = '';
230
                if ($do_edits) {
230
                if ($do_edits) {
231
                        try {
231
                        try {
232
                                OIDplus::config()->setValue('color_invert', $set_value ? 1 : 0);
232
                                OIDplus::config()->setValue('color_invert', $set_value ? 1 : 0);
233
                                OIDplus::config()->setValue('oobe_colors_done', '1');
233
                                OIDplus::config()->setValue('oobe_colors_done', '1');
234
                        } catch (Exception $e) {
234
                        } catch (Exception $e) {
235
                                $msg = $e->getMessage();
235
                                $msg = $e->getMessage();
236
                                $errors_happened = true;
236
                                $errors_happened = true;
237
                        }
237
                        }
238
                }
238
                }
239
 
239
 
240
                echo ' <font color="red"><b>'.$msg.'</b></font>';
240
                echo ' <font color="red"><b>'.$msg.'</b></font>';
241
        }
241
        }
242
 
242
 
243
}
243
}
244
 
244