Mytube   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadModule() 0 9 3
A grabEntries() 0 22 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: jayjay <http://www.sint-niklaas.be>
28
 * Requirements (Tested with):
29
 *  Module: MyTube
30
 *  Version: 1.0
31
 *  RSSFit version: 1.21
32
 *  XOOPS version: 2.0.18.1
33
 */
34
if (!\defined('RSSFIT_ROOT_PATH')) {
35
    exit();
36
}
37
38
/**
39
 * Class Mytube
40
 */
41
class Mytube
42
{
43
    public $dirname = 'mytube';
44
    public $modname;
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
58
        return $mod;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array
65
    {
66
        $myts = \MyTextSanitizer::getInstance();
67
        $ret  = null;
68
        $i    = 0;
69
        $sql  = 'SELECT l.lid, l.title as ltitle, l.date, l.cid, l.hits, l.description, c.title as ctitle FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' l, ' . $xoopsDB->prefix('xoopstube_cat') . ' c WHERE l.cid=c.cid AND l.status>0 ORDER BY l.date DESC';
70
71
        $result = $xoopsDB->query($sql, $this->grab, 0);
72
        if ($result instanceof \mysqli_result) {
73
            $ret = [];
74
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
75
                $ret[$i]['title']       = $row['ltitle'];
76
                $link                   = XOOPS_URL . '/modules/' . $this->dirname . '/singlevideo.php?cid=' . $row['cid'] . '&amp;lid=' . $row['lid'];
77
                $ret[$i]['link']        = $ret[$i]['guid'] = $link;
78
                $ret[$i]['timestamp']   = $row['date'];
79
                $ret[$i]['description'] = $myts->displayTarea($row['description']);
80
                $ret[$i]['category']    = $this->modname;
81
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
82
                $i++;
83
            }
84
        }
85
        return $ret;
86
    }
87
}
88