b_lx_author_edit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 1
dl 0
loc 23
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Module: Lexikon -  glossary module
5
 * Author: adapted from AMS
6
 * Licence: GNU
7
 */
8
9
use XoopsModules\Lexikon\{
10
    Utility
11
};
12
13
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
14
15
/**
16
 * @param $options
17
 * @return array
18
 */
19
function b_lx_author_show($options)
20
{
21
    $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
22
    $utility = new Utility();
23
    /** @var \XoopsModuleHandler $moduleHandler */
24
    $moduleHandler = xoops_getHandler('module');
25
    $lexikon       = $moduleHandler->getByDirname('lexikon');
26
    if (!isset($lxConfig)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $lxConfig seems to never exist and therefore isset should always be false.
Loading history...
27
        /** @var \XoopsConfigHandler $configHandler */
28
        $configHandler = xoops_getHandler('config');
29
        $lxConfig      = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid'));
30
    }
31
    require_once XOOPS_ROOT_PATH . '/modules/lexikon/class/Utility.php';
32
33
    $block = [];
34
    if (!isset($options[3])) {
35
        $options[3] = 'average';
36
    }
37
    $authors = $utility::getBlockAuthors($options[1], $options[0], $options[2], $options[3]);
38
    if ($authors && is_array($authors)) {
39
        $block['authors'] = $authors;
40
    }
41
    $block['profile'] = (1 == $lxConfig['authorprofile']) ? 1 : 0;
42
43
    return $block;
44
}
45
46
/**
47
 * @param $options
48
 * @return string
49
 */
50
function b_lx_author_edit($options)
51
{
52
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
53
    $form = new \XoopsFormElementTray('', '<br>');
54
55
    $sort_select = new \XoopsFormSelect(_MB_LEXIKON_ORDER, 'options[0]', $options[0]);
56
    $sort_select->addOption('count', _MB_LEXIKON_TERMSCOUNT);
57
    $sort_select->addOption('read', _MB_LEXIKON_HITS);
58
    $form->addElement($sort_select);
59
60
    $form->addElement(new \XoopsFormText(_MB_LEXIKON_DISP, 'options[1]', 20, 15, $options[1]));
61
62
    $name_select = new \XoopsFormSelect(_MB_LEXIKON_DISPLAYNAME, 'options[2]', $options[2]);
63
    $name_select->addOption('uname', _MB_LEXIKON_USERNAME);
64
    $name_select->addOption('name', _MB_LEXIKON_REALNAME);
65
    $form->addElement($name_select);
66
67
    $average_select = new \XoopsFormSelect(_MB_LEXIKON_COMPUTING, 'options[3]', $options[3]);
68
    $average_select->addOption('average', _MB_LEXIKON_AVERAGE);
69
    $average_select->addOption('total', _MB_LEXIKON_TOTALS);
70
    $form->addElement($average_select);
71
72
    return $form->render();
73
}
74