Conditions | 16 |
Paths | 12 |
Total Lines | 99 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 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 |
||
51 | function template_main() |
||
52 | { |
||
53 | global $context, $txt, $scripturl; |
||
54 | |||
55 | echo ' |
||
56 | <dl class="settings"> |
||
57 | <dt> |
||
58 | <strong>', $txt['um_menu_button_name'], ':</strong> |
||
59 | </dt> |
||
60 | <dd> |
||
61 | <input type="text" name="name" id="bnbox" value="', $context['button_data']['name'], '" tabindex="1" class="input_text" style="width: 100%;" /> |
||
62 | </dd> |
||
63 | <dt> |
||
64 | <strong>', $txt['um_menu_button_position'], ':</strong> |
||
65 | </dt> |
||
66 | <dd> |
||
67 | <select name="position" size="10" style="width: 22%;" onchange="this.form.position.disabled = this.options[this.selectedIndex].value == \'\';">'; |
||
68 | |||
69 | foreach (['after', 'child_of', 'before'] as $v) |
||
70 | printf(' |
||
71 | <option value="%s"%s>%s...</option>', |
||
72 | $v, |
||
73 | $context['button_data']['position'] == $v ? ' selected="selected"' : '', |
||
74 | $txt['um_menu_' . $v]); |
||
75 | |||
76 | echo ' |
||
77 | </select> |
||
78 | <select name="parent" size="10" style="width: 75%;">'; |
||
79 | |||
80 | foreach ($context['button_names'] as $idx => $title) |
||
81 | printf(' |
||
82 | <option value="%s"%s>%s...</option>', |
||
83 | $idx, |
||
84 | $context['button_data']['position'] == $idx ? ' selected="selected"' : '', |
||
85 | empty($title[0]) ? $title[1] : str_repeat(' ', $title[0]) . $title[1] |
||
86 | ); |
||
87 | |||
88 | echo ' |
||
89 | </select> |
||
90 | </dd> |
||
91 | <dt> |
||
92 | <strong>', $txt['um_menu_button_type'], ':</strong> |
||
93 | </dt> |
||
94 | <dd> |
||
95 | <input type="radio" class="input_check" name="type" value="forum"', $context['button_data']['type'] == 'forum' ? ' checked="checked"' : '', '/>', $txt['um_menu_forum'], '<br /> |
||
96 | <input type="radio" class="input_check" name="type" value="external"', $context['button_data']['type'] == 'external' ? ' checked="checked"' : '', '/>', $txt['um_menu_external'], ' |
||
97 | </dd> |
||
98 | <dt> |
||
99 | <strong>', $txt['um_menu_link_type'], ':</strong> |
||
100 | </dt> |
||
101 | <dd> |
||
102 | <input type="radio" class="input_check" name="target" value="_self"', $context['button_data']['target'] == '_self' ? ' checked="checked"' : '', '/>', $txt['um_menu_same_window'], '<br /> |
||
103 | <input type="radio" class="input_check" name="target" value="_blank"', $context['button_data']['target'] == '_blank' ? ' checked="checked"' : '', '/>', $txt['um_menu_new_tab'], ' |
||
104 | </dd> |
||
105 | <dt> |
||
106 | <strong>', $txt['um_menu_button_link'], ':</strong><br /> |
||
107 | </dt> |
||
108 | <dd> |
||
109 | <input type="text" name="link" value="', $context['button_data']['link'], '" tabindex="1" class="input_text" style="width: 100%;" /> |
||
110 | <span class="smalltext">', $txt['um_menu_button_link_desc'], '</span> |
||
111 | </dd> |
||
112 | <dt> |
||
113 | <strong>', $txt['um_menu_button_perms'], ':</strong> |
||
114 | </dt> |
||
115 | <dd> |
||
116 | <fieldset id="group_perms"> |
||
117 | <legend><a href="#" onclick="this.parentNode.parentNode.style.display = \'none\';document.getElementById(\'group_perms_groups_link\').style.display = \'block\'; return false;">', $txt['avatar_select_permission'], '</a></legend>'; |
||
118 | |||
119 | foreach ($context['button_data']['permissions'] as $id => $permission) |
||
120 | { |
||
121 | echo ' |
||
122 | <label> |
||
123 | <input type="checkbox" class="input_check" name="permissions[]" value="', $id, '"', $permission['checked'] ? ' checked="checked"' : '', ' /> |
||
124 | <span'; |
||
125 | |||
126 | if ($permission['is_post_group']) |
||
127 | echo ' title="' . $txt['mboards_groups_post_group'] . '"'; |
||
128 | |||
129 | echo '>', $permission['name'], '</span> |
||
130 | </label> |
||
131 | <br>'; |
||
132 | } |
||
133 | |||
134 | echo ' |
||
135 | <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'permissions[]\');" id="check_group_all"', $context['all_groups_checked'] ? ' checked="checked"' : '', ' /> |
||
136 | <label for="check_group_all"><em>', $txt['check_all'], '</em></label><br /> |
||
137 | </fieldset> |
||
138 | <a href="#" onclick="document.getElementById(\'group_perms\').style.display = \'block\'; this.style.display = \'none\'; return false;" id="group_perms_groups_link" style="display: none;">[ ', $txt['avatar_select_permission'], ' ]</a> |
||
139 | <script type="text/javascript"><!-- // --><![CDATA[ |
||
140 | document.getElementById("group_perms").style.display = "none"; |
||
141 | document.getElementById("group_perms_groups_link").style.display = ""; |
||
142 | // ]]></script> |
||
143 | </dd> |
||
144 | <dt> |
||
145 | <strong>', $txt['um_menu_button_status'], ':</strong> |
||
146 | </dt> |
||
147 | <dd> |
||
148 | <input type="radio" class="input_check" name="status" value="active"', $context['button_data']['status'] == 'active' ? ' checked="checked"' : '', ' />', $txt['um_menu_button_active'], ' <br /> |
||
149 | <input type="radio" class="input_check" name="status" value="inactive"', $context['button_data']['status'] == 'inactive' ? ' checked="checked"' : '', ' />', $txt['um_menu_button_inactive'], ' |
||
150 | </dd> |
||
167 | } |