Conditions | 21 |
Paths | 1168 |
Total Lines | 156 |
Code Lines | 103 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
33 | function header() |
||
|
|||
34 | { |
||
35 | $xoops = Xoops::getInstance(); |
||
36 | $xoops->loadLocale('system'); |
||
37 | |||
38 | $xoops->theme()->setNamedAsset('jqueryuicss', 'media/jquery/ui/themes/smoothness/jquery-ui.css'); |
||
39 | $xoops->theme()->setNamedAsset('bootstrap', 'media/bootstrap/js/bootstrap.min.js'); |
||
40 | $xoops->theme()->addBaseScriptAssets(array('@jquery', '@bootstrap')); |
||
41 | |||
42 | $xoops->theme()->addBaseStylesheetAssets(array( |
||
43 | 'xoops.css', |
||
44 | 'media/bootstrap/css/bootstrap.css', |
||
45 | //'themes/default/media/bootstrap/css/xoops.bootstrap.css', |
||
46 | //'themes/default/css/style.css', |
||
47 | )); |
||
48 | |||
49 | $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss'); |
||
50 | $xoops->theme()->addStylesheet('media/xoops/css/moduladmin.css'); |
||
51 | $xoops->theme()->addStylesheet(\XoopsBaseConfig::get('adminthemes-url') . '/default/css/style.css'); |
||
52 | |||
53 | // $xoops->theme()->addBaseScriptAssets('@jquery'); |
||
54 | // bootstrap has to come before jquery.ui or dialog close buttons are blank |
||
55 | //$xoops->theme()->addBaseScriptAssets('@bootstrap'); |
||
56 | $xoops->theme()->addBaseScriptAssets('@jqueryui'); |
||
57 | $xoops->theme()->addBaseScriptAssets('@jgrowl'); |
||
58 | // ddsmoothmenu |
||
59 | $xoops->theme()->addScript(\XoopsBaseConfig::get('adminthemes-url') . '/default/js/ddsmoothmenu.js'); |
||
60 | $xoops->theme()->addScript(\XoopsBaseConfig::get('adminthemes-url') . '/default/js/tooltip.js'); |
||
61 | |||
62 | $quick = array(); |
||
63 | $quick[] = array('title' => SystemLocale::CONTROL_PANEL, 'link' => \XoopsBaseConfig::get('url') . '/admin.php'); |
||
64 | $quick[] = array('title' => XoopsLocale::HOME_PAGE, 'link' => \XoopsBaseConfig::get('url')); |
||
65 | $quick[] = array('title' => DefaultThemeLocale::XOOPS_NEWS, 'link' => \XoopsBaseConfig::get('url') . '/admin.php?xoopsorgnews=1'); |
||
66 | $quick[] = array('title' => 'separator'); |
||
67 | $quick[] = array('title' => XoopsLocale::A_LOGOUT, 'link' => \XoopsBaseConfig::get('url') . '/user.php?op=logout'); |
||
68 | $xoops->tpl()->assign('quick_menu', $quick); |
||
69 | |||
70 | XoopsLoad::load('module', 'system'); |
||
71 | XoopsLoad::load('extension', 'system'); |
||
72 | $system_module = new SystemModule(); |
||
73 | $system_extension = new SystemExtension(); |
||
74 | |||
75 | $adminmenu = null; |
||
76 | include __DIR__ . '/menu.php'; |
||
77 | if (!$xoops->isModule() || 'system' === $xoops->module->getVar('dirname', 'n')) { |
||
78 | $modpath = \XoopsBaseConfig::get('url') . '/admin.php'; |
||
79 | $modname = DefaultThemeLocale::SYSTEM_OPTIONS; |
||
80 | $modid = 1; |
||
81 | $moddir = 'system'; |
||
82 | |||
83 | $mod_options = $adminmenu; |
||
84 | foreach (array_keys($mod_options) as $item) { |
||
85 | $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) |
||
86 | ? \XoopsBaseConfig::get('url') . '/modules/' . $moddir . '/' . $mod_options[$item]['link'] |
||
87 | : $mod_options[$item]['link']; |
||
88 | $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' |
||
89 | : \XoopsBaseConfig::get('adminthemes-url') . '/default/' . $mod_options[$item]['icon']; |
||
90 | unset($mod_options[$item]['icon_small']); |
||
91 | } |
||
92 | |||
93 | } else { |
||
94 | $moddir = $xoops->module->getVar('dirname', 'n'); |
||
95 | $modpath = \XoopsBaseConfig::get('url') . '/modules/' . $moddir; |
||
96 | $modname = $xoops->module->getVar('name'); |
||
97 | $modid = $xoops->module->getVar('mid'); |
||
98 | |||
99 | $mod_options = $xoops->module->getAdminMenu(); |
||
100 | foreach (array_keys($mod_options) as $item) { |
||
101 | $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) |
||
102 | ? \XoopsBaseConfig::get('url') . "/modules/{$moddir}/" . $mod_options[$item]['link'] |
||
103 | : $mod_options[$item]['link']; |
||
104 | if ( XoopsLoad::fileExists($xoops->path('media/xoops/images/icons/32/' . $mod_options[$item]['icon']) ) ) { |
||
105 | $mod_options[$item]['icon'] = $xoops->url('media/xoops/images/icons/32/' . $mod_options[$item]['icon']); |
||
106 | |||
107 | } elseif ( XoopsLoad::fileExists($xoops->path('modules/' . $xoops->module->dirname() . '/assets/icons/32/' . $mod_options[$item]['icon'])) ) { |
||
108 | $mod_options[$item]['icon'] = $xoops->url('modules/' . $xoops->module->dirname() . '/assets/icons/32/' . $mod_options[$item]['icon']); |
||
109 | } else { |
||
110 | $mod_options[$item]['icon'] = $xoops->url("modules/" . $xoops->module->dirname() . "/icons/32/" . $mod_options[$item]['icon']); |
||
111 | } |
||
112 | } |
||
113 | $xoops->tpl()->assign('modhasconfig', $xoops->module->getVar('hasconfig')); |
||
114 | } |
||
115 | $xoops->tpl()->assign('mod_options', $mod_options); |
||
116 | $xoops->tpl()->assign('modpath', $modpath); |
||
117 | $xoops->tpl()->assign('modname', $modname); |
||
118 | $xoops->tpl()->assign('modid', $modid); |
||
119 | $xoops->tpl()->assign('moddir', $moddir); |
||
120 | |||
121 | // Modules list |
||
122 | $module_list = $system_module->getModuleList(); |
||
123 | $xoops->tpl()->assign('module_menu', $module_list); |
||
124 | unset($module_list); |
||
125 | |||
126 | // Extensions list |
||
127 | $extension_list = $system_extension->getExtensionList(); |
||
128 | $xoops->tpl()->assign('extension_menu', $extension_list); |
||
129 | unset($extension_list); |
||
130 | |||
131 | $extension_mod = $system_extension->getExtension( $moddir ); |
||
132 | $xoops->tpl()->assign('extension_mod', $extension_mod); |
||
133 | |||
134 | // add preferences menu |
||
135 | $menu = array(); |
||
136 | |||
137 | $OPT = array(); |
||
138 | |||
139 | $menu[] = array( |
||
140 | 'link' => \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences', 'title' => XoopsLocale::PREFERENCES, |
||
141 | 'absolute' => 1, 'url' => \XoopsBaseConfig::get('url') . '/modules/system/', 'options' => $OPT |
||
142 | ); |
||
143 | $menu[] = array('title' => 'separator'); |
||
144 | |||
145 | // Module adminmenu |
||
146 | if ($xoops->isModule() && $xoops->module->getVar('dirname') !== 'system') { |
||
147 | |||
148 | if ($xoops->module->getInfo('system_menu')) { |
||
149 | //$xoops->theme()->addStylesheet('modules/system/css/menu.css'); |
||
150 | |||
151 | $xoops->module->loadAdminMenu(); |
||
152 | // Get menu tab handler |
||
153 | /* @var $menu_handler SystemMenuHandler */ |
||
154 | $menu_handler = $xoops->getModuleHandler('menu', 'system'); |
||
155 | // Define top navigation |
||
156 | if ($xoops->module->getVar('hasconfig')) { |
||
157 | $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=preferences&op=showmod&mod=" . $xoops->module->getVar('mid', 'e'), XoopsLocale::PREFERENCES); |
||
158 | } |
||
159 | if ($xoops->module->getInfo('extension')) { |
||
160 | $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=extensions&op=update&module=" . $xoops->module->getVar('dirname', 'e'), XoopsLocale::A_UPDATE); |
||
161 | } else { |
||
162 | $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . $xoops->module->getVar('dirname', 'e'), XoopsLocale::A_UPDATE); |
||
163 | } |
||
164 | if ($xoops->module->getInfo('blocks')) { |
||
165 | $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=blocksadmin&op=list&filter=1&selgen=" . $xoops->module->getVar('mid', 'e') . "&selmod=-2&selgrp=-1&selvis=-1", XoopsLocale::BLOCKS); |
||
166 | } |
||
167 | if ($xoops->module->getInfo('hasMain')) { |
||
168 | $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/" . $xoops->module->getVar('dirname', 'e') . "/", SystemLocale::GO_TO_MODULE); |
||
169 | } |
||
170 | // Define main tab navigation |
||
171 | $i = 0; |
||
172 | $current = $i; |
||
173 | foreach ($xoops->module->adminmenu as $menu) { |
||
174 | if (stripos($_SERVER['REQUEST_URI'], $menu['link']) !== false) { |
||
175 | $current = $i; |
||
176 | } |
||
177 | $menu_handler->addMenuTabs( $xoops->url('modules/' . $xoops->module->getVar('dirname') . '/' . $menu['link']), $menu['title']); |
||
178 | ++$i; |
||
179 | } |
||
180 | if ($xoops->module->getInfo('help')) { |
||
181 | if (stripos($_SERVER['REQUEST_URI'], 'admin/' . $xoops->module->getInfo('help')) !== false) { |
||
182 | $current = $i; |
||
183 | } |
||
184 | $menu_handler->addMenuTabs('../../system/help.php?mid=' . $xoops->module->getVar('mid', 's') . '&' . $xoops->module->getInfo('help'), XoopsLocale::HELP); |
||
185 | } |
||
186 | |||
187 | // Display navigation tabs |
||
188 | $xoops->tpl()->assign('xo_system_menu', $menu_handler->render($current, false)); |
||
189 | } |
||
194 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.