RssfitReferences   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A loadModule() 0 10 3
A grabEntries() 0 25 5
1
<?php
2
/**
3
 * ****************************************************************************
4
 * references - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright       Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
15
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package         references
17
 * @author          Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
18
 *
19
 * ****************************************************************************
20
 */
21
if (!defined('RSSFIT_ROOT_PATH')) {
22
    exit();
23
}
24
25
class RssfitReferences
26
{
27
    public $dirname = 'references';
28
    public $modname;
29
    public $grab;
30
31
    public function __construct()
32
    {
33
    }
34
35
    public function loadModule()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
36
    {
37
        $mod =& $GLOBALS['module_handler']->getByDirname($this->dirname);
38
        if (!$mod || !$mod->getVar('isactive')) {
39
            return false;
40
        }
41
        $this->modname = $mod->getVar('name');
42
43
        return $mod;
44
    }
45
46
    public function &grabEntries(&$obj)
47
    {
48
        $ret = false;
49
        require XOOPS_ROOT_PATH . '/modules/references/include/common.php';
50
        $start      = 0;
51
        $limit      = $this->grab;
52
        $items      = $h_references_articles->getRecentArticles($start, $limit);
0 ignored issues
show
Bug introduced by
The variable $h_references_articles 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...
53
        $i          = 0;
54
        $categories = $h_references_categories->getCategories();
0 ignored issues
show
Bug introduced by
The variable $h_references_categories 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...
55
56
        if (false != $items && count($items) > 0) {
57
            foreach ($items as $item) {
58
                $ret[$i]['link']        = $item->getUrl();
59
                $ret[$i]['title']       = $item->getVar('article_title');
60
                $ret[$i]['timestamp']   = $item->getVar('article_timestamp');
61
                $ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT);
62
                $categoryId             = $item->getVar('article_category_id');
63
                $ret[$i]['category']    = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : '';
64
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
65
                ++$i;
66
            }
67
        }
68
69
        return $ret;
70
    }
71
}
72