Completed
Branch master (1b2f30)
by Michael
06:29 queued 03:22
created

blocks/faqs_recent_questions.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 * @param $options
8
 * @return array
9
 */
10
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
11
12
function b_faqs_recent_questions_show($options)
13
{
14
    include_once(XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php');
15
16
    $block = array();
17
18 View Code Duplication
    if ($options[0] == 0) {
19
        $categoryid = -1;
20
    } else {
21
        $categoryid = $options[0];
22
    }
23
24
    $sort              = $options[1];
25
    $limit             = $options[2];
26
    $maxQuestionLength = $options[3];
27
28
    // Creating the faq handler object
29
    $faqHandler = sf_gethandler('faq');
30
31
    // creating the FAQ objects that belong to the selected category
32
    $faqsObj   = $faqHandler->getFaqs($limit, 0, _SF_STATUS_OPENED, $categoryid, $sort);
33
    $totalfaqs = count($faqsObj);
34
35 View Code Duplication
    if ($faqsObj) {
36
        for ($i = 0; $i < $totalfaqs; ++$i) {
37
            $newfaqs = array();
38
39
            $newfaqs['linktext'] = $faqsObj[$i]->question($maxQuestionLength);
40
            $newfaqs['id']       = $faqsObj[$i]->faqid();
41
            if ($sort === 'datesub') {
42
                $newfaqs['new'] = $faqsObj[$i]->datesub();
43
            } elseif ($sort === 'counter') {
44
                $newfaqs['new'] = $faqsObj[$i]->counter();
45
            } elseif ($sort === 'weight') {
46
                $newfaqs['new'] = $faqsObj[$i]->weight();
47
            }
48
49
            $block['newfaqs'][] = $newfaqs;
50
        }
51
        $block['lang_allunanswered'] = _MB_SF_ALLUNANSWERED;
52
    }
53
54
    return $block;
55
}
56
57
/**
58
 * @param $options
59
 * @return string
60
 */
61
function b_faqs_recent_questions_edit($options)
62
{
63
    include_once(XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php');
64
65
    $form = sf_createCategorySelect($options[0]);
66
67
    $form .= '&nbsp;<br>' . _MB_SF_ORDER . "&nbsp;<select name='options[]'>";
68
69
    $form .= "<option value='datesub'";
70
    if ($options[1] === 'datesub') {
71
        $form .= " selected='selected'";
72
    }
73
    $form .= '>' . _MB_SF_DATE . "</option>\n";
74
75
    $form .= "<option value='counter'";
76
    if ($options[1] === 'counter') {
77
        $form .= " selected='selected'";
78
    }
79
    $form .= '>' . _MB_SF_HITS . "</option>\n";
80
81
    $form .= "<option value='weight'";
82
    if ($options[1] === 'weight') {
83
        $form .= " selected='selected'";
84
    }
85
    $form .= '>' . _MB_SF_WEIGHT . "</option>\n";
86
87
    $form .= "</select>\n";
88
89
    $form .= '&nbsp;' . _MB_SF_DISP . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . "' />&nbsp;" . _MB_SF_QUESTIONS . '';
90
    $form .= '&nbsp;<br>' . _MB_SF_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[3] . "' />&nbsp;" . _MB_SF_LENGTH . '';
91
92
    $form .= '<br />' . _MB_SF_SHOW_DATE . "&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
93
    if ($options[4] == 1) {
94
        $form .= " checked='checked'";
95
    }
96
    $form .= ' />&nbsp;' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'";
97
    if ($options[4] == 0) {
98
        $form .= " checked='checked'";
99
    }
100
    $form .= ' />&nbsp;' . _NO . '';
101
102
    return $form;
103
}
104