Passed
Push — master ( dcbd4a...4bb7b0 )
by Michael
02:37
created

b_marquee_smartmedia()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 21
c 0
b 0
f 0
nc 8
nop 3
dl 0
loc 32
rs 8.439
1
<?php
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (http://www.herve-thouzard.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 (http://www.herve-thouzard.com)
15
 * @license           http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package           marquee
17
 * @author            Hervé Thouzard (http://www.herve-thouzard.com)
18
 *
19
 * Version :
20
 * ****************************************************************************
21
 *
22
 * @param $limit
23
 * @param $dateFormat
24
 * @param $itemsSize
25
 *
26
 * @return array
27
 */
28
29
// Script to list recent clips from the smartmedia module (tested with smartmedia 0.85)
30
function b_marquee_smartmedia($limit, $dateFormat, $itemsSize)
0 ignored issues
show
Unused Code introduced by
The parameter $dateFormat is not used and could be removed. ( Ignorable by Annotation )

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

30
function b_marquee_smartmedia($limit, /** @scrutinizer ignore-unused */ $dateFormat, $itemsSize)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
{
32
    $block = [];
33
    if (!defined('SMARTMEDIA_DIRNAME')) {
34
        define('SMARTMEDIA_DIRNAME', 'smartmedia');
35
    }
36
    require_once XOOPS_ROOT_PATH . '/modules/' . SMARTMEDIA_DIRNAME . '/include/common.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
    $title_length = 99999;
0 ignored issues
show
Unused Code introduced by
The assignment to $title_length is dead and can be removed.
Loading history...
38
    if ($itemsSize > 0) {
39
        $title_length = $itemsSize;
40
    }
41
    $maxClips = $limit;
42
43
    $smartmediaClipHandler = smartmedia_gethandler('clip');
0 ignored issues
show
Bug introduced by
The function smartmedia_gethandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

43
    $smartmediaClipHandler = /** @scrutinizer ignore-call */ smartmedia_gethandler('clip');
Loading history...
44
45
    $clipsArray =& $smartmediaClipHandler->getClipsFromAdmin(0, $maxClips, 'clips.created_date', 'DESC', 'all');
46
47
    if ($clipsArray) {
48
        foreach ($clipsArray as $clipArray) {
49
            $clip    = [];
50
            $block[] = [
51
                'date'     => '',
52
                'category' => '',
53
                'author'   => '',
54
                'title'    => $clipArray['title'],
55
                'link'     => '<a href="' . SMARTMEDIA_URL . 'clip.php?categoryid=' . $clipArray['categoryid'] . '&folderid=' . $clipArray['folderid'] . '&clipid=' . $clipArray['clipid'] . '">' . $clipArray['title'] . '</a>'
0 ignored issues
show
Bug introduced by
The constant SMARTMEDIA_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
56
            ];
57
            unset($clip);
58
        }
59
    }
60
61
    return $block;
62
}
63