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 partners from the smartpartner module (tested with smartparnter 1.2) |
29
|
|
|
function b_marquee_smartpartner($limit, $dateFormat, $itemsSize) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$block = $newObjects = []; |
32
|
|
|
if (!defined('SMARTPARTNER_DIRNAME')) { |
33
|
|
|
define('SMARTPARTNER_DIRNAME', 'smartpartner'); |
34
|
|
|
} |
35
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/' . SMARTPARTNER_DIRNAME . '/include/common.php'; |
36
|
|
|
// Creating the partner handler object |
37
|
|
|
$smartpartnerPartnerHandler = smartpartner_gethandler('partner'); |
|
|
|
|
38
|
|
|
$smartpartnerCategoryHandler = smartpartner_gethandler('category'); |
39
|
|
|
// Randomize |
40
|
|
|
$partnersObj = $smartpartnerPartnerHandler->getPartners(0, 0, _SPARTNER_STATUS_ACTIVE); |
|
|
|
|
41
|
|
|
if (count($partnersObj) > 1) { |
42
|
|
|
$keyArray = array_keys($partnersObj); |
43
|
|
|
$keyRand = array_rand($keyArray, count($keyArray)); |
44
|
|
|
for ($i = 0; ($i < count($partnersObj)) && ($i < $limit); ++$i) { |
45
|
|
|
$newObjects[$i] = $partnersObj[$keyRand[$i]]; |
46
|
|
|
} |
47
|
|
|
$partnersObj = $newObjects; |
48
|
|
|
} |
49
|
|
|
$catId = []; |
50
|
|
|
foreach ($partnersObj as $partnerObj) { |
51
|
|
|
if (!in_array($partnerObj->categoryid(), $catId, true)) { |
52
|
|
|
$catId[] = $partnerObj->categoryid(); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
if ($partnersObj) { |
56
|
|
|
foreach ($catId as $j => $jValue) { |
57
|
|
|
$categoryObj = $smartpartnerCategoryHandler->get($jValue); |
|
|
|
|
58
|
|
|
for ($i = 0, $iMax = count($partnersObj); $i < $iMax; ++$i) { |
59
|
|
|
if ($partnersObj[$i]->categoryid() == $jValue) { |
60
|
|
|
$smartConfig = smartpartner_getModuleConfig(); |
|
|
|
|
61
|
|
|
if ($itemsSize > 0) { |
62
|
|
|
$title = xoops_substr($partnersObj[$i]->title(), 0, $itemsSize + 3); |
63
|
|
|
} else { |
64
|
|
|
$title = $partnersObj[$i]->title(); |
65
|
|
|
} |
66
|
|
|
$block[] = [ |
67
|
|
|
'date' => '', |
68
|
|
|
'category' => '', |
69
|
|
|
'author' => '', |
70
|
|
|
'title' => $title, |
71
|
|
|
'link' => "<a href='" . XOOPS_URL . '/modules/smartpartner/partner.php?id=' . $partnersObj[$i]->id() . "'>" . $title . '</a>', |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return $block; |
79
|
|
|
} |
80
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.