b_myiframe_iframe_edit()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 16
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 26
rs 9.7333
1
<?php declare(strict_types=1);
2
3
/**
4
 * ****************************************************************************
5
 * MYIFRAME - MODULE FOR XOOPS
6
 * Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com)
7
 * ****************************************************************************
8
 */
9
10
use XoopsModules\Newbb;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Newbb was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use XoopsModules\Myiframe\{
12
    Constants,
13
    Helper
14
};
15
16
/** @var Helper $helper */
17
18
require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
19
20
/**
21
 * @param $options
22
 * @return array
23
 */
24
function b_myiframe_iframe_show($options)
25
{
26
    if (!class_exists(Helper::class)) {
27
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type array.
Loading history...
28
    }
29
    $frame         = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $frame is dead and can be removed.
Loading history...
30
    $helper        = Helper::getInstance();
31
    $block         = [];
32
    $tblalign      = [
33
        'top',
34
        'middle',
35
        'bottom',
36
        'left',
37
        'rigth',
38
    ];
39
    $tblscrolling  = [
40
        'yes',
41
        'no',
42
        'auto',
43
    ];
44
    $iframeHandler = $helper->getHandler('MyiframeBase');
45
    $frame         = $iframeHandler->get($options[0]);
46
47
    if (is_object($frame)) {
48
        $block['longdesc']     = $frame->getVar('frame_description');
49
        $block['width']        = $frame->getVar('frame_width');
50
        $block['height']       = $frame->getVar('frame_height');
51
        $block['align']        = $tblalign[$frame->getVar('frame_align') - 1];
52
        $block['frameborder']  = $frame->getVar('frame_frameborder');
53
        $block['marginwidth']  = $frame->getVar('frame_marginwidth');
54
        $block['marginheight'] = $frame->getVar('frame_marginheight');
55
        $block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling') - 1];
56
        $block['url']          = $frame->getVar('frame_url');
57
    }
58
59
    return $block;
60
}
61
62
/**
63
 * @param $options
64
 * @return string
65
 */
66
function b_myiframe_iframe_edit($options)
67
{
68
    if (!class_exists(Helper::class)) {
69
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
70
    }
71
    $helper = Helper::getInstance();
72
73
    /** @var \MyiframeBaseHandler $iframeHandler */
74
    $iframeHandler = $helper->getHandler('MyiframeBase');
75
    $frarray       = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $frarray is dead and can be removed.
Loading history...
76
    $critere       = new \Criteria('1', '1', '=');
77
    $critere->setSort('frame_description');
78
    $frarray = $iframeHandler->getObjects($critere);
79
80
    $form = '' . _MB_MYIFRAME_IFRAME . "&nbsp;<select name='options[0]'>";
81
    /** @var Myiframe $oneframe */
82
    foreach ($frarray as $oneframe) {
83
        $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'";
84
        if ($options[0] == $oneframe->getVar('frame_frameid')) {
85
            $form .= " selected='selected'";
86
        }
87
        $form .= '>' . $oneframe->getVar('frame_description') . '</option>';
88
    }
89
    $form .= "</select>\n";
90
91
    return $form;
92
}
93
94
/**
95
 * @param $options
96
 */
97
function b_myiframe_iframe_onthefly($options): void
98
{
99
    $options = explode('|', $options);
100
    $block   = b_myiframe_iframe_show($options);
101
102
    $tpl = new \XoopsTpl();
103
    $tpl->assign('block', $block);
104
    $tpl->display('db:myiframe_block_show.tpl');
105
}
106