Rev 838 | Rev 1086 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
829 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * MIT License |
||
1050 | daniel-mar | 5 | * |
829 | daniel-mar | 6 | * Copyright (c) 2022 Simon Tushev |
1050 | daniel-mar | 7 | * |
829 | daniel-mar | 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: |
||
1050 | daniel-mar | 14 | * |
829 | daniel-mar | 15 | * The above copyright notice and this permission notice shall be included in all |
16 | * copies or substantial portions of the Software. |
||
1050 | daniel-mar | 17 | * |
829 | daniel-mar | 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 | |||
1050 | daniel-mar | 27 | namespace TushevOrg\OIDplus; |
829 | daniel-mar | 28 | |
1050 | daniel-mar | 29 | use ViaThinkSoft\OIDplus\OIDplus; |
30 | use ViaThinkSoft\OIDplus\OIDplusConfig; |
||
31 | use ViaThinkSoft\OIDplus\OIDplusException; |
||
32 | use ViaThinkSoft\OIDplus\OIDplusPagePluginPublic; |
||
33 | |||
829 | daniel-mar | 34 | class OIDplusPagePublicUITweaks extends OIDplusPagePluginPublic { |
35 | |||
36 | public function init($html=true) { |
||
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) { |
||
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_login_tree', 'UITweaks plugin: 1=Collapse login 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 | 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) { |
||
48 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
49 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
50 | } |
||
51 | }); |
||
838 | daniel-mar | 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) { |
53 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
54 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
55 | } |
||
56 | }); |
||
829 | daniel-mar | 57 | |
58 | OIDplus::config()->prepareConfigKey('uitweaks_menu_width', 'UITweaks plugin: default width of tree pane (in px)', '450', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
||
59 | if (!is_numeric($value) || ($value < 0)) { |
||
60 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
61 | } |
||
1050 | daniel-mar | 62 | }); |
829 | daniel-mar | 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) { |
64 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
65 | throw new OIDplusException(_L('Please enter a valid value.')); |
||
66 | } |
||
67 | }); |
||
68 | } |
||
1050 | daniel-mar | 69 | |
829 | daniel-mar | 70 | public function htmlHeaderUpdate(&$head_elems) { |
71 | $w = js_escape(OIDplus::config()->getValue('uitweaks_menu_width')); |
||
838 | daniel-mar | 72 | $rw = OIDplus::config()->getValue('uitweaks_menu_remember_width') == 1 ? 'true' : 'false'; |
73 | $o = OIDplus::config()->getValue('uitweaks_expand_objects_tree') == 1 ? 'true' : 'false'; |
||
74 | $l = OIDplus::config()->getValue('uitweaks_collapse_login_tree') == 1 ? 'true' : 'false'; |
||
75 | $r = OIDplus::config()->getValue('uitweaks_collapse_res_tree') == 1 ? 'true' : 'false'; |
||
76 | $r = OIDplus::config()->getValue('uitweaks_prefer_admin_login_tab') == 1 ? 'true' : 'false'; |
||
1050 | daniel-mar | 77 | |
829 | daniel-mar | 78 | $s = "<script>\n"; |
79 | $s .= " oidplus_menu_width = $w;\n"; |
||
80 | $s .= " let uitweaks = {\n"; |
||
838 | daniel-mar | 81 | $s .= " \"menu_remember_width\": $rw,\n"; |
82 | $s .= " \"expand_objects_tree\": $o,\n"; |
||
83 | $s .= " \"collapse_login_tree\": $l,\n"; |
||
84 | $s .= " \"collapse_res_tree\": $r,\n"; |
||
85 | $s .= " \"prefer_admin_login_tab\": $r,\n"; |
||
829 | daniel-mar | 86 | $s .= " };\n"; |
87 | $s .= "</script>"; |
||
1050 | daniel-mar | 88 | |
829 | daniel-mar | 89 | $head_elems[] = $s; |
90 | } |
||
91 | |||
92 | |||
93 | |||
94 | } |