Conditions | 13 |
Paths | 4096 |
Total Lines | 128 |
Code Lines | 114 |
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 |
||
112 | function b_xoopspartners_edit($options) |
||
113 | { |
||
114 | if (0 == $options[0]) { //put spaces between partners |
||
115 | $chk0no = ' checked'; |
||
116 | $chk0yes = ''; |
||
117 | } else { |
||
118 | $chk0no = ''; |
||
119 | $chk0yes = ' checked'; |
||
120 | } |
||
121 | if (0 == $options[1]) { //fade partners in/out |
||
122 | $chk1no = ' checked'; |
||
123 | $chk1yes = ''; |
||
124 | } else { |
||
125 | $chk1no = ''; |
||
126 | $chk1yes = ' checked'; |
||
127 | } |
||
128 | if (0 == $options[2]) { //randomize partners in block |
||
129 | $chk2no = ' checked'; |
||
130 | $chk2yes = ''; |
||
131 | } else { |
||
132 | $chk2no = ''; |
||
133 | $chk2yes = ' checked'; |
||
134 | } |
||
135 | $form = "<table class='bnone'>\n" |
||
136 | . " <tr>\n" |
||
137 | . ' <td>' |
||
138 | . _MB_XOOPSPARTNERS_PSPACE |
||
139 | . "</td>\n" |
||
140 | . ' <td>' |
||
141 | . "<input type='radio' name='options[0]' id ='options0_0' value='0'{$chk0no}>" |
||
142 | . "<label for='options0_0'>" |
||
143 | . _NO |
||
144 | . '</label> ' |
||
145 | . "<input type='radio' name='options[0]' id ='options0_1' value='1'{$chk0yes}>" |
||
146 | . "<label for='options0_1'>" |
||
147 | . _YES |
||
148 | . '</label>' |
||
149 | . "</td>\n" |
||
150 | . " </tr>\n" |
||
151 | . " <tr>\n" |
||
152 | . ' <td>' |
||
153 | . _MB_XOOPSPARTNERS_FADE |
||
154 | . "</td>\n" |
||
155 | . ' <td>' |
||
156 | . "<input type='radio' name='options[1]' id='options1_0' value='0'{$chk1no}>" |
||
157 | . _NO |
||
158 | . "<label for='options1_0'>" |
||
159 | . _NO |
||
160 | . '</label> ' |
||
161 | . "<input type='radio' name='options[1]' id='options1_1' value='1'{$chk1yes}>" |
||
162 | . _YES |
||
163 | . "<label for='options1_1'>" |
||
164 | . _YES |
||
165 | . '</label>' |
||
166 | . "</td>\n" |
||
167 | . " </tr>\n" |
||
168 | . " <tr>\n" |
||
169 | . ' <td>' |
||
170 | . _MB_XOOPSPARTNERS_BRAND |
||
171 | . "</td>\n" |
||
172 | . ' <td>' |
||
173 | . "<input type='radio' name='options[2]' id='option2_0' value='0'{$chk2no}>" |
||
174 | . _NO |
||
175 | . "<label for='options2_0'>" |
||
176 | . _NO |
||
177 | . '</label>' |
||
178 | . "<input type='radio' name='options[2]' id='options2_1' value='1'{$chk2yes}>" |
||
179 | . _YES |
||
180 | . "<label for='options2_1'>" |
||
181 | . _YES |
||
182 | . '</label>' |
||
183 | . "</td>\n" |
||
184 | . " </tr>\n" |
||
185 | . " <tr>\n" |
||
186 | . ' <td>' |
||
187 | . _MB_XOOPSPARTNERS_BLIMIT |
||
188 | . "</td>\n" |
||
189 | . " <td><input class='right' type='number' name='options[3]' size='5' value='{$options[3]}' min='0'></td>\n" |
||
190 | . " </tr>\n" |
||
191 | . " <tr>\n" |
||
192 | . ' <td>' |
||
193 | . _MB_XOOPSPARTNERS_BSHOW |
||
194 | . "</td>\n" |
||
195 | . " <td>\n" |
||
196 | . " <select size='1' name='options[4]'>\n"; |
||
197 | $sel = (1 == $options[4]) ? ' selected' : ''; |
||
198 | $form .= " <option value='1'{$sel}>" . _MB_XOOPSPARTNERS_IMAGES . "</option>\n"; |
||
199 | |||
200 | $sel = (2 == $options[4]) ? ' selected' : ''; |
||
201 | $form .= " <option value='2'{$sel}>" . _MB_XOOPSPARTNERS_TEXT . "</option>\n"; |
||
202 | |||
203 | $sel = (3 == $options[4]) ? ' selected' : ''; |
||
204 | $form .= " <option value='3'{$sel}>" . _MB_XOOPSPARTNERS_BOTH . "</option>\n" . " </select>\n" . " </td>\n" . " </tr>\n" . " <tr>\n" . ' <td>' . _MB_XOOPSPARTNERS_BSORT . "</td>\n" . " <td>\n" . " <select size='1' name='options[5]'>\n"; |
||
205 | |||
206 | $sel = ('id' === $options[5]) ? ' selected' : ''; |
||
207 | $form .= " <option value='id'{$sel}>" . _MB_XOOPSPARTNERS_ID . "</option>\n"; |
||
208 | |||
209 | $sel = ('hits' === $options[5]) ? ' selected' : ''; |
||
210 | $form .= " <option value='hits'{$sel}>" . _MB_XOOPSPARTNERS_HITS . "</option>\n"; |
||
211 | |||
212 | $sel = ('title' === $options[5]) ? ' selected' : ''; |
||
213 | $form .= " <option value='title'{$sel}>" . _MB_XOOPSPARTNERS_TITLE . "</option>\n"; |
||
214 | |||
215 | $sel = ('weight' === $options[5]) ? ' selected' : ''; |
||
216 | $form .= " <option value='weight'{$sel}>" . _MB_XOOPSPARTNERS_WEIGHT . "</option>\n" . " </select>\n" . " <select size='1' name='options[6]'>\n"; |
||
217 | |||
218 | $sel = ('ASC' === $options[6]) ? ' selected' : ''; |
||
219 | $form .= " <option value='ASC'{$sel}>" . _MB_XOOPSPARTNERS_ASC . "</option>\n"; |
||
220 | |||
221 | $sel = ('DESC' === $options[6]) ? ' selected' : ''; |
||
222 | $form .= " <option value='DESC'{$sel}>" |
||
223 | . _MB_XOOPSPARTNERS_DESC |
||
224 | . "</option>\n" |
||
225 | . " </select>\n" |
||
226 | . " </td>\n" |
||
227 | . " </tr>\n" |
||
228 | . " <tr>\n" |
||
229 | . ' <td>' |
||
230 | . _MB_XOOPSPARTNERS_TTL_LENGTH |
||
231 | . "</td>\n" |
||
232 | . ' <td>' |
||
233 | . "<input type='number' class='right' name='options[7]' size='5' value='{$options[7]}' min='0'>" |
||
234 | . "</td>\n" |
||
235 | . " </tr>\n" |
||
236 | . " <tr>\n" |
||
237 | . "</table>\n"; |
||
238 | |||
239 | return $form; |
||
240 | } |
||
241 |