Conditions | 4 |
Paths | 6 |
Total Lines | 55 |
Lines | 5 |
Ratio | 9.09 % |
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 |
||
31 | function bookshop_adminMenu($currentoption = 0, $breadcrumb = '') |
||
32 | { |
||
33 | global $xoopsConfig, $xoopsModule; |
||
34 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/bookshop/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
|
|||
35 | include_once XOOPS_ROOT_PATH . '/modules/bookshop/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
||
36 | } else { |
||
37 | include_once XOOPS_ROOT_PATH . '/modules/bookshop/language/english/modinfo.php'; |
||
38 | } |
||
39 | global $adminmenu; |
||
40 | include __DIR__ . '/menu.php'; |
||
41 | |||
42 | echo "<style type=\"text/css\">\n"; |
||
43 | echo "#buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }\n"; |
||
44 | echo "#buttonbar { float:left; width:100%; background: #e7e7e7 url('../assets/images/modadminbg.gif') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; }\n"; |
||
45 | echo "#buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; }\n"; |
||
46 | echo '#buttonbar li { display:inline; margin:0; padding:0; }'; |
||
47 | echo "#buttonbar a { float:left; background:url('../assets/images/left_both.gif') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; }\n"; |
||
48 | echo "#buttonbar a span { float:left; display:block; background:url('../assets/images/right_both.gif') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }\n"; |
||
49 | echo "/* Commented Backslash Hack hides rule from IE5-Mac \*/\n"; |
||
50 | echo "#buttonbar a span {float:none;}\n"; |
||
51 | echo "/* End IE5-Mac hack */\n"; |
||
52 | echo "#buttonbar a:hover span { color:#333; }\n"; |
||
53 | echo "#buttonbar .current a { background-position:0 -150px; border-width:0; }\n"; |
||
54 | echo "#buttonbar .current a span { background-position:100% -150px; padding-bottom:5px; color:#333; }\n"; |
||
55 | echo "#buttonbar a:hover { background-position:0% -150px; }\n"; |
||
56 | echo "#buttonbar a:hover span { background-position:100% -150px; }\n"; |
||
57 | echo "</style>\n"; |
||
58 | |||
59 | echo "<div id=\"buttontop\">\n"; |
||
60 | echo "<table style=\"width: 100%; padding: 0; \" cellspacing=\"0\">\n"; |
||
61 | echo "<tr>\n"; |
||
62 | echo "<td style=\"width: 70%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;\">\n"; |
||
63 | echo "<a href=\"../index.php\">" . _AM_BOOKSHOP_GO_TO_MODULE . "</a> | <a href=\"" . XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $xoopsModule->getVar('mid') . "\">" . _AM_BOOKSHOP_PREFERENCES . "</a>\n"; |
||
64 | echo "</td>\n"; |
||
65 | echo "<td style=\"width: 30%; font-size: 10px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;\">\n"; |
||
66 | echo '<b>' . $xoopsModule->getVar('name') . ' ' . _AM_BOOKSHOP_ADMINISTRATION . '</b> ' . $breadcrumb . "\n"; |
||
67 | echo "</td>\n"; |
||
68 | echo "</tr>\n"; |
||
69 | echo "</table>\n"; |
||
70 | echo "</div>\n"; |
||
71 | echo "<div id=\"buttonbar\">\n"; |
||
72 | echo "<ul>\n"; |
||
73 | foreach ($GLOBALS['adminmenu'] as $key => $link) { |
||
74 | if ($key == $currentoption) { |
||
75 | echo "<li class=\"current\">\n"; |
||
76 | } else { |
||
77 | echo "<li>\n"; |
||
78 | } |
||
79 | echo "<a href=\"" . XOOPS_URL . '/modules/bookshop/' . $link['link'] . "\"><span>" . $link['title'] . "</span></a>\n"; |
||
80 | echo "</li>\n"; |
||
81 | } |
||
82 | echo "</ul>\n"; |
||
83 | echo "</div>\n"; |
||
84 | echo "<br style=\"clear:both;\" />\n"; |
||
85 | } |
||
86 | |||
232 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.