| Conditions | 16 |
| Paths | 1536 |
| Total Lines | 72 |
| Code Lines | 51 |
| Lines | 4 |
| Ratio | 5.56 % |
| 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 |
||
| 17 | function b_scrolling_term_show($options) |
||
| 18 | { |
||
| 19 | global $xoopsDB, $xoopsUser; |
||
| 20 | $myts = MyTextSanitizer:: getInstance(); |
||
| 21 | |||
| 22 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 23 | $moduleHandler = xoops_getHandler('module'); |
||
| 24 | $lexikon = $moduleHandler->getByDirname('lexikon'); |
||
| 25 | if (!isset($lxConfig)) { |
||
|
|
|||
| 26 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 27 | $configHandler = xoops_getHandler('config'); |
||
| 28 | $lxConfig = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid')); |
||
| 29 | } |
||
| 30 | require_once XOOPS_ROOT_PATH . '/modules/lexikon/class/Utility.php'; |
||
| 31 | |||
| 32 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 33 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 34 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 35 | $module_id = $lexikon->getVar('mid'); |
||
| 36 | $allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
||
| 37 | |||
| 38 | $block = []; |
||
| 39 | $block['speed'] = isset($options[1]) && '' != $options[1] ? $options[1] : ''; |
||
| 40 | $block['bgcolor'] = isset($options[2]) && '' != $options[2] ? $options[2] : '#FFFFFF'; |
||
| 41 | $block['direction'] = $options[3]; |
||
| 42 | $block['alternate'] = isset($options[4]) ? 1 : 0; |
||
| 43 | $block['includedate'] = isset($options[6]) ? 1 : 0; |
||
| 44 | $block['style'] = $options[7]; |
||
| 45 | |||
| 46 | if (!empty($options[10])) { |
||
| 47 | $categories = array_filter(array_slice($options, 10)); |
||
| 48 | } else { |
||
| 49 | $categories = $allowed_cats; |
||
| 50 | } |
||
| 51 | $categories = array_intersect($categories, $allowed_cats); |
||
| 52 | $categories = implode(',', $categories); |
||
| 53 | if (0 == count($categories)) { |
||
| 54 | return $block; |
||
| 55 | } |
||
| 56 | |||
| 57 | $sql = $xoopsDB->query( |
||
| 58 | ' |
||
| 59 | SELECT entryID, term, definition, datesub, html |
||
| 60 | FROM ' . $xoopsDB->prefix('lxentries') . ' |
||
| 61 | WHERE datesub < ' . time() . " AND datesub > 0 AND offline = '0' AND submit = '0' AND request = '0' AND categoryID IN (" . $categories . ') |
||
| 62 | ORDER BY ' . $options[8] . ' ' . $options[9] . ' |
||
| 63 | LIMIT 0, ' . $options[0] . ' ' |
||
| 64 | ); |
||
| 65 | $totals = $xoopsDB->getRowsNum($sql); |
||
| 66 | |||
| 67 | if ($totals > 1) { |
||
| 68 | while (list($entryID, $term, $definition, $datesub, $html) = $xoopsDB->fetchRow($sql)) { |
||
| 69 | $items = []; |
||
| 70 | $userlink = '<a style="cursor:help;background-color: transparent;" href=\"' . XOOPS_URL . '/modules/' . $lexikon->dirname() . '/entry.php?entryID=' . (int)$entryID . '\">'; |
||
| 71 | $items['id'] = (int)$entryID; |
||
| 72 | $items['term'] = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5); |
||
| 73 | if ($options[5] > 0) { |
||
| 74 | $html = 1 == $html ? 1 : 0; |
||
| 75 | $definition = preg_replace("/'/", '’', $definition); |
||
| 76 | $items['definition'] = $utility::truncateTagSafe($myts->displayTarea($definition, $html), $options[5] + 3); |
||
| 77 | } else { |
||
| 78 | $items['definition'] = ''; |
||
| 79 | } |
||
| 80 | if ('1' == $options[6]) { |
||
| 81 | $items['date'] = formatTimestamp($datesub, $lxConfig['dateformat']); |
||
| 82 | } |
||
| 83 | $items['url'] = $userlink; |
||
| 84 | $block['scrollitems'][] = $items; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | return $block; |
||
| 89 | } |
||
| 156 |