Conditions | 46 |
Paths | 290 |
Total Lines | 152 |
Code Lines | 69 |
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 |
||
147 | function template_generic_menu_tabs(&$menu_context) |
||
148 | { |
||
149 | global $context, $settings, $scripturl, $txt; |
||
150 | |||
151 | // Handy shortcut. |
||
152 | $tab_context = &$menu_context['tab_data']; |
||
153 | |||
154 | if (!empty($tab_context['title'])) |
||
155 | { |
||
156 | echo ' |
||
157 | <div class="cat_bar">'; |
||
158 | |||
159 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
||
160 | if (function_exists('template_admin_quick_search')) |
||
161 | template_admin_quick_search(); |
||
162 | |||
163 | echo ' |
||
164 | <h3 class="catbg">'; |
||
165 | |||
166 | // Exactly how many tabs do we have? |
||
167 | if (!empty($context['tabs'])) |
||
168 | { |
||
169 | foreach ($context['tabs'] as $id => $tab) |
||
170 | { |
||
171 | // Can this not be accessed? |
||
172 | if (!empty($tab['disabled'])) |
||
173 | { |
||
174 | $tab_context['tabs'][$id]['disabled'] = true; |
||
175 | continue; |
||
176 | } |
||
177 | |||
178 | // Did this not even exist - or do we not have a label? |
||
179 | if (!isset($tab_context['tabs'][$id])) |
||
180 | $tab_context['tabs'][$id] = array('label' => $tab['label']); |
||
181 | elseif (!isset($tab_context['tabs'][$id]['label'])) |
||
182 | $tab_context['tabs'][$id]['label'] = $tab['label']; |
||
183 | |||
184 | // Has a custom URL defined in the main admin structure? |
||
185 | if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
||
186 | $tab_context['tabs'][$id]['url'] = $tab['url']; |
||
187 | |||
188 | // Any additional parameters for the url? |
||
189 | if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
||
190 | $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
||
191 | |||
192 | // Has it been deemed selected? |
||
193 | if (!empty($tab['is_selected'])) |
||
194 | $tab_context['tabs'][$id]['is_selected'] = true; |
||
195 | |||
196 | // Does it have its own help? |
||
197 | if (!empty($tab['help'])) |
||
198 | $tab_context['tabs'][$id]['help'] = $tab['help']; |
||
199 | |||
200 | // Is this the last one? |
||
201 | if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
||
202 | $tab_context['tabs'][$id]['is_last'] = true; |
||
203 | } |
||
204 | |||
205 | // Find the selected tab |
||
206 | foreach ($tab_context['tabs'] as $sa => $tab) |
||
207 | { |
||
208 | if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa)) |
||
209 | { |
||
210 | $selected_tab = $tab; |
||
211 | $tab_context['tabs'][$sa]['is_selected'] = true; |
||
212 | } |
||
213 | } |
||
214 | } |
||
215 | |||
216 | // Show an icon and/or a help item? |
||
217 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
||
218 | { |
||
219 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
||
220 | echo ' |
||
221 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
||
222 | elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
||
223 | echo ' |
||
224 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
||
225 | |||
226 | if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
||
227 | echo ' |
||
228 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>'; |
||
229 | |||
230 | echo $tab_context['title']; |
||
231 | } |
||
232 | else |
||
233 | echo ' |
||
234 | ', $tab_context['title']; |
||
235 | |||
236 | echo ' |
||
237 | </h3> |
||
238 | </div><!-- .cat_bar -->'; |
||
239 | } |
||
240 | |||
241 | // Shall we use the tabs? Yes, it's the only known way! |
||
242 | if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
||
243 | echo ' |
||
244 | <p class="information"> |
||
245 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
||
246 | </p>'; |
||
247 | |||
248 | // Print out all the items in this tab (if any). |
||
249 | if (!empty($context['tabs'])) |
||
250 | { |
||
251 | // The admin tabs. |
||
252 | echo ' |
||
253 | <a class="mobile_generic_menu_', $context['cur_menu_id'], '_tabs"> |
||
254 | <span class="menu_icon"></span> |
||
255 | <span class="text_menu">', sprintf($txt['mobile_generic_menu'], $tab_context['title']), '</span> |
||
256 | </a> |
||
257 | <div id="adm_submenus"> |
||
258 | <div id="mobile_generic_menu_', $context['cur_menu_id'], '_tabs" class="popup_container"> |
||
259 | <div class="popup_window description"> |
||
260 | <div class="popup_heading"> |
||
261 | ', sprintf($txt['mobile_generic_menu'], $tab_context['title']), ' |
||
262 | <a href="javascript:void(0);" class="main_icons hide_popup"></a> |
||
263 | </div>'; |
||
264 | |||
265 | echo ' |
||
266 | <div class="generic_menu"> |
||
267 | <ul class="dropmenu dropdown_menu_', $context['cur_menu_id'], '_tabs">'; |
||
268 | |||
269 | foreach ($tab_context['tabs'] as $sa => $tab) |
||
270 | { |
||
271 | if (!empty($tab['disabled'])) |
||
272 | continue; |
||
273 | |||
274 | if (!empty($tab['is_selected'])) |
||
275 | echo ' |
||
276 | <li> |
||
277 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
||
278 | </li>'; |
||
279 | else |
||
280 | echo ' |
||
281 | <li> |
||
282 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
||
283 | </li>'; |
||
284 | } |
||
285 | |||
286 | // The end of tabs |
||
287 | echo ' |
||
288 | </ul> |
||
289 | </div> |
||
290 | </div> |
||
291 | </div> |
||
292 | </div><!-- #adm_submenus --> |
||
293 | <script> |
||
294 | $( ".mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).click(function() { |
||
295 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).show(); |
||
296 | }); |
||
297 | $( ".hide_popup" ).click(function() { |
||
298 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).hide(); |
||
299 | }); |
||
304 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.