Completed
Push — master ( c1777d...d193e2 )
by Michael
13:22
created

entries_authors.php ➔ b_lx_author_edit()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 1
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 16 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 *
4
 * Module: Lexikon -  glossary module
5
 * Version: v 1.00
6
 * Release Date: 8 May 2004
7
 * Author: adapted from AMS
8
 * Licence: GNU
9
 */
10
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
11
12
/**
13
 * @param $options
14
 * @return array
15
 */
16
function b_lx_author_show($options)
17
{
18
    $myts = MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
$myts is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
    /** @var XoopsModuleHandler $moduleHandler */
20
    $moduleHandler = xoops_getHandler('module');
21
    $lexikon       = $moduleHandler->getByDirname('lexikon');
22 View Code Duplication
    if (!isset($lxConfig)) {
0 ignored issues
show
Bug introduced by
The variable $lxConfig seems only to be defined at a later point. As such the call to isset() seems to always evaluate to false.

This check marks calls to isset(...) or empty(...) that are found before the variable itself is defined. These will always have the same result.

This is likely the result of code being shifted around. Consider removing these calls.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
        $configHandler = xoops_getHandler('config');
24
        $lxConfig      = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid'));
25
    }
26
    include_once XOOPS_ROOT_PATH . '/modules/lexikon/class/Utility.php';
27
28
    $block = array();
29
    if (!isset($options[3])) {
30
        $options[3] = 'average';
31
    }
32
    $authors = LexikonUtility::getBlockAuthors($options[1], $options[0], $options[2], $options[3]);
33
    if (is_array($authors) && count($authors) > 0) {
34
        $block['authors'] = $authors;
35
    }
36
    $block['profile'] = ($lxConfig['authorprofile'] == 1) ? 1 : 0;
37
38
    return $block;
39
}
40
41
/**
42
 * @param $options
43
 * @return string
44
 */
45
function b_lx_author_edit($options)
46
{
47
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
48
    $form = new XoopsFormElementTray('', '<br>');
49
50
    $sort_select = new XoopsFormSelect(_MB_LEXIKON_ORDER, 'options[0]', $options[0]);
51
    $sort_select->addOption('count', _MB_LEXIKON_TERMSCOUNT);
52
    $sort_select->addOption('read', _MB_LEXIKON_HITS);
53
    $form->addElement($sort_select);
54
55
    $form->addElement(new XoopsFormText(_MB_LEXIKON_DISP, 'options[1]', 20, 15, $options[1]));
56
57
    $name_select = new XoopsFormSelect(_MB_LEXIKON_DISPLAYNAME, 'options[2]', $options[2]);
58
    $name_select->addOption('uname', _MB_LEXIKON_USERNAME);
59
    $name_select->addOption('name', _MB_LEXIKON_REALNAME);
60
    $form->addElement($name_select);
61
62
    $average_select = new XoopsFormSelect(_MB_LEXIKON_COMPUTING, 'options[3]', $options[3]);
63
    $average_select->addOption('average', _MB_LEXIKON_AVERAGE);
64
    $average_select->addOption('total', _MB_LEXIKON_TOTALS);
65
    $form->addElement($average_select);
66
67
    return $form->render();
68
}
69