Completed
Pull Request — master (#4)
by Michael
01:27
created

myiframe_iframe.php ➔ b_myiframe_iframe_show()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 26
nc 2
nop 1
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * ****************************************************************************
4
 * MYIFRAME - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 * ****************************************************************************
7
 */
8
9
include_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
10
11
/**
12
 * @param $options
13
 * @return array
14
 */
15
function b_myiframe_iframe_show($options)
16
{
17
    $block         = array();
18
    $tblalign      = array(
19
        'top',
20
        'middle',
21
        'bottom',
22
        'left',
23
        'rigth'
24
    );
25
    $tblscrolling  = array(
26
        'yes',
27
        'no',
28
        'auto'
29
    );
30
    $iframeHandler = xoops_getModuleHandler('myiframe', 'myiframe');
31
    $frame         = null;
0 ignored issues
show
Unused Code introduced by
$frame 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...
32
    $frame         = $iframeHandler->get($options[0]);
33
34
    if (is_object($frame)) {
35
        $block['longdesc']     = $frame->getVar('frame_description');
36
        $block['width']        = $frame->getVar('frame_width');
37
        $block['height']       = $frame->getVar('frame_height');
38
        $block['align']        = $tblalign[$frame->getVar('frame_align') - 1];
39
        $block['frameborder']  = $frame->getVar('frame_frameborder');
40
        $block['marginwidth']  = $frame->getVar('frame_marginwidth');
41
        $block['marginheight'] = $frame->getVar('frame_marginheight');
42
        $block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling') - 1];
43
        $block['url']          = $frame->getVar('frame_url');
44
    }
45
    return $block;
46
}
47
48
/**
49
 * @param $options
50
 * @return string
51
 */
52
function b_myiframe_iframe_edit($options)
53
{
54
    $iframeHandler = xoops_getModuleHandler('myiframe', 'myiframe');
55
    $frarray       = array();
0 ignored issues
show
Unused Code introduced by
$frarray 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...
56
    $critere       = new Criteria('1', '1', '=');
57
    $critere->setSort('frame_description');
58
    $frarray = $iframeHandler->getObjects($critere);
59
60
    $form = '' . _MB_MYIFRAME_IFRAME . "&nbsp;<select name='options[0]'>";
61
    foreach ($frarray as $oneframe) {
62
        $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'";
63
        if ($options[0] == $oneframe->getVar('frame_frameid')) {
64
            $form .= " selected='selected'";
65
        }
66
        $form .= '>' . $oneframe->getVar('frame_description') . '</option>';
67
    }
68
    $form .= "</select>\n";
69
    return $form;
70
}
71
72
/**
73
 * @param $options
74
 */
75
function b_myiframe_iframe_onthefly($options)
76
{
77
    $options = explode('|', $options);
78
    $block   = &b_myiframe_iframe_show($options);
79
80
    $tpl = new XoopsTpl();
81
    $tpl->assign('block', $block);
82
    $tpl->display('db:myiframe_block_show.tpl');
83
}
84