Completed
Push — master ( 66731e...5478d6 )
by Michael
02:20
created

smartmedia.php ➔ b_marquee_smartmedia()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 33
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 22
nc 8
nop 3
dl 0
loc 33
rs 8.439
c 0
b 0
f 0
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 : $Id:
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)
31
{
32
    $block = array();
33
    if (!defined('SMARTMEDIA_DIRNAME')) {
34
        define('SMARTMEDIA_DIRNAME', 'smartmedia');
35
    }
36
    include_once(XOOPS_ROOT_PATH . '/modules/' . SMARTMEDIA_DIRNAME . '/include/common.php');
37
    $title_length = 99999;
0 ignored issues
show
Unused Code introduced by
$title_length is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
    if ($itemsSize > 0) {
39
        $title_length = $itemsSize;
0 ignored issues
show
Unused Code introduced by
$title_length is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
    }
41
    $maxClips = $limit;
42
43
    $smartmediaClipHandler =& smartmedia_gethandler('clip');
44
    
45
    $clipsArray =& $smartmediaClipHandler->getClipsFromAdmin(0, $maxClips, 'clips.created_date', 'DESC', 'all');
46
47
    if ($clipsArray) {
48
        foreach ($clipsArray as $clipArray) {
49
            $clip    = array();
50
            $block[] = array(
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>'
56
            );
57
            unset($clip);
58
        }
59
    }
60
61
    return $block;
62
}
63