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