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

Smartpartner::loadModule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 2
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
* About this RSSFit plug-in
27
* Author: tuff <http://www.brandycoke.com>
28
* Requirements:
29
* Requirements (Tested with):
30
*  Module: SmartPartner <http://www.smartfactory.ca>
31
*  Version: 1.02
32
*  RSSFit verision: 1.2 / 1.5
33
*  XOOPS version: 2.0.13.2 / 2.2.3
34
*/
35
36
use XoopsModules\Rssfit\{
37
    AbstractPlugin
38
};
39
use XoopsModules\Smartpartner\{
40
    Constants,
41
    Helper as PluginHelper,
42
    PartnerHandler
43
};
44
45
if (!\defined('RSSFIT_ROOT_PATH')) {
46
    exit();
47
}
48
49
/**
50
 * Class Smartpartner
51
 * @package XoopsModules\Rssfit\Plugins
52
 */
53
final class Smartpartner extends AbstractPlugin
54
{
55
    public function __construct() {
56
        if (\class_exists(PluginHelper::class)) {
57
            $this->helper = PluginHelper::getInstance();
58
            $this->dirname = $this->helper->dirname();
59
        }
60
    }
61
62
63
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
64
    {
65
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
66
        $ret  = null;
67
        require_once XOOPS_ROOT_PATH . '/modules/smartpartner/include/common.php';
68
        /** @var PartnerHandler $partnerHandler */
69
        $partnerHandler = PluginHelper::getInstance()->getHandler('Partner');
70
        $partners       = $partnerHandler->getPartners($this->grab, 0, Constants::SPARTNER_STATUS_ACTIVE, 'weight', 'DESC');
71
        if (\is_array($partners) && \count($partners) > 0) {
72
            $ret = [];
73
            for ($i = 0, $iMax = \count($partners); $i < $iMax; ++$i) {
74
                $ret[$i]['link']        = $ret[$i]['guid'] = SMARTPARTNER_URL . 'partner.php?id=' . $partners[$i]->getVar('id');
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Rssfit\Plugins\SMARTPARTNER_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
75
                $ret[$i]['title']       = $partners[$i]->getVar('title', 'n');
76
                $ret[$i]['description'] = $partners[$i]->getVar('summary');
77
                $ret[$i]['category']    = $this->modname;
78
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
79
            }
80
        }
81
82
        return $ret;
83
    }
84
}
85