Rev 838 | Rev 1086 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 838 | Rev 1050 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * MIT License |
4 | * MIT License |
5 | * |
5 | * |
6 | * Copyright (c) 2022 Simon Tushev |
6 | * Copyright (c) 2022 Simon Tushev |
7 | * |
7 | * |
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | * of this software and associated documentation files (the "Software"), to deal |
9 | * of this software and associated documentation files (the "Software"), to deal |
10 | * in the Software without restriction, including without limitation the rights |
10 | * in the Software without restriction, including without limitation the rights |
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12 | * copies of the Software, and to permit persons to whom the Software is |
12 | * copies of the Software, and to permit persons to whom the Software is |
13 | * furnished to do so, subject to the following conditions: |
13 | * furnished to do so, subject to the following conditions: |
14 | * |
14 | * |
15 | * The above copyright notice and this permission notice shall be included in all |
15 | * The above copyright notice and this permission notice shall be included in all |
16 | * copies or substantial portions of the Software. |
16 | * copies or substantial portions of the Software. |
17 | * |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
24 | * SOFTWARE. |
24 | * SOFTWARE. |
25 | */ |
25 | */ |
26 | 26 | ||
- | 27 | namespace TushevOrg\OIDplus; |
|
- | 28 | ||
- | 29 | use ViaThinkSoft\OIDplus\OIDplus; |
|
- | 30 | use ViaThinkSoft\OIDplus\OIDplusConfig; |
|
27 | if (!defined('INSIDE_OIDPLUS')) die(); |
31 | use ViaThinkSoft\OIDplus\OIDplusException; |
- | 32 | use ViaThinkSoft\OIDplus\OIDplusPagePluginPublic; |
|
28 | 33 | ||
29 | class OIDplusPagePublicUITweaks extends OIDplusPagePluginPublic { |
34 | class OIDplusPagePublicUITweaks extends OIDplusPagePluginPublic { |
30 | 35 | ||
31 | public function init($html=true) { |
36 | public function init($html=true) { |
32 | OIDplus::config()->prepareConfigKey('uitweaks_expand_objects_tree', 'UITweaks plugin: 1=Fully expand objects tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
37 | OIDplus::config()->prepareConfigKey('uitweaks_expand_objects_tree', 'UITweaks plugin: 1=Fully expand objects tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
33 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
38 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
34 | throw new OIDplusException(_L('Please enter a valid value.')); |
39 | throw new OIDplusException(_L('Please enter a valid value.')); |
35 | } |
40 | } |
36 | }); |
41 | }); |
37 | OIDplus::config()->prepareConfigKey('uitweaks_collapse_login_tree', 'UITweaks plugin: 1=Collapse login tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
42 | OIDplus::config()->prepareConfigKey('uitweaks_collapse_login_tree', 'UITweaks plugin: 1=Collapse login tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
38 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
43 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
39 | throw new OIDplusException(_L('Please enter a valid value.')); |
44 | throw new OIDplusException(_L('Please enter a valid value.')); |
40 | } |
45 | } |
41 | }); |
46 | }); |
42 | OIDplus::config()->prepareConfigKey('uitweaks_collapse_res_tree', 'UITweaks plugin: 1=Collapse Documents&Resources tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
47 | OIDplus::config()->prepareConfigKey('uitweaks_collapse_res_tree', 'UITweaks plugin: 1=Collapse Documents&Resources tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
43 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
48 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
44 | throw new OIDplusException(_L('Please enter a valid value.')); |
49 | throw new OIDplusException(_L('Please enter a valid value.')); |
45 | } |
50 | } |
46 | }); |
51 | }); |
47 | OIDplus::config()->prepareConfigKey('uitweaks_prefer_admin_login_tab', 'UITweaks plugin: 1=Prefer `Login as administrator` tab at login, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
52 | OIDplus::config()->prepareConfigKey('uitweaks_prefer_admin_login_tab', 'UITweaks plugin: 1=Prefer `Login as administrator` tab at login, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
48 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
53 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
49 | throw new OIDplusException(_L('Please enter a valid value.')); |
54 | throw new OIDplusException(_L('Please enter a valid value.')); |
50 | } |
55 | } |
51 | }); |
56 | }); |
52 | 57 | ||
53 | OIDplus::config()->prepareConfigKey('uitweaks_menu_width', 'UITweaks plugin: default width of tree pane (in px)', '450', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
58 | OIDplus::config()->prepareConfigKey('uitweaks_menu_width', 'UITweaks plugin: default width of tree pane (in px)', '450', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
54 | if (!is_numeric($value) || ($value < 0)) { |
59 | if (!is_numeric($value) || ($value < 0)) { |
55 | throw new OIDplusException(_L('Please enter a valid value.')); |
60 | throw new OIDplusException(_L('Please enter a valid value.')); |
56 | } |
61 | } |
57 | }); |
62 | }); |
58 | OIDplus::config()->prepareConfigKey('uitweaks_menu_remember_width', 'UITweaks plugin: 1=Remember menu width (save to browser.localStorage), 0=Default behavior', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
63 | OIDplus::config()->prepareConfigKey('uitweaks_menu_remember_width', 'UITweaks plugin: 1=Remember menu width (save to browser.localStorage), 0=Default behavior', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
59 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
64 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
60 | throw new OIDplusException(_L('Please enter a valid value.')); |
65 | throw new OIDplusException(_L('Please enter a valid value.')); |
61 | } |
66 | } |
62 | }); |
67 | }); |
63 | } |
68 | } |
64 | 69 | ||
65 | public function htmlHeaderUpdate(&$head_elems) { |
70 | public function htmlHeaderUpdate(&$head_elems) { |
66 | $w = js_escape(OIDplus::config()->getValue('uitweaks_menu_width')); |
71 | $w = js_escape(OIDplus::config()->getValue('uitweaks_menu_width')); |
67 | $rw = OIDplus::config()->getValue('uitweaks_menu_remember_width') == 1 ? 'true' : 'false'; |
72 | $rw = OIDplus::config()->getValue('uitweaks_menu_remember_width') == 1 ? 'true' : 'false'; |
68 | $o = OIDplus::config()->getValue('uitweaks_expand_objects_tree') == 1 ? 'true' : 'false'; |
73 | $o = OIDplus::config()->getValue('uitweaks_expand_objects_tree') == 1 ? 'true' : 'false'; |
69 | $l = OIDplus::config()->getValue('uitweaks_collapse_login_tree') == 1 ? 'true' : 'false'; |
74 | $l = OIDplus::config()->getValue('uitweaks_collapse_login_tree') == 1 ? 'true' : 'false'; |
70 | $r = OIDplus::config()->getValue('uitweaks_collapse_res_tree') == 1 ? 'true' : 'false'; |
75 | $r = OIDplus::config()->getValue('uitweaks_collapse_res_tree') == 1 ? 'true' : 'false'; |
71 | $r = OIDplus::config()->getValue('uitweaks_prefer_admin_login_tab') == 1 ? 'true' : 'false'; |
76 | $r = OIDplus::config()->getValue('uitweaks_prefer_admin_login_tab') == 1 ? 'true' : 'false'; |
72 | 77 | ||
73 | $s = "<script>\n"; |
78 | $s = "<script>\n"; |
74 | $s .= " oidplus_menu_width = $w;\n"; |
79 | $s .= " oidplus_menu_width = $w;\n"; |
75 | $s .= " let uitweaks = {\n"; |
80 | $s .= " let uitweaks = {\n"; |
76 | $s .= " \"menu_remember_width\": $rw,\n"; |
81 | $s .= " \"menu_remember_width\": $rw,\n"; |
77 | $s .= " \"expand_objects_tree\": $o,\n"; |
82 | $s .= " \"expand_objects_tree\": $o,\n"; |
78 | $s .= " \"collapse_login_tree\": $l,\n"; |
83 | $s .= " \"collapse_login_tree\": $l,\n"; |
79 | $s .= " \"collapse_res_tree\": $r,\n"; |
84 | $s .= " \"collapse_res_tree\": $r,\n"; |
80 | $s .= " \"prefer_admin_login_tab\": $r,\n"; |
85 | $s .= " \"prefer_admin_login_tab\": $r,\n"; |
81 | $s .= " };\n"; |
86 | $s .= " };\n"; |
82 | $s .= "</script>"; |
87 | $s .= "</script>"; |
83 | 88 | ||
84 | $head_elems[] = $s; |
89 | $head_elems[] = $s; |
85 | } |
90 | } |
86 | 91 | ||
87 | 92 | ||
88 | 93 | ||
89 | } |
94 | } |
90 | 95 |