Conditions | 9 |
Paths | 64 |
Total Lines | 98 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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');"> </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 . " <input type='radio' name='options[2]' value='1'"; |
||
112 | if (1 == $options[2]) { |
||
113 | $form .= ' checked'; |
||
114 | } |
||
115 | $form .= '> ' . _YES . "<input type='radio' name='options[2]' value='0'"; |
||
116 | if (0 == $options[2]) { |
||
117 | $form .= ' checked'; |
||
118 | } |
||
119 | $form .= '> ' . _NO . '<br>'; |
||
120 | $form .= MGO_BLO_BARRA . " <input type='radio' name='options[3]' value='1'"; |
||
121 | if (1 == $options[3]) { |
||
122 | $form .= ' checked'; |
||
123 | } |
||
124 | $form .= '> ' . _YES . "<input type='radio' name='options[3]' value='0'"; |
||
125 | if (0 == $options[3]) { |
||
126 | $form .= ' checked'; |
||
127 | } |
||
128 | $form .= '> ' . _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 |