1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Rssfit\Plugins; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* |
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
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
17
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
18
|
|
|
* @package RSSFit - Extendable XML news feed generator |
19
|
|
|
* @author NS Tai (aka tuff) <http://www.brandycoke.com> |
20
|
|
|
* @author XOOPS Development Team |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
/* |
24
|
|
|
* This file is a dummy for making a RSSFit plug-in, follow the following steps |
25
|
|
|
* if you really want to do so. |
26
|
|
|
* Step 0: Stop here if you are not sure what you are doing, it's no fun at all |
27
|
|
|
* Step 1: Clone this file and rename as something like rssfit.[mod_dir].php |
28
|
|
|
* Step 2: Replace the text "RssfitSample" with "Rssfit[mod_dir]" at line 59 and |
29
|
|
|
* line 65, i.e. "RssfitNews" for the module "News" |
30
|
|
|
* Step 3: Modify the word in line 60 from 'sample' to [mod_dir] |
31
|
|
|
* Step 4: Modify the function "grabEntries" to satisfy your needs |
32
|
|
|
* Step 5: Move your new plug-in file to the RSSFit plugins folder, |
33
|
|
|
* i.e. your-xoops-root/modules/rssfit/plugins |
34
|
|
|
* Step 6: Install your plug-in by pointing your browser to |
35
|
|
|
* your-xoops-url/modules/rssfit/admin/?do=plugins |
36
|
|
|
* Step 7: Finally, tell us about yourself and this file by modifying the |
37
|
|
|
* "About this RSSFit plug-in" section which is located... somewhere. |
38
|
|
|
* |
39
|
|
|
* [mod_dir]: Name of the driectory of your module, i.e. 'news' |
40
|
|
|
* |
41
|
|
|
* About this RSSFit plug-in |
42
|
|
|
* Author: John Doe <http://www.your.site> |
43
|
|
|
* Requirements (or Tested with): |
44
|
|
|
* Module: Blah <http://www.where.to.find.it> |
45
|
|
|
* Version: 1.0 |
46
|
|
|
* RSSFit verision: 1.2 / 1.5 |
47
|
|
|
* XOOPS version: 2.0.13.2 / 2.2.3 |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
if (!\defined('RSSFIT_ROOT_PATH')) { |
51
|
|
|
exit(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Class Sample |
56
|
|
|
* @package XoopsModules\Rssfit\Plugins |
57
|
|
|
*/ |
58
|
|
|
class Wgteams |
59
|
|
|
{ |
60
|
|
|
public $dirname = 'wgteams'; |
61
|
|
|
public $modname; |
62
|
|
|
public $grab; |
63
|
|
|
public $module; // optional, see line 71 |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return false|string |
67
|
|
|
*/ |
68
|
|
|
public function loadModule() |
69
|
|
|
{ |
70
|
|
|
$mod = $GLOBALS['module_handler']->getByDirname($this->dirname); |
71
|
|
|
if (!$mod || !$mod->getVar('isactive')) { |
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
$this->modname = $mod->getVar('name'); |
75
|
|
|
$this->module = $mod; // optional, remove this line if there is nothing |
76
|
|
|
// to do with module info when grabbing entries |
77
|
|
|
return $mod; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param \XoopsObject $obj |
82
|
|
|
* @return bool|array |
83
|
|
|
*/ |
84
|
|
|
public function grabEntries(&$obj) |
|
|
|
|
85
|
|
|
{ |
86
|
|
|
global $xoopsDB; |
87
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
88
|
|
|
$ret = false; |
89
|
|
|
$i = 0; |
90
|
|
|
// The following example code grabs the latest entries from the module wgteams |
91
|
|
|
$sql = 'SELECT r.rel_date_create, t.team_id, t.team_name, m.member_firstname, m.member_lastname '; |
92
|
|
|
$sql .= 'FROM (' . $xoopsDB->prefix('wgteams_relations') . ' r INNER JOIN ' . $xoopsDB->prefix('wgteams_teams') . ' t ON r.rel_team_id = t.team_id) '; |
93
|
|
|
$sql .= 'INNER JOIN ' . $xoopsDB->prefix('wgteams_members') . ' m ON r.rel_member_id = m.member_id ORDER BY r.rel_date_create DESC'; |
94
|
|
|
$result = $xoopsDB->query($sql, $this->grab, 0); |
95
|
|
|
if ($result instanceof \mysqli_result) { |
96
|
|
|
$ret = []; |
97
|
|
|
while (false !== ($row = $xoopsDB->fetchArray($result))) { |
98
|
|
|
$link = XOOPS_URL . '/modules/' . $this->dirname . '/index.php?team_id=' . $row['team_id']; |
99
|
|
|
/* |
100
|
|
|
* Required elements of an RSS item |
101
|
|
|
*/ |
102
|
|
|
// 1. Title of an item |
103
|
|
|
$ret[$i]['title'] = $row['team_name']; |
104
|
|
|
// 2. URL of an item |
105
|
|
|
$ret[$i]['link'] = $link; |
106
|
|
|
// 3. Item modification date, must be in Unix time format |
107
|
|
|
$ret[$i]['timestamp'] = $row['rel_date_create']; |
108
|
|
|
// 4. The item synopsis, or description, whatever |
109
|
|
|
$ret[$i]['description'] = $row['member_firstname'] . ' ' . $row['member_lastname']; |
110
|
|
|
/* |
111
|
|
|
* Optional elements of an RSS item |
112
|
|
|
*/ |
113
|
|
|
// 5. The item synopsis, or description, whatever |
114
|
|
|
$ret[$i]['guid'] = $link; |
115
|
|
|
// 6. A string + domain that identifies a categorization taxonomy |
116
|
|
|
$ret[$i]['category'] = $this->modname; |
117
|
|
|
$ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
118
|
|
|
// 7. extra tags examples |
119
|
|
|
$ret[$i]['extras'] = []; |
120
|
|
|
// 7a. without attribute |
121
|
|
|
//$ret[$i]['extras']['author'] = ['content' => '[email protected]']; |
122
|
|
|
// 7b. with attributes |
123
|
|
|
//$ret[$i]['extras']['enclosure']['attributes'] = ['url' => 'url-to-any-file', 'length' => 1024000, 'type' => 'audio/mpeg']; |
124
|
|
|
$i++; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
return $ret; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.