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 Wgsimpleacc |
||
59 | { |
||
60 | public $dirname = 'wgsimpleacc'; |
||
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) |
||
0 ignored issues
–
show
|
|||
85 | { |
||
86 | global $xoopsDB; |
||
87 | $myts = \MyTextSanitizer::getInstance(); |
||
0 ignored issues
–
show
|
|||
88 | $ret = false; |
||
89 | $i = 0; |
||
90 | // The following example code grabs the latest entries from the module |
||
91 | $sql = 'SELECT t.tra_id, t.tra_datecreated, t.tra_year, t.tra_nb, t.tra_desc, a1.acc_key, a1.acc_name, a2.all_name, a3.as_name, c.cli_name '; |
||
92 | $sql .= 'FROM (((' . $xoopsDB->prefix('wgsimpleacc_transactions') . ' t INNER JOIN ' . $xoopsDB->prefix('wgsimpleacc_accounts') . ' a1 '; |
||
93 | $sql .= 'ON t.tra_accid = a1.acc_id) INNER JOIN ' . $xoopsDB->prefix('wgsimpleacc_allocations') . ' a2 ON t.tra_allid = a2.all_id) '; |
||
94 | $sql .= 'INNER JOIN ' . $xoopsDB->prefix('wgsimpleacc_assets') . ' a3 ON t.tra_asid = a3.as_id) '; |
||
95 | $sql .= 'LEFT JOIN ' . $xoopsDB->prefix('wgsimpleacc_clients') . ' c ON t.tra_cliid = c.cli_id '; |
||
96 | $sql .= 'ORDER BY t.tra_datecreated DESC'; |
||
97 | |||
98 | $result = $xoopsDB->query($sql, $this->grab, 0); |
||
99 | if ($result instanceof \mysqli_result) { |
||
100 | $ret = []; |
||
101 | while (false !== ($row = $xoopsDB->fetchArray($result))) { |
||
102 | $link = XOOPS_URL . '/modules/' . $this->dirname . '/transactions.php?op=show&tra_id=' . $row['tra_id']; |
||
103 | /* |
||
104 | * Required elements of an RSS item |
||
105 | */ |
||
106 | // 1. Title of an item |
||
107 | $ret[$i]['title'] = $row['tra_year'] . '/' . $row['tra_nb']; |
||
108 | // 2. URL of an item |
||
109 | $ret[$i]['link'] = $link; |
||
110 | // 3. Item modification date, must be in Unix time format |
||
111 | $ret[$i]['timestamp'] = $row['tra_datecreated']; |
||
112 | // 4. The item synopsis, or description, whatever |
||
113 | $ret[$i]['description'] = \strip_tags($row['tra_desc']); |
||
114 | /* |
||
115 | * Optional elements of an RSS item |
||
116 | */ |
||
117 | // 5. The item synopsis, or description, whatever |
||
118 | $ret[$i]['guid'] = $link; |
||
119 | // 6. A string + domain that identifies a categorization taxonomy |
||
120 | $ret[$i]['category'] = $this->modname; |
||
121 | $ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
||
122 | // 7. extra tags examples |
||
123 | $ret[$i]['extras'] = []; |
||
124 | // 7a. without attribute |
||
125 | $ret[$i]['extras']['account'] = ['content' => $row['acc_name']]; |
||
126 | $ret[$i]['extras']['allocation'] = ['content' => $row['all_name']]; |
||
127 | if (\strlen(\strip_tags($row['cli_name'])) > 0) { |
||
128 | $ret[$i]['extras']['client'] = ['content' => \strip_tags($row['cli_name'])]; |
||
129 | } |
||
130 | // 7b. with attributes |
||
131 | //$ret[$i]['extras']['enclosure']['attributes'] = ['url' => 'url-to-any-file', 'length' => 1024000, 'type' => 'audio/mpeg']; |
||
132 | $i++; |
||
133 | } |
||
134 | } |
||
135 | return $ret; |
||
136 | } |
||
137 | } |
||
138 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.