Rev 328 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 328 | Rev 360 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | class OIDplusPageAdminColors extends OIDplusPagePluginAdmin { |
20 | class OIDplusPageAdminColors extends OIDplusPagePluginAdmin { |
21 | 21 | ||
22 | public function action($actionID, $params) { |
22 | public function action($actionID, $params) { |
23 | if ($actionID == 'color_update') { |
23 | if ($actionID == 'color_update') { |
24 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
24 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
25 | throw new OIDplusException('You need to log in as administrator.'); |
25 | throw new OIDplusException(_L('You need to log in as administrator.')); |
26 | } |
26 | } |
27 | 27 | ||
28 | OIDplus::config()->setValue('color_hue_shift', $params['hue_shift']); |
28 | OIDplus::config()->setValue('color_hue_shift', $params['hue_shift']); |
29 | OIDplus::config()->setValue('color_sat_shift', $params['sat_shift']); |
29 | OIDplus::config()->setValue('color_sat_shift', $params['sat_shift']); |
30 | OIDplus::config()->setValue('color_val_shift', $params['val_shift']); |
30 | OIDplus::config()->setValue('color_val_shift', $params['val_shift']); |
Line 32... | Line 32... | ||
32 | 32 | ||
33 | OIDplus::logger()->log("[OK]A?", "Changed system color theme"); |
33 | OIDplus::logger()->log("[OK]A?", "Changed system color theme"); |
34 | 34 | ||
35 | return array("status" => 0); |
35 | return array("status" => 0); |
36 | } else { |
36 | } else { |
37 | throw new OIDplusException("Unknown action ID"); |
37 | throw new OIDplusException(_L('Unknown action ID')); |
38 | } |
38 | } |
39 | } |
39 | } |
40 | 40 | ||
41 | public function init($html=true) { |
41 | public function init($html=true) { |
42 | OIDplus::config()->prepareConfigKey('color_hue_shift', 'HSV Hue shift of CSS colors (-360..360)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
42 | OIDplus::config()->prepareConfigKey('color_hue_shift', 'HSV Hue shift of CSS colors (-360..360)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
43 | if (!is_numeric($value) || ($value < -360) || ($value > 360)) { |
43 | if (!is_numeric($value) || ($value < -360) || ($value > 360)) { |
44 | throw new OIDplusException("Please enter a valid value."); |
44 | throw new OIDplusException(_L('Please enter a valid value.')); |
45 | } |
45 | } |
46 | }); |
46 | }); |
47 | OIDplus::config()->prepareConfigKey('color_sat_shift', 'HSV Saturation shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
47 | OIDplus::config()->prepareConfigKey('color_sat_shift', 'HSV Saturation shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
48 | if (!is_numeric($value) || ($value < -100) || ($value > 100)) { |
48 | if (!is_numeric($value) || ($value < -100) || ($value > 100)) { |
49 | throw new OIDplusException("Please enter a valid value."); |
49 | throw new OIDplusException(_L('Please enter a valid value.')); |
50 | } |
50 | } |
51 | }); |
51 | }); |
52 | OIDplus::config()->prepareConfigKey('color_val_shift', 'HSV Value shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
52 | OIDplus::config()->prepareConfigKey('color_val_shift', 'HSV Value shift of CSS colors (-100..100)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
53 | if (!is_numeric($value) || ($value < -100) || ($value > 100)) { |
53 | if (!is_numeric($value) || ($value < -100) || ($value > 100)) { |
54 | throw new OIDplusException("Please enter a valid value."); |
54 | throw new OIDplusException(_L('Please enter a valid value.')); |
55 | } |
55 | } |
56 | }); |
56 | }); |
57 | OIDplus::config()->prepareConfigKey('color_invert', 'Invert colors? (0=no, 1=yes)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
57 | OIDplus::config()->prepareConfigKey('color_invert', 'Invert colors? (0=no, 1=yes)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
58 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
58 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
59 | throw new OIDplusException("Please enter a valid value (0 or 1)."); |
59 | throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).')); |
60 | } |
60 | } |
61 | }); |
61 | }); |
62 | } |
62 | } |
63 | 63 | ||
64 | public function gui($id, &$out, &$handled) { |
64 | public function gui($id, &$out, &$handled) { |
65 | if ($id === 'oidplus:colors') { |
65 | if ($id === 'oidplus:colors') { |
66 | $handled = true; |
66 | $handled = true; |
67 | $out['title'] = 'Colors'; |
67 | $out['title'] = _L('Colors'); |
68 | $out['icon'] = OIDplus::webpath(__DIR__).'icon_big.png'; |
68 | $out['icon'] = OIDplus::webpath(__DIR__).'icon_big.png'; |
69 | 69 | ||
70 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
70 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
71 | $out['icon'] = 'img/error_big.png'; |
71 | $out['icon'] = 'img/error_big.png'; |
72 | $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>'; |
72 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
73 | return; |
73 | return; |
74 | } |
74 | } |
75 | 75 | ||
76 | $out['text'] = '<br><p>'; |
76 | $out['text'] = '<br><p>'; |
77 | $out['text'] .= ' <label for="amount">Hue shift:</label>'; |
77 | $out['text'] .= ' <label for="amount">'._L('Hue shift').':</label>'; |
78 | $out['text'] .= ' <input type="text" id="hshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
78 | $out['text'] .= ' <input type="text" id="hshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
79 | $out['text'] .= '</p>'; |
79 | $out['text'] .= '</p>'; |
80 | $out['text'] .= '<div id="slider-hshift"></div>'; |
80 | $out['text'] .= '<div id="slider-hshift"></div>'; |
81 | 81 | ||
82 | $out['text'] .= '<br><p>'; |
82 | $out['text'] .= '<br><p>'; |
83 | $out['text'] .= ' <label for="amount">Saturation shift:</label>'; |
83 | $out['text'] .= ' <label for="amount">'._L('Saturation shift').':</label>'; |
84 | $out['text'] .= ' <input type="text" id="sshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
84 | $out['text'] .= ' <input type="text" id="sshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
85 | $out['text'] .= '</p>'; |
85 | $out['text'] .= '</p>'; |
86 | $out['text'] .= '<div id="slider-sshift"></div>'; |
86 | $out['text'] .= '<div id="slider-sshift"></div>'; |
87 | 87 | ||
88 | $out['text'] .= '<br><p>'; |
88 | $out['text'] .= '<br><p>'; |
89 | $out['text'] .= ' <label for="amount">Value shift:</label>'; |
89 | $out['text'] .= ' <label for="amount">'._L('Value shift').':</label>'; |
90 | $out['text'] .= ' <input type="text" id="vshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
90 | $out['text'] .= ' <input type="text" id="vshift" readonly style="border:0; background:transparent; font-weight:bold;">'; |
91 | $out['text'] .= '</p>'; |
91 | $out['text'] .= '</p>'; |
92 | $out['text'] .= '<div id="slider-vshift"></div>'; |
92 | $out['text'] .= '<div id="slider-vshift"></div>'; |
93 | 93 | ||
94 | $out['text'] .= '<br><p>'; |
94 | $out['text'] .= '<br><p>'; |
95 | $out['text'] .= ' <label for="amount">Invert colors:</label>'; |
95 | $out['text'] .= ' <label for="amount">'._L('Invert colors').':</label>'; |
96 | $out['text'] .= ' <input type="text" id="icolor" readonly style="border:0; background:transparent; font-weight:bold;">'; |
96 | $out['text'] .= ' <input type="text" id="icolor" readonly style="border:0; background:transparent; font-weight:bold;">'; |
97 | $out['text'] .= '</p>'; |
97 | $out['text'] .= '</p>'; |
98 | $out['text'] .= '<div id="slider-icolor"></div>'; |
98 | $out['text'] .= '<div id="slider-icolor"></div>'; |
99 | 99 | ||
100 | $out['text'] .= '<script>'; |
100 | $out['text'] .= '<script>'; |
Line 104... | Line 104... | ||
104 | $out['text'] .= 'if (g_invcolors == null) g_invcolors = g_invcolors_saved = '.OIDplus::config()->getValue('color_invert').";\n"; |
104 | $out['text'] .= 'if (g_invcolors == null) g_invcolors = g_invcolors_saved = '.OIDplus::config()->getValue('color_invert').";\n"; |
105 | $out['text'] .= 'setup_color_sliders();'; |
105 | $out['text'] .= 'setup_color_sliders();'; |
106 | $out['text'] .= '</script>'; |
106 | $out['text'] .= '</script>'; |
107 | 107 | ||
108 | $out['text'] .= '<br>'; |
108 | $out['text'] .= '<br>'; |
109 | $out['text'] .= '<input type="button" onclick="color_reset_sliders_cfg()" value="Reset to last saved config">'.str_repeat(' ',5); |
109 | $out['text'] .= '<input type="button" onclick="color_reset_sliders_cfg()" value="'._L('Reset to last saved config').'">'.str_repeat(' ',5); |
110 | $out['text'] .= '<input type="button" onclick="color_reset_sliders_factory()" value="Reset default setting">'.str_repeat(' ',5); |
110 | $out['text'] .= '<input type="button" onclick="color_reset_sliders_factory()" value="'._L('Reset default setting').'">'.str_repeat(' ',5); |
111 | $out['text'] .= '<input type="button" onclick="test_color_theme()" value="Test">'.str_repeat(' ',5); |
111 | $out['text'] .= '<input type="button" onclick="test_color_theme()" value="'._L('Test').'">'.str_repeat(' ',5); |
112 | $out['text'] .= '<input type="button" onclick="crudActionColorUpdate()" value="Set permanently">'; |
112 | $out['text'] .= '<input type="button" onclick="crudActionColorUpdate()" value="'._L('Set permanently').'">'; |
113 | } |
113 | } |
114 | } |
114 | } |
115 | 115 | ||
116 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
116 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
117 | if (!OIDplus::authUtils()::isAdminLoggedIn()) return false; |
117 | if (!OIDplus::authUtils()::isAdminLoggedIn()) return false; |
Line 123... | Line 123... | ||
123 | } |
123 | } |
124 | 124 | ||
125 | $json[] = array( |
125 | $json[] = array( |
126 | 'id' => 'oidplus:colors', |
126 | 'id' => 'oidplus:colors', |
127 | 'icon' => $tree_icon, |
127 | 'icon' => $tree_icon, |
128 | 'text' => 'Colors' |
128 | 'text' => _L('Colors') |
129 | ); |
129 | ); |
130 | 130 | ||
131 | return true; |
131 | return true; |
132 | } |
132 | } |
133 | 133 | ||
Line 141... | Line 141... | ||
141 | } |
141 | } |
142 | 142 | ||
143 | public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ { |
143 | public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ { |
144 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
144 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
145 | 145 | ||
146 | echo "<p><u>Step $step: Color Theme</u></p>"; |
146 | echo '<p><u>'._L('Step %1: Color Theme',$step).'</u></p>'; |
147 | 147 | ||
148 | echo '<input type="checkbox" name="color_invert" id="color_invert"'; |
148 | echo '<input type="checkbox" name="color_invert" id="color_invert"'; |
149 | if (isset($_REQUEST['sent'])) { |
149 | if (isset($_REQUEST['sent'])) { |
150 | if ($set_value = isset($_REQUEST['color_invert'])) { |
150 | if ($set_value = isset($_REQUEST['color_invert'])) { |
151 | echo ' checked'; |
151 | echo ' checked'; |
Line 153... | Line 153... | ||
153 | } else { |
153 | } else { |
154 | if (OIDplus::config()->getValue('color_invert') == 1) { |
154 | if (OIDplus::config()->getValue('color_invert') == 1) { |
155 | echo ' checked'; |
155 | echo ' checked'; |
156 | } |
156 | } |
157 | } |
157 | } |
158 | echo '> <label for="color_invert">Dark Theme (inverted colors)</label><br>'; |
158 | echo '> <label for="color_invert">'._L('Dark Theme (inverted colors)').'</label><br>'; |
159 | 159 | ||
160 | $msg = ''; |
160 | $msg = ''; |
161 | if ($do_edits) { |
161 | if ($do_edits) { |
162 | try { |
162 | try { |
163 | OIDplus::config()->setValue('color_invert', $set_value ? 1 : 0); |
163 | OIDplus::config()->setValue('color_invert', $set_value ? 1 : 0); |