| Conditions | 7 |
| Paths | 48 |
| Total Lines | 64 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 135 | function b_tdmdownloads_top_edit($options) |
||
| 136 | { |
||
| 137 | //appel de la class |
||
| 138 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 139 | $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); |
||
| 140 | $criteria = new \CriteriaCompo(); |
||
| 141 | $criteria = new \CriteriaCompo(); |
||
| 142 | $criteria->setSort('cat_weight ASC, cat_title'); |
||
| 143 | $criteria->setOrder('ASC'); |
||
| 144 | $downloadscatArray = $categoryHandler->getAll($criteria); |
||
| 145 | $form = _MB_TDMDOWNLOADS_DISP . " \n"; |
||
| 146 | $form .= '<input type="hidden" name="options[0]" value="' . $options[0] . "\">\n"; |
||
| 147 | $form .= '<input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text"> ' . _MB_TDMDOWNLOADS_FILES . "<br>\n"; |
||
| 148 | $form .= _MB_TDMDOWNLOADS_CHARS . ' : <input name="options[2]" size="5" maxlength="255" value="' . $options[2] . "\" type=\"text\"><br>\n"; |
||
| 149 | if (false === $options[3]) { |
||
| 150 | $checked_yes = ''; |
||
| 151 | $checked_no = 'checked'; |
||
| 152 | } else { |
||
| 153 | $checked_yes = 'checked'; |
||
| 154 | $checked_no = ''; |
||
| 155 | } |
||
| 156 | $form .= _MB_TDMDOWNLOADS_LOGO . ' : <input name="options[3]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 157 | $form .= '<input name="options[3]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 158 | if (false === $options[4]) { |
||
| 159 | $checked_yes = ''; |
||
| 160 | $checked_no = 'checked'; |
||
| 161 | } else { |
||
| 162 | $checked_yes = 'checked'; |
||
| 163 | $checked_no = ''; |
||
| 164 | } |
||
| 165 | $form .= _MB_TDMDOWNLOADS_DESCRIPTION . ' : <input name="options[4]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 166 | $form .= '<input name="options[4]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n"; |
||
| 167 | if (false === $options[5]) { |
||
| 168 | $checked_yes = ''; |
||
| 169 | $checked_no = 'checked'; |
||
| 170 | } else { |
||
| 171 | $checked_yes = 'checked'; |
||
| 172 | $checked_no = ''; |
||
| 173 | } |
||
| 174 | $form .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : <input name="options[5]" value="1" type="radio" ' . $checked_yes . '>' . _YES . " \n"; |
||
| 175 | $form .= '<input name="options[5]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br><br>\n"; |
||
| 176 | $floatelect = new \XoopsFormSelect(_MB_TDMDOWNLOADS_FLOAT, 'options[6]', $options[6]); |
||
| 177 | $floatelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT); |
||
| 178 | $floatelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT); |
||
| 179 | $form .= _MB_TDMDOWNLOADS_FLOAT . ' : ' . $floatelect->render() . '<br>'; |
||
| 180 | $form .= _MB_TDMDOWNLOADS_WHITE . ' : <input name="options[7]" size="5" maxlength="255" value="' . $options[7] . "\" type=\"text\"><br>\n"; |
||
| 181 | $form .= _MB_TDMDOWNLOADS_CHARSDSC . ' : <input name="options[8]" size="5" maxlength="255" value="' . $options[8] . "\" type=\"text\"><br>\n"; |
||
| 182 | array_shift($options); |
||
| 183 | array_shift($options); |
||
| 184 | array_shift($options); |
||
| 185 | array_shift($options); |
||
| 186 | array_shift($options); |
||
| 187 | array_shift($options); |
||
| 188 | array_shift($options); |
||
| 189 | array_shift($options); |
||
| 190 | array_shift($options); |
||
| 191 | $form .= _MB_TDMDOWNLOADS_CATTODISPLAY . "<br><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n"; |
||
| 192 | $form .= '<option value="0" ' . (!in_array(0, $options, true) ? '' : 'selected="selected"') . '>' . _MB_TDMDOWNLOADS_ALLCAT . "</option>\n"; |
||
| 193 | foreach (array_keys($downloadscatArray) as $i) { |
||
| 194 | $form .= '<option value="' . $downloadscatArray[$i]->getVar('cat_cid') . '" ' . (!in_array($downloadscatArray[$i]->getVar('cat_cid'), $options, true) ? '' : 'selected') . '>' . $downloadscatArray[$i]->getVar('cat_title') . "</option>\n"; |
||
| 195 | } |
||
| 196 | $form .= "</select>\n"; |
||
| 197 | |||
| 198 | return $form; |
||
| 199 | } |
||
| 200 |