b_faqs_context_show()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 31
rs 9.7666
cc 4
nc 4
nop 1
1
<?php declare(strict_types=1);
2
3
use XoopsModules\Smartfaq\Helper;
4
5
/**
6
 * Module: SmartFAQ
7
 * Author: The SmartFactory <www.smartfactory.ca>
8
 * Licence: GNU
9
 * @param $options
10
 * @return array
11
 */
12
function b_faqs_context_show($options)
13
{
14
    //    require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
15
16
    $block = [];
17
18
    if (0 == $options[0]) {
19
        $categoryid = -1;
0 ignored issues
show
Unused Code introduced by
The assignment to $categoryid is dead and can be removed.
Loading history...
20
    } else {
21
        $categoryid = $options[0];
22
    }
23
24
    $limit = $options[0];
25
26
    // Creating the faq handler object
27
    /** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
28
    $faqHandler = Helper::getInstance()->getHandler('Faq');
29
30
    // creating the FAQ objects that belong to the selected category
31
    $faqsObj = $faqHandler->getContextualFaqs($limit);
32
33
    if ($faqsObj) {
34
        foreach ($faqsObj as $iValue) {
35
            $faq             = [];
36
            $faq['id']       = $iValue->faqid();
37
            $faq['question'] = $iValue->question();
38
            $block['faqs'][] = $faq;
39
        }
40
    }
41
42
    return $block;
43
}
44
45
/**
46
 * @param $options
47
 * @return string
48
 */
49
function b_faqs_context_edit($options)
50
{
51
    $form = _MB_SF_DISP . '&nbsp;';
52
    $form .= "<input type='text' name='options[]' value='" . $options[0] . "'>&nbsp;" . _MB_SF_FAQS;
53
54
    return $form;
55
}
56