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