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