|
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 polls from the xoopspoll module version 1.0 |
|
27
|
|
|
function b_marquee_xoopspoll($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 * FROM ' . $db->prefix('xoopspoll_desc') . ' WHERE start_time<=' . time() . ' AND end_time>' . time() . ' ORDER BY start_time DESC', $limit, 0); |
|
34
|
|
|
while (false !== ($myrow = $db->fetchArray($result))) { |
|
35
|
|
|
$title = htmlspecialchars($myrow['question'], ENT_QUOTES | ENT_HTML5); |
|
36
|
|
|
if ($itemsSize > 0) { |
|
37
|
|
|
$title = xoops_substr($title, 0, $itemsSize + 3); |
|
38
|
|
|
} |
|
39
|
|
|
$block[] = [ |
|
40
|
|
|
'date' => formatTimestamp($myrow['start_time'], $dateFormat), |
|
41
|
|
|
'category' => '', |
|
42
|
|
|
'author' => $myrow['user_id'], |
|
43
|
|
|
'title' => $title, |
|
44
|
|
|
'link' => "<a href='" . XOOPS_URL . '/modules/xoopspoll/index.php?poll_id=' . $myrow['poll_id'] . "'>" . $title . '</a>', |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $block; |
|
49
|
|
|
} |
|
50
|
|
|
|