Conditions | 21 |
Paths | > 20000 |
Total Lines | 141 |
Code Lines | 99 |
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 |
||
181 | function b_arts_spot_edit($options) |
||
182 | { |
||
183 | global $xoopsDB; |
||
184 | $myts = \MyTextSanitizer:: getInstance(); |
||
185 | $helper = \XoopsModules\Soapbox\Helper::getInstance(); |
||
186 | $columnIDs = []; |
||
187 | $module_name = 'soapbox'; |
||
188 | $moduleHandler = xoops_getHandler('module'); |
||
189 | $soapModule = $moduleHandler->getByDirname($module_name); |
||
190 | if (!is_object($soapModule)) { |
||
191 | return null; |
||
192 | } |
||
193 | $form = ''; |
||
194 | //----- |
||
195 | $chked = ''; |
||
196 | $form .= _MB_SOAPBOX_SPOTLIGHT; |
||
197 | if (1 === $options[0]) { |
||
198 | $chked = ' checked'; |
||
199 | } |
||
200 | $form .= "<input type='radio' name='options[0]' value='1'" . $chked . '> ' . _YES; |
||
201 | $chked = ''; |
||
202 | if (0 === $options[0]) { |
||
203 | $chked = ' checked'; |
||
204 | } |
||
205 | $form .= " <input type='radio' name='options[0]' value='0'" . $chked . '>' . _NO . '<br>'; |
||
206 | //----- |
||
207 | //----- |
||
208 | $form .= _MB_SOAPBOX_ARTSTOSHOW . "<input type='text' name='options[1]' value='" . $myts->htmlSpecialChars($options[1]) . "'> " . _MB_SOAPBOX_ARTCLS . '.<br>'; |
||
209 | //----- |
||
210 | $chked = ''; |
||
211 | $form .= _MB_SOAPBOX_SHOWDATE; |
||
212 | if (1 === $options[2]) { |
||
213 | $chked = ' checked'; |
||
214 | } |
||
215 | $form .= "<input type='radio' name='options[2]' value='1'" . $chked . '> ' . _YES; |
||
216 | $chked = ''; |
||
217 | if (0 === $options[2]) { |
||
218 | $chked = ' checked'; |
||
219 | } |
||
220 | $form .= " <input type='radio' name='options[2]' value='0'" . $chked . '>' . _NO . '<br>'; |
||
221 | //----- |
||
222 | $chked = ''; |
||
223 | $form .= _MB_SOAPBOX_SHOWBYLINE; |
||
224 | if (1 === $options[3]) { |
||
225 | $chked = ' checked'; |
||
226 | } |
||
227 | $form .= "<input type='radio' name='options[3]' value='1'" . $chked . '> ' . _YES; |
||
228 | $chked = ''; |
||
229 | if (0 === $options[3]) { |
||
230 | $chked = ' checked'; |
||
231 | } |
||
232 | $form .= ' <input type="radio" name="options[3]" value="0"' . $chked . '>' . _NO . '<br>'; |
||
233 | //----- |
||
234 | $chked = ''; |
||
235 | $form .= _MB_SOAPBOX_SHOWSTATS; |
||
236 | if (1 === $options[4]) { |
||
237 | $chked = ' checked'; |
||
238 | } |
||
239 | $form .= "<input type='radio' name='options[4]' value='1'" . $chked . '> ' . _YES; |
||
240 | $chked = ''; |
||
241 | if (0 === $options[4]) { |
||
242 | $chked = ' checked'; |
||
243 | } |
||
244 | $form .= " <input type='radio' name='options[4]' value='0' " . $chked . '>' . _NO . '<br>'; |
||
245 | |||
246 | $form .= _MB_SOAPBOX_TEMPLATE . "<select name='options[5]' >"; |
||
247 | $form .= "<option value='ver'"; |
||
248 | if ('ver' === $options[5]) { |
||
249 | $form .= ' selected'; |
||
250 | } |
||
251 | $form .= '>' . _MB_SOAPBOX_VERTICAL . "</option>\n"; |
||
252 | $form .= "<option value='hor'"; |
||
253 | if ('hor' === $options[5]) { |
||
254 | $form .= ' selected'; |
||
255 | } |
||
256 | $form .= '>' . _MB_SOAPBOX_HORIZONTAL . '</option>'; |
||
257 | $form .= '</select><br>'; |
||
258 | |||
259 | $chked = ''; |
||
260 | $form .= _MB_SOAPBOX_SHOWPIC; |
||
261 | if (1 === $options[6]) { |
||
262 | $chked = ' checked'; |
||
263 | } |
||
264 | $form .= "<input type='radio' name='options[6]' value='1' " . $chked . '> ' . _YES; |
||
265 | |||
266 | $chked = ''; |
||
267 | if (0 === $options[6]) { |
||
268 | $chked = ' checked'; |
||
269 | } |
||
270 | $form .= " <input type='radio' name='options[6]' value='0' " . $chked . '>' . _NO . '<br>'; |
||
271 | //---------- sortname ------ |
||
272 | $form .= '' . _MB_SOAPBOX_ORDER . " <select name='options[7]'>"; |
||
273 | |||
274 | $form .= "<option value='datesub'"; |
||
275 | if ('datesub' === $options[7]) { |
||
276 | $form .= ' selected'; |
||
277 | } |
||
278 | $form .= '>' . _MB_SOAPBOX_DATE . "</option>\n"; |
||
279 | |||
280 | $form .= "<option value='counter'"; |
||
281 | if ('counter' === $options[7]) { |
||
282 | $form .= ' selected'; |
||
283 | } |
||
284 | $form .= '>' . _MB_SOAPBOX_HITS . "</option>\n"; |
||
285 | |||
286 | $form .= "<option value='weight'"; |
||
287 | if ('weight' === $options[7]) { |
||
288 | $form .= ' selected'; |
||
289 | } |
||
290 | $form .= '>' . _MB_SOAPBOX_WEIGHT . "</option>\n"; |
||
291 | |||
292 | $form .= "<option value='rating'"; |
||
293 | if ('rating' === $options[7]) { |
||
294 | $form .= ' selected'; |
||
295 | } |
||
296 | $form .= '>' . _MB_SOAPBOX_RATING . "</option>\n"; |
||
297 | |||
298 | $form .= "</select>\n"; |
||
299 | |||
300 | $form .= ' <br>' . _MB_SOAPBOX_CHARS . " <input type='text' name='options[8]' value='" . $myts->htmlSpecialChars($options[8]) . "'> " . _MB_SOAPBOX_LENGTH . ''; |
||
301 | |||
302 | //------------------------------------- |
||
303 | /** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */ |
||
304 | $entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler(); |
||
305 | $categoryobArray = $entrydataHandler->getColumns(); |
||
306 | $form .= '<br>' . _MB_SOAPBOX_SPOTLIGHT_TOPIC . "<br><select name='options[]' multiple='multiple'>"; |
||
307 | $form .= "<option value='0'>(ALL)</option>"; |
||
308 | if (!empty($categoryobArray)) { |
||
309 | foreach ($categoryobArray as $_categoryob) { |
||
310 | $categoryID = $_categoryob->getVar('columnID'); |
||
311 | $name = $_categoryob->getVar('name'); |
||
312 | $sel = ''; |
||
313 | if (in_array($categoryID, $columnIDs, true)) { |
||
314 | $sel = ' selected="selected"'; |
||
315 | } |
||
316 | $form .= "<option value='" . $categoryID . "' " . $sel . '>' . $categoryID . ' : ' . $name . '</option>'; |
||
317 | } |
||
318 | } |
||
319 | $form .= "</select><br>\n"; |
||
320 | |||
321 | return $form; |
||
322 | } |
||
323 |