Completed
Push — master ( 00e474...9d3fbd )
by Michael
04:26
created

extra/modules/rss/plugins/rssfit.oledrion.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link http://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
if (!defined('RSSFIT_ROOT_PATH')) {
21
    exit();
22
}
23
24
/**
25
 * Class RssfitOledrion
26
 */
27
class RssfitOledrion
28
{
29
    public $dirname = 'oledrion';
30
    public $modname;
31
    public $grab;
32
33
    /**
34
     * RssfitOledrion constructor.
35
     */
36
    public function __construct()
37
    {
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function loadModule()
0 ignored issues
show
loadModule uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
44
    {
45
        $mod = $GLOBALS['moduleHandler']->getByDirname($this->dirname);
46
        if (!$mod || !$mod->getVar('isactive')) {
47
            return false;
48
        }
49
        $this->modname = $mod->getVar('name');
50
51
        return $mod;
52
    }
53
54
    /**
55
     * @param $obj
56
     * @return bool
57
     */
58
    public function grabEntries($obj)
59
    {
60
        $ret = false;
61
        include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
62
        $items = $h_oledrion_products->getRecentProducts(new Oledrion_parameters(array(
0 ignored issues
show
The variable $h_oledrion_products does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
63
                                                                                     'start' => 0,
64
                                                                                     'limit' => $this->grab
65
                                                                                 )));
66
        $i     = 0;
67
68
        if (false !== $items && count($items) > 0) {
69
            foreach ($items as $item) {
70
                $ret[$i]['link']      = $ret[$i]['guid'] = $item->getLink();
71
                $ret[$i]['title']     = $item->getVar('product_title', 'n');
72
                $ret[$i]['timestamp'] = $item->getVar('product_submitted');
73
                if (xoops_trim($item->getVar('product_summary')) != '') {
74
                    $description = $item->getVar('product_summary');
75
                } else {
76
                    $description = $item->getVar('product_description');
77
                }
78
                $ret[$i]['description'] = $description;
79
                $ret[$i]['category']    = $this->modname;
80
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
81
                ++$i;
82
            }
83
        }
84
85
        return $ret;
86
    }
87
}
88