|
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\Myalbum\Helper as PluginHelper; |
|
53
|
|
|
use XoopsModules\Rssfit\{ |
|
54
|
|
|
AbstractPlugin |
|
55
|
|
|
}; |
|
56
|
|
|
|
|
57
|
|
|
if (!\defined('RSSFIT_ROOT_PATH')) { |
|
58
|
|
|
exit(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Class Myalbum |
|
63
|
|
|
* @package XoopsModules\Rssfit\Plugins |
|
64
|
|
|
*/ |
|
65
|
|
|
final class Myalbum 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
|
|
|
public function myGetUnameFromId(int $uid): string |
|
75
|
|
|
{ |
|
76
|
|
|
static $thisUser = false; |
|
77
|
|
|
static $lastUid = false; |
|
78
|
|
|
static $lastName = ''; |
|
79
|
|
|
|
|
80
|
|
|
if ($lastUid === $uid) { |
|
81
|
|
|
return $lastName; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
if (!\is_object($thisUser)) { |
|
85
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
|
86
|
|
|
$memberHandler = \xoops_getHandler('member'); |
|
87
|
|
|
$thisUser = $memberHandler->getUser($uid); |
|
88
|
|
|
} |
|
89
|
|
|
$name = \htmlspecialchars($thisUser->getVar('name'), \ENT_QUOTES | \ENT_HTML5); |
|
90
|
|
|
if ('' === $name) { |
|
91
|
|
|
$name = \htmlspecialchars($thisUser->getVar('uname'), \ENT_QUOTES | \ENT_HTML5); |
|
92
|
|
|
} |
|
93
|
|
|
$lastUid = $uid; |
|
94
|
|
|
$lastName = $name; |
|
95
|
|
|
|
|
96
|
|
|
return $name; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array |
|
100
|
|
|
{ |
|
101
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
102
|
|
|
$ret = null; |
|
103
|
|
|
$i = 0; |
|
104
|
|
|
// For myalbum-p with thumbs enabled |
|
105
|
|
|
|
|
106
|
|
|
$sql = 'SELECT p.lid, p.title, p.ext, p.date, t.description, c.cid, c.title as cat, p.submitter'; |
|
107
|
|
|
$sql .= ' FROM ' . $xoopsDB->prefix('myalbum_photos') . ' p, '; |
|
108
|
|
|
$sql .= $xoopsDB->prefix('myalbum_text') . ' t, '; |
|
109
|
|
|
$sql .= $xoopsDB->prefix('myalbum_cat') . ' c '; |
|
110
|
|
|
$sql .= 'WHERE p.status > 0 AND p.cid = c.cid AND p.lid = t.lid '; |
|
111
|
|
|
$sql .= 'ORDER BY date DESC'; |
|
112
|
|
|
$result = $xoopsDB->query($sql, $this->grab, 0); |
|
113
|
|
|
if ($result instanceof \mysqli_result) { |
|
114
|
|
|
$ret = []; |
|
115
|
|
|
while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
116
|
|
|
$link = XOOPS_URL . '/modules/' . $this->dirname . '/photo.php?lid=' . $row['lid']; |
|
117
|
|
|
$thumb = XOOPS_URL . '/uploads/thumbs/' . $row['lid'] . '.' . $row['ext']; |
|
118
|
|
|
$name = $this->myGetUnameFromId($row['submitter']); |
|
119
|
|
|
$title = $myts->displayTarea($row['title']); |
|
120
|
|
|
$cat = $myts->displayTarea($row['cat']); |
|
121
|
|
|
$catlink = XOOPS_URL . '/modules/' . $this->dirname . '/viewcat.php?cid=' . $row['cid']; |
|
122
|
|
|
/* |
|
123
|
|
|
* Required elements of an RSS item |
|
124
|
|
|
*/ |
|
125
|
|
|
// 1. Title of an item |
|
126
|
|
|
$ret[$i]['title'] = $this->modname . ': ' . $title; |
|
127
|
|
|
// 2. URL of an item |
|
128
|
|
|
$ret[$i]['link'] = $link; |
|
129
|
|
|
// 3. Item modification date, must be in Unix time format |
|
130
|
|
|
$ret[$i]['timestamp'] = $row['date']; |
|
131
|
|
|
// 4. The item synopsis, or description, whatever |
|
132
|
|
|
$desc = '<p><a href="' . $link . '"><img src="' . $thumb . '" align="left" alt="' . $title . '" border="0"></a> '; |
|
133
|
|
|
$desc .= 'By ' . $name . ' in <a href="' . $catlink . '">' . $cat . '</a><br>'; |
|
134
|
|
|
$desc .= $myts->displayTarea($row['description']) . '</p><br clear="all">'; |
|
135
|
|
|
$ret[$i]['description'] = $desc; |
|
136
|
|
|
/* |
|
137
|
|
|
* Optional elements of an RSS item |
|
138
|
|
|
*/ |
|
139
|
|
|
// 5. The item synopsis, or description, whatever |
|
140
|
|
|
$ret[$i]['guid'] = $link; |
|
141
|
|
|
// 6. A string + domain that identifies a categorization taxonomy |
|
142
|
|
|
$ret[$i]['category'] = $cat; |
|
143
|
|
|
$ret[$i]['domain'] = $catlink; |
|
144
|
|
|
|
|
145
|
|
|
$i++; |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
return $ret; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|