Conditions | 17 |
Paths | 240 |
Total Lines | 55 |
Code Lines | 34 |
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 |
||
90 | function ShowAdminHelp() |
||
91 | { |
||
92 | global $txt, $helptxt, $context, $scripturl, $boarddir, $boardurl; |
||
93 | |||
94 | if (!isset($_GET['help']) || !is_string($_GET['help'])) |
||
95 | fatal_lang_error('no_access', false); |
||
96 | |||
97 | if (!isset($helptxt)) |
||
98 | $helptxt = array(); |
||
99 | |||
100 | // Load the admin help language file and template. |
||
101 | loadLanguage('Help'); |
||
102 | |||
103 | // Permission specific help? |
||
104 | if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
||
105 | loadLanguage('ManagePermissions'); |
||
106 | |||
107 | loadTemplate('Help'); |
||
108 | |||
109 | // Allow mods to load their own language file here |
||
110 | call_integration_hook('integrate_helpadmin'); |
||
111 | |||
112 | // What help string should be used? |
||
113 | if (isset($helptxt[$_GET['help']])) |
||
114 | $context['help_text'] = $helptxt[$_GET['help']]; |
||
115 | elseif (isset($txt[$_GET['help']])) |
||
116 | $context['help_text'] = $txt[$_GET['help']]; |
||
117 | else |
||
118 | fatal_lang_error('not_found', false, array(), 404); |
||
119 | |||
120 | switch ($_GET['help']) { |
||
121 | case 'cal_short_months': |
||
122 | $context['help_text'] = sprintf($context['help_text'], $txt['months_short'][1], $txt['months_titles'][1]); |
||
123 | break; |
||
124 | case 'cal_short_days': |
||
125 | $context['help_text'] = sprintf($context['help_text'], $txt['days_short'][1], $txt['days'][1]); |
||
126 | break; |
||
127 | case 'cron_is_real_cron': |
||
128 | $context['help_text'] = sprintf($context['help_text'], allowedTo('admin_forum') ? $boarddir : '[' . $txt['hidden'] . ']', $boardurl); |
||
129 | break; |
||
130 | case 'queryless_urls': |
||
131 | $context['help_text'] = sprintf($context['help_text'], (isset($_SERVER['SERVER_SOFTWARE']) && (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) ? $helptxt['queryless_urls_supported'] : $helptxt['queryless_urls_unsupported'])); |
||
132 | break; |
||
133 | } |
||
134 | |||
135 | // Does this text contain a link that we should fill in? |
||
136 | if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
||
137 | $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
||
138 | |||
139 | // Set the page title to something relevant. |
||
140 | $context['page_title'] = $context['forum_name'] . ' - ' . $txt['help']; |
||
141 | |||
142 | // Don't show any template layers, just the popup sub template. |
||
143 | $context['template_layers'] = array(); |
||
144 | $context['sub_template'] = 'popup'; |
||
145 | } |
||
147 | ?> |