Conditions | 7 |
Paths | 64 |
Total Lines | 80 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
32 | function b_lxentries_alpha_show($options) |
||
33 | { |
||
34 | global $xoopsDB, $xoopsUser, $xoopsModule; |
||
35 | $myts = \MyTextSanitizer::getInstance(); |
||
|
|||
36 | |||
37 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
38 | $moduleHandler = xoops_getHandler('module'); |
||
39 | $lexikon = $moduleHandler->getByDirname('lexikon'); |
||
40 | if (!isset($lxConfig)) { |
||
41 | /** @var \XoopsConfigHandler $configHandler */ |
||
42 | $configHandler = xoops_getHandler('config'); |
||
43 | $lxConfig = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid')); |
||
44 | } |
||
45 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
46 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
47 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
48 | $module_id = $lexikon->getVar('mid'); |
||
49 | $allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
||
50 | $catids = implode(',', $allowed_cats); |
||
51 | $catperms = " AND categoryID IN ($catids) "; |
||
52 | |||
53 | $block = []; |
||
54 | // To handle options in the template |
||
55 | if (1 == $options[0]) { |
||
56 | $block['layout'] = 1; |
||
57 | } else { |
||
58 | $block['layout'] = 0; |
||
59 | } |
||
60 | if ($options[1]) { |
||
61 | $block['number'] = $options[1]; |
||
62 | } else { |
||
63 | $block['number'] = 8; |
||
64 | } |
||
65 | $block['title'] = _MB_LEXIKON_TERMINITIAL; |
||
66 | $block['moduledirname'] = $lexikon->dirname(); |
||
67 | $count = 0; |
||
68 | for ($a = 48; $a < (48 + 10); ++$a) { |
||
69 | $letterlinks = []; |
||
70 | $initial = uchr($a); |
||
71 | $sql = $xoopsDB->query('SELECT init FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$initial' AND datesub < '" . time() . "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " . $catperms . ' '); |
||
72 | $howmany = $xoopsDB->getRowsNum($sql); |
||
73 | $letterlinks['total'] = $howmany; |
||
74 | $letterlinks['id'] = uchr($a); |
||
75 | $letterlinks['linktext'] = uchr($a); |
||
76 | $letterlinks['count'] = $count; |
||
77 | |||
78 | $block['initstuff'][] = $letterlinks; |
||
79 | } |
||
80 | for ($a = 65; $a < (65 + 26); ++$a) { |
||
81 | $letterlinks = []; |
||
82 | $initial = uchr($a); |
||
83 | $sql = $xoopsDB->query('SELECT init FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$initial' AND datesub < '" . time() . "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " . $catperms . ' '); |
||
84 | $howmany = $xoopsDB->getRowsNum($sql); |
||
85 | $letterlinks['total'] = $howmany; |
||
86 | $letterlinks['id'] = uchr($a); |
||
87 | $letterlinks['linktext'] = uchr($a); |
||
88 | $letterlinks['count'] = $count; |
||
89 | |||
90 | $block['initstuff'][] = $letterlinks; |
||
91 | } |
||
92 | /*for ($a = 1040; $a < (1040 + 32); ++$a) { |
||
93 | $letterlinks = []; |
||
94 | $initial = uchr($a); |
||
95 | $sql = $xoopsDB->query('SELECT init FROM ' |
||
96 | . $xoopsDB->prefix('lxentries') |
||
97 | . " WHERE init = '$initial' AND datesub < '" |
||
98 | . time() |
||
99 | . "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " |
||
100 | . $catperms |
||
101 | . ' '); |
||
102 | $howmany = $xoopsDB->getRowsNum($sql); |
||
103 | $letterlinks['total'] = $howmany; |
||
104 | $letterlinks['id'] = uchr($a); |
||
105 | $letterlinks['linktext'] = uchr($a); |
||
106 | $letterlinks['count'] = (int)$count; |
||
107 | |||
108 | $block['initstuff'][] = $letterlinks; |
||
109 | }*/ |
||
110 | |||
111 | return $block; |
||
112 | } |
||
128 |