Passed
Push — master ( b0fca4...7540c5 )
by Michael
06:08 queued 02:59
created

Adslight::loadModule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
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
 * Adslight RSSFit plugin based on Jobs RSSFit plugin by www.jlmzone.com
27
 * Done by Bjuti (www.bjuti.info)
28
 *  Last release date:  Jan. 18 2010
29
 *  RSSFit version: 1.2 / 1.5
30
 *  XOOPS version: 2.0.13.2 / 2.2.3 / 2.3.2b / 2.4.3
31
 */
32
33
use XoopsModules\Adslight\Helper as PluginHelper;
34
use XoopsModules\Rssfit\{
35
    AbstractPlugin
36
};
37
38
if (!\defined('RSSFIT_ROOT_PATH')) {
39
    exit();
40
}
41
42
/**
43
 * Class Adslight
44
 */
45
final class Adslight extends AbstractPlugin
46
{
47
    public function __construct() {
48
        if (\class_exists(PluginHelper::class)) {
49
            $this->helper = PluginHelper::getInstance();
50
            $this->dirname = $this->helper->dirname();
51
        }
52
    }
53
54
55
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
56
    {
57
        $ret    = null;
58
        $i      = 0;
59
        $sql    = 'SELECT lid, title, status, desctext, date from ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid = 'Yes' ORDER BY date DESC";
60
        $result = $xoopsDB->query($sql, $this->grab, 0);
61
        if ($result instanceof \mysqli_result) {
62
            $ret = [];
63
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
64
                $link                   = XOOPS_URL . '/modules/' . $this->dirname . '/viewads.php?lid=' . $row['lid'] ?? '';
65
                $ret[$i]['title']       = $row['title'];
66
                $ret[$i]['link']        = $link;
67
                $ret[$i]['timestamp']   = $row['date'];
68
                $ret[$i]['description'] = $row['desctext'];  // $myts->displayTarea($row['desctext']);
69
                $ret[$i]['extras']      = [];
70
                $i++;
71
            }
72
        }
73
74
        return $ret;
75
    }
76
}
77