Conditions | 33 |
Paths | > 20000 |
Total Lines | 123 |
Code Lines | 77 |
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 |
||
143 | private function getCheckUserpage() |
||
144 | { |
||
145 | //check field params: minimum one param is selected |
||
146 | foreach (\array_keys($this->tables) as $t) { |
||
147 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
148 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
149 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
150 | |||
151 | foreach (\array_keys($fields) as $f) { |
||
152 | $fieldName = $fields[$f]->getVar('field_name'); |
||
153 | // check fields for parameters |
||
154 | if ($f > 0) { |
||
155 | $fieldParams = (int)$fields[$f]->getVar('field_parent') + (int)$fields[$f]->getVar('field_admin') + (int)$fields[$f]->getVar('field_inlist') + (int)$fields[$f]->getVar('field_inform') |
||
156 | + (int)$fields[$f]->getVar('field_user') + (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
||
157 | + (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot') + (int)$fields[$f]->getVar('field_block') |
||
158 | + (int)$fields[$f]->getVar('field_main') + (int)$fields[$f]->getVar('field_search') + (int)$fields[$f]->getVar('field_required'); |
||
159 | if (0 == $fieldParams) { |
||
160 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS1); |
||
161 | $this->infos[] = ['icon' => 'error', 'info' => $info]; |
||
162 | } |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 | |||
167 | //check field params: user file no usage in index or item |
||
168 | foreach (\array_keys($this->tables) as $t) { |
||
169 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
170 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
171 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
172 | |||
173 | foreach (\array_keys($fields) as $f) { |
||
174 | $fieldName = $fields[$f]->getVar('field_name'); |
||
175 | if (1 == $fields[$f]->getVar('field_user')) { |
||
176 | // check fields for parameters |
||
177 | if ($f > 0) { |
||
178 | $fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
||
179 | + (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
||
180 | if (0 == $fieldParams) { |
||
181 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS2); |
||
182 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
183 | } |
||
184 | } |
||
185 | } |
||
186 | } |
||
187 | } |
||
188 | //check field params: user file index multiple usage |
||
189 | //check field params: user file item multiple usage |
||
190 | foreach (\array_keys($this->tables) as $t) { |
||
191 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
192 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
193 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
194 | |||
195 | foreach (\array_keys($fields) as $f) { |
||
196 | $fieldName = $fields[$f]->getVar('field_name'); |
||
197 | if (1 == $fields[$f]->getVar('field_user')) { |
||
198 | // check fields for parameters |
||
199 | if ($f > 0) { |
||
200 | $fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot'); |
||
201 | if ($fieldParams > 1) { |
||
202 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS3); |
||
203 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
204 | } |
||
205 | $fieldParams = (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
||
206 | if ($fieldParams > 1) { |
||
207 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS3); |
||
208 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
209 | } |
||
210 | } |
||
211 | } |
||
212 | } |
||
213 | } |
||
214 | |||
215 | //check table params: user submit or rate or broken, but table not for user side |
||
216 | foreach (\array_keys($this->tables) as $t) { |
||
217 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
218 | if ((0 == $this->tables[$t]->getVar('table_user')) && (1 == $this->tables[$t]->getVar('table_submit') || 1 == $this->tables[$t]->getVar('table_broken') || 1 == $this->tables[$t]->getVar('table_rate'))) { |
||
219 | $info = \str_replace(['%t'], [$tableName], _AM_MODULEBUILDER_BUILDING_CHECK_USERPAGE1); |
||
220 | $this->infos[] = ['icon' => 'error', 'info' => $info]; |
||
221 | } |
||
222 | } |
||
223 | |||
224 | //check field/table params: params for index file, but table param table_index = 0 |
||
225 | //check field/table params: params for user file, but table param table_user = 0 |
||
226 | foreach (\array_keys($this->tables) as $t) { |
||
227 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
228 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
229 | $tableIndex = (int)$this->tables[$t]->getVar('table_index'); |
||
230 | $tableUser = (int)$this->tables[$t]->getVar('table_user'); |
||
231 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
232 | |||
233 | $fieldParamsIndex = 0; |
||
234 | $fieldParamsUser = 0; |
||
235 | foreach (\array_keys($fields) as $f) { |
||
236 | $fieldName = $fields[$f]->getVar('field_name'); |
||
237 | if (1 == $fields[$f]->getVar('field_user')) { |
||
238 | // check fields for parameters |
||
239 | if ($f > 0) { |
||
240 | $fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot'); |
||
241 | $fieldParamsIndex += $fieldParams; |
||
242 | if ($fieldParams >= 1 && 0 == $tableIndex) { |
||
243 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS5); |
||
244 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
245 | } |
||
246 | $fieldParams = (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
||
247 | $fieldParamsUser += $fieldParams; |
||
248 | if ($fieldParams >= 1 && 0 == $tableUser) { |
||
249 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS7); |
||
250 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
251 | } |
||
252 | } |
||
253 | } |
||
254 | } |
||
255 | if (0 == $fieldParamsIndex && 1 == $tableIndex) { |
||
256 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS4); |
||
|
|||
257 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
258 | } |
||
259 | if (0 == $fieldParamsUser && 1 == $tableUser) { |
||
260 | $info = \str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS6); |
||
261 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
262 | } |
||
263 | } |
||
264 | |||
265 | return true; |
||
266 | } |
||
459 |