| Conditions | 7 |
| Paths | 48 |
| Total Lines | 123 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 declare(strict_types=1); |
||
| 238 | function b_tdmdownloads_top_edit($options) |
||
| 239 | { |
||
| 240 | //appel de la class |
||
| 241 | |||
| 242 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 243 | |||
| 244 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
||
| 245 | |||
| 246 | $criteria = new \CriteriaCompo(); |
||
| 247 | |||
| 248 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
| 249 | |||
| 250 | $criteria->setOrder('ASC'); |
||
| 251 | |||
| 252 | $downloadscatArray = $categoryHandler->getAll($criteria); |
||
| 253 | |||
| 254 | $form = _MB_TDMDOWNLOADS_DISP . " \n"; |
||
| 255 | |||
| 256 | $form .= '<input type="hidden" name="options[0]" value="' . $options[0] . "\">\n"; |
||
| 257 | |||
| 258 | $form .= '<input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text"> ' . _MB_TDMDOWNLOADS_FILES . "<br>\n"; |
||
| 259 | |||
| 260 | $form .= _MB_TDMDOWNLOADS_CHARS . ' (<small>' . _MB_TDMDOWNLOADS_CHARSDSC . '</small>): <input name="options[2]" size="5" maxlength="255" value="' . $options[2] . "\" type=\"text\"><br>\n"; |
||
| 261 | |||
| 262 | if (false == $options[3]) { |
||
| 263 | $checked_yes = ''; |
||
| 264 | |||
| 265 | $checked_no = 'checked'; |
||
| 266 | } else { |
||
| 267 | $checked_yes = 'checked'; |
||
| 268 | |||
| 269 | $checked_no = ''; |
||
| 270 | } |
||
| 271 | |||
| 272 | $form .= _MB_TDMDOWNLOADS_LOGO . ' : <input name="options[3]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 273 | |||
| 274 | $form .= '<input name="options[3]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 275 | |||
| 276 | if (false == $options[4]) { |
||
| 277 | $checked_yes = ''; |
||
| 278 | |||
| 279 | $checked_no = 'checked'; |
||
| 280 | } else { |
||
| 281 | $checked_yes = 'checked'; |
||
| 282 | |||
| 283 | $checked_no = ''; |
||
| 284 | } |
||
| 285 | |||
| 286 | $form .= _MB_TDMDOWNLOADS_DESCRIPTION . ' : <input name="options[4]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 287 | |||
| 288 | $form .= '<input name="options[4]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 289 | |||
| 290 | if (false == $options[5]) { |
||
| 291 | $checked_yes = ''; |
||
| 292 | |||
| 293 | $checked_no = 'checked'; |
||
| 294 | } else { |
||
| 295 | $checked_yes = 'checked'; |
||
| 296 | |||
| 297 | $checked_no = ''; |
||
| 298 | } |
||
| 299 | |||
| 300 | $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : <input name="options[5]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 301 | |||
| 302 | $form .= '<input name="options[5]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br><br>\n"; |
||
| 303 | |||
| 304 | $floatSelect = new \XoopsFormSelect('', 'options[6]', $options[6]); |
||
| 305 | |||
| 306 | $floatSelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT); |
||
| 307 | |||
| 308 | $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); |
||
| 309 | |||
| 310 | $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '<br>'; |
||
| 311 | |||
| 312 | $form .= _MB_TDMDOWNLOADS_WIDTH . ' (<small>' . _MB_TDMDOWNLOADS_WIDTHDSC . '</small>): <input name="options[7]" size="5" maxlength="255" value="' . $options[7] . "\" type=\"text\"><br>\n"; |
||
| 313 | |||
| 314 | $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ': <input name="options[8]" size="5" maxlength="255" value="' . $options[8] . "\" type=\"text\"><br>\n"; |
||
| 315 | |||
| 316 | $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]); |
||
| 317 | |||
| 318 | $styleSelect->addOption('default', 'default'); |
||
| 319 | |||
| 320 | $styleSelect->addOption('simple1', 'simple1'); |
||
| 321 | |||
| 322 | $styleSelect->addOption('simple2', 'simple2'); |
||
| 323 | |||
| 324 | $styleSelect->addOption('simple3', 'simple3'); |
||
| 325 | |||
| 326 | $styleSelect->addOption('simple4', 'simple4'); |
||
| 327 | |||
| 328 | $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '<br>'; |
||
| 329 | |||
| 330 | array_shift($options); |
||
| 331 | |||
| 332 | array_shift($options); |
||
| 333 | |||
| 334 | array_shift($options); |
||
| 335 | |||
| 336 | array_shift($options); |
||
| 337 | |||
| 338 | array_shift($options); |
||
| 339 | |||
| 340 | array_shift($options); |
||
| 341 | |||
| 342 | array_shift($options); |
||
| 343 | |||
| 344 | array_shift($options); |
||
| 345 | |||
| 346 | array_shift($options); |
||
| 347 | |||
| 348 | $form .= _MB_TDMDOWNLOADS_CATTODISPLAY . "<br><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n"; |
||
| 349 | |||
| 350 | $form .= '<option value="0" ' . (!in_array(0, $options, false) ? '' : 'selected="selected"') . '>' . _MB_TDMDOWNLOADS_ALLCAT . "</option>\n"; |
||
| 351 | |||
| 352 | foreach (array_keys($downloadscatArray) as $i) { |
||
| 353 | /** @var \XoopsModules\Tdmdownloads\Category[] $downloadscatArray */ |
||
| 354 | |||
| 355 | $form .= '<option value="' . $downloadscatArray[$i]->getVar('cat_cid') . '" ' . (!in_array($downloadscatArray[$i]->getVar('cat_cid'), $options, false) ? '' : 'selected') . '>' . $downloadscatArray[$i]->getVar('cat_title') . "</option>\n"; |
||
| 356 | } |
||
| 357 | |||
| 358 | $form .= "</select>\n"; |
||
| 359 | |||
| 360 | return $form; |
||
| 361 | } |
||
| 362 |