Conditions | 3 |
Paths | 4 |
Total Lines | 88 |
Code Lines | 66 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 2 | Features | 1 |
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 |
||
104 | function b_wgsitenotice_cookie_reg_edit($options) |
||
105 | { |
||
106 | |||
107 | $helper = Helper::getInstance(); |
||
108 | $versionsHandler = $helper->getHandler('Versions'); |
||
109 | |||
110 | $criteria = new \CriteriaCompo(); |
||
111 | $criteria->add(new \Criteria('version_current', 1)); |
||
112 | $criteria->setSort('version_weight'); |
||
113 | $criteria->setOrder('ASC'); |
||
114 | $versionsAll = $versionsHandler->getAll($criteria); |
||
115 | unset($criteria); |
||
116 | |||
117 | $cookie = $options[0]; |
||
118 | //remove existing cookie in order to see results |
||
119 | \setcookie($cookie,"0"); |
||
120 | |||
121 | $unique_id = new \XoopsFormText('', 'options[0]', 100, 255, $cookie); |
||
122 | $form = \_MB_WGSITENOTICE_COOKIE_REG_NAME . ': ' . $unique_id->render() . '<br><br>'; |
||
123 | |||
124 | $data_sel = new \XoopsFormSelect("", 'options[1]', $options[1]); |
||
125 | $data_sel->addOption('no-data', \_MB_WGSITENOTICE_COOKIE_REG_NONE); |
||
126 | foreach (\array_keys($versionsAll) as $i) { |
||
127 | $data_sel->addOption($versionsAll[$i]->getVar('version_id'), $versionsAll[$i]->getVar('version_name')); |
||
128 | } |
||
129 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_DATA . ': ' . $data_sel->render() . '<br>'; |
||
130 | |||
131 | $cookie_reg_sel = new \XoopsFormSelect("", 'options[2]', $options[2]); |
||
132 | $cookie_reg_sel->addOption('no-cookiereg', \_MB_WGSITENOTICE_COOKIE_REG_NONE); |
||
133 | foreach (\array_keys($versionsAll) as $i) { |
||
134 | $cookie_reg_sel->addOption($versionsAll[$i]->getVar('version_id'), $versionsAll[$i]->getVar('version_name')); |
||
135 | } |
||
136 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_BASE . ': ' . $cookie_reg_sel->render() . '<br>'; |
||
137 | |||
138 | $display_sel = new \XoopsFormSelect("", 'options[3]', $options[3]); |
||
139 | $display_sel->addOption('block', \_MB_WGSITENOTICE_COOKIE_REG_DISPLAY_BLOCK); |
||
140 | $display_sel->addOption('smarty', \_MB_WGSITENOTICE_COOKIE_REG_DISPLAY_SMARTY); |
||
141 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_DISPLAY . ': ' . $display_sel->render() . '<br>'; |
||
142 | |||
143 | $form .= '<br>' . \_MB_WGSITENOTICE_COOKIE_REG_OPT_STYLE . ':<br>'; |
||
144 | $form .= \str_repeat( '-' , \strlen(\_MB_WGSITENOTICE_COOKIE_REG_OPT_STYLE) + 5 ) . '<br>'; |
||
145 | |||
146 | $opacity_sel = new \XoopsFormSelect("", 'options[4]', $options[4]); |
||
147 | $opacity_sel->addOption('0.1', '0.1'); |
||
148 | $opacity_sel->addOption('0.2', '0.2'); |
||
149 | $opacity_sel->addOption('0.3', '0.3'); |
||
150 | $opacity_sel->addOption('0.4', '0.4'); |
||
151 | $opacity_sel->addOption('0.5', '0.5'); |
||
152 | $opacity_sel->addOption('0.6', '0.6'); |
||
153 | $opacity_sel->addOption('0.7', '0.7'); |
||
154 | $opacity_sel->addOption('0.8', '0.8'); |
||
155 | $opacity_sel->addOption('0.9', '0.9'); |
||
156 | $opacity_sel->addOption('1.0', '1.0'); |
||
157 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_OPACITY . ': ' . $opacity_sel->render() . '<br><br>'; |
||
158 | |||
159 | $bg_from_sel = new \XoopsFormColorPicker("", 'options[5]', $options[5]); |
||
160 | $bg_to_sel = new \XoopsFormColorPicker("", 'options[6]', $options[6]); |
||
161 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_BACKGROUND . ': ' . $bg_from_sel->render() . ' ' . $bg_to_sel->render() . '<br>'; |
||
162 | |||
163 | $color_sel = new \XoopsFormColorPicker("", 'options[7]', $options[7]); |
||
164 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_COLOR . ': ' . $color_sel->render() . '<br><br>'; |
||
165 | |||
166 | $height_sel = new \XoopsFormText('', 'options[8]', 20, 255, $options[8]); |
||
167 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_HEIGHT . ': ' . $height_sel->render() . '<br><br>'; |
||
168 | |||
169 | $form .= '<br>' . \_MB_WGSITENOTICE_COOKIE_REG_OPT_SMARTY . ':<br>'; |
||
170 | $form .= \str_repeat( '-' , \strlen(\_MB_WGSITENOTICE_COOKIE_REG_OPT_SMARTY) + 5 ) . '<br>'; |
||
171 | |||
172 | $position_sel = new \XoopsFormSelect("", 'options[9]', $options[9]); |
||
173 | $position_sel->addOption('top', \_MB_WGSITENOTICE_COOKIE_REG_POSITION_TOP); |
||
174 | $position_sel->addOption('bottom', \_MB_WGSITENOTICE_COOKIE_REG_POSITION_BOTTOM); |
||
175 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_POSITION . ': ' . $position_sel->render() . '<br>'; |
||
176 | |||
177 | $smarty_id = new \XoopsFormText('', 'options[10]', 60, 255, $options[10]); |
||
178 | $form .= \_MB_WGSITENOTICE_COOKIE_REG_DISPLAY_SMARTY_DESC . ':<br><{$' . $smarty_id->render() . '}><br><br>'; |
||
179 | |||
180 | \array_shift($options); |
||
181 | \array_shift($options); |
||
182 | \array_shift($options); |
||
183 | \array_shift($options); |
||
184 | \array_shift($options); |
||
185 | \array_shift($options); |
||
186 | \array_shift($options); |
||
187 | \array_shift($options); |
||
188 | \array_shift($options); |
||
189 | \array_shift($options); |
||
190 | |||
191 | return $form; |
||
192 | } |
||
193 |