b_news_bigstory_show()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 48
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 35
c 0
b 0
f 0
dl 0
loc 48
rs 9.0488
cc 5
nc 3
nop 0
1
<?php declare(strict_types=1);
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
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @author         XOOPS Development Team
16
 */
17
18
use XoopsModules\News;
19
use XoopsModules\News\Helper;
20
use XoopsModules\News\NewsStory;
21
22
/**
23
 * @return array|null|false
24
 */
25
function b_news_bigstory_show()
26
{
27
    // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
28
29
    /** @var Helper $helper */
30
    if (!class_exists(Helper::class)) {
31
        return false;
32
    }
33
34
    $helper = Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
35
36
    $myts       = \MyTextSanitizer::getInstance();
37
    $restricted = News\Utility::getModuleOption('restrictindex');
38
    $dateformat = News\Utility::getModuleOption('dateformat');
39
    $infotips   = News\Utility::getModuleOption('infotips');
40
41
    $block    = [];
42
    $onestory = new NewsStory();
43
    $stories  = $onestory->getBigStory(1, 0, $restricted, 0, 1, true, 'counter');
44
    if (0 == count($stories)) {
45
        $block['message'] = _MB_NEWS_NOTYET;
46
    } else {
47
        foreach ($stories as $key => $story) {
48
            $htmltitle = '';
49
            if ($infotips > 0) {
50
                $block['infotips'] = News\Utility::makeInfotips($story->hometext());
51
                $htmltitle         = ' title="' . $block['infotips'] . '"';
52
            } else {
53
                $htmltitle = ' title="' . $story->title('Show') . '"';
54
            }
55
            $block['htmltitle']         = $htmltitle;
56
            $block['message']           = _MB_NEWS_TMRSI;
57
            $block['story_title']       = $story->title('Show');
58
            $block['story_id']          = $story->storyid();
59
            $block['story_date']        = formatTimestamp($story->published(), $dateformat);
60
            $block['story_hits']        = $story->counter();
61
            $block['story_rating']      = $story->rating();
62
            $block['story_votes']       = $story->votes();
63
            $block['story_author']      = $story->uname();
64
            $block['story_text']        = $story->hometext();
65
            $block['story_topic_title'] = $story->topic_title();
66
            $block['story_topic_color'] = '#' . $myts->displayTarea($story->topic_color);
67
            $block['story_picture']     = XOOPS_URL . '/uploads/news/image/' . $story->picture();
68
            $block['story_pictureinfo'] = $story->pictureinfo();
69
        }
70
    }
71
72
    return $block;
73
}
74
75
/**
76
 * @param $options
77
 */
78
function b_news_bigstory_onthefly($options): void
79
{
80
    $options = explode('|', $options);
81
    $block   = b_news_bigstory_show($options);
0 ignored issues
show
Unused Code introduced by
The call to b_news_bigstory_show() has too many arguments starting with $options. ( Ignorable by Annotation )

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

81
    $block   = /** @scrutinizer ignore-call */ b_news_bigstory_show($options);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
82
83
    $tpl = new \XoopsTpl();
84
    $tpl->assign('block', $block);
85
    $tpl->display('db:news_block_bigstory.tpl');
86
}
87