| Conditions | 21 |
| Paths | 720 |
| Total Lines | 81 |
| Code Lines | 50 |
| 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 |
||
| 140 | private function getCheckUserpage() |
||
| 141 | { |
||
| 142 | foreach (array_keys($this->tables) as $t) { |
||
| 143 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
| 144 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
| 145 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
| 146 | |||
| 147 | foreach (array_keys($fields) as $f) { |
||
| 148 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 149 | // check fields for parameters |
||
| 150 | if ($f > 0) { |
||
| 151 | $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') |
||
| 152 | + (int)$fields[$f]->getVar('field_user') + (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
||
| 153 | + (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot') + (int)$fields[$f]->getVar('field_block') |
||
| 154 | + (int)$fields[$f]->getVar('field_main') + (int)$fields[$f]->getVar('field_search') + (int)$fields[$f]->getVar('field_required'); |
||
| 155 | if (0 == $fieldParams) { |
||
| 156 | $info = str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS1); |
||
| 157 | $this->infos[] = ['icon' => 'error', 'info' => $info]; |
||
| 158 | } |
||
| 159 | } |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | //check user file no usage in index or item |
||
| 164 | foreach (array_keys($this->tables) as $t) { |
||
| 165 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
| 166 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
| 167 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
| 168 | |||
| 169 | foreach (array_keys($fields) as $f) { |
||
| 170 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 171 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 172 | // check fields for parameters |
||
| 173 | if ($f > 0) { |
||
| 174 | $fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
||
| 175 | + (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
||
| 176 | if (0 == $fieldParams) { |
||
| 177 | $info = str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS2); |
||
| 178 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
| 179 | } |
||
| 180 | } |
||
| 181 | } |
||
| 182 | } |
||
| 183 | } |
||
| 184 | //check user file index multiple usage |
||
| 185 | //check user file item multiple usage |
||
| 186 | foreach (array_keys($this->tables) as $t) { |
||
| 187 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
| 188 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
| 189 | $fields = $this->cf->getTableFields($this->modId, $tableId); |
||
| 190 | |||
| 191 | foreach (array_keys($fields) as $f) { |
||
| 192 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 193 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 194 | // check fields for parameters |
||
| 195 | if ($f > 0) { |
||
| 196 | $fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot'); |
||
| 197 | if ($fieldParams > 1) { |
||
| 198 | $info = str_replace(['%f', '%t'], [$fieldName, $tableName], _AM_MODULEBUILDER_BUILDING_CHECK_FIELDS3); |
||
| 199 | $this->infos[] = ['icon' => 'warning', 'info' => $info]; |
||
| 200 | } |
||
| 201 | $fieldParams = (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
||
| 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 | } |
||
| 207 | } |
||
| 208 | } |
||
| 209 | } |
||
| 210 | |||
| 211 | //check user submit or rate or broken, but table not for user side |
||
| 212 | foreach (array_keys($this->tables) as $t) { |
||
| 213 | $tableId = $this->tables[$t]->getVar('table_id'); |
||
|
|
|||
| 214 | $tableName = $this->tables[$t]->getVar('table_name'); |
||
| 215 | 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'))) { |
||
| 216 | $info = str_replace(['%t'], [$tableName], _AM_MODULEBUILDER_BUILDING_CHECK_USERPAGE1); |
||
| 217 | $this->infos[] = ['icon' => 'error', 'info' => $info]; |
||
| 218 | } |
||
| 219 | } |
||
| 220 | return true; |
||
| 221 | } |
||
| 367 |