|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace XoopsModules\Rssfit\Plugins; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
* You may not change or alter any portion of this comment or credits |
|
9
|
|
|
* of supporting developers from this source code or any supporting source code |
|
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
20
|
|
|
* @package RSSFit - Extendable XML news feed generator |
|
21
|
|
|
* @author NS Tai (aka tuff) <http://www.brandycoke.com> |
|
22
|
|
|
* @author XOOPS Development Team |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/* |
|
26
|
|
|
* About this RSSFit plug-in |
|
27
|
|
|
* Author: tuff <http://www.brandycoke.com> |
|
28
|
|
|
* Requirements (Tested with): |
|
29
|
|
|
* Module: SmartFAQ <http://www.smartfactory.ca> |
|
30
|
|
|
* Version: 1.04 / 1.1 dev |
|
31
|
|
|
* RSSFit verision: 1.2 / 1.5 |
|
32
|
|
|
* XOOPS version: 2.0.13.2 / 2.2.3 |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
use XoopsModules\Rssfit\{ |
|
36
|
|
|
AbstractPlugin |
|
37
|
|
|
}; |
|
38
|
|
|
use XoopsModules\Smartfaq\Helper as PluginHelper; |
|
39
|
|
|
|
|
40
|
|
|
if (!\defined('RSSFIT_ROOT_PATH')) { |
|
41
|
|
|
exit(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Class Smartfaq |
|
46
|
|
|
* @package XoopsModules\Rssfit\Plugins |
|
47
|
|
|
*/ |
|
48
|
|
|
final class Smartfaq extends AbstractPlugin |
|
49
|
|
|
{ |
|
50
|
|
|
public function __construct() { |
|
51
|
|
|
if (\class_exists(PluginHelper::class)) { |
|
52
|
|
|
$this->helper = PluginHelper::getInstance(); |
|
53
|
|
|
$this->dirname = $this->helper->dirname(); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array |
|
58
|
|
|
{ |
|
59
|
|
|
$ret = null; |
|
60
|
|
|
// @require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php'; |
|
61
|
|
|
|
|
62
|
|
|
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */ |
|
63
|
|
|
$faqHandler = PluginHelper::getInstance()->getHandler('Faq'); |
|
64
|
|
|
$faqs = $faqHandler->getAllPublished($this->grab, 0); |
|
65
|
|
|
if (false !== $faqs && \count($faqs) > 0) { |
|
66
|
|
|
$ret = []; |
|
67
|
|
|
/** @var \XoopsModules\Smartfaq\AnswerHandler $answerHandler */ |
|
68
|
|
|
$answerHandler = PluginHelper::getInstance()->getHandler('Answer'); |
|
69
|
|
|
for ($i = 0, $iMax = \count($faqs); $i < $iMax; ++$i) { |
|
70
|
|
|
if (!$answer = $answerHandler->getOfficialAnswer($faqs[$i]->faqid())) { |
|
71
|
|
|
continue; |
|
72
|
|
|
} |
|
73
|
|
|
$ret[$i]['link'] = $ret[$i]['guid'] = XOOPS_URL . '/modules/smartfaq/faq.php?faqid=' . $faqs[$i]->faqid(); |
|
74
|
|
|
$q = $faqs[$i]->getVar('howdoi', 'n'); |
|
75
|
|
|
$q = empty($q) ? $faqs[$i]->getVar('question', 'n') : $q; |
|
76
|
|
|
$ret[$i]['title'] = $q; |
|
77
|
|
|
$ret[$i]['timestamp'] = $faqs[$i]->getVar('datesub'); |
|
78
|
|
|
$ret[$i]['description'] = $answer->getVar('answer'); |
|
79
|
|
|
$ret[$i]['category'] = $this->modname; |
|
80
|
|
|
$ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $ret; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|