| Conditions | 7 |
| Paths | 48 |
| Total Lines | 70 |
| 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 |
||
| 161 | function b_tdmdownloads_top_edit($options) |
||
| 162 | { |
||
| 163 | //appel de la class |
||
| 164 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 165 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
||
| 166 | $criteria = new \CriteriaCompo(); |
||
| 167 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
| 168 | $criteria->setOrder('ASC'); |
||
| 169 | $downloadscatArray = $categoryHandler->getAll($criteria); |
||
| 170 | $form = _MB_TDMDOWNLOADS_DISP . " \n"; |
||
| 171 | $form .= '<input type="hidden" name="options[0]" value="' . $options[0] . "\">\n"; |
||
| 172 | $form .= '<input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text"> ' . _MB_TDMDOWNLOADS_FILES . "<br>\n"; |
||
| 173 | $form .= _MB_TDMDOWNLOADS_CHARS . ' (<small>' . _MB_TDMDOWNLOADS_CHARSDSC . '</small>): <input name="options[2]" size="5" maxlength="255" value="' . $options[2] . "\" type=\"text\"><br>\n"; |
||
| 174 | if (false == $options[3]) { |
||
| 175 | $checked_yes = ''; |
||
| 176 | $checked_no = 'checked'; |
||
| 177 | } else { |
||
| 178 | $checked_yes = 'checked'; |
||
| 179 | $checked_no = ''; |
||
| 180 | } |
||
| 181 | $form .= _MB_TDMDOWNLOADS_LOGO . ' : <input name="options[3]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 182 | $form .= '<input name="options[3]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 183 | if (false == $options[4]) { |
||
| 184 | $checked_yes = ''; |
||
| 185 | $checked_no = 'checked'; |
||
| 186 | } else { |
||
| 187 | $checked_yes = 'checked'; |
||
| 188 | $checked_no = ''; |
||
| 189 | } |
||
| 190 | $form .= _MB_TDMDOWNLOADS_DESCRIPTION . ' : <input name="options[4]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 191 | $form .= '<input name="options[4]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 192 | if (false == $options[5]) { |
||
| 193 | $checked_yes = ''; |
||
| 194 | $checked_no = 'checked'; |
||
| 195 | } else { |
||
| 196 | $checked_yes = 'checked'; |
||
| 197 | $checked_no = ''; |
||
| 198 | } |
||
| 199 | $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : <input name="options[5]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 200 | $form .= '<input name="options[5]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br><br>\n"; |
||
| 201 | $floatSelect = new \XoopsFormSelect('', 'options[6]', $options[6]); |
||
| 202 | $floatSelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT); |
||
| 203 | $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); |
||
| 204 | $form .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '<br>'; |
||
| 205 | $form .= _MB_TDMDOWNLOADS_WIDTH . ' (<small>' . _MB_TDMDOWNLOADS_WIDTHDSC . '</small>): <input name="options[7]" size="5" maxlength="255" value="' . $options[7] . "\" type=\"text\"><br>\n"; |
||
| 206 | $form .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ': <input name="options[8]" size="5" maxlength="255" value="' . $options[8] . "\" type=\"text\"><br>\n"; |
||
| 207 | $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]); |
||
| 208 | $styleSelect->addOption('default', 'default'); |
||
| 209 | $styleSelect->addOption('simple1', 'simple1'); |
||
| 210 | $styleSelect->addOption('simple2', 'simple2'); |
||
| 211 | $styleSelect->addOption('simple3', 'simple3'); |
||
| 212 | $styleSelect->addOption('simple4', 'simple4'); |
||
| 213 | $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '<br>'; |
||
| 214 | array_shift($options); |
||
| 215 | array_shift($options); |
||
| 216 | array_shift($options); |
||
| 217 | array_shift($options); |
||
| 218 | array_shift($options); |
||
| 219 | array_shift($options); |
||
| 220 | array_shift($options); |
||
| 221 | array_shift($options); |
||
| 222 | array_shift($options); |
||
| 223 | $form .= _MB_TDMDOWNLOADS_CATTODISPLAY . "<br><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n"; |
||
| 224 | $form .= '<option value="0" ' . (!in_array(0, $options, false) ? '' : 'selected="selected"') . '>' . _MB_TDMDOWNLOADS_ALLCAT . "</option>\n"; |
||
| 225 | foreach (array_keys($downloadscatArray) as $i) { |
||
| 226 | /** @var \XoopsModules\Tdmdownloads\Category[] $downloadscatArray */ |
||
| 227 | $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"; |
||
| 228 | } |
||
| 229 | $form .= "</select>\n"; |
||
| 230 | return $form; |
||
| 231 | } |
||
| 232 |