| Conditions | 12 |
| Paths | 1024 |
| Total Lines | 49 |
| Code Lines | 34 |
| 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 |
||
| 14 | function b_lxentries_top_show($options) |
||
| 15 | { |
||
| 16 | global $xoopsDB, $xoopsUser; |
||
| 17 | $myts = MyTextSanitizer:: getInstance(); |
||
|
|
|||
| 18 | |||
| 19 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 20 | $moduleHandler = xoops_getHandler('module'); |
||
| 21 | $lexikon = $moduleHandler->getByDirname('lexikon'); |
||
| 22 | if (!isset($lxConfig)) { |
||
| 23 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 24 | $configHandler = xoops_getHandler('config'); |
||
| 25 | $lxConfig = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid')); |
||
| 26 | } |
||
| 27 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 28 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 29 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 30 | $module_id = $lexikon->getVar('mid'); |
||
| 31 | $allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
||
| 32 | $catids = implode(',', $allowed_cats); |
||
| 33 | $catperms = " AND categoryID IN ($catids) "; |
||
| 34 | |||
| 35 | $words = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE offline = '0' AND submit='0' AND request='0' AND block = '1'"); |
||
| 36 | $totalwords = $xoopsDB->getRowsNum($words); |
||
| 37 | |||
| 38 | $block = []; |
||
| 39 | $block['marquee'] = (1 == $options[2]) ? 1 : 0; |
||
| 40 | $block['alternate'] = (1 == $options[3]) ? 1 : 0; |
||
| 41 | $block['showcounter'] = (1 == $options[4]) ? 1 : 0; |
||
| 42 | $block['direction'] = $options[5]; |
||
| 43 | $block['speed'] = isset($options[6]) && '' != $options[6] ? $options[6] : '2'; |
||
| 44 | $block['bgcolor'] = isset($options[7]) && '' != $options[7] ? $options[7] : '#FFFFFF'; |
||
| 45 | |||
| 46 | $sql = 'SELECT entryID, categoryID, term, counter FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE datesub < ' . time() . " AND datesub > 0 AND offline = '0' " . $catperms . ' ORDER BY ' . $options[0] . ' DESC'; |
||
| 47 | $result = $xoopsDB->query($sql, $options[1], 0); |
||
| 48 | |||
| 49 | if ($totalwords > 0) { // If there are definitions |
||
| 50 | while (list($entryID, $categoryID, $term, $counter) = $xoopsDB->fetchRow($result)) { |
||
| 51 | $popentries = []; |
||
| 52 | $linktext = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5); |
||
| 53 | $popentries['dir'] = $lexikon->dirname(); |
||
| 54 | $popentries['linktext'] = $linktext; |
||
| 55 | $popentries['id'] = (int)$entryID; |
||
| 56 | $popentries['counter'] = (int)$counter; |
||
| 57 | |||
| 58 | $block['popstuff'][] = $popentries; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | return $block; |
||
| 63 | } |
||
| 107 |