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
|
|
|
|
11
|
|
|
use XoopsModules\Smartfaq; |
12
|
|
|
use XoopsModules\Smartfaq\Constants; |
13
|
|
|
|
14
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param $options |
18
|
|
|
* @return array |
19
|
|
|
*/ |
20
|
|
|
function b_faqs_recent_questions_show($options) |
21
|
|
|
{ |
22
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'; |
23
|
|
|
|
24
|
|
|
$block = []; |
25
|
|
|
|
26
|
|
|
if (0 == $options[0]) { |
27
|
|
|
$categoryid = -1; |
28
|
|
|
} else { |
29
|
|
|
$categoryid = $options[0]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$sort = $options[1]; |
33
|
|
|
$limit = $options[2]; |
34
|
|
|
$maxQuestionLength = $options[3]; |
35
|
|
|
|
36
|
|
|
// Creating the faq handler object |
37
|
|
|
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */ |
38
|
|
|
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq'); |
39
|
|
|
|
40
|
|
|
// creating the FAQ objects that belong to the selected category |
41
|
|
|
$faqsObj = $faqHandler->getFaqs($limit, 0, Constants::SF_STATUS_OPENED, $categoryid, $sort); |
42
|
|
|
|
43
|
|
|
if ($faqsObj) { |
|
|
|
|
44
|
|
|
foreach ($faqsObj as $iValue) { |
45
|
|
|
$newfaqs = []; |
46
|
|
|
|
47
|
|
|
$newfaqs['linktext'] = $iValue->question($maxQuestionLength); |
48
|
|
|
$newfaqs['id'] = $iValue->faqid(); |
49
|
|
|
if ('datesub' === $sort) { |
50
|
|
|
$newfaqs['new'] = $iValue->datesub(); |
51
|
|
|
} elseif ('counter' === $sort) { |
52
|
|
|
$newfaqs['new'] = $iValue->counter(); |
53
|
|
|
} elseif ('weight' === $sort) { |
54
|
|
|
$newfaqs['new'] = $iValue->weight(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$block['newfaqs'][] = $newfaqs; |
58
|
|
|
} |
59
|
|
|
$block['lang_allunanswered'] = _MB_SF_ALLUNANSWERED; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $block; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $options |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
function b_faqs_recent_questions_edit($options) |
70
|
|
|
{ |
71
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'; |
72
|
|
|
|
73
|
|
|
$form = Smartfaq\Utility::createCategorySelect($options[0]); |
74
|
|
|
|
75
|
|
|
$form .= ' <br>' . _MB_SF_ORDER . " <select name='options[]'>"; |
76
|
|
|
|
77
|
|
|
$form .= "<option value='datesub'"; |
78
|
|
|
if ('datesub' === $options[1]) { |
79
|
|
|
$form .= ' selected'; |
80
|
|
|
} |
81
|
|
|
$form .= '>' . _MB_SF_DATE . "</option>\n"; |
82
|
|
|
|
83
|
|
|
$form .= "<option value='counter'"; |
84
|
|
|
if ('counter' === $options[1]) { |
85
|
|
|
$form .= ' selected'; |
86
|
|
|
} |
87
|
|
|
$form .= '>' . _MB_SF_HITS . "</option>\n"; |
88
|
|
|
|
89
|
|
|
$form .= "<option value='weight'"; |
90
|
|
|
if ('weight' === $options[1]) { |
91
|
|
|
$form .= ' selected'; |
92
|
|
|
} |
93
|
|
|
$form .= '>' . _MB_SF_WEIGHT . "</option>\n"; |
94
|
|
|
|
95
|
|
|
$form .= "</select>\n"; |
96
|
|
|
|
97
|
|
|
$form .= ' ' . _MB_SF_DISP . " <input type='text' name='options[]' value='" . $options[2] . "'> " . _MB_SF_QUESTIONS . ''; |
98
|
|
|
$form .= ' <br>' . _MB_SF_CHARS . " <input type='text' name='options[]' value='" . $options[3] . "'> " . _MB_SF_LENGTH . ''; |
99
|
|
|
|
100
|
|
|
$form .= '<br>' . _MB_SF_SHOW_DATE . " <input type='radio' id='options[]' name='options[]' value='1'"; |
101
|
|
|
if (1 == $options[4]) { |
102
|
|
|
$form .= ' checked'; |
103
|
|
|
} |
104
|
|
|
$form .= '> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; |
|
|
|
|
105
|
|
|
if (0 == $options[4]) { |
106
|
|
|
$form .= ' checked'; |
107
|
|
|
} |
108
|
|
|
$form .= '> ' . _NO . ''; |
|
|
|
|
109
|
|
|
|
110
|
|
|
return $form; |
111
|
|
|
} |
112
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.