|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* **************************************************************************** |
|
5
|
|
|
* marquee - MODULE FOR XOOPS |
|
6
|
|
|
* Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com) |
|
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
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright Hervé Thouzard (https://www.herve-thouzard.com) |
|
16
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @author Hervé Thouzard (https://www.herve-thouzard.com) |
|
18
|
|
|
* |
|
19
|
|
|
* Version : |
|
20
|
|
|
* **************************************************************************** |
|
21
|
|
|
* |
|
22
|
|
|
* @param $limit |
|
23
|
|
|
* @param $dateFormat |
|
24
|
|
|
* @param $itemsSize |
|
25
|
|
|
* |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
use XoopsModules\Catads; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
// Script to list recent ads from the catads module (tested with catads v 1.4) |
|
32
|
|
|
/** |
|
33
|
|
|
* @param $limit |
|
34
|
|
|
* @param $dateFormat |
|
35
|
|
|
* @param $itemsSize |
|
36
|
|
|
* @return array |
|
37
|
|
|
*/ |
|
38
|
|
|
function b_marquee_catads($limit, $dateFormat, $itemsSize) |
|
39
|
|
|
{ |
|
40
|
|
|
global $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
41
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/catads/class/cat.php'; |
|
42
|
|
|
$block = []; |
|
43
|
|
|
if (empty($xoopsModule) || 'catads' !== $xoopsModule->getVar('dirname')) { |
|
44
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
45
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
46
|
|
|
$module = $moduleHandler->getByDirname('catads'); |
|
47
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
48
|
|
|
$configHandler = xoops_getHandler('config'); |
|
49
|
|
|
$config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
|
|
50
|
|
|
} else { |
|
51
|
|
|
$module = $xoopsModule; |
|
|
|
|
|
|
52
|
|
|
$config = $xoopsModuleConfig; |
|
53
|
|
|
} |
|
54
|
|
|
//echo '<br>ok'; |
|
55
|
|
|
$ads_hnd = Catads\Helper::getInstance()->getHandler('Ads'); |
|
|
|
|
|
|
56
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('waiting', '0')); |
|
57
|
|
|
$criteria->add(new \Criteria('published', time(), '<')); |
|
58
|
|
|
$criteria->add(new \Criteria('expired', time(), '>')); |
|
59
|
|
|
$criteria->setSort('published'); |
|
60
|
|
|
$criteria->setOrder('DESC'); |
|
61
|
|
|
$criteria->setLimit($limit); |
|
62
|
|
|
$nbads = $ads_hnd->getCount($criteria); |
|
63
|
|
|
$itemArray = []; |
|
64
|
|
|
$catBuffer = []; |
|
65
|
|
|
if ($nbads > 0) { |
|
66
|
|
|
$ads = $ads_hnd->getObjects($criteria); |
|
67
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
|
|
68
|
|
|
foreach ($ads as $oneads) { |
|
69
|
|
|
if ($itemsSize > 0) { |
|
70
|
|
|
$title = xoops_substr($oneads->getVar('ads_title'), 0, $itemsSize); |
|
71
|
|
|
} else { |
|
72
|
|
|
$title = $oneads->getVar('ads_title'); |
|
73
|
|
|
} |
|
74
|
|
|
if (!isset($catBuffer[$oneads->getVar('cat_id')])) { |
|
75
|
|
|
$tmpcat = new Catads\AdsCategory($oneads->getVar('cat_id')); |
|
|
|
|
|
|
76
|
|
|
$catBuffer[$oneads->getVar('cat_id')] = $tmpcat->title(); |
|
77
|
|
|
$catTitle = $tmpcat->title(); |
|
|
|
|
|
|
78
|
|
|
} else { |
|
79
|
|
|
$catTitle = $catBuffer[$oneads->getVar('cat_id')]; |
|
80
|
|
|
} |
|
81
|
|
|
$block[] = [ |
|
82
|
|
|
'date' => formatTimestamp($oneads->getVar('published'), $dateFormat), |
|
83
|
|
|
'category' => '', |
|
84
|
|
|
'author' => \XoopsUser::getUnameFromId($oneads->getVar('uid')), |
|
85
|
|
|
'title' => $title, |
|
86
|
|
|
'link' => "<a href='" . XOOPS_URL . '/modules/catads/adsitem.php?ads_id=' . $oneads->getVar('ads_id') . "'>" . $title . '</a>', |
|
87
|
|
|
]; |
|
88
|
|
|
unset($itemArray); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
return $block; |
|
93
|
|
|
} |
|
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths