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
|
|
|
* Version : |
19
|
|
|
* **************************************************************************** |
20
|
|
|
* |
21
|
|
|
* @param $limit |
22
|
|
|
* @param $dateFormat |
23
|
|
|
* @param $itemsSize |
24
|
|
|
* |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
// Script to list recent articles from wfsection 1 & 2 |
29
|
|
|
function b_marquee_wfsection($limit, $dateFormat, $itemsSize) |
30
|
|
|
{ |
31
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
32
|
|
|
$block = []; |
33
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
34
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
35
|
|
|
$moduleHandler = xoops_getHandler('module'); |
36
|
|
|
$wfsection = $moduleHandler->getByDirname('wfsection'); |
37
|
|
|
$wfsectionVersion = (int)$wfsection->getInfo('version'); |
38
|
|
|
if ($wfsectionVersion >= 2) { |
39
|
|
|
} else { // wfsection 1 |
40
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/wfsection/include/groupaccess.php'; |
41
|
|
|
global $xoopsDB; |
42
|
|
|
$sql = 'SELECT articleid, title, published, expired, counter, groupid, uid FROM ' . $xoopsDB->prefix('wfs_article') . ' WHERE published < ' . time() . ' AND published > 0 AND (expired = 0 OR expired > ' . time() . ') AND noshowart = 0 AND offline = 0 ORDER BY published DESC'; |
43
|
|
|
$result = $xoopsDB->query($sql, $limit, 0); |
44
|
|
|
if (!$xoopsDB->isResultSet($result)) { |
45
|
|
|
throw new \RuntimeException( |
46
|
|
|
\sprintf(_DB_QUERY_ERROR, $sql) . $xoopsDB->error(), E_USER_ERROR); |
47
|
|
|
} |
48
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
49
|
|
|
if (checkAccess($myrow['groupid'])) { |
|
|
|
|
50
|
|
|
$wfs = []; |
|
|
|
|
51
|
|
|
$title = htmlspecialchars($myrow['title'], ENT_QUOTES | ENT_HTML5); |
52
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
53
|
|
|
if ($itemsSize > 0) { |
54
|
|
|
$title = htmlspecialchars(mb_substr($myrow['title'], 0, $itemsSize), ENT_QUOTES | ENT_HTML5); |
55
|
|
|
} else { |
56
|
|
|
$title = htmlspecialchars($myrow['title'], ENT_QUOTES | ENT_HTML5); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
$block[] = [ |
60
|
|
|
'date' => formatTimestamp($myrow['published'], $dateFormat), |
61
|
|
|
'category' => '', |
62
|
|
|
'author' => \XoopsUser::getUnameFromId($myrow['uid']), |
63
|
|
|
'title' => $title, |
64
|
|
|
'link' => "<a href='" . XOOPS_URL . '/modules/wfsection/article.php?articleid=' . $myrow['articleid'] . "'>" . $title . '</a>', |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} // wfsection 1 ou 2 ? |
69
|
|
|
|
70
|
|
|
return $block; |
71
|
|
|
} |
72
|
|
|
|