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'); |
|
|
|
|
11
|
|
|
|
12
|
|
|
function b_faqs_new_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
|
|
|
// creating the FAQ objects that belong to the selected category |
31
|
|
|
$faqsObj = $faqHandler->getAllPublished($limit, 0, $categoryid, $sort); |
32
|
|
|
$totalfaqs = count($faqsObj); |
33
|
|
View Code Duplication |
if ($faqsObj) { |
|
|
|
|
34
|
|
|
for ($i = 0; $i < $totalfaqs; ++$i) { |
35
|
|
|
$newfaqs = array(); |
36
|
|
|
$newfaqs['linktext'] = $faqsObj[$i]->question($maxQuestionLength); |
37
|
|
|
$newfaqs['id'] = $faqsObj[$i]->faqid(); |
38
|
|
|
if ($sort === 'datesub') { |
39
|
|
|
$newfaqs['new'] = $faqsObj[$i]->datesub(); |
40
|
|
|
} elseif ($sort === 'counter') { |
41
|
|
|
$newfaqs['new'] = $faqsObj[$i]->counter(); |
42
|
|
|
} elseif ($sort === 'weight') { |
43
|
|
|
$newfaqs['new'] = $faqsObj[$i]->weight(); |
44
|
|
|
} |
45
|
|
|
$newfaqs['show_date'] = $options[4]; |
46
|
|
|
$block['newfaqs'][] = $newfaqs; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $block; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param $options |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
function b_faqs_new_edit($options) |
58
|
|
|
{ |
59
|
|
|
global $xoopsDB, $xoopsModule, $xoopsUser; |
|
|
|
|
60
|
|
|
include_once(XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'); |
61
|
|
|
|
62
|
|
|
$form = sf_createCategorySelect($options[0]); |
63
|
|
|
|
64
|
|
|
$form .= ' <br>' . _MB_SF_ORDER . " <select name='options[]'>"; |
65
|
|
|
|
66
|
|
|
$form .= "<option value='datesub'"; |
67
|
|
|
if ($options[1] === 'datesub') { |
68
|
|
|
$form .= " selected='selected'"; |
69
|
|
|
} |
70
|
|
|
$form .= '>' . _MB_SF_DATE . "</option>\n"; |
71
|
|
|
|
72
|
|
|
$form .= "<option value='counter'"; |
73
|
|
|
if ($options[1] === 'counter') { |
74
|
|
|
$form .= " selected='selected'"; |
75
|
|
|
} |
76
|
|
|
$form .= '>' . _MB_SF_HITS . "</option>\n"; |
77
|
|
|
|
78
|
|
|
$form .= "<option value='weight'"; |
79
|
|
|
if ($options[1] === 'weight') { |
80
|
|
|
$form .= " selected='selected'"; |
81
|
|
|
} |
82
|
|
|
$form .= '>' . _MB_SF_WEIGHT . "</option>\n"; |
83
|
|
|
|
84
|
|
|
$form .= "</select>\n"; |
85
|
|
|
|
86
|
|
|
$form .= ' ' . _MB_SF_DISP . " <input type='text' name='options[]' value='" . $options[2] . "' /> " . _MB_SF_FAQS . ''; |
87
|
|
|
$form .= ' <br>' . _MB_SF_CHARS . " <input type='text' name='options[]' value='" . $options[3] . "' /> " . _MB_SF_LENGTH . ''; |
88
|
|
|
|
89
|
|
|
$form .= '<br />' . _MB_SF_SHOW_DATE . " <input type='radio' id='options[]' name='options[]' value='1'"; |
90
|
|
|
if ($options[4] == 1) { |
91
|
|
|
$form .= " checked='checked'"; |
92
|
|
|
} |
93
|
|
|
$form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; |
94
|
|
|
if ($options[4] == 0) { |
95
|
|
|
$form .= " checked='checked'"; |
96
|
|
|
} |
97
|
|
|
$form .= ' /> ' . _NO . ''; |
98
|
|
|
|
99
|
|
|
return $form; |
100
|
|
|
} |
101
|
|
|
|
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.