/
faq.php
118 lines (92 loc) · 4.15 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
<?php
/**
* $Id: faq.php,v 1.31 2006/09/29 18:49:10 malanciault Exp $
* Module: SmartFAQ
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
include_once("header.php");
$faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : 0;
if ($faqid == 0) {
redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
exit();
}
// Creating the FAQ handler object
$faq_handler =& sf_gethandler('faq');
// Creating the FAQ object for the selected FAQ
$faqObj = new sfFaq($faqid);
// If the selected FAQ was not found, exit
if ($faqObj->notLoaded()) {
redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
exit();
}
// 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 = faqAccessGranted($faqObj);
if ($faqAccessGrantedResult < 0) {
redirect_header("javascript:history.go(-1)", 1, _NOPERM);
exit;
}
// Update the read counter of the selected FAQ
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && $xoopsModuleConfig['adminhits'] == 1) || ($xoopsUser && !$xoopsUser->isAdmin($xoopsModule->mid()))) {
$faqObj->updateCounter();
}
$xoopsOption['template_main'] = 'smartfaq_faq.html';
include_once(XOOPS_ROOT_PATH . "/header.php");
include_once("footer.php");
$faq = $faqObj->toArray(null, $categoryObj, false);
// Populating the smarty variables with informations related to the selected FAQ
/*$faq['questionlink'] = $faqObj->question($xoopsModuleConfig['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 a the FAQ class...
if ($faqAccessGrantedResult == 0) {
$faq['answer'] = xoops_substr($faq['answer'], 0, 150);
}
$faq['who_when'] = $faqObj->getWhoAndWhen();
$faq['adminlink'] = sf_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 = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
$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 ($faqObj->cancomment() == 1) {
include_once XOOPS_ROOT_PATH . "/include/comment_view.php";
}
//code to include smartie
if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
include_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
$xoopsTpl->assign('smarttie',1);
}
//end code for smarttie
include_once XOOPS_ROOT_PATH . '/footer.php';
?>