Passed
Push — master ( 919ce4...d1101e )
by Michael
03:15 queued 11s
created

RssfitAdslight::grabEntries()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 34
rs 9.7333
c 1
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
###############################################################################
6
##                RSSFit - Extendable XML news feed generator                ##
7
##                Copyright (c) 2004 - 2005 NS Tai (aka tuff)                ##
8
##                       <http://www.brandycoke.com> & ... nbsp;   ##
9
###############################################################################
10
##                    XOOPS - PHP Content Management System                  ##
11
##                       Copyright (c) 2000 XOOPS.org                        ##
12
##                          <https://xoops.org>   ... nbsp;   ##
13
###############################################################################
14
##  This program is free software; you can redistribute it and/or modify     ##
15
##  it under the terms of the GNU General Public License as published by     ##
16
##  the Free Software Foundation; either version 2 of the License, or        ##
17
##  (at your option) any later version.                                      ##
18
##                                                                           ##
19
##  You may not change or alter any portion of this comment or credits       ##
20
##  of supporting developers from this source code or any supporting         ##
21
##  source code which is considered copyrighted (c) material of the          ##
22
##  original comment or credit authors.                                      ##
23
##                                                                           ##
24
##  This program is distributed in the hope that it will be useful,          ##
25
##  but WITHOUT ANY WARRANTY; without even the implied warranty of           ##
26
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            ##
27
##  GNU General Public License for more details.                             ##
28
##                                                                           ##
29
##  You should have received a copy of the GNU General Public License        ##
30
##  along with this program; if not, write to the Free Software              ##
31
##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA ##
32
###############################################################################
33
/*
34
* Adslight RSSFit plugin based on Jobs RSSFit plugin by www.jlmzone.com
35
* Done by Bjuti (www.bjuti.info)
36
*  Last release date:  Jan. 18 2010
37
*  RSSFit version: 1.2 / 1.5
38
*  XOOPS version: 2.0.13.2 / 2.2.3 / 2.3.2b / 2.4.3
39
*/
40
if (!defined('RSSFIT_ROOT_PATH')) {
41
    exit();
42
}
43
44
/**
45
 * Class RssfitAdslight
46
 */
47
class RssfitAdslight
48
{
49
    public $dirname = 'adslight';
50
    public $modname;
51
    public $grab;
52
    public $module;    // optional, see line 74
53
54
    public function __construct()
55
    {
56
    }
57
58
    public function loadModule(): bool
59
    {
60
        $mod = &$GLOBALS['moduleHandler']->getByDirname($this->dirname);
61
        if (!$mod || !$mod->getVar('isactive')) {
62
            return false;
63
        }
64
        $this->modname = $mod->getVar('name');
65
        //$this->module =& $mod;    // optional, remove this line if there is nothing
66
        // to do with module info when grabbing entries
67
        return $mod;
68
    }
69
70
    /**
71
     * @param $obj
72
     * @return bool
73
     */
74
    public function &grabEntries($obj)
0 ignored issues
show
Unused Code introduced by
The parameter $obj is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function &grabEntries(/** @scrutinizer ignore-unused */ $obj)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        global $xoopsDB;
77
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
78
        $ret  = false;
79
        $i    = 0;
80
        //    The following example code grabs the latest entries from the module MyLinks
81
        $sql    = 'SELECT lid, title, status, desctext, date_created from ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid = 'Yes' ORDER BY date_created DESC";
82
        $result = $xoopsDB->query($sql, $this->grab, 0);
83
        while (false !== ($row = $xoopsDB->fetchArray($result))) {
84
            $link = XOOPS_URL . '/modules/' . $this->dirname . '/viewads.php?lid=' . $row['lid'];
85
            /*
86
             * Required elements of an RSS item
87
             */
88
            //    1. Title of an item
89
            $ret[$i]['title'] = $row['title'];
90
            //    2. URL of an item
91
            $ret[$i]['link'] = $link;
92
            //    3. Item modification date_created, must be in Unix time format
93
            $ret[$i]['timestamp'] = $row['date_created'];
94
            //    4. The item synopsis, or description, whatever
95
            $ret[$i]['description'] = $row['desctext'];  // $myts->displayTarea($row['desctext']);
96
            /*
97
            * Optional elements of an RSS item
98
            */ //    5. The item synopsis, or description, whatever
99
            // $ret[$i]['guid'] = $link;
100
            //    6. A string + domain that identifies a categorization taxonomy
101
            //    $ret[$i]['category'] = $this->modname;
102
            // $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/';
103
            //    7. extra tags examples
104
            $ret[$i]['extras'] = [];
105
            $i++;
106
        }
107
        return $ret;
108
    }
109
}
110