-
Notifications
You must be signed in to change notification settings - Fork 3
/
faq.php
124 lines (95 loc) · 4.35 KB
/
faq.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php declare(strict_types=1);
/**
* Module: SmartFAQ
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
use Xmf\Request;
use XoopsModules\Smartfaq;
use XoopsModules\Smartfaq\Helper;
$GLOBALS['xoopsOption']['template_main'] = 'smartfaq_faq.tpl';
require_once __DIR__ . '/header.php';
/** @var Smartfaq\Helper $helper */
$helper = Helper::getInstance();
$faqid = Request::getInt('faqid', 0, 'GET');
if (0 == $faqid) {
redirect_header('<script>javascript:history.go(-1)</script>', 1, _MD_SF_NOFAQSELECTED);
}
// Creating the FAQ handler object
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
$faqHandler = Helper::getInstance()->getHandler('Faq');
// Creating the FAQ object for the selected FAQ
$faqObj = new Smartfaq\Faq($faqid);
// If the selected FAQ was not found, exit
if ($faqObj->notLoaded()) {
redirect_header('<script>javascript:history.go(-1)</script>', 1, _MD_SF_NOFAQSELECTED);
}
// Creating the category object that holds the selected FAQ
$categoryObj = $faqObj->category();
// Creating the answer object
$answerObj = $faqObj->answer();
// Check user permissions to access that category of the selected FAQ
$faqAccessGrantedResult = Smartfaq\Utility::faqAccessGranted($faqObj);
if ($faqAccessGrantedResult < 0) {
redirect_header('<script>javascript:history.go(-1)</script>', 1, _NOPERM);
}
// Update the read counter of the selected FAQ
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && 1 == $helper->getConfig('adminhits'))
|| ($xoopsUser
&& !$xoopsUser->isAdmin($xoopsModule->mid()))) {
$faqObj->updateCounter();
}
require_once XOOPS_ROOT_PATH . '/header.php';
require_once __DIR__ . '/footer.php';
$faq = $faqObj->toArray(null, $categoryObj, false);
// Populating the smarty variables with information related to the selected FAQ
/*$faq['questionlink'] = $faqObj->question($helper->getConfig('questionsize'));
$faq['question'] = $faqObj->question();
$faq['categoryid'] = $categoryObj->categoryid();
$faq['categoryname'] = $categoryObj->name();
$faq['categorydescription'] = $categoryObj->description();
$faq['counter'] = $faqObj->counter();
$faq['comments'] = $faqObj->comments();
$faq['cancomment'] = $faqObj->cancomment();
*/
$faq['categoryPath'] = $categoryObj->getCategoryPath(true);
$faq['answer'] = $answerObj->answer();
// Check to see if we need to display partial answer. This should probably be in the FAQ class...
if (0 == $faqAccessGrantedResult) {
$faq['answer'] = xoops_substr($faq['answer'], 0, 150);
}
$faq['who_when'] = $faqObj->getWhoAndWhen();
$faq['adminlink'] = Smartfaq\Utility::getAdminLinks($faqObj->faqid());
$faq['comments'] = $faqObj->comments();
// Language constants
$xoopsTpl->assign('faq', $faq);
$xoopsTpl->assign('display_categoryname', false);
$xoopsTpl->assign('xcodes', $faqObj->getVar('xcodes'));
$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'));
$xoopsTpl->assign('lang_printerpage', _MD_SF_PRINTERFRIENDLY);
$xoopsTpl->assign('lang_sendstory', _MD_SF_SENDSTORY);
$xoopsTpl->assign('faqid', $faqObj->getVar('faqid'));
$xoopsTpl->assign('lang_reads', _MD_SF_READS);
$xoopsTpl->assign('lang_home', _MD_SF_HOME);
$xoopsTpl->assign('lang_faq', _MD_SF_FAQ);
$xoopsTpl->assign('lang_postedby', _MD_SF_POSTEDBY);
$xoopsTpl->assign('lang_on', _MD_SF_ON);
$xoopsTpl->assign('lang_datesub', _MD_SF_DATESUB);
$xoopsTpl->assign('lang_hitsdetail', _MD_SF_HITSDETAIL);
$xoopsTpl->assign('lang_hits', _MD_SF_READS);
$xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS);
// Page Title Hack by marcan
$module_name = htmlspecialchars($xoopsModule->getVar('name'), ENT_QUOTES | ENT_HTML5);
$xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $categoryObj->name() . ' - ' . $faq['question']);
// End Page Title Hack by marcan
// Include the comments if the selected FAQ supports comments
if (1 == $faqObj->cancomment()) {
require XOOPS_ROOT_PATH . '/include/comment_view.php';
}
//code to include smartie
if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
require_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
$xoopsTpl->assign('smarttie', 1);
}
//end code for smarttie
require_once XOOPS_ROOT_PATH . '/footer.php';