1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Rssfit\Plugins; |
6
|
|
|
|
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
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
20
|
|
|
* @package RSSFit - Extendable XML news feed generator |
21
|
|
|
* @author NS Tai (aka tuff) <http://www.brandycoke.com> |
22
|
|
|
* @author XOOPS Development Team |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
/* |
26
|
|
|
* This file is a dummy for making a RSSFit plug-in, follow the following steps |
27
|
|
|
* if you really want to do so. |
28
|
|
|
* Step 0: Stop here if you are not sure what you are doing, it's no fun at all |
29
|
|
|
* Step 1: Clone this file and rename as something like rssfit.[mod_dir].php |
30
|
|
|
* Step 2: Replace the text "RssfitMyalbum" with "Rssfit[mod_dir]" at line 59 and |
31
|
|
|
* line 65, i.e. "RssfitNews" for the module "News" |
32
|
|
|
* Step 3: Modify the word in line 60 from 'Myalbum' to [mod_dir] |
33
|
|
|
* Step 4: Modify the function "grabEntries" to satisfy your needs |
34
|
|
|
* Step 5: Move your new plug-in file to the RSSFit plugins folder, |
35
|
|
|
* i.e. your-xoops-root/modules/rssfit/plugins |
36
|
|
|
* Step 6: Install your plug-in by pointing your browser to |
37
|
|
|
* your-xoops-url/modules/rssfit/admin/?do=plugins |
38
|
|
|
* Step 7: Finally, tell us about yourself and this file by modifying the |
39
|
|
|
* "About this RSSFit plug-in" section which is located... somewhere. |
40
|
|
|
* |
41
|
|
|
* [mod_dir]: Name of the driectory of your module, i.e. 'news' |
42
|
|
|
* |
43
|
|
|
* About this RSSFit plug-in |
44
|
|
|
* Author: John Doe <http://www.your.site> |
45
|
|
|
* Requirements (or Tested with): |
46
|
|
|
* Module: Blah <http://www.where.to.find.it> |
47
|
|
|
* Version: 1.0 |
48
|
|
|
* RSSFit verision: 1.2 / 1.5 |
49
|
|
|
* XOOPS version: 2.0.13.2 / 2.2.3 |
50
|
|
|
*/ |
51
|
|
|
|
52
|
|
|
use XoopsModules\Extcal\Helper as PluginHelper; |
53
|
|
|
use XoopsModules\Rssfit\{ |
54
|
|
|
AbstractPlugin |
55
|
|
|
}; |
56
|
|
|
|
57
|
|
|
if (!\defined('RSSFIT_ROOT_PATH')) { |
58
|
|
|
exit(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Class Extcal |
63
|
|
|
* @package XoopsModules\Rssfit\Plugins |
64
|
|
|
*/ |
65
|
|
|
final class Extcal extends AbstractPlugin |
66
|
|
|
{ |
67
|
|
|
public function __construct() { |
68
|
|
|
if (\class_exists(PluginHelper::class)) { |
69
|
|
|
$this->helper = PluginHelper::getInstance(); |
70
|
|
|
$this->dirname = $this->helper->dirname(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array |
76
|
|
|
{ |
77
|
|
|
$ret = null; |
78
|
|
|
$i = 0; |
79
|
|
|
|
80
|
|
|
// read confgs to get timestamp format |
81
|
|
|
$extcal = $this->module; |
82
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
83
|
|
|
$configHandler = \xoops_getHandler('config'); |
84
|
|
|
$extcalConfig = $configHandler->getConfigsByCat(0, $extcal->getVar('mid')); |
85
|
|
|
$dateLongForm = $extcalConfig['date_long']; |
86
|
|
|
|
87
|
|
|
$eventHandler = PluginHelper::getInstance()->getHandler('Event'); |
88
|
|
|
$catHandler = PluginHelper::getInstance()->getHandler('Category'); |
89
|
|
|
$events = $eventHandler->getUpcomingEvent($this->grab,0); |
90
|
|
|
|
91
|
|
|
if (\is_array($events)) { |
92
|
|
|
$ret = []; |
93
|
|
|
foreach ($events as $event) { |
94
|
|
|
++$i; |
95
|
|
|
$cat = $catHandler->getCat($event->getVar('cat_id'), 0); |
96
|
|
|
$category = $cat->getVar('cat_name'); |
97
|
|
|
$link = XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id'); |
98
|
|
|
$eventStart = \formatTimestamp($event->getVar('event_start'), $dateLongForm); |
99
|
|
|
$temp = \htmlspecialchars($event->getVar('event_title'), \ENT_QUOTES); |
100
|
|
|
$title = \xoops_utf8_encode($temp); |
101
|
|
|
$temp = \htmlspecialchars($event->getVar('event_desc'), \ENT_QUOTES); |
102
|
|
|
$description = \xoops_utf8_encode($temp); |
103
|
|
|
$address = $event->getVar('event_address'); |
104
|
|
|
|
105
|
|
|
$eventUrl = $event->getVar('event_url'); |
106
|
|
|
if ('' === $eventUrl) { |
107
|
|
|
$eventUrl = $link; |
108
|
|
|
} |
109
|
|
|
$desc = "<a href=\"$eventUrl\"><b>$title</b></a><br>"; |
110
|
|
|
$desc .= '<table>'; |
111
|
|
|
$desc .= "<tr><td valign='top'>When:</td><td>$eventStart</td></tr>"; |
112
|
|
|
if ('' !== $address) { |
113
|
|
|
$desc .= "<tr><td valign='top'>Where:</td><td>$address</td></tr>"; |
114
|
|
|
} |
115
|
|
|
$desc .= "<tr><td valign='top'>What:</td><td>$description</td></tr>"; |
116
|
|
|
$desc .= '</table>'; |
117
|
|
|
|
118
|
|
|
$ret[$i]['title'] = $category . ': ' . $title; |
119
|
|
|
$ret[$i]['link'] = $link; |
120
|
|
|
$ret[$i]['description'] = $desc; |
121
|
|
|
$ret[$i]['timestamp'] = $event->getVar('event_submitdate'); |
122
|
|
|
// $ret[$i]['timestamp'] = time(); |
123
|
|
|
$ret[$i]['guid'] = $link; |
124
|
|
|
$ret[$i]['category'] = $category; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
return $ret; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|