Rmdp   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
c 0
b 0
f 0
dl 0
loc 45
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A grabEntries() 0 20 3
A loadModule() 0 10 3
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
 * About this RSSFit plug-in
27
 * Author: agamen0n <http://www.tradux.xoopstotal.com.br>
28
 * Requirements:
29
 *  Module: RMDP <http://www.xoops-mexico.net>
30
 *  Version: 1.0
31
 *  RSSFit version: 1.1
32
 */
33
if (!\defined('RSSFIT_ROOT_PATH')) {
34
    exit();
35
}
36
37
/**
38
 * Class Rmdp
39
 */
40
class Rmdp extends \XoopsObject
41
{
42
    public $dirname = 'rmdp';
43
    public $modname;
44
    public $module;
45
    public $grab;
46
47
    /**
48
     * @return \XoopsModule
49
     */
50
    public function loadModule():?\XoopsModule
51
    {
52
        $mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
53
        if (!$mod || !$mod->getVar('isactive')) {
54
            return null;
55
        }
56
        $this->modname = $mod->getVar('name');
57
        $this->module = $mod;
58
59
        return $mod;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array
66
    {
67
        $ret = null;
68
        $i = 0;
69
        $sql = 'SELECT id_soft, id_cat, nombre, fecha, longdesc FROM ' . $xoopsDB->prefix('rmdp_software') . ' ORDER BY fecha DESC';
70
        $result = $xoopsDB->query($sql, $this->grab, 0);
71
        if ($result instanceof \mysqli_result) {
72
            $ret = [];
73
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
74
                $ret[$i]['title']       = $row['nombre'];
75
                $link                   = XOOPS_URL . '/modules/' . $this->dirname . '/down.php?id=' . $row['id_soft'];
76
                $ret[$i]['link']        = $ret[$i]['guid'] = $link;
77
                $ret[$i]['timestamp']   = $row['fecha'];
78
                $ret[$i]['description'] = $row['longdesc'];
79
                $ret[$i]['category']    = $this->modname;
80
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
81
                $i++;
82
            }
83
        }
84
        return $ret;
85
    }
86
}
87