| Total Complexity | 43 |
| Total Lines | 355 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like XoopsGuiDark often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use XoopsGuiDark, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 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() |
||
| 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 | include_once dirname(__DIR__) . '/ComposerInfo.php'; |
||
| 70 | |||
| 71 | // Determine if information box must be shown |
||
| 72 | $currentScript = str_replace(XOOPS_ROOT_PATH . '/', '', (string) $_SERVER['SCRIPT_FILENAME']); |
||
| 73 | |||
| 74 | if('admin.php' == $currentScript){ |
||
| 75 | $show = Request::getString('show', '', 'GET'); |
||
| 76 | if('info' == $show){ |
||
| 77 | $tpl->assign('showTransitionInfo', true); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | $iconsSet = xoops_getModuleOption('typeicons', 'system'); |
||
|
|
|||
| 82 | |||
| 83 | if ($iconsSet == '') { |
||
| 84 | $icons = 'transition'; |
||
| 85 | } |
||
| 86 | |||
| 87 | $tpl->assign('theme_icons', XOOPS_URL . '/modules/system/images/icons/' . $iconsSet); |
||
| 88 | |||
| 89 | // language |
||
| 90 | $tpl->assign('xoops_language', $xoopsConfig['language']); |
||
| 91 | |||
| 92 | $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
| 93 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/close_errors.js'); |
||
| 94 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/formenu.js'); |
||
| 95 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/menu.js'); |
||
| 96 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tooltip.js'); |
||
| 97 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.js'); |
||
| 98 | $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.slideshow.js'); |
||
| 99 | |||
| 100 | $xoTheme->addStylesheet('https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:300,300i,400,400i,700,700i'); |
||
| 101 | // $xoTheme->addStylesheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); |
||
| 102 | $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/style.css'); |
||
| 103 | $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/dark.css', ['title' => 'dark', 'media' => 'screen']); |
||
| 104 | //$xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/silver.css', array('title' => 'silver', 'media' => 'screen')); |
||
| 105 | //$xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/orange.css', array('title' => 'orange', 'media' => 'screen')); |
||
| 106 | |||
| 107 | $tpl->assign('lang_cp', _CPHOME); |
||
| 108 | //start system overview |
||
| 109 | //$tpl->assign('lang_xoops_version', XOOPS_VERSION); |
||
| 110 | $tpl->assign('lang_php_version', PHP_VERSION); |
||
| 111 | $tpl->assign('lang_smarty_version', $tpl::SMARTY_VERSION); |
||
| 112 | $tpl->assign('lang_mysql_version', mysqli_get_server_info($xoopsDB->conn)); |
||
| 113 | $tpl->assign('lang_server_api', PHP_SAPI); |
||
| 114 | $tpl->assign('lang_os_name', PHP_OS); |
||
| 115 | // $tpl->assign('safe_mode', ini_get('safe_mode') ? 'On' : 'Off'); |
||
| 116 | // $tpl->assign('register_globals', ini_get('register_globals') ? 'On' : 'Off'); |
||
| 117 | // $tpl->assign('magic_quotes_gpc', ini_get('magic_quotes_gpc') ? 'On' : 'Off'); |
||
| 118 | $tpl->assign('allow_url_fopen', ini_get('allow_url_fopen') ? 'On' : 'Off'); |
||
| 119 | $tpl->assign('fsockopen', function_exists('fsockopen') ? 'On' : 'Off'); |
||
| 120 | // $tpl->assign('allow_call_time_pass_reference', ini_get('allow_call_time_pass_reference') ? 'On' : 'Off'); |
||
| 121 | $tpl->assign('post_max_size', ini_get('post_max_size')); |
||
| 122 | $tpl->assign('max_input_time', ini_get('max_input_time')); |
||
| 123 | $tpl->assign('output_buffering', ini_get('output_buffering')); |
||
| 124 | $tpl->assign('max_execution_time', ini_get('max_execution_time')); |
||
| 125 | $tpl->assign('memory_limit', ini_get('memory_limit')); |
||
| 126 | $tpl->assign('file_uploads', ini_get('file_uploads') ? 'On' : 'Off'); |
||
| 127 | $tpl->assign('upload_max_filesize', ini_get('upload_max_filesize')); |
||
| 128 | $tpl->assign('xoops_sitename', $xoopsConfig['sitename']); |
||
| 129 | |||
| 130 | // COMPOSER PACKAGES VERSION INFO ******************* |
||
| 131 | |||
| 132 | ComposerInfo::getComposerInfo($tpl); |
||
| 133 | |||
| 134 | // ADD MENU ***************************************** |
||
| 135 | $menu = []; |
||
| 136 | $menu[0]['link'] = XOOPS_URL; |
||
| 137 | $menu[0]['title'] = "<span class='fa fa-home'></span> " . _YOURHOME; |
||
| 138 | $menu[0]['absolute'] = 1; |
||
| 139 | $menu[1]['link'] = XOOPS_URL . '/admin.php?xoopsorgnews=1'; |
||
| 140 | $menu[1]['title'] = "<span class='fa fa-newspaper-o'></span> " . _OXYGEN_NEWS; |
||
| 141 | $menu[1]['absolute'] = 1; |
||
| 142 | $menu[1]['icon'] = XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png'; |
||
| 143 | $menu[2]['link'] = XOOPS_URL . '/user.php?op=logout'; |
||
| 144 | $menu[2]['title'] = "<span class='fa fa-sign-out'></span> " . _LOGOUT; |
||
| 145 | $menu[2]['absolute'] = 1; |
||
| 146 | $menu[2]['icon'] = XOOPS_ADMINTHEME_URL . '/dark/images/logout.png'; |
||
| 147 | $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-cog"></span> ' . _CPHOME, 'menu' => $menu]); |
||
| 148 | |||
| 149 | //add SYSTEM Menu items |
||
| 150 | include __DIR__ . '/menu.php'; |
||
| 151 | if (empty($xoopsModule) || 'system' === $xoopsModule->getVar('dirname', 'n')) { |
||
| 152 | $modpath = XOOPS_URL . '/admin.php'; |
||
| 153 | $modname = _OXYGEN_SYSOPTIONS; |
||
| 154 | $modid = 1; |
||
| 155 | $moddir = 'system'; |
||
| 156 | |||
| 157 | $mod_options = $adminmenu; |
||
| 158 | foreach (array_keys($mod_options) as $item) { |
||
| 159 | $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . '/modules/' . $moddir . '/' . $mod_options[$item]['link'] : $mod_options[$item]['link']; |
||
| 160 | $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . '/modules/system/images/' . $mod_options[$item]['icon']; |
||
| 161 | unset($mod_options[$item]['icon_small']); |
||
| 162 | } |
||
| 163 | } else { |
||
| 164 | $moddir = $xoopsModule->getVar('dirname', 'n'); |
||
| 165 | $modpath = XOOPS_URL . '/modules/' . $moddir; |
||
| 166 | $modname = $xoopsModule->getInfo('name') . ' (' . $xoopsModule->getInfo('version') . ')'; |
||
| 167 | $modid = $xoopsModule->getVar('mid'); |
||
| 168 | |||
| 169 | $mod_options = $xoopsModule->getAdminMenu(); |
||
| 170 | foreach (array_keys($mod_options) as $item) { |
||
| 171 | $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['link'] : $mod_options[$item]['link']; |
||
| 172 | // $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['icon']; |
||
| 173 | //mb for direct URL access to icons in modules Admin |
||
| 174 | $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'])); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | $tpl->assign('mod_options', $mod_options); |
||
| 179 | $tpl->assign('modpath', $modpath); |
||
| 180 | $tpl->assign('modname', $modname); |
||
| 181 | $tpl->assign('modid', $modid); |
||
| 182 | $tpl->assign('moddir', $moddir); |
||
| 183 | |||
| 184 | // add MODULES Menu items |
||
| 185 | /** @var XoopsModuleHandler $module_handler */ |
||
| 186 | $module_handler = xoops_getHandler('module'); |
||
| 187 | $criteria = new CriteriaCompo(); |
||
| 188 | $criteria->add(new Criteria('hasadmin', 1)); |
||
| 189 | $criteria->add(new Criteria('isactive', 1)); |
||
| 190 | $criteria->setSort('mid'); |
||
| 191 | $mods = $module_handler->getObjects($criteria); |
||
| 192 | |||
| 193 | $menu = []; |
||
| 194 | /** @var XoopsGroupPermHandler $moduleperm_handler */ |
||
| 195 | $moduleperm_handler = xoops_getHandler('groupperm'); |
||
| 196 | foreach ($mods as $mod) { |
||
| 197 | $rtn = []; |
||
| 198 | $modOptions = []; //add for sub menus |
||
| 199 | $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups()); |
||
| 200 | if ($sadmin) { |
||
| 201 | $info = $mod->getInfo(); |
||
| 202 | if (!empty($info['adminindex'])) { |
||
| 203 | $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex']; |
||
| 204 | } else { |
||
| 205 | $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mod->getVar('mid'); |
||
| 206 | } |
||
| 207 | $rtn['title'] = htmlspecialchars((string) $mod->name(), ENT_QUOTES | ENT_HTML5); |
||
| 208 | $rtn['absolute'] = 1; |
||
| 209 | $rtn['url'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus |
||
| 210 | $modOptions = $mod->getAdminMenu(); //add for sub menus |
||
| 211 | $rtn['options'] = $modOptions; //add for sub menus |
||
| 212 | |||
| 213 | if (isset($info['icon']) && $info['icon'] !== '') { |
||
| 214 | $rtn['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['icon']; |
||
| 215 | } |
||
| 216 | $menu[] = $rtn; |
||
| 217 | } |
||
| 218 | } |
||
| 219 | $tpl->append('navitems', [ |
||
| 220 | 'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin', |
||
| 221 | 'text' => '<span class="fa fa-puzzle-piece"></span> ' . _AM_SYSTEM_MODULES, |
||
| 222 | 'dir' => $mod->getVar('dirname', 'n'), |
||
| 223 | 'menu' => $menu]); |
||
| 224 | |||
| 225 | // add preferences menu |
||
| 226 | $menu = []; |
||
| 227 | |||
| 228 | $OPT = []; |
||
| 229 | $OPT[] = [ |
||
| 230 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=1', |
||
| 231 | 'title' => _OXYGEN_GENERAL, |
||
| 232 | 'absolute' => 1, |
||
| 233 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 234 | $OPT[] = [ |
||
| 235 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=2', |
||
| 236 | 'title' => _OXYGEN_USERSETTINGS, |
||
| 237 | 'absolute' => 1, |
||
| 238 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 239 | $OPT[] = [ |
||
| 240 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=3', |
||
| 241 | 'title' => _OXYGEN_METAFOOTER, |
||
| 242 | 'absolute' => 1, |
||
| 243 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 244 | $OPT[] = [ |
||
| 245 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=4', |
||
| 246 | 'title' => _OXYGEN_CENSOR, |
||
| 247 | 'absolute' => 1, |
||
| 248 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 249 | $OPT[] = [ |
||
| 250 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=5', |
||
| 251 | 'title' => _OXYGEN_SEARCH, |
||
| 252 | 'absolute' => 1, |
||
| 253 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 254 | $OPT[] = [ |
||
| 255 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=6', |
||
| 256 | 'title' => _OXYGEN_MAILER, |
||
| 257 | 'absolute' => 1, |
||
| 258 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 259 | $OPT[] = [ |
||
| 260 | 'link' => 'admin.php?fct=preferences&op=show&confcat_id=7', |
||
| 261 | 'title' => _OXYGEN_AUTHENTICATION, |
||
| 262 | 'absolute' => 1, |
||
| 263 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 264 | $OPT[] = [ |
||
| 265 | 'link' => 'admin.php?fct=preferences&op=showmod&mod=1', |
||
| 266 | 'title' => _OXYGEN_MODULESETTINGS, |
||
| 267 | 'absolute' => 1, |
||
| 268 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png']; |
||
| 269 | |||
| 270 | $menu[] = [ |
||
| 271 | 'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences', |
||
| 272 | 'title' => _OXYGEN_SYSOPTIONS, |
||
| 273 | 'absolute' => 1, |
||
| 274 | 'url' => XOOPS_URL . '/modules/system/', |
||
| 275 | 'options' => $OPT]; |
||
| 276 | |||
| 277 | foreach ($mods as $mod) { |
||
| 278 | $rtn = []; |
||
| 279 | $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups()); |
||
| 280 | if ($sadmin && ($mod->getVar('hasnotification') || \is_array($mod->getInfo('config')) || \is_array($mod->getInfo('comments')))) { |
||
| 281 | $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mod->getVar('mid'); |
||
| 282 | $rtn['title'] = htmlspecialchars((string) $mod->name(), ENT_QUOTES | ENT_HTML5); |
||
| 283 | $rtn['absolute'] = 1; |
||
| 284 | $rtn['icon'] = XOOPS_ADMINTHEME_URL . '/gui/oxygen/icons/prefs_small.png'; |
||
| 285 | $menu[] = $rtn; |
||
| 286 | } |
||
| 287 | } |
||
| 288 | $tpl->append('navitems', [ |
||
| 289 | 'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences', |
||
| 290 | 'text' => '<span class="fa fa-wrench"></span> ' . _OXYGEN_SITEPREF, |
||
| 291 | 'dir' => $mod->getVar('dirname', 'n'), |
||
| 292 | 'menu' => $menu]); |
||
| 293 | |||
| 294 | //add OPTIONS/Links Menu Items |
||
| 295 | $menu = []; |
||
| 296 | $menu[] = [ |
||
| 297 | 'link' => 'https://xoops.org', |
||
| 298 | 'title' => _OXYGEN_XOOPSPROJECT, |
||
| 299 | 'absolute' => 1]; |
||
| 300 | $menu[] = [ |
||
| 301 | 'link' => 'https://xoops.org', |
||
| 302 | 'title' => _OXYGEN_WEBSITE, |
||
| 303 | 'absolute' => 1, |
||
| 304 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png']; |
||
| 305 | $menu[] = [ |
||
| 306 | 'link' => 'https://xoops.org/modules/repository/', |
||
| 307 | 'title' => _OXYGEN_XOOPSMODULES, |
||
| 308 | 'absolute' => 1, |
||
| 309 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png']; |
||
| 310 | $menu[] = [ |
||
| 311 | 'link' => 'https://xoops.org/modules/extgallery/', |
||
| 312 | 'title' => _OXYGEN_XOOPSTHEMES, |
||
| 313 | 'absolute' => 1, |
||
| 314 | 'icon' => XOOPS_ADMINTHEME_URL . '/dark/images/tweb.png']; |
||
| 315 | |||
| 316 | $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_INTERESTSITES, 'menu' => $menu]); |
||
| 317 | |||
| 318 | //add OPTIONS/links for local support |
||
| 319 | if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php')) { |
||
| 320 | $links = include XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php'; |
||
| 321 | if (count($links) > 0) { |
||
| 322 | $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_LOCALSUPPORT, 'menu' => $links]); |
||
| 323 | } |
||
| 324 | } |
||
| 325 | |||
| 326 | if (is_object($xoopsModule) || !empty($_GET['xoopsorgnews'])) { |
||
| 327 | if (is_object($xoopsModule) && file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('adminmenu'))) { |
||
| 328 | include $file; |
||
| 329 | } |
||
| 330 | |||
| 331 | return null; |
||
| 332 | } |
||
| 333 | |||
| 334 | foreach ($mods as $mod) { |
||
| 335 | $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups()); |
||
| 336 | if ($sadmin) { |
||
| 337 | $rtn = []; |
||
| 338 | $info = $mod->getInfo(); |
||
| 339 | if (!empty($info ['adminindex'])) { |
||
| 340 | $rtn ['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['adminindex']; |
||
| 341 | } else { |
||
| 342 | $rtn ['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mod->getVar('mid'); |
||
| 343 | } |
||
| 344 | $rtn ['title'] = htmlspecialchars((string) $mod->getVar('name'), ENT_QUOTES | ENT_HTML5); |
||
| 345 | $rtn ['description'] = $mod->getInfo('description'); |
||
| 346 | $rtn ['absolute'] = 1; |
||
| 347 | if (isset($info ['icon_big'])) { |
||
| 348 | $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['icon_big']; |
||
| 349 | } elseif (isset($info ['image'])) { |
||
| 350 | $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['image']; |
||
| 351 | } |
||
| 352 | |||
| 353 | $tpl->append('modules', $rtn); |
||
| 354 | } |
||
| 355 | } |
||
| 356 | } |
||
| 357 | |||
| 358 | // Function to read and parse composer.lock file |
||
| 359 | private function getComposerData(string $composerLockPath): array |
||
| 378 | } |
||
| 379 | |||
| 380 | |||
| 381 | // Function to extract package name and version (using array_map for optimization) |
||
| 382 | private function extractPackages(array $packages): array |
||
| 389 | ); |
||
| 390 | } |
||
| 392 |