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

Lexikon::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
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
 * Requirements (Tested with):
28
 *  Module: Wordbook <http://dev.xoops.org/modules/xfmod/project/?wordbook>
29
 *  Version: 1.17
30
 *  RSSFit version: 1.1 / 1.5
31
 *  XOOPS verson: 2.0.13.2 / 2.2.3 (!)
32
 */
33
34
use XoopsModules\Lexikon\Helper as PluginHelper;
35
use XoopsModules\Rssfit\{
36
    AbstractPlugin
37
};
38
39
if (!\defined('RSSFIT_ROOT_PATH')) {
40
    exit();
41
}
42
43
/**
44
 * Class lexikon
45
 */
46
final class Lexikon extends AbstractPlugin
47
{
48
    public function __construct() {
49
        if (\class_exists(PluginHelper::class)) {
50
            $this->helper = PluginHelper::getInstance();
51
            $this->dirname = $this->helper->dirname();
52
        }
53
    }
54
55
56
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
57
    {
58
        $myts = \MyTextSanitizer::getInstance();
59
        //$permiscHandler = xoops_getHandler('groupperm');
60
        $ret    = null;
61
        $i      = 0;
62
        $sql    = 'SELECT entryID, categoryID, term, definition, datesub FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE submit = 0 AND offline = 0 ORDER BY datesub DESC';
63
        $result = $xoopsDB->query($sql, $this->grab, 0);
64
        if ($result instanceof \mysqli_result) {
65
            $ret = [];
66
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
67
                //  required
68
                $ret[$i]['title'] = $row['term'];
69
                $link             = XOOPS_URL . '/modules/' . $this->dirname . '/entry.php?entryID=' . $row['entryID'];
70
                //$ret[$i]['link'] = $ret[$i]['guid'] = $link;
71
                $ret[$i]['link']        = $link;
72
                $ret[$i]['timestamp']   = $row['datesub'];
73
                $ret[$i]['description'] = $myts->displayTarea($row['definition']);
74
                //  optional
75
                //5. The item synopsis, or description, whatever
76
                //$ret[$i]['guid'] = $link;
77
                //  6. A string + domain that identifies a categorization taxonomy
78
                $ret[$i]['category'] = $this->modname;
79
                $ret[$i]['domain']   = XOOPS_URL . '/modules/' . $this->dirname . '/';
80
                /*$ret[$i]['extras'] = [];
81
                //  7a. without attribute
82
                $ret[$i]['extras']['author'] = array('content' => '[email protected]');
83
                //  7b. with attributes
84
                $ret[$i]['extras']['enclosure']['attributes'] = array('url' => 'url-to-any-file', 'length' => 1024000, 'type' => 'audio/mpeg');
85
                */
86
                $i++;
87
            }
88
        }
89
90
        return $ret;
91
    }
92
}
93