Rev 838 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
829 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * MIT License |
||
5 | * |
||
6 | * Copyright (c) 2022 Simon Tushev |
||
7 | * |
||
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 |
||
10 | * in the Software without restriction, including without limitation the rights |
||
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 |
||
13 | * furnished to do so, subject to the following conditions: |
||
14 | * |
||
15 | * The above copyright notice and this permission notice shall be included in all |
||
16 | * copies or substantial portions of the Software. |
||
17 | * |
||
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, |
||
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 |
||
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 |
||
24 | * SOFTWARE. |
||
25 | */ |
||
26 | |||
27 | if (!defined('INSIDE_OIDPLUS')) die(); |
||
28 | |||
29 | class OIDplusPagePublicUITweaks extends OIDplusPagePluginPublic { |
||
30 | |||
31 | 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) { |
||
33 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
34 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
35 | } |
||
36 | }); |
||
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) { |
||
38 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
39 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
40 | } |
||
41 | }); |
||
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) { |
||
43 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
44 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
45 | } |
||
46 | }); |
||
47 | |||
48 | OIDplus::config()->prepareConfigKey('uitweaks_menu_width', 'UITweaks plugin: default width of tree pane (in px)', '450', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
||
49 | if (!is_numeric($value) || ($value < 0)) { |
||
50 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
51 | } |
||
52 | }); |
||
53 | 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) { |
||
54 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
55 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
56 | } |
||
57 | }); |
||
58 | } |
||
59 | |||
60 | public function htmlHeaderUpdate(&$head_elems) { |
||
61 | $w = js_escape(OIDplus::config()->getValue('uitweaks_menu_width')); |
||
62 | $rw = OIDplus::config()->getValue('uitweaks_menu_remember_width') == 1 ? 'true' : 'false'; |
||
63 | $o = OIDplus::config()->getValue('uitweaks_expand_objects_tree') == 1 ? 'true' : 'false'; |
||
64 | $l = OIDplus::config()->getValue('uitweaks_collapse_login_tree') == 1 ? 'true' : 'false'; |
||
65 | $r = OIDplus::config()->getValue('uitweaks_collapse_res_tree') == 1 ? 'true' : 'false'; |
||
66 | |||
67 | $s = "<script>\n"; |
||
68 | $s .= " oidplus_menu_width = $w;\n"; |
||
69 | $s .= " let uitweaks = {\n"; |
||
70 | $s .= " \"menu_remember_width\": $rw,\n"; |
||
71 | $s .= " \"expand_objects_tree\": $o,\n"; |
||
72 | $s .= " \"collapse_login_tree\": $l,\n"; |
||
73 | $s .= " \"collapse_res_tree\": $r,\n"; |
||
74 | $s .= " };\n"; |
||
75 | $s .= "</script>"; |
||
76 | |||
77 | $head_elems[] = $s; |
||
78 | } |
||
79 | |||
80 | |||
81 | |||
82 | } |