| Conditions | 25 |
| Paths | > 20000 |
| Total Lines | 150 |
| Code Lines | 104 |
| 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 |
||
| 197 | function b_columns_spot_edit($options) |
||
| 198 | { |
||
| 199 | $myts = \MyTextSanitizer:: getInstance(); |
||
| 200 | $helper = \XoopsModules\Soapbox\Helper::getInstance(); |
||
| 201 | $columnIDs = []; |
||
| 202 | $module_name = 'soapbox'; |
||
| 203 | $moduleHandler = xoops_getHandler('module'); |
||
| 204 | $soapModule = $moduleHandler->getByDirname($module_name); |
||
| 205 | if (!is_object($soapModule)) { |
||
| 206 | return null; |
||
| 207 | } |
||
| 208 | $form = ''; |
||
| 209 | //----- |
||
| 210 | $chked = ''; |
||
| 211 | $form .= _MB_SOAPBOX_SPOTLIGHT; |
||
| 212 | if (1 === $options[0]) { |
||
| 213 | $chked = ' checked'; |
||
| 214 | } |
||
| 215 | $form .= "<input type='radio' name='options[0]' value='1'" . $chked . '> ' . _YES; |
||
| 216 | $chked = ''; |
||
| 217 | if (0 === $options[0]) { |
||
| 218 | $chked = ' checked'; |
||
| 219 | } |
||
| 220 | $form .= " <input type='radio' name='options[0]' value='0'" . $chked . '>' . _NO . '<br>'; |
||
| 221 | //----- |
||
| 222 | //----- |
||
| 223 | $form .= _MB_SOAPBOX_ARTSTOSHOW . "<input type='text' name='options[1]' value='" . $myts->htmlSpecialChars($options[1]) . "'> " . _MB_SOAPBOX_ARTCLS . '.<br>'; |
||
| 224 | //----- |
||
| 225 | $chked = ''; |
||
| 226 | $form .= _MB_SOAPBOX_SHOWDATE; |
||
| 227 | if (1 === $options[2]) { |
||
| 228 | $chked = ' checked'; |
||
| 229 | } |
||
| 230 | $form .= "<input type='radio' name='options[2]' value='1'" . $chked . '> ' . _YES; |
||
| 231 | $chked = ''; |
||
| 232 | if (0 === $options[2]) { |
||
| 233 | $chked = ' checked'; |
||
| 234 | } |
||
| 235 | $form .= " <input type='radio' name='options[2]' value='0'" . $chked . '>' . _NO . '<br>'; |
||
| 236 | //----- |
||
| 237 | $chked = ''; |
||
| 238 | $form .= _MB_SOAPBOX_SHOWBYLINE; |
||
| 239 | if (1 === $options[3]) { |
||
| 240 | $chked = ' checked'; |
||
| 241 | } |
||
| 242 | $form .= "<input type='radio' name='options[3]' value='1'" . $chked . '> ' . _YES; |
||
| 243 | $chked = ''; |
||
| 244 | if (0 === $options[3]) { |
||
| 245 | $chked = ' checked'; |
||
| 246 | } |
||
| 247 | $form .= ' <input type="radio" name="options[3]" value="0"' . $chked . '>' . _NO . '<br>'; |
||
| 248 | //----- |
||
| 249 | $chked = ''; |
||
| 250 | $form .= _MB_SOAPBOX_SHOWSTATS; |
||
| 251 | if (1 === $options[4]) { |
||
| 252 | $chked = ' checked'; |
||
| 253 | } |
||
| 254 | $form .= "<input type='radio' name='options[4]' value='1'" . $chked . '> ' . _YES; |
||
| 255 | $chked = ''; |
||
| 256 | if (0 === $options[4]) { |
||
| 257 | $chked = ' checked'; |
||
| 258 | } |
||
| 259 | $form .= " <input type='radio' name='options[4]' value='0' " . $chked . '>' . _NO . '<br>'; |
||
| 260 | |||
| 261 | $form .= _MB_SOAPBOX_TEMPLATE . "<select name='options[5]' >"; |
||
| 262 | $form .= "<option value='ver'"; |
||
| 263 | if ('ver' === $options[5]) { |
||
| 264 | $form .= ' selected'; |
||
| 265 | } |
||
| 266 | $form .= '>' . _MB_SOAPBOX_VERTICAL . "</option>\n"; |
||
| 267 | $form .= "<option value='hor'"; |
||
| 268 | if ('hor' === $options[5]) { |
||
| 269 | $form .= ' selected'; |
||
| 270 | } |
||
| 271 | $form .= '>' . _MB_SOAPBOX_HORIZONTAL . '</option>'; |
||
| 272 | $form .= '</select><br>'; |
||
| 273 | |||
| 274 | $chked = ''; |
||
| 275 | $form .= _MB_SOAPBOX_SHOWPIC; |
||
| 276 | if (1 === $options[6]) { |
||
| 277 | $chked = ' checked'; |
||
| 278 | } |
||
| 279 | $form .= "<input type='radio' name='options[6]' value='1' " . $chked . '> ' . _YES; |
||
| 280 | |||
| 281 | $chked = ''; |
||
| 282 | if (0 === $options[6]) { |
||
| 283 | $chked = ' checked'; |
||
| 284 | } |
||
| 285 | $form .= " <input type='radio' name='options[6]' value='0' " . $chked . '>' . _NO . '<br>'; |
||
| 286 | //---------- sortname ------ |
||
| 287 | $form .= '' . _MB_SOAPBOX_ORDER . " <select name='options[7]'>"; |
||
| 288 | |||
| 289 | $form .= "<option value='datesub'"; |
||
| 290 | if ('datesub' === $options[7]) { |
||
| 291 | $form .= ' selected'; |
||
| 292 | } |
||
| 293 | $form .= '>' . _MB_SOAPBOX_DATE . "</option>\n"; |
||
| 294 | |||
| 295 | $form .= "<option value='counter'"; |
||
| 296 | if ('counter' === $options[7]) { |
||
| 297 | $form .= ' selected'; |
||
| 298 | } |
||
| 299 | $form .= '>' . _MB_SOAPBOX_HITS . "</option>\n"; |
||
| 300 | |||
| 301 | $form .= "<option value='weight'"; |
||
| 302 | if ('weight' === $options[7]) { |
||
| 303 | $form .= ' selected'; |
||
| 304 | } |
||
| 305 | $form .= '>' . _MB_SOAPBOX_WEIGHT . "</option>\n"; |
||
| 306 | |||
| 307 | $form .= "<option value='rating'"; |
||
| 308 | if ('rating' === $options[7]) { |
||
| 309 | $form .= ' selected'; |
||
| 310 | } |
||
| 311 | $form .= '>' . _MB_SOAPBOX_RATING . "</option>\n"; |
||
| 312 | |||
| 313 | $form .= "</select>\n"; |
||
| 314 | |||
| 315 | $form .= ' <br>' . _MB_SOAPBOX_CHARS . " <input type='text' name='options[8]' value='" . $myts->htmlSpecialChars($options[8]) . "'> " . _MB_SOAPBOX_LENGTH . ''; |
||
| 316 | |||
| 317 | //------------------------------------- |
||
| 318 | // Try to see what tabs are visibles (if we are in restricted view of course) |
||
| 319 | $opt_columnIDs = []; |
||
| 320 | if (!empty($options[9])) { |
||
| 321 | $opt_columnIDs = array_slice($options, 9); |
||
| 322 | } |
||
| 323 | if (!empty($opt_columnIDs) && is_array($opt_columnIDs)) { |
||
| 324 | foreach ($opt_columnIDs as $v) { |
||
| 325 | $columnIDs[] = (int)$v; |
||
| 326 | } |
||
| 327 | } |
||
| 328 | /** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */ |
||
| 329 | $entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler(); |
||
| 330 | $categoryobArray = $entrydataHandler->getColumns(); |
||
| 331 | $form .= '<br>' . _MB_SOAPBOX_SPOTLIGHT_TOPIC . "<br><select name='options[]' multiple='multiple'>"; |
||
| 332 | $form .= "<option value='0'>(ALL)</option>"; |
||
| 333 | if (!empty($categoryobArray)) { |
||
| 334 | foreach ($categoryobArray as $_categoryob) { |
||
| 335 | $categoryID = $_categoryob->getVar('columnID'); |
||
| 336 | $name = $_categoryob->getVar('name'); |
||
| 337 | $sel = ''; |
||
| 338 | if (in_array($categoryID, $columnIDs, true)) { |
||
| 339 | $sel = ' selected="selected"'; |
||
| 340 | } |
||
| 341 | $form .= "<option value='" . $categoryID . "' " . $sel . '>' . $categoryID . ' : ' . $name . '</option>'; |
||
| 342 | } |
||
| 343 | } |
||
| 344 | $form .= "</select><br>\n"; |
||
| 345 | |||
| 346 | return $form; |
||
| 347 | } |
||
| 348 |