mgo_go2_edita()   B
last analyzed

Complexity

Conditions 9
Paths 64

Size

Total Lines 98
Code Lines 58

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 58
nc 64
nop 1
dl 0
loc 98
rs 7.3608
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
### =============================================================
3
### Mastop InfoDigital - Paixão por Internet
4
### =============================================================
5
### Arquivo para Manipulação de Seções
6
### =============================================================
7
### Developer: Fernando Santos (topet05), [email protected]
8
### Copyright: Mastop InfoDigital © 2003-2007
9
### -------------------------------------------------------------
10
### www.mastop.com.br
11
### =============================================================
12
###
13
### =============================================================
14
if (!defined('MGO_MOD_DIR')) {
15
    /** @var \XoopsModules\Mastopgo2\Helper $helper */
16
    $helper = \XoopsModules\Mastopgo2\Helper::getInstance();
17
    $helper->loadLanguage('modinfo');
18
}
19
20
/** @var \XoopsModules\Mastopgo2\Helper $helper */
21
$helper = \XoopsModules\Mastopgo2\Helper::getInstance();
22
$helper->loadLanguage('modinfo');
23
24
require_once XOOPS_ROOT_PATH . '/modules/' . MGO_BLO_MODDIR . '/include/funcoes.inc.php';
25
/**
26
 * @param $options
27
 * @return array|bool
28
 */
29
function mgo_go2_exibe($options)
30
{
31
    //    $sec_classe = mgo_getClass(MGO_MOD_TABELA0);
32
    $sec_classe = new \XoopsModules\Mastopgo2\Section();
33
    $dstacs     = $sec_classe->montaGaleria($options[1], $options[0], $options[2], $options[3], $options[4], $options[7]);
34
    if ($dstacs) {
35
        $block                     = [];
36
        $block['dstac']            = $dstacs;
37
        $block['mgo_blo_bgcolor']  = $options[5];
38
        $block['mgo_blo_txtcolor'] = $options[6];
39
        $block['mgo_blo_section']  = $options[0];
40
    } else {
41
        return false;
42
    }
43
44
    return $block;
45
}
46
47
/**
48
 * @param $options
49
 * @return string
50
 */
51
function mgo_go2_edita($options)
52
{
53
    $picker_url = XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/assets/js/color_picker';
54
    $form       = '
55
<script src="' . $picker_url . '/plugin.js" type="text/JavaScript"></script>
56
<script type="text/javascript">
57
    var atual_color = "campo_img";
58
    var atual_campo = "campo";
59
60
    function pegaPicker(campo, e) {
61
        atual_color = campo.name + "_img";
62
        atual_campo = campo.name;
63
        $S("plugin").left = (XY(e) - 10) + "px";
64
        $S("plugin").top = (XY(e, 1) + 10) + "px";
65
        toggle("plugin");
66
        updateH(campo.value);
67
        $("plugHEX").innerHTML = campo.value
68
        loadSV();
69
    }
70
71
    function mkColor(v) {
72
        $S(atual_color).background = "#" + v;
73
        $(atual_campo).value = v;
74
    }
75
76
    function troca(campo, nome) {
77
        if (campo.checked) {
78
            $(nome).value = 1;
79
        } else {
80
            $(nome).value = 0;
81
        }
82
    }
83
</script>
84
    ';
85
    $form       .= <<< PICKER
86
<div id="plugin" onmousedown="HSVslide('drag','plugin',event)" style="Z-INDEX: 20; display:none;">
87
    <div id="plugHEX" onmousedown="stop=0; setTimeout('stop=1',100); toggle('plugin');">&nbsp</div>
88
    <div id="plugCLOSE" onmousedown="toggle('plugin')">X</div>
89
    <br>
90
    <div id="SV" onmousedown="HSVslide('SVslide','plugin',event)" title="Saturation + Value">
91
        <div id="SVslide" style="TOP: -4px; LEFT: -4px;"><br></div>
92
    </div>
93
    <div id="H" onmousedown="HSVslide('Hslide','plugin',event)" title="Hue">
94
        <div id="Hslide" style="TOP: -7px; LEFT: -8px;"><br></div>
95
        <div id="Hmodel"></div>
96
    </div>
97
</div>
98
PICKER;
99
100
    //  $sec_classe = mgo_getClass(MGO_MOD_TABELA0);
101
    $sec_classe = new \XoopsModules\Mastopgo2\Section();
102
    $sec_todos  = $sec_classe->pegaTudo();
103
    $sec_select = "<option value='0' " . ((0 == $options[0]) ? 'selected' : '') . '>' . _ALL . '</option>';
104
    if ($sec_todos) {
105
        foreach ($sec_todos as $v) {
106
            $sec_select .= "<option value='" . $v->getVar($v->id) . "' " . (($options[0] == $v->getVar($v->id)) ? 'selected' : '') . '>' . $v->getVar('sec_30_nome') . '</option>';
107
        }
108
    }
109
    $form .= MGO_BLO_SHOW_SECTION . " <select name='options[0]'>" . $sec_select . '</select><br>';
110
    $form .= MGO_BLO_ALTURA . " <input type='text' name='options[1]' value='" . $options[1] . "'><br>";
111
    $form .= MGO_BLO_SETAS . "&nbsp;<input type='radio' name='options[2]' value='1'";
112
    if (1 == $options[2]) {
113
        $form .= ' checked';
114
    }
115
    $form .= '>&nbsp;' . _YES . "<input type='radio' name='options[2]' value='0'";
116
    if (0 == $options[2]) {
117
        $form .= ' checked';
118
    }
119
    $form .= '>&nbsp;' . _NO . '<br>';
120
    $form .= MGO_BLO_BARRA . "&nbsp;<input type='radio' name='options[3]' value='1'";
121
    if (1 == $options[3]) {
122
        $form .= ' checked';
123
    }
124
    $form .= '>&nbsp;' . _YES . "<input type='radio' name='options[3]' value='0'";
125
    if (0 == $options[3]) {
126
        $form .= ' checked';
127
    }
128
    $form .= '>&nbsp;' . _NO . '<br>';
129
    $form .= MGO_BLO_DELAY . " <input type='text' name='options[4]' value='" . $options[4] . "'><br>";
130
    $form .= MGO_BLO_BGCOLOR
131
             . ' #<input size="6" type="text" name="options[5]" id="options[5]" value="'
132
             . $options[5]
133
             . '" onblur=\'$S(this.name+"_img").background="#"+this.value;\'><img id="options[5]_img" align="absmiddle" src="'
134
             . $picker_url
135
             . '/color.gif" onmouseover="this.style.border=\'2px solid black\'"  onmouseout="this.style.border=\'2px solid #DEE3E7\'" onclick=\'pegaPicker($("options[5]"), event)\' style="border: 2px solid #DEE3E7; background: #;'
136
             . $options[5]
137
             . '"><br>;';
138
    $form .= MGO_BLO_TXTCOLOR
139
             . ' #<input size="6" type="text" name="options[6]" id="options[6]" value="'
140
             . $options[6]
141
             . '" onblur=\'$S(this.name+"_img").background="#"+this.value;\'><img id="options[6]_img" align="absmiddle" src="'
142
             . $picker_url
143
             . '/color.gif" onmouseover="this.style.border=\'2px solid black\'"  onmouseout="this.style.border=\'2px solid #DEE3E7\'" onclick=\'pegaPicker($("options[6]"), event)\' style="border: 2px solid #DEE3E7; background: #;'
144
             . $options[6]
145
             . '"><br>;';
146
    $form .= MGO_BLO_TRANSP . " <input type='text' size='3' name='options[7]' value='" . $options[7] . "'>%<br>";
147
148
    return $form;
149
}
150