1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Module: SmartFAQ |
5
|
|
|
* Author: mariuss |
6
|
|
|
* Licence: GNU |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use Xmf\Request; |
10
|
|
|
|
11
|
|
|
require \dirname(__DIR__, 3) . '/include/cp_header.php'; |
12
|
|
|
|
13
|
|
|
$op = 'go'; //'start'; |
14
|
|
|
|
15
|
|
|
if ('go' === Request::getCmd('op', 'start', 'POST')) { |
16
|
|
|
$op = 'go'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
if ('start' === $op) { |
|
|
|
|
20
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
21
|
|
|
|
22
|
|
|
xoops_cp_header(); |
23
|
|
|
|
24
|
|
|
xoops_cp_footer(); |
25
|
|
|
exit(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
if ('go' === $op) { |
|
|
|
|
29
|
|
|
header('Content-Disposition: attachment; filename=smartfaq.xml'); |
30
|
|
|
header('Connection: close'); |
31
|
|
|
header('Content-Type: text/xml; name=smartfaq.xml'); |
32
|
|
|
|
33
|
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
34
|
|
|
echo "<!DOCTYPE qandaset PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" \"https://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">\r\n"; |
35
|
|
|
echo "<qandaset defaultlabel=\"qanda\" Conformance=\"1.0 {module version}\">\r\n"; |
36
|
|
|
|
37
|
|
|
echo " <blockinfo>\r\n"; |
38
|
|
|
echo " <publisher>\r\n"; |
39
|
|
|
echo " <publishername>\r\n"; |
40
|
|
|
echo " {site name}\r\n"; |
41
|
|
|
echo " <ulink url=\"{site url}\">\r\n"; |
42
|
|
|
echo " </publishername>\r\n"; |
43
|
|
|
echo " </publisher>\r\n"; |
44
|
|
|
echo " <date>{time of export}</date>\r\n"; |
45
|
|
|
echo " </blockinfo>\r\n"; |
46
|
|
|
|
47
|
|
|
echo " <title>{module title}</title>\r\n"; |
48
|
|
|
|
49
|
|
|
$resultC = $xoopsDB->queryF('SELECT * FROM ' . $xoopsDB->prefix('smartfaq_categories')); |
50
|
|
|
while (false !== ($arrC = $xoopsDB->fetchArray($resultC))) { |
51
|
|
|
extract($arrC, EXTR_PREFIX_ALL, 'c'); |
52
|
|
|
|
53
|
|
|
echo " <qandadiv ID=\"c$c_categoryid\" Revision=\"$c_created\">\r\n"; |
54
|
|
|
echo ' <title>' . encodeText($c_name) . "</title>\r\n"; |
55
|
|
|
echo ' <para>' . encodeText($c_description) . "</para>\r\n"; |
56
|
|
|
|
57
|
|
|
$resultQ = $xoopsDB->queryF('select * from ' . $xoopsDB->prefix('smartfaq_faq') . " where categoryid=$c_categoryid"); |
58
|
|
|
while (false !== ($arrQ = $xoopsDB->fetchArray($resultQ))) { |
59
|
|
|
extract($arrQ, EXTR_PREFIX_ALL, 'q'); |
60
|
|
|
|
61
|
|
|
echo " <qandaentry ID=\"q$q_faqid\" Revision=\"$q_datesub\" Condition=\"$q_html $q_smiley $q_xcodes\" XrefLabel=\"$q_modulelink $q_contextpage\" Vendor=\"" . getUserFullName($q_uid) . "\">\r\n"; |
62
|
|
|
echo " <question>\r\n"; |
63
|
|
|
echo ' <para>' . encodeText($q_question) . "</para>\r\n"; |
64
|
|
|
if (!empty($q_howdoi)) { |
65
|
|
|
echo " <note Conformance=\"howdoi\">\r\n"; |
66
|
|
|
echo " <title>{'How do I' from language file}</title>\r\n"; |
67
|
|
|
echo ' <para>' . encodeText($q_howdoi) . "</para>\r\n"; |
68
|
|
|
echo " </note>\r\n"; |
69
|
|
|
} |
70
|
|
|
if (!empty($q_diduno)) { |
71
|
|
|
echo " <note Conformance=\"diduno\">\r\n"; |
72
|
|
|
echo " <title>{'Did you know' from language file}</title>\r\n"; |
73
|
|
|
echo ' <para>' . encodeText($q_diduno) . "</para>\r\n"; |
74
|
|
|
echo " </note>\r\n"; |
75
|
|
|
} |
76
|
|
|
echo " </question>\r\n"; |
77
|
|
|
|
78
|
|
|
$resultA = $xoopsDB->queryF('select * from ' . $xoopsDB->prefix('smartfaq_answers') . " where answerid=$q_answerid"); |
79
|
|
|
while (false !== ($arrA = $xoopsDB->fetchArray($resultA))) { |
80
|
|
|
extract($arrA, EXTR_PREFIX_ALL, 'a'); |
81
|
|
|
|
82
|
|
|
echo " <answer ID=\"a$a_answerid\" Revision=\"$a_datesub\" Vendor=\"" . getUserFullName($a_uid) . "\">\r\n"; |
83
|
|
|
echo ' <para>' . encodeText($a_answer) . "</para>\r\n"; |
84
|
|
|
echo " </answer>\r\n"; |
85
|
|
|
} |
86
|
|
|
$xoopsDB->freeRecordSet($resultA); |
87
|
|
|
|
88
|
|
|
echo " </qandaentry>\r\n"; |
89
|
|
|
} |
90
|
|
|
$xoopsDB->freeRecordSet($resultQ); |
91
|
|
|
|
92
|
|
|
echo " </qandadiv>\r\n"; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
echo "</qandaset>\r\n"; |
96
|
|
|
|
97
|
|
|
exit(); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param $text |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
function encodeText($text) |
105
|
|
|
{ |
106
|
|
|
return utf8_encode(htmlspecialchars($text, ENT_QUOTES)); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param $uid |
111
|
|
|
* @return mixed |
112
|
|
|
*/ |
113
|
|
|
function getUserFullName($uid) |
114
|
|
|
{ |
115
|
|
|
global $xoopsDB; |
116
|
|
|
|
117
|
|
|
return $uid; |
118
|
|
|
} |
119
|
|
|
|