XoopsGuiDark::header()   F
last analyzed

Complexity

Conditions 37
Paths > 20000

Size

Total Lines 288
Code Lines 216

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 37
eloc 216
nc 45360
nop 0
dl 0
loc 288
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
use Xmf\Request;
13
14
xoops_load('gui', 'system');
15
16
/*
17
 * Xoops Cpanel default GUI class
18
 *
19
 * @copyright   (c) 2000-2016 XOOPS Project (www.xoops.org)
20
 * @license     GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
21
 * @package     system
22
 * @usbpackage  GUI
23
 * @since       2.4
24
 * @author      Mamba       <[email protected]>
25
 * @author      Mojtabajml  <[email protected]>
26
 * @author      Voltan      <[email protected]>
27
 * @author      BitC3R0     <[email protected]>
28
 * @author      trabis      <[email protected]>
29
 */
30
31
/**
32
 * Class XoopsGuiDark
33
 */
34
class XoopsGuiDark extends XoopsSystemGui
35
{
36
    /**
37
     *
38
     */
39
    /*
40
    public function __construct()
41
    {
42
        // Check cookie
43
        $used = isset($_COOKIE['transition_theme']) ? $_COOKIE['transition_theme'] : 0;
44
45
        if(0 == $used){
46
47
            setcookie('transition_theme', 1, time() + (86400*365), '/', null, null, true);
48
49
            header('location: ' . XOOPS_URL . '/admin.php?show=info');
50
            die();
51
        }
52
    }
53
    */
54
    /**
55
     * @return bool
56
     */
57
    public static function validate()
58
    {
59
        return true;
60
    }
61
62
    public function header()
63
    {
64
        parent::header();
65
66
        global $xoopsConfig, $xoopsUser, $xoopsModule, $xoTheme, $xoopsTpl, $xoopsDB;
67
        $tpl =& $this->template;
68
69
        // Determine if information box must be shown
70
        $currentScript = str_replace(XOOPS_ROOT_PATH . '/', '', $_SERVER['SCRIPT_FILENAME']);
71
72
        if('admin.php' == $currentScript){
73
            $show = Request::getString('show', '', 'GET');
74
            if('info' == $show){
75
                $tpl->assign('showTransitionInfo', true);
76
            }
77
        }
78
79
        $iconsSet = xoops_getModuleOption('typeicons', 'system');
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

79
        $iconsSet = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('typeicons', 'system');
Loading history...
80
81
        if ($iconsSet == '') {
82
            $icons = 'transition';
83
        }
84
85
        $tpl->assign('theme_icons', XOOPS_URL . '/modules/system/images/icons/' . $iconsSet);
86
87
        // language
88
        $tpl->assign('xoops_language', $xoopsConfig['language']);
89
90
        $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
91
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/close_errors.js');
92
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/formenu.js');
93
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/menu.js');
94
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tooltip.js');
95
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.js');
96
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.slideshow.js');
97
98
        $xoTheme->addStylesheet('https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:300,300i,400,400i,700,700i');
99
//        $xoTheme->addStylesheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
100
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/style.css');
101
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/dark.css', array('title' => 'dark', 'media' => 'screen'));
102
        //$xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/silver.css', array('title' => 'silver', 'media' => 'screen'));
103
        //$xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/orange.css', array('title' => 'orange', 'media' => 'screen'));
104
105
        $tpl->assign('lang_cp', _CPHOME);
106
        //start system overview
107
        //$tpl->assign('lang_xoops_version', XOOPS_VERSION);
108
        $tpl->assign('lang_php_version', PHP_VERSION);
109
        $tpl->assign('lang_smarty_version', $tpl::SMARTY_VERSION);
110
        $tpl->assign('lang_mysql_version', mysqli_get_server_info($xoopsDB->conn));
111
        $tpl->assign('lang_server_api', PHP_SAPI);
112
        $tpl->assign('lang_os_name', PHP_OS);
113
//        $tpl->assign('safe_mode', ini_get('safe_mode') ? 'On' : 'Off');
114
//        $tpl->assign('register_globals', ini_get('register_globals') ? 'On' : 'Off');
115
//        $tpl->assign('magic_quotes_gpc', ini_get('magic_quotes_gpc') ? 'On' : 'Off');
116
        $tpl->assign('allow_url_fopen', ini_get('allow_url_fopen') ? 'On' : 'Off');
117
        $tpl->assign('fsockopen', function_exists('fsockopen') ? 'On' : 'Off');
118
//        $tpl->assign('allow_call_time_pass_reference', ini_get('allow_call_time_pass_reference') ? 'On' : 'Off');
119
        $tpl->assign('post_max_size', ini_get('post_max_size'));
120
        $tpl->assign('max_input_time', ini_get('max_input_time'));
121
        $tpl->assign('output_buffering', ini_get('output_buffering'));
122
        $tpl->assign('max_execution_time', ini_get('max_execution_time'));
123
        $tpl->assign('memory_limit', ini_get('memory_limit'));
124
        $tpl->assign('file_uploads', ini_get('file_uploads') ? 'On' : 'Off');
125
        $tpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
126
        $tpl->assign('xoops_sitename', $xoopsConfig['sitename']);
127
128
        // ADD MENU *****************************************
129
130
        //Add  CONTROL PANEL  Menu  items
131
        $menu                = array();
132
        $menu[0]['link']     = XOOPS_URL;
133
        $menu[0]['title']    = "<span class='fa fa-home'></span> " . _YOURHOME;
134
        $menu[0]['absolute'] = 1;
135
        $menu[1]['link']     = XOOPS_URL . '/admin.php?xoopsorgnews=1';
136
        $menu[1]['title']    = "<span class='fa fa-newspaper-o'></span> " . _OXYGEN_NEWS;
137
        $menu[1]['absolute'] = 1;
138
        $menu[1]['icon']     = XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png';
139
        $menu[2]['link']     = XOOPS_URL . '/user.php?op=logout';
140
        $menu[2]['title']    = "<span class='fa fa-sign-out'></span> " . _LOGOUT;
141
        $menu[2]['absolute'] = 1;
142
        $menu[2]['icon']     = XOOPS_ADMINTHEME_URL . '/dark/images/logout.png';
143
        $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-cog"></span> ' . _CPHOME, 'menu' => $menu));
144
145
        //add SYSTEM  Menu items
146
        include __DIR__ . '/menu.php';
147
        if (empty($xoopsModule) || 'system' === $xoopsModule->getVar('dirname', 'n')) {
148
            $modpath = XOOPS_URL . '/admin.php';
149
            $modname = _OXYGEN_SYSOPTIONS;
150
            $modid   = 1;
151
            $moddir  = 'system';
152
153
            $mod_options = $adminmenu;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $adminmenu seems to be never defined.
Loading history...
154
            foreach (array_keys($mod_options) as $item) {
155
                $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . '/modules/' . $moddir . '/' . $mod_options[$item]['link'] : $mod_options[$item]['link'];
156
                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . '/modules/system/images/' . $mod_options[$item]['icon'];
157
                unset($mod_options[$item]['icon_small']);
158
            }
159
        } else {
160
            $moddir  = $xoopsModule->getVar('dirname', 'n');
161
            $modpath = XOOPS_URL . '/modules/' . $moddir;
162
            $modname = $xoopsModule->getInfo('name') . '  (' . $xoopsModule->getInfo('version') . ')';
163
            $modid   = $xoopsModule->getVar('mid');
164
165
            $mod_options = $xoopsModule->getAdminMenu();
166
            foreach (array_keys($mod_options) as $item) {
167
                $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['link'] : $mod_options[$item]['link'];
168
                //                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['icon'];
169
                //mb for direct URL access to icons in modules Admin
170
                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : (filter_var($mod_options[$item]['icon'], FILTER_VALIDATE_URL) ? $mod_options[$item]['icon'] : (XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['icon']));
171
            }
172
        }
173
174
        $tpl->assign('mod_options', $mod_options);
175
        $tpl->assign('modpath', $modpath);
176
        $tpl->assign('modname', $modname);
177
        $tpl->assign('modid', $modid);
178
        $tpl->assign('moddir', $moddir);
179
180
        // add MODULES  Menu items
181
        /** @var XoopsModuleHandler $module_handler */
182
        $module_handler = xoops_getHandler('module');
183
        $criteria       = new CriteriaCompo();
184
        $criteria->add(new Criteria('hasadmin', 1));
185
        $criteria->add(new Criteria('isactive', 1));
186
        $criteria->setSort('mid');
187
        $mods = $module_handler->getObjects($criteria);
188
189
        $menu               = array();
190
        /** @var XoopsGroupPermHandler $moduleperm_handler */
191
        $moduleperm_handler = xoops_getHandler('groupperm');
192
        foreach ($mods as $mod) {
193
            $rtn        = array();
194
            $modOptions = array();                                                         //add for sub menus
195
            $sadmin     = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
196
            if ($sadmin) {
197
                $info = $mod->getInfo();
198
                if (!empty($info['adminindex'])) {
199
                    $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex'];
200
                } else {
201
                    $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
202
                }
203
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES | ENT_HTML5);
204
                $rtn['absolute'] = 1;
205
                $rtn['url']      = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus
206
                $modOptions      = $mod->getAdminMenu();                                        //add for sub menus
207
                $rtn['options']  = $modOptions;                                             //add for sub menus
208
209
                if (isset($info['icon']) && $info['icon'] !== '') {
210
                    $rtn['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['icon'];
211
                }
212
                $menu[] = $rtn;
213
            }
214
        }
215
        $tpl->append('navitems', array(
216
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin',
217
            'text' => '<span class="fa fa-puzzle-piece"></span> ' . _AM_SYSTEM_MODULES,
218
            'dir'  => $mod->getVar('dirname', 'n'),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mod seems to be defined by a foreach iteration on line 192. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
219
            'menu' => $menu));
220
221
        // add preferences menu
222
        $menu = array();
223
224
        $OPT   = array();
225
        $OPT[] = array(
226
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=1',
227
            'title'    => _OXYGEN_GENERAL,
228
            'absolute' => 1,
229
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
230
        $OPT[] = array(
231
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=2',
232
            'title'    => _OXYGEN_USERSETTINGS,
233
            'absolute' => 1,
234
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
235
        $OPT[] = array(
236
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=3',
237
            'title'    => _OXYGEN_METAFOOTER,
238
            'absolute' => 1,
239
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
240
        $OPT[] = array(
241
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=4',
242
            'title'    => _OXYGEN_CENSOR,
243
            'absolute' => 1,
244
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
245
        $OPT[] = array(
246
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=5',
247
            'title'    => _OXYGEN_SEARCH,
248
            'absolute' => 1,
249
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
250
        $OPT[] = array(
251
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=6',
252
            'title'    => _OXYGEN_MAILER,
253
            'absolute' => 1,
254
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
255
        $OPT[] = array(
256
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=7',
257
            'title'    => _OXYGEN_AUTHENTICATION,
258
            'absolute' => 1,
259
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
260
        $OPT[] = array(
261
            'link'     => 'admin.php?fct=preferences&amp;op=showmod&amp;mod=1',
262
            'title'    => _OXYGEN_MODULESETTINGS,
263
            'absolute' => 1,
264
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
265
266
        $menu[] = array(
267
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
268
            'title'    => _OXYGEN_SYSOPTIONS,
269
            'absolute' => 1,
270
            'url'      => XOOPS_URL . '/modules/system/',
271
            'options'  => $OPT);
272
273
        foreach ($mods as $mod) {
274
            $rtn    = array();
275
            $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
276
            if ($sadmin && ($mod->getVar('hasnotification') || \is_array($mod->getInfo('config')) || \is_array($mod->getInfo('comments')))) {
277
                $rtn['link']     = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
278
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES | ENT_HTML5);
279
                $rtn['absolute'] = 1;
280
                $rtn['icon']     = XOOPS_ADMINTHEME_URL . '/gui/oxygen/icons/prefs_small.png';
281
                $menu[]          = $rtn;
282
            }
283
        }
284
        $tpl->append('navitems', array(
285
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
286
            'text' => '<span class="fa fa-wrench"></span> ' . _OXYGEN_SITEPREF,
287
            'dir'  => $mod->getVar('dirname', 'n'),
288
            'menu' => $menu));
289
290
        //add OPTIONS/Links Menu Items
291
        $menu   = array();
292
        $menu[] = array(
293
            'link'     => 'https://xoops.org',
294
            'title'    => _OXYGEN_XOOPSPROJECT,
295
            'absolute' => 1);
296
        $menu[] = array(
297
            'link'     => 'https://xoops.org',
298
            'title'    => _OXYGEN_WEBSITE,
299
            'absolute' => 1,
300
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png');
301
        $menu[] = array(
302
            'link'     => 'https://xoops.org/modules/repository/',
303
            'title'    => _OXYGEN_XOOPSMODULES,
304
            'absolute' => 1,
305
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png');
306
        $menu[] = array(
307
            'link'     => 'https://xoops.org/modules/extgallery/',
308
            'title'    => _OXYGEN_XOOPSTHEMES,
309
            'absolute' => 1,
310
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/tweb.png');
311
312
        $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_INTERESTSITES, 'menu' => $menu));
313
314
        //add OPTIONS/links for local support
315
        if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php')) {
316
            $links = include XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php';
317
            if (count($links) > 0) {
318
                $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_LOCALSUPPORT, 'menu' => $links));
319
            }
320
        }
321
322
        if (is_object($xoopsModule) || !empty($_GET['xoopsorgnews'])) {
323
            if (is_object($xoopsModule) && file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('adminmenu'))) {
324
                include $file;
325
            }
326
327
            return null;
328
        }
329
330
        foreach ($mods as $mod) {
331
            $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
332
            if ($sadmin) {
333
                $rtn  = array();
334
                $info = $mod->getInfo();
335
                if (!empty($info ['adminindex'])) {
336
                    $rtn ['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['adminindex'];
337
                } else {
338
                    $rtn ['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
339
                }
340
                $rtn ['title']       = htmlspecialchars($mod->getVar('name'), ENT_QUOTES | ENT_HTML5);
341
                $rtn ['description'] = $mod->getInfo('description');
342
                $rtn ['absolute']    = 1;
343
                if (isset($info ['icon_big'])) {
344
                    $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['icon_big'];
345
                } elseif (isset($info ['image'])) {
346
                    $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['image'];
347
                }
348
349
                $tpl->append('modules', $rtn);
350
            }
351
        }
352
    }
353
}
354