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
|
|
|
// ------------------------------------------------------------------------ // |
29
|
|
|
// TplLeagueStats plugin for Marquee 2.4 // |
30
|
|
|
// written by Defkon1 [defkon1 at gmail dot com] // |
31
|
|
|
// ------------------------------------------------------------------------ // |
32
|
|
|
function b_marquee_tplleaguestats($limit, $dateFormat, $itemsSize) |
33
|
|
|
{ |
34
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
35
|
|
|
//######################## SETTINGS ###################### |
36
|
|
|
$displaySeason = false; // display season name? |
37
|
|
|
$hour = 1; // GMT+1 -> var = 1 |
38
|
|
|
$useItemSize = false; // use marquee $itemsize value? |
39
|
|
|
$overwriteLimit = true; // overwrite marquee's limit settings? |
40
|
|
|
$newLimit = 6; // new limit (valid only if |
41
|
|
|
// overwrite_limit_settings = true) |
42
|
|
|
$overwriteDateformat = true; // overwrite marquee's dateformat? |
43
|
|
|
$newDateformat = 'd/m/Y'; // new dateformat (valid only if |
44
|
|
|
// overwrite_dateformat_settings=true) |
45
|
|
|
//######################## SETTINGS ###################### |
46
|
|
|
global $xoopsDB; |
47
|
|
|
if ($overwriteLimit) { |
|
|
|
|
48
|
|
|
$limit = $newLimit; |
49
|
|
|
} |
50
|
|
|
if ($overwriteDateformat) { |
|
|
|
|
51
|
|
|
$dateFormat = $newDateformat; |
52
|
|
|
} |
53
|
|
|
$block = []; |
54
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
55
|
|
|
$sql = 'SELECT H.OpponentName as home, A.OpponentName as away, M.LeagueMatchHomeGoals as home_p, M.LeagueMatchAwayGoals as away_p, |
56
|
|
|
M.LeagueMatchDate as date, S.SeasonName as season |
57
|
|
|
FROM ' . $xoopsDB->prefix('tplls_leaguematches') . ' M |
58
|
|
|
LEFT JOIN ' . $xoopsDB->prefix('tplls_opponents') . ' AS H ON M.LeagueMatchHomeID = H.OpponentID |
59
|
|
|
LEFT JOIN ' . $xoopsDB->prefix('tplls_opponents') . ' AS A ON M.LeagueMatchAwayID = A.OpponentID |
60
|
|
|
LEFT JOIN ' . $xoopsDB->prefix('tplls_seasonnames') . " AS S ON M.LeagueMatchSeasonID = S.SeasonID |
61
|
|
|
ORDER BY M.LeagueMatchDate DESC |
62
|
|
|
LIMIT 0,$limit"; |
63
|
|
|
$result = $xoopsDB->query($sql); |
64
|
|
|
if (!$xoopsDB->isResultSet($result)) { |
65
|
|
|
throw new \RuntimeException( |
66
|
|
|
\sprintf(_DB_QUERY_ERROR, $sql) . $xoopsDB->error(), E_USER_ERROR); |
67
|
|
|
} |
68
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
69
|
|
|
$title = htmlspecialchars($myrow['home'], ENT_QUOTES | ENT_HTML5) . ' - ' . htmlspecialchars($myrow['away'], ENT_QUOTES | ENT_HTML5) . ' ' . htmlspecialchars($myrow['home_p'], ENT_QUOTES | ENT_HTML5) . '-' . htmlspecialchars($myrow['away_p'], ENT_QUOTES | ENT_HTML5); |
70
|
|
|
if ($useItemSize && $itemsSize > 0) { |
71
|
|
|
$title = xoops_substr($title, 0, $itemsSize + 3); |
72
|
|
|
} |
73
|
|
|
$arrDate = explode('-', $myrow['date']); |
74
|
|
|
$season = ''; |
75
|
|
|
if ($displaySeason) { |
76
|
|
|
$season = $myrow['season']; |
77
|
|
|
} |
78
|
|
|
$block[] = [ |
79
|
|
|
'date' => formatTimestamp(mktime($hour, 0, 0, $arrDate[1], $arrDate[2], $arrDate[0]), $dateFormat), |
|
|
|
|
80
|
|
|
'category' => $season, |
81
|
|
|
'author' => '', |
82
|
|
|
'title' => $title, |
83
|
|
|
'link' => '<a href="' . XOOPS_URL . '/modules/tplleaguestats">' . $title . '</a>', |
84
|
|
|
]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return $block; |
88
|
|
|
} |
89
|
|
|
|