1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * Module: SmartFAQ |
||||
5 | * Author: The SmartFactory <www.smartfactory.ca> |
||||
6 | * Licence: GNU |
||||
7 | */ |
||||
8 | |||||
9 | use XoopsModules\Smartfaq; |
||||
10 | |||||
11 | require_once __DIR__ . '/header.php'; |
||||
12 | |||||
13 | $faqid = isset($_GET['faqid']) ? (int)$_GET['faqid'] : 0; |
||||
14 | |||||
15 | if (0 == $faqid) { |
||||
16 | redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
17 | } |
||||
18 | |||||
19 | // Creating the FAQ handler object |
||||
20 | /** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */ |
||||
21 | $faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq'); |
||||
22 | |||||
23 | // Creating the FAQ object for the selected FAQ |
||||
24 | $faqObj = new Smartfaq\Faq($faqid); |
||||
25 | |||||
26 | // If the selected FAQ was not found, exit |
||||
27 | if ($faqObj->notLoaded()) { |
||||
28 | redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED); |
||||
29 | } |
||||
30 | |||||
31 | // Creating the category object that holds the selected FAQ |
||||
32 | $categoryObj = $faqObj->category(); |
||||
33 | |||||
34 | // Creating the answer object |
||||
35 | $answerObj = $faqObj->answer(); |
||||
36 | |||||
37 | // Check user permissions to access that category of the selected FAQ |
||||
38 | $faqAccessGrantedResult = Smartfaq\Utility::faqAccessGranted($faqObj); |
||||
39 | if ($faqAccessGrantedResult < 0) { |
||||
40 | redirect_header('javascript:history.go(-1)', 1, _NOPERM); |
||||
0 ignored issues
–
show
|
|||||
41 | } |
||||
42 | |||||
43 | // Update the read counter of the selected FAQ |
||||
44 | if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && 1 == $xoopsModuleConfig['adminhits']) |
||||
45 | || ($xoopsUser |
||||
46 | && !$xoopsUser->isAdmin($xoopsModule->mid()))) { |
||||
47 | $faqObj->updateCounter(); |
||||
48 | } |
||||
49 | $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_faq.tpl'; |
||||
50 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||||
0 ignored issues
–
show
|
|||||
51 | require_once __DIR__ . '/footer.php'; |
||||
52 | |||||
53 | $faq = $faqObj->toArray(null, $categoryObj, false); |
||||
54 | |||||
55 | // Populating the smarty variables with informations related to the selected FAQ |
||||
56 | /*$faq['questionlink'] = $faqObj->question($xoopsModuleConfig['questionsize']); |
||||
57 | $faq['question'] = $faqObj->question(); |
||||
58 | |||||
59 | $faq['categoryid'] = $categoryObj->categoryid(); |
||||
60 | $faq['categoryname'] = $categoryObj->name(); |
||||
61 | |||||
62 | $faq['categorydescription'] = $categoryObj->description(); |
||||
63 | $faq['counter'] = $faqObj->counter(); |
||||
64 | $faq['comments'] = $faqObj->comments(); |
||||
65 | $faq['cancomment'] = $faqObj->cancomment(); |
||||
66 | */ |
||||
67 | $faq['categoryPath'] = $categoryObj->getCategoryPath(true); |
||||
68 | $faq['answer'] = $answerObj->answer(); |
||||
69 | |||||
70 | // Check to see if we need to display partial answer. This should probably be in a the FAQ class... |
||||
71 | if (0 == $faqAccessGrantedResult) { |
||||
72 | $faq['answer'] = xoops_substr($faq['answer'], 0, 150); |
||||
0 ignored issues
–
show
The function
xoops_substr was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
73 | } |
||||
74 | |||||
75 | $faq['who_when'] = $faqObj->getWhoAndWhen(); |
||||
76 | |||||
77 | $faq['adminlink'] = Smartfaq\Utility::getAdminLinks($faqObj->faqid()); |
||||
78 | |||||
79 | $faq['comments'] = $faqObj->comments(); |
||||
80 | |||||
81 | // Language constants |
||||
82 | $xoopsTpl->assign('faq', $faq); |
||||
83 | $xoopsTpl->assign('display_categoryname', false); |
||||
84 | |||||
85 | $xoopsTpl->assign('xcodes', $faqObj->getVar('xcodes')); |
||||
86 | $xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_MD_SF_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_MD_SF_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/faq.php?faqid=' . $faqObj->getVar('faqid')); |
||||
0 ignored issues
–
show
|
|||||
87 | $xoopsTpl->assign('lang_printerpage', _MD_SF_PRINTERFRIENDLY); |
||||
88 | $xoopsTpl->assign('lang_sendstory', _MD_SF_SENDSTORY); |
||||
89 | $xoopsTpl->assign('faqid', $faqObj->getVar('faqid')); |
||||
90 | $xoopsTpl->assign('lang_reads', _MD_SF_READS); |
||||
91 | $xoopsTpl->assign('lang_home', _MD_SF_HOME); |
||||
92 | $xoopsTpl->assign('lang_faq', _MD_SF_FAQ); |
||||
93 | $xoopsTpl->assign('lang_postedby', _MD_SF_POSTEDBY); |
||||
94 | $xoopsTpl->assign('lang_on', _MD_SF_ON); |
||||
95 | $xoopsTpl->assign('lang_datesub', _MD_SF_DATESUB); |
||||
96 | $xoopsTpl->assign('lang_hitsdetail', _MD_SF_HITSDETAIL); |
||||
97 | $xoopsTpl->assign('lang_hits', _MD_SF_READS); |
||||
98 | $xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS); |
||||
99 | |||||
100 | // Page Title Hack by marcan |
||||
101 | $module_name = $myts->htmlSpecialChars($xoopsModule->getVar('name')); |
||||
102 | $xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $categoryObj->name() . ' - ' . $faq['question']); |
||||
103 | // End Page Title Hack by marcan |
||||
104 | |||||
105 | // Include the comments if the selected FAQ supports comments |
||||
106 | if (1 == $faqObj->cancomment()) { |
||||
107 | require_once XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||||
108 | } |
||||
109 | |||||
110 | //code to include smartie |
||||
111 | if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) { |
||||
112 | require_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php'; |
||||
113 | $xoopsTpl->assign('smarttie', 1); |
||||
114 | } |
||||
115 | //end code for smarttie |
||||
116 | |||||
117 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||||
118 |