1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* marquee - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com) |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright Hervé Thouzard (https://www.herve-thouzard.com) |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Hervé Thouzard (https://www.herve-thouzard.com) |
17
|
|
|
* **************************************************************************** |
18
|
|
|
* |
19
|
|
|
* @param $limit |
20
|
|
|
* @param $dateFormat |
21
|
|
|
* @param $itemsSize |
22
|
|
|
* |
23
|
|
|
* @return array |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
// Script to list the recent faqs from the xfaq module version 1.01 |
27
|
|
|
function b_marquee_xfaq($limit, $dateFormat, $itemsSize) |
28
|
|
|
{ |
29
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
30
|
|
|
$block = []; |
31
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
32
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
33
|
|
|
$result = $db->query('SELECT f.*, t.topic_title, t.topic_submitter FROM ' . $db->prefix('xfaq_faq') . ' f, ' . $db->prefix('xfaq_topic') . ' t WHERE f.faq_online>0 AND (f.faq_topic=t.topic_id) ORDER BY faq_date_created DESC', $limit, 0); |
34
|
|
|
while (false !== ($myrow = $db->fetchArray($result))) { |
35
|
|
|
$title = htmlspecialchars($myrow['faq_question'], ENT_QUOTES | ENT_HTML5); |
36
|
|
|
if ($itemsSize > 0) { |
37
|
|
|
$title = xoops_substr($title, 0, $itemsSize + 3); |
38
|
|
|
} |
39
|
|
|
$block[] = [ |
40
|
|
|
'date' => formatTimestamp($myrow['faq_date_created'], $dateFormat), |
41
|
|
|
'category' => htmlspecialchars($myrow['topic_title'], ENT_QUOTES | ENT_HTML5), |
42
|
|
|
'author' => \XoopsUser::getUnameFromId((int)$myrow['topic_submitter']), |
43
|
|
|
'title' => $title, |
44
|
|
|
'link' => "<a href='" . XOOPS_URL . '/modules/xfaq/faq.php?faq_id=' . $myrow['faq_id'] . "'>{$title}</a>", |
45
|
|
|
]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $block; |
49
|
|
|
} |
50
|
|
|
|