Subversion Repositories oidplus

Rev

Rev 829 | Rev 1050 | 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
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
                });
838 daniel-mar 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) {
48
                        if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
49
                                throw new OIDplusException(_L('Please enter a valid value.'));
50
                        }
51
                });
829 daniel-mar 52
 
53
                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)) {
55
                                throw new OIDplusException(_L('Please enter a valid value.'));
56
                        }
57
                });            
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) {
59
                        if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
60
                                throw new OIDplusException(_L('Please enter a valid value.'));
61
                        }
62
                });
63
        }
64
 
65
        public function htmlHeaderUpdate(&$head_elems) {
66
                $w  = js_escape(OIDplus::config()->getValue('uitweaks_menu_width'));
838 daniel-mar 67
                $rw = OIDplus::config()->getValue('uitweaks_menu_remember_width')               == 1 ? 'true' : 'false';
68
                $o  = OIDplus::config()->getValue('uitweaks_expand_objects_tree')               == 1 ? 'true' : 'false';
69
                $l  = OIDplus::config()->getValue('uitweaks_collapse_login_tree')               == 1 ? 'true' : 'false';
70
                $r  = OIDplus::config()->getValue('uitweaks_collapse_res_tree')                 == 1 ? 'true' : 'false';
71
                $r  = OIDplus::config()->getValue('uitweaks_prefer_admin_login_tab')    == 1 ? 'true' : 'false';
829 daniel-mar 72
 
73
                $s  = "<script>\n";
74
                $s .= "  oidplus_menu_width = $w;\n";
75
                $s .= "  let uitweaks = {\n";
838 daniel-mar 76
                $s .= "    \"menu_remember_width\":     $rw,\n";
77
                $s .= "    \"expand_objects_tree\":     $o,\n";
78
                $s .= "    \"collapse_login_tree\":     $l,\n";
79
                $s .= "    \"collapse_res_tree\":       $r,\n";
80
                $s .= "    \"prefer_admin_login_tab\":  $r,\n";
829 daniel-mar 81
                $s .= "  };\n";
82
                $s .= "</script>";
83
 
84
                $head_elems[] = $s;
85
        }
86
 
87
 
88
 
89
}