@@ -1035,7 +1035,7 @@ |
||
1035 | 1035 | } else { |
1036 | 1036 | $cols .= '*'; |
1037 | 1037 | } |
1038 | - $cols .=') as `count`' . (!empty($options['cols']) ? ',' . $options['cols'] : ''); |
|
1038 | + $cols .= ') as `count`' . (!empty($options['cols']) ? ',' . $options['cols'] : ''); |
|
1039 | 1039 | App::$cur->db->cols = $cols; |
1040 | 1040 | if (!empty($options['group'])) { |
1041 | 1041 | App::$cur->db->group($options['group']); |
@@ -437,6 +437,9 @@ discard block |
||
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | + /** |
|
441 | + * @param boolean $new |
|
442 | + */ |
|
440 | 443 | public function logChanges($new) { |
441 | 444 | if (!App::$cur->db->connect || !App::$cur->dashboard) { |
442 | 445 | return false; |
@@ -539,7 +542,7 @@ discard block |
||
539 | 542 | /** |
540 | 543 | * Information extractor for col relations path |
541 | 544 | * |
542 | - * @param string|array $info |
|
545 | + * @param string $info |
|
543 | 546 | * @return array |
544 | 547 | */ |
545 | 548 | public static function parseColRecursion($info) { |
@@ -625,7 +628,7 @@ discard block |
||
625 | 628 | * Generate params string for col by name |
626 | 629 | * |
627 | 630 | * @param string $colName |
628 | - * @return boolean|string |
|
631 | + * @return false|string |
|
629 | 632 | */ |
630 | 633 | public static function genColParams($colName) { |
631 | 634 | if (empty(static::$cols[$colName]) || static::$storage['type'] == 'moduleConfig') { |
@@ -780,7 +783,7 @@ discard block |
||
780 | 783 | /** |
781 | 784 | * return relations list |
782 | 785 | * |
783 | - * @return array |
|
786 | + * @return string |
|
784 | 787 | */ |
785 | 788 | public static function relations() { |
786 | 789 | return []; |
@@ -1303,7 +1306,7 @@ discard block |
||
1303 | 1306 | * |
1304 | 1307 | * @param array $params |
1305 | 1308 | * @param array $where |
1306 | - * @return boolean |
|
1309 | + * @return false|null |
|
1307 | 1310 | */ |
1308 | 1311 | public static function update($params, $where = []) { |
1309 | 1312 | static::fixPrefix($params); |
@@ -151,10 +151,12 @@ discard block |
||
151 | 151 | } |
152 | 152 | if (strpos($valuePath, ':')) { |
153 | 153 | return self::getColValue($object->$rel, $param, $convert, $manageHref); |
154 | - } else { |
|
154 | + } |
|
155 | + else { |
|
155 | 156 | return $convert ? Model::resloveTypeValue($object->$rel, $param, $manageHref) : $object->$rel->$param; |
156 | 157 | } |
157 | - } else { |
|
158 | + } |
|
159 | + else { |
|
158 | 160 | return $convert ? Model::resloveTypeValue($object, $valuePath, $manageHref) : $object->$valuePath; |
159 | 161 | } |
160 | 162 | } |
@@ -193,7 +195,8 @@ discard block |
||
193 | 195 | case 'method': |
194 | 196 | if (!empty($colInfo['colParams']['params'])) { |
195 | 197 | $values = call_user_func_array([App::$cur->$colInfo['colParams']['module'], $colInfo['colParams']['method']], $colInfo['colParams']['params']); |
196 | - } else { |
|
198 | + } |
|
199 | + else { |
|
197 | 200 | $values = $colInfo['colParams']['module']->$colInfo['colParams']['method'](); |
198 | 201 | } |
199 | 202 | $value = !empty($values[$item->$colName]) ? $values[$item->$colName] : 'Не задано'; |
@@ -210,7 +213,8 @@ discard block |
||
210 | 213 | $relModel = strpos($relModel, '\\') === 0 ? substr($relModel, 1) : $relModel; |
211 | 214 | if ($manageHref) { |
212 | 215 | $value = $relValue ? "<a href='/admin/" . str_replace('\\', '/view/', $relModel) . "/" . $relValue->pk() . "'>" . $relValue->name() . "</a>" : 'Не задано'; |
213 | - } else { |
|
216 | + } |
|
217 | + else { |
|
214 | 218 | $value = $relValue ? $relValue->name() : 'Не задано'; |
215 | 219 | } |
216 | 220 | break; |
@@ -220,7 +224,8 @@ discard block |
||
220 | 224 | $file = Files\File::get($item->$colName); |
221 | 225 | if ($file) { |
222 | 226 | $value = '<img src="' . $file->path . '?resize=60x120" />'; |
223 | - } else { |
|
227 | + } |
|
228 | + else { |
|
224 | 229 | $value = '<img src="/static/system/images/no-image.png?resize=60x120" />'; |
225 | 230 | } |
226 | 231 | break; |
@@ -228,7 +233,8 @@ discard block |
||
228 | 233 | $file = Files\File::get($item->$colName); |
229 | 234 | if ($file) { |
230 | 235 | $value = '<a href="' . $file->path . '">' . $file->name . '.' . $file->type->ext . '</a>'; |
231 | - } else { |
|
236 | + } |
|
237 | + else { |
|
232 | 238 | $value = 'Файл не загружен'; |
233 | 239 | } |
234 | 240 | break; |
@@ -279,7 +285,8 @@ discard block |
||
279 | 285 | $onclick .= 'return false;'; |
280 | 286 | $value = "<a href ='#' onclick='{$onclick}' >{$name}</a>"; |
281 | 287 | $value .= $content; |
282 | - } else { |
|
288 | + } |
|
289 | + else { |
|
283 | 290 | $value = 'Местоположение не заданно'; |
284 | 291 | } |
285 | 292 | |
@@ -299,7 +306,8 @@ discard block |
||
299 | 306 | $itemModel = get_class($curItem); |
300 | 307 | $relation = $itemModel::getRelation($relationName); |
301 | 308 | $sourceModel = $relation['model']; |
302 | - } else { |
|
309 | + } |
|
310 | + else { |
|
303 | 311 | $relation = static::getRelation($type['relation']); |
304 | 312 | $sourceModel = $relation['model']; |
305 | 313 | } |
@@ -307,10 +315,12 @@ discard block |
||
307 | 315 | $value = $sourceModel::get($item->$colName); |
308 | 316 | if ($value) { |
309 | 317 | $value = $value->name(); |
310 | - } else { |
|
318 | + } |
|
319 | + else { |
|
311 | 320 | $value = $item->$colName; |
312 | 321 | } |
313 | - } else { |
|
322 | + } |
|
323 | + else { |
|
314 | 324 | switch ($type) { |
315 | 325 | case 'map': |
316 | 326 | if ($item->$colName && json_decode($item->$colName, true)) { |
@@ -351,7 +361,8 @@ discard block |
||
351 | 361 | $onclick .= 'return false;'; |
352 | 362 | $value = "<a href ='#' onclick='{$onclick}' >{$name}</a>"; |
353 | 363 | $value .= $content; |
354 | - } else { |
|
364 | + } |
|
365 | + else { |
|
355 | 366 | $value = 'Местоположение не заданно'; |
356 | 367 | } |
357 | 368 | |
@@ -393,7 +404,8 @@ discard block |
||
393 | 404 | } |
394 | 405 | if (!isset($cols[$array]) && isset($cols[static::colPrefix() . $array])) { |
395 | 406 | $array = static::colPrefix() . $array; |
396 | - } else { |
|
407 | + } |
|
408 | + else { |
|
397 | 409 | static::checkForJoin($array, $rootModel); |
398 | 410 | } |
399 | 411 | return; |
@@ -412,7 +424,8 @@ discard block |
||
412 | 424 | } |
413 | 425 | if (is_array($array[$key])) { |
414 | 426 | static::fixPrefix($array[$key], 'key', $rootModel); |
415 | - } else { |
|
427 | + } |
|
428 | + else { |
|
416 | 429 | static::checkForJoin($key, $rootModel); |
417 | 430 | } |
418 | 431 | } |
@@ -425,10 +438,12 @@ discard block |
||
425 | 438 | } |
426 | 439 | if (!isset($cols[$array[0]]) && isset($cols[static::colPrefix() . $array[0]])) { |
427 | 440 | $array[0] = static::colPrefix() . $array[0]; |
428 | - } else { |
|
441 | + } |
|
442 | + else { |
|
429 | 443 | static::checkForJoin($array[0], $rootModel); |
430 | 444 | } |
431 | - } elseif (isset($array[0]) && is_array($array[0])) { |
|
445 | + } |
|
446 | + elseif (isset($array[0]) && is_array($array[0])) { |
|
432 | 447 | foreach ($array as &$item) { |
433 | 448 | static::fixPrefix($item, 'first', $rootModel); |
434 | 449 | } |
@@ -461,7 +476,8 @@ discard block |
||
461 | 476 | } |
462 | 477 | if (strlen($oldValue) + strlen($this->_params[$fullColName]) < 200) { |
463 | 478 | $changes_text[] = (!empty($class::$labels[$colName]) ? $class::$labels[$colName] : $colName) . ": \"{$oldValue}\" => \"{$this->$colName}\""; |
464 | - } else { |
|
479 | + } |
|
480 | + else { |
|
465 | 481 | $changes_text[] = !empty($class::$labels[$colName]) ? $class::$labels[$colName] : $colName; |
466 | 482 | } |
467 | 483 | } |
@@ -480,7 +496,8 @@ discard block |
||
480 | 496 | ]); |
481 | 497 | $change->save(); |
482 | 498 | } |
483 | - } elseif ($new) { |
|
499 | + } |
|
500 | + elseif ($new) { |
|
484 | 501 | $activity = new Dashboard\Activity([ |
485 | 502 | 'user_id' => \Users\User::$cur->id, |
486 | 503 | 'module' => substr($class, 0, strpos($class, '\\')), |
@@ -568,7 +585,8 @@ discard block |
||
568 | 585 | } |
569 | 586 | $info = $relations[$rel]['model']::parseColRecursion($info); |
570 | 587 | } |
571 | - } else { |
|
588 | + } |
|
589 | + else { |
|
572 | 590 | $cols = static::cols(); |
573 | 591 | if (!empty(static::$labels[$info['col']])) { |
574 | 592 | $info['label'] = static::$labels[$info['col']]; |
@@ -576,9 +594,11 @@ discard block |
||
576 | 594 | |
577 | 595 | if (isset(static::$cols[$info['col']])) { |
578 | 596 | $info['colParams'] = static::$cols[$info['col']]; |
579 | - } elseif (isset(static::$cols[str_replace(static::colPrefix(), '', $info['col'])])) { |
|
597 | + } |
|
598 | + elseif (isset(static::$cols[str_replace(static::colPrefix(), '', $info['col'])])) { |
|
580 | 599 | $info['colParams'] = static::$cols[str_replace(static::colPrefix(), '', $info['col'])]; |
581 | - } else { |
|
600 | + } |
|
601 | + else { |
|
582 | 602 | $info['colParams'] = []; |
583 | 603 | } |
584 | 604 | if (!isset($cols[$info['col']]) && isset($cols[static::colPrefix() . $info['col']])) { |
@@ -709,7 +729,8 @@ discard block |
||
709 | 729 | $tableName = static::table(); |
710 | 730 | $colPrefix = static::colPrefix(); |
711 | 731 | $indexes = static::indexes(); |
712 | - } else { |
|
732 | + } |
|
733 | + else { |
|
713 | 734 | $tableName = $this->table(); |
714 | 735 | $colPrefix = $this->colPrefix(); |
715 | 736 | $indexes = $this->indexes(); |
@@ -855,7 +876,8 @@ discard block |
||
855 | 876 | static::$needJoin = []; |
856 | 877 | if (is_array($param)) { |
857 | 878 | App::$cur->db->where($param); |
858 | - } else { |
|
879 | + } |
|
880 | + else { |
|
859 | 881 | if ($col === null) { |
860 | 882 | |
861 | 883 | $col = static::index(); |
@@ -866,7 +888,8 @@ discard block |
||
866 | 888 | $col = static::colPrefix() . $col; |
867 | 889 | } |
868 | 890 | App::$cur->db->where($col, $param); |
869 | - } else { |
|
891 | + } |
|
892 | + else { |
|
870 | 893 | return false; |
871 | 894 | } |
872 | 895 | } |
@@ -898,22 +921,27 @@ discard block |
||
898 | 921 | if (!$query) { |
899 | 922 | return []; |
900 | 923 | } |
901 | - if (!empty($options['where'])) |
|
902 | - $query->where($options['where']); |
|
903 | - if (!empty($options['cols'])) |
|
904 | - $query->cols = $options['cols']; |
|
924 | + if (!empty($options['where'])) { |
|
925 | + $query->where($options['where']); |
|
926 | + } |
|
927 | + if (!empty($options['cols'])) { |
|
928 | + $query->cols = $options['cols']; |
|
929 | + } |
|
905 | 930 | if (!empty($options['group'])) { |
906 | 931 | $query->group($options['group']); |
907 | 932 | } |
908 | 933 | if (!empty($options['having'])) { |
909 | 934 | $query->having($options['having']); |
910 | 935 | } |
911 | - if (!empty($options['order'])) |
|
912 | - $query->order($options['order']); |
|
913 | - if (!empty($options['join'])) |
|
914 | - $query->join($options['join']); |
|
915 | - if (!empty($options['distinct'])) |
|
916 | - $query->distinct = $options['distinct']; |
|
936 | + if (!empty($options['order'])) { |
|
937 | + $query->order($options['order']); |
|
938 | + } |
|
939 | + if (!empty($options['join'])) { |
|
940 | + $query->join($options['join']); |
|
941 | + } |
|
942 | + if (!empty($options['distinct'])) { |
|
943 | + $query->distinct = $options['distinct']; |
|
944 | + } |
|
917 | 945 | |
918 | 946 | foreach (static::$relJoins as $join) { |
919 | 947 | $query->join($join[0], $join[1]); |
@@ -939,13 +967,15 @@ discard block |
||
939 | 967 | } |
940 | 968 | static::$needJoin = []; |
941 | 969 | |
942 | - if (!empty($options['limit'])) |
|
943 | - $limit = (int) $options['limit']; |
|
970 | + if (!empty($options['limit'])) { |
|
971 | + $limit = (int) $options['limit']; |
|
972 | + } |
|
944 | 973 | else { |
945 | 974 | $limit = 0; |
946 | 975 | } |
947 | - if (!empty($options['start'])) |
|
948 | - $start = (int) $options['start']; |
|
976 | + if (!empty($options['start'])) { |
|
977 | + $start = (int) $options['start']; |
|
978 | + } |
|
949 | 979 | else { |
950 | 980 | $start = 0; |
951 | 981 | } |
@@ -954,7 +984,8 @@ discard block |
||
954 | 984 | } |
955 | 985 | if (isset($options['key'])) { |
956 | 986 | $key = $options['key']; |
957 | - } else { |
|
987 | + } |
|
988 | + else { |
|
958 | 989 | $key = static::index(); |
959 | 990 | } |
960 | 991 | try { |
@@ -966,7 +997,8 @@ discard block |
||
966 | 997 | if ($exc->getCode() == '42S02') { |
967 | 998 | static::createTable(); |
968 | 999 | $result = $query->query($queryArr); |
969 | - } else { |
|
1000 | + } |
|
1001 | + else { |
|
970 | 1002 | throw $exc; |
971 | 1003 | } |
972 | 1004 | } |
@@ -1029,7 +1061,8 @@ discard block |
||
1029 | 1061 | $classPath = explode('\\', get_called_class()); |
1030 | 1062 | if (!empty(static::$storage['options']['share'])) { |
1031 | 1063 | $moduleConfig = Config::share($classPath[0]); |
1032 | - } else { |
|
1064 | + } |
|
1065 | + else { |
|
1033 | 1066 | $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false); |
1034 | 1067 | } |
1035 | 1068 | $appType = App::$cur->type; |
@@ -1038,7 +1071,8 @@ discard block |
||
1038 | 1071 | $appType = $options['appType']; |
1039 | 1072 | } |
1040 | 1073 | $storage = !empty($moduleConfig['storage'][$appType]) ? $moduleConfig['storage'][$appType] : []; |
1041 | - } else { |
|
1074 | + } |
|
1075 | + else { |
|
1042 | 1076 | $storage = !empty($moduleConfig['storage']) ? $moduleConfig['storage'] : []; |
1043 | 1077 | } |
1044 | 1078 | if (!empty($storage[$classPath[1]])) { |
@@ -1070,17 +1104,20 @@ discard block |
||
1070 | 1104 | $classPath = explode('\\', get_called_class()); |
1071 | 1105 | if (!empty(static::$storage['options']['share'])) { |
1072 | 1106 | $moduleConfig = Config::share($classPath[0]); |
1073 | - } else { |
|
1107 | + } |
|
1108 | + else { |
|
1074 | 1109 | $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false); |
1075 | 1110 | } |
1076 | 1111 | if (!empty($moduleConfig['storage']['appTypeSplit'])) { |
1077 | 1112 | if (empty($options['appType'])) { |
1078 | 1113 | $appType = App::$cur->type; |
1079 | - } else { |
|
1114 | + } |
|
1115 | + else { |
|
1080 | 1116 | $appType = $options['appType']; |
1081 | 1117 | } |
1082 | 1118 | $storage = !empty($moduleConfig['storage'][$appType]) ? $moduleConfig['storage'][$appType] : []; |
1083 | - } else { |
|
1119 | + } |
|
1120 | + else { |
|
1084 | 1121 | $storage = !empty($moduleConfig['storage']) ? $moduleConfig['storage'] : []; |
1085 | 1122 | } |
1086 | 1123 | if (!empty($storage[$classPath[1]])) { |
@@ -1088,7 +1125,8 @@ discard block |
||
1088 | 1125 | $class = get_called_class(); |
1089 | 1126 | if (isset($options['key'])) { |
1090 | 1127 | $arrayKey = $options['key']; |
1091 | - } else { |
|
1128 | + } |
|
1129 | + else { |
|
1092 | 1130 | $arrayKey = static::index(); |
1093 | 1131 | } |
1094 | 1132 | foreach ($storage[$classPath[1]] as $key => $item) { |
@@ -1101,7 +1139,8 @@ discard block |
||
1101 | 1139 | usort($items, function($a, $b) use($options) { |
1102 | 1140 | if ($a->{$options['order'][0]} > $b->{$options['order'][0]} && $options['order'][1] = 'asc') { |
1103 | 1141 | return 1; |
1104 | - } elseif ($a->{$options['order'][0]} < $b->{$options['order'][0]} && $options['order'][1] = 'asc') { |
|
1142 | + } |
|
1143 | + elseif ($a->{$options['order'][0]} < $b->{$options['order'][0]} && $options['order'][1] = 'asc') { |
|
1105 | 1144 | return -1; |
1106 | 1145 | } |
1107 | 1146 | return 0; |
@@ -1131,12 +1170,14 @@ discard block |
||
1131 | 1170 | $count = 0; |
1132 | 1171 | if (empty($options['appType'])) { |
1133 | 1172 | $appType = App::$cur->type; |
1134 | - } else { |
|
1173 | + } |
|
1174 | + else { |
|
1135 | 1175 | $appType = $options['appType']; |
1136 | 1176 | } |
1137 | 1177 | if (!empty(static::$storage['options']['share'])) { |
1138 | 1178 | $moduleConfig = Config::share($classPath[0]); |
1139 | - } else { |
|
1179 | + } |
|
1180 | + else { |
|
1140 | 1181 | $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false); |
1141 | 1182 | } |
1142 | 1183 | if (!empty($moduleConfig['storage'][$appType][$classPath[1]])) { |
@@ -1149,7 +1190,8 @@ discard block |
||
1149 | 1190 | if (Model::checkWhere($item, $options['where'])) { |
1150 | 1191 | $count++; |
1151 | 1192 | } |
1152 | - } else { |
|
1193 | + } |
|
1194 | + else { |
|
1153 | 1195 | $count++; |
1154 | 1196 | } |
1155 | 1197 | } |
@@ -1185,7 +1227,8 @@ discard block |
||
1185 | 1227 | } |
1186 | 1228 | |
1187 | 1229 | return $result; |
1188 | - } else { |
|
1230 | + } |
|
1231 | + else { |
|
1189 | 1232 | return forward_static_call_array(['Model', 'checkWhere'], array_merge([$item], $where)); |
1190 | 1233 | } |
1191 | 1234 | } |
@@ -1221,20 +1264,24 @@ discard block |
||
1221 | 1264 | if (!empty($options['group'])) { |
1222 | 1265 | static::fixPrefix($options['group'], 'first'); |
1223 | 1266 | } |
1224 | - if (!empty($options['where'])) |
|
1225 | - $query->where($options['where']); |
|
1226 | - if (!empty($options['join'])) |
|
1227 | - $query->join($options['join']); |
|
1267 | + if (!empty($options['where'])) { |
|
1268 | + $query->where($options['where']); |
|
1269 | + } |
|
1270 | + if (!empty($options['join'])) { |
|
1271 | + $query->join($options['join']); |
|
1272 | + } |
|
1228 | 1273 | if (!empty($options['order'])) { |
1229 | 1274 | $query->order($options['order']); |
1230 | 1275 | } |
1231 | - if (!empty($options['limit'])) |
|
1232 | - $limit = (int) $options['limit']; |
|
1276 | + if (!empty($options['limit'])) { |
|
1277 | + $limit = (int) $options['limit']; |
|
1278 | + } |
|
1233 | 1279 | else { |
1234 | 1280 | $limit = 0; |
1235 | 1281 | } |
1236 | - if (!empty($options['start'])) |
|
1237 | - $start = (int) $options['start']; |
|
1282 | + if (!empty($options['start'])) { |
|
1283 | + $start = (int) $options['start']; |
|
1284 | + } |
|
1238 | 1285 | else { |
1239 | 1286 | $start = 0; |
1240 | 1287 | } |
@@ -1270,10 +1317,12 @@ discard block |
||
1270 | 1317 | if (!empty($options['distinct'])) { |
1271 | 1318 | if (is_bool($options['distinct'])) { |
1272 | 1319 | $cols .= 'DISTINCT *'; |
1273 | - } else { |
|
1320 | + } |
|
1321 | + else { |
|
1274 | 1322 | $cols .= "DISTINCT {$options['distinct']}"; |
1275 | 1323 | } |
1276 | - } else { |
|
1324 | + } |
|
1325 | + else { |
|
1277 | 1326 | $cols .= '*'; |
1278 | 1327 | } |
1279 | 1328 | $cols .=') as `count`' . (!empty($options['cols']) ? ',' . $options['cols'] : ''); |
@@ -1292,7 +1341,8 @@ discard block |
||
1292 | 1341 | if (!empty($options['group'])) { |
1293 | 1342 | $count = $result->getArray(); |
1294 | 1343 | return $count; |
1295 | - } else { |
|
1344 | + } |
|
1345 | + else { |
|
1296 | 1346 | $count = $result->fetch(); |
1297 | 1347 | return $count['count']; |
1298 | 1348 | } |
@@ -1312,8 +1362,9 @@ discard block |
||
1312 | 1362 | |
1313 | 1363 | $values = []; |
1314 | 1364 | foreach ($cols as $col => $param) { |
1315 | - if (isset($params[$col])) |
|
1316 | - $values[$col] = $params[$col]; |
|
1365 | + if (isset($params[$col])) { |
|
1366 | + $values[$col] = $params[$col]; |
|
1367 | + } |
|
1317 | 1368 | } |
1318 | 1369 | if (empty($values)) { |
1319 | 1370 | return false; |
@@ -1358,18 +1409,21 @@ discard block |
||
1358 | 1409 | |
1359 | 1410 | if (!empty(static::$storage['options']['share'])) { |
1360 | 1411 | $moduleConfig = Config::share($classPath[0]); |
1361 | - } else { |
|
1412 | + } |
|
1413 | + else { |
|
1362 | 1414 | $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false); |
1363 | 1415 | } |
1364 | 1416 | |
1365 | 1417 | if (!empty($moduleConfig['storage']['appTypeSplit'])) { |
1366 | 1418 | if (empty($options['appType'])) { |
1367 | 1419 | $appType = App::$cur->type; |
1368 | - } else { |
|
1420 | + } |
|
1421 | + else { |
|
1369 | 1422 | $appType = $options['appType']; |
1370 | 1423 | } |
1371 | 1424 | $storage = !empty($moduleConfig['storage'][$appType]) ? $moduleConfig['storage'][$appType] : []; |
1372 | - } else { |
|
1425 | + } |
|
1426 | + else { |
|
1373 | 1427 | $storage = !empty($moduleConfig['storage']) ? $moduleConfig['storage'] : []; |
1374 | 1428 | } |
1375 | 1429 | if (empty($storage[$classPath[1]])) { |
@@ -1382,7 +1436,8 @@ discard block |
||
1382 | 1436 | break; |
1383 | 1437 | } |
1384 | 1438 | } |
1385 | - } else { |
|
1439 | + } |
|
1440 | + else { |
|
1386 | 1441 | $id = !empty($storage['scheme'][$classPath[1]]['ai']) ? $storage['scheme'][$classPath[1]]['ai'] : 1; |
1387 | 1442 | $this->$col = $id; |
1388 | 1443 | $storage['scheme'][$classPath[1]]['ai'] = $id + 1; |
@@ -1390,12 +1445,14 @@ discard block |
||
1390 | 1445 | } |
1391 | 1446 | if (!empty($moduleConfig['storage']['appTypeSplit'])) { |
1392 | 1447 | $moduleConfig['storage'][$appType] = $storage; |
1393 | - } else { |
|
1448 | + } |
|
1449 | + else { |
|
1394 | 1450 | $moduleConfig['storage'] = $storage; |
1395 | 1451 | } |
1396 | 1452 | if (empty(static::$storage['options']['share'])) { |
1397 | 1453 | Config::save('module', $moduleConfig, $classPath[0]); |
1398 | - } else { |
|
1454 | + } |
|
1455 | + else { |
|
1399 | 1456 | Config::save('share', $moduleConfig, $classPath[0]); |
1400 | 1457 | } |
1401 | 1458 | return true; |
@@ -1442,7 +1499,8 @@ discard block |
||
1442 | 1499 | if ($catalog && $catalogParent) { |
1443 | 1500 | if ($catalogParent->tree_path) { |
1444 | 1501 | return $catalogParent->tree_path . $catalogParent->id . '/'; |
1445 | - } else { |
|
1502 | + } |
|
1503 | + else { |
|
1446 | 1504 | return $this->getCatalogTree($catalogParent) . $catalogParent->id . '/'; |
1447 | 1505 | } |
1448 | 1506 | } |
@@ -1458,7 +1516,8 @@ discard block |
||
1458 | 1516 | $category = $categoryModel::get($this->{$categoryModel::index()}); |
1459 | 1517 | if ($category) { |
1460 | 1518 | $this->tree_path = $category->tree_path . $category->pk() . '/'; |
1461 | - } else { |
|
1519 | + } |
|
1520 | + else { |
|
1462 | 1521 | $this->tree_path = '/'; |
1463 | 1522 | } |
1464 | 1523 | } |
@@ -1507,11 +1566,13 @@ discard block |
||
1507 | 1566 | if ($this->get($this->_params[$this->index()])) { |
1508 | 1567 | App::$cur->db->where($this->index(), $this->_params[$this->index()]); |
1509 | 1568 | App::$cur->db->update($this->table(), $values); |
1510 | - } else { |
|
1569 | + } |
|
1570 | + else { |
|
1511 | 1571 | |
1512 | 1572 | $this->_params[$this->index()] = App::$cur->db->insert($this->table(), $values); |
1513 | 1573 | } |
1514 | - } else { |
|
1574 | + } |
|
1575 | + else { |
|
1515 | 1576 | $new = true; |
1516 | 1577 | $this->_params[$this->index()] = App::$cur->db->insert($this->table(), $values); |
1517 | 1578 | } |
@@ -1561,18 +1622,21 @@ discard block |
||
1561 | 1622 | $classPath = explode('\\', get_called_class()); |
1562 | 1623 | if (!empty(static::$storage['options']['share'])) { |
1563 | 1624 | $moduleConfig = Config::share($classPath[0]); |
1564 | - } else { |
|
1625 | + } |
|
1626 | + else { |
|
1565 | 1627 | $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false); |
1566 | 1628 | } |
1567 | 1629 | |
1568 | 1630 | if (!empty($moduleConfig['storage']['appTypeSplit'])) { |
1569 | 1631 | if (empty($options['appType'])) { |
1570 | 1632 | $appType = App::$cur->type; |
1571 | - } else { |
|
1633 | + } |
|
1634 | + else { |
|
1572 | 1635 | $appType = $options['appType']; |
1573 | 1636 | } |
1574 | 1637 | $storage = !empty($moduleConfig['storage'][$appType]) ? $moduleConfig['storage'][$appType] : []; |
1575 | - } else { |
|
1638 | + } |
|
1639 | + else { |
|
1576 | 1640 | $storage = !empty($moduleConfig['storage']) ? $moduleConfig['storage'] : []; |
1577 | 1641 | } |
1578 | 1642 | if (empty($storage[$classPath[1]])) { |
@@ -1587,12 +1651,14 @@ discard block |
||
1587 | 1651 | } |
1588 | 1652 | if (!empty($moduleConfig['storage']['appTypeSplit'])) { |
1589 | 1653 | $moduleConfig['storage'][$appType] = $storage; |
1590 | - } else { |
|
1654 | + } |
|
1655 | + else { |
|
1591 | 1656 | $moduleConfig['storage'] = $storage; |
1592 | 1657 | } |
1593 | 1658 | if (empty(static::$storage['options']['share'])) { |
1594 | 1659 | Config::save('module', $moduleConfig, $classPath[0]); |
1595 | - } else { |
|
1660 | + } |
|
1661 | + else { |
|
1596 | 1662 | Config::save('share', $moduleConfig, $classPath[0]); |
1597 | 1663 | } |
1598 | 1664 | return true; |
@@ -1650,8 +1716,9 @@ discard block |
||
1650 | 1716 | public static function findRelation($col) { |
1651 | 1717 | |
1652 | 1718 | foreach (static::relations() as $relName => $rel) { |
1653 | - if ($rel['col'] == $col) |
|
1654 | - return $relName; |
|
1719 | + if ($rel['col'] == $col) { |
|
1720 | + return $relName; |
|
1721 | + } |
|
1655 | 1722 | } |
1656 | 1723 | return NULL; |
1657 | 1724 | } |
@@ -1706,7 +1773,8 @@ discard block |
||
1706 | 1773 | if ($relation) { |
1707 | 1774 | if (!isset($relation['type'])) { |
1708 | 1775 | $type = 'to'; |
1709 | - } else { |
|
1776 | + } |
|
1777 | + else { |
|
1710 | 1778 | $type = $relation['type']; |
1711 | 1779 | } |
1712 | 1780 | $getCol = null; |
@@ -1722,7 +1790,8 @@ discard block |
||
1722 | 1790 | if (empty($ids)) { |
1723 | 1791 | if (empty($params['count'])) { |
1724 | 1792 | return []; |
1725 | - } else { |
|
1793 | + } |
|
1794 | + else { |
|
1726 | 1795 | return 0; |
1727 | 1796 | } |
1728 | 1797 | } |
@@ -1777,10 +1846,12 @@ discard block |
||
1777 | 1846 | return $relation['model']::getCount($options); |
1778 | 1847 | } |
1779 | 1848 | return 0; |
1780 | - } else { |
|
1849 | + } |
|
1850 | + else { |
|
1781 | 1851 | if (class_exists($relation['model'])) { |
1782 | 1852 | $this->loadedRelations[$name][json_encode($params)] = $relation['model']::$getType($options, $getCol, $getParams); |
1783 | - } else { |
|
1853 | + } |
|
1854 | + else { |
|
1784 | 1855 | $this->loadedRelations[$name][json_encode($params)] = []; |
1785 | 1856 | } |
1786 | 1857 | } |
@@ -1851,7 +1922,8 @@ discard block |
||
1851 | 1922 | static::fixPrefix($fixedName); |
1852 | 1923 | if (isset($this->_params[$fixedName])) { |
1853 | 1924 | return new Value($this, $fixedName); |
1854 | - } elseif (isset($this->_params[$name])) { |
|
1925 | + } |
|
1926 | + elseif (isset($this->_params[$name])) { |
|
1855 | 1927 | return new Value($this, $name); |
1856 | 1928 | } |
1857 | 1929 | return call_user_func_array([$this, 'loadRelation'], array_merge([$name], $params)); |
@@ -1886,7 +1958,8 @@ discard block |
||
1886 | 1958 | static::fixPrefix($fixedName); |
1887 | 1959 | if (isset($this->_params[$fixedName])) { |
1888 | 1960 | return new Value($this, $fixedName); |
1889 | - } elseif ($this->_params[$name]) { |
|
1961 | + } |
|
1962 | + elseif ($this->_params[$name]) { |
|
1890 | 1963 | return new Value($this, $name); |
1891 | 1964 | } |
1892 | 1965 | return null; |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | if (is_bool($options['distinct'])) { |
1272 | 1272 | $cols .= 'DISTINCT *'; |
1273 | 1273 | } else { |
1274 | - $cols .= "DISTINCT {$options['distinct']}"; |
|
1274 | + $cols .= "distinct {$options['distinct']}"; |
|
1275 | 1275 | } |
1276 | 1276 | } else { |
1277 | 1277 | $cols .= '*'; |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | if ($rel['col'] == $col) |
1654 | 1654 | return $relName; |
1655 | 1655 | } |
1656 | - return NULL; |
|
1656 | + return null; |
|
1657 | 1657 | } |
1658 | 1658 | |
1659 | 1659 | /** |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | $options = [$relation['col'], $this->pk()]; |
1766 | 1766 | break; |
1767 | 1767 | default: |
1768 | - if ($this->$relation['col'] === NULL) { |
|
1768 | + if ($this->$relation['col'] === null) { |
|
1769 | 1769 | return null; |
1770 | 1770 | } |
1771 | 1771 | $getType = 'get'; |
@@ -1786,7 +1786,7 @@ discard block |
||
1786 | 1786 | } |
1787 | 1787 | return $this->loadedRelations[$name][json_encode($params)]; |
1788 | 1788 | } |
1789 | - return NULL; |
|
1789 | + return null; |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | /** |
@@ -22,7 +22,7 @@ |
||
22 | 22 | if (!empty($_SESSION['_INJI_MSG'])) { |
23 | 23 | foreach ($_SESSION['_INJI_MSG'] as $key => $msg) { |
24 | 24 | if ($msg['text'] == $text) { |
25 | - $msg['count'] ++; |
|
25 | + $msg['count']++; |
|
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | } |
@@ -52,8 +52,9 @@ |
||
52 | 52 | */ |
53 | 53 | static function get($clean = false) |
54 | 54 | { |
55 | - if (empty($_SESSION['_INJI_MSG'])) |
|
56 | - return []; |
|
55 | + if (empty($_SESSION['_INJI_MSG'])) { |
|
56 | + return []; |
|
57 | + } |
|
57 | 58 | $msgs = $_SESSION['_INJI_MSG']; |
58 | 59 | if ($clean) { |
59 | 60 | $_SESSION['_INJI_MSG'] = []; |
@@ -307,7 +307,7 @@ |
||
307 | 307 | if (is_array($counts)) { |
308 | 308 | $sum = 0; |
309 | 309 | foreach ($counts as $count) { |
310 | - $sum +=$count['count']; |
|
310 | + $sum += $count['count']; |
|
311 | 311 | } |
312 | 312 | return $sum; |
313 | 313 | } |
@@ -86,7 +86,8 @@ discard block |
||
86 | 86 | $user->{$path[0]}->{$path[1]} = $info->value; |
87 | 87 | $relations[$path[0]] = $path[0]; |
88 | 88 | } |
89 | - } else { |
|
89 | + } |
|
90 | + else { |
|
90 | 91 | if (!$user->{$field->userfield}) { |
91 | 92 | $user->{$field->userfield} = $info->value; |
92 | 93 | } |
@@ -142,7 +143,8 @@ discard block |
||
142 | 143 | $user->{$path[0]}->{$path[1]} = $info->value; |
143 | 144 | $relations[$path[0]] = $path[0]; |
144 | 145 | } |
145 | - } else { |
|
146 | + } |
|
147 | + else { |
|
146 | 148 | if (!$user->{$field->userfield}) { |
147 | 149 | $user->{$field->userfield} = $info->value; |
148 | 150 | } |
@@ -262,7 +264,8 @@ discard block |
||
262 | 264 | $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val); |
263 | 265 | } |
264 | 266 | $qstr = 'IN (' . implode(',', $optionValueArr) . ')'; |
265 | - } else { |
|
267 | + } |
|
268 | + else { |
|
266 | 269 | $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue); |
267 | 270 | } |
268 | 271 | $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' . |
@@ -281,7 +284,8 @@ discard block |
||
281 | 284 | $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val); |
282 | 285 | } |
283 | 286 | $qstr = 'IN (' . implode(',', $optionValueArr) . ')'; |
284 | - } else { |
|
287 | + } |
|
288 | + else { |
|
285 | 289 | $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue); |
286 | 290 | } |
287 | 291 | $selectOptions['join'][] = [Ecommerce\Item\Offer\Param::table(), Ecommerce\Item\Offer::index() . ' = ' . 'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer::index() . ' AND ' . |
@@ -306,7 +310,8 @@ discard block |
||
306 | 310 | $first = false; |
307 | 311 | } |
308 | 312 | $selectOptions['where'][] = $where; |
309 | - } elseif (!empty($options['parent'])) { |
|
313 | + } |
|
314 | + elseif (!empty($options['parent'])) { |
|
310 | 315 | $category = \Ecommerce\Category::get($options['parent']); |
311 | 316 | $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE']; |
312 | 317 | } |
@@ -492,7 +497,8 @@ discard block |
||
492 | 497 | foreach ($cartItem->price->offer->bonuses as $bonus) { |
493 | 498 | if ($bonus->limited && $bonus->left <= 0) { |
494 | 499 | continue; |
495 | - } elseif ($bonus->limited && $bonus->left > 0) { |
|
500 | + } |
|
501 | + elseif ($bonus->limited && $bonus->left > 0) { |
|
496 | 502 | $bonus->left -= 1; |
497 | 503 | $bonus->save(); |
498 | 504 | } |
@@ -223,7 +223,7 @@ |
||
223 | 223 | ]; |
224 | 224 | |
225 | 225 | $selectOptions['where'][] = [ |
226 | - [Ecommerce\Item\Offer\Price\Type::index(), NULL, 'is'], |
|
226 | + [Ecommerce\Item\Offer\Price\Type::index(), null, 'is'], |
|
227 | 227 | [ |
228 | 228 | [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '', '=', 'OR'], |
229 | 229 | [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '%|' . \Users\User::$cur->role_id . '|%', 'LIKE', 'OR'], |
@@ -268,7 +268,7 @@ |
||
268 | 268 | $result->send(); |
269 | 269 | } |
270 | 270 | |
271 | - $item->sales ++; |
|
271 | + $item->sales++; |
|
272 | 272 | $item->save(); |
273 | 273 | |
274 | 274 | if (empty($_GET['count'])) |
@@ -22,10 +22,12 @@ discard block |
||
22 | 22 | $user_id = $this->Users->registration($_POST, true); |
23 | 23 | if (!$user_id) { |
24 | 24 | $error = true; |
25 | - } else { |
|
25 | + } |
|
26 | + else { |
|
26 | 27 | $user = Users\User::get($user_id); |
27 | 28 | } |
28 | - } else { |
|
29 | + } |
|
30 | + else { |
|
29 | 31 | $user = Users\User::$cur; |
30 | 32 | } |
31 | 33 | $ids = []; |
@@ -69,7 +71,8 @@ discard block |
||
69 | 71 | if ($deliverys && empty($deliverys[$_POST['delivery']])) { |
70 | 72 | $error = 1; |
71 | 73 | Msg::add('Выберите способ доставки', 'danger'); |
72 | - } elseif ($deliverys && !empty($deliverys[$_POST['delivery']])) { |
|
74 | + } |
|
75 | + elseif ($deliverys && !empty($deliverys[$_POST['delivery']])) { |
|
73 | 76 | $cart->delivery_id = $_POST['delivery']; |
74 | 77 | foreach ($deliverys[$cart->delivery_id]->fields as $field) { |
75 | 78 | if (empty($_POST['deliveryFields'][$field->id]) && $field->required) { |
@@ -81,10 +84,12 @@ discard block |
||
81 | 84 | if ($payTypes && (empty($_POST['payType']) || empty($payTypes[$_POST['payType']]))) { |
82 | 85 | $error = 1; |
83 | 86 | Msg::add('Выберите способ оплаты', 'danger'); |
84 | - } elseif ($payTypes && !empty($payTypes[$_POST['payType']])) { |
|
87 | + } |
|
88 | + elseif ($payTypes && !empty($payTypes[$_POST['payType']])) { |
|
85 | 89 | $payType = $payTypes[$_POST['payType']]; |
86 | 90 | $cart->paytype_id = $payType->id; |
87 | - } else { |
|
91 | + } |
|
92 | + else { |
|
88 | 93 | $payType = null; |
89 | 94 | } |
90 | 95 | foreach (\Ecommerce\UserAdds\Field::getList() as $field) { |
@@ -98,10 +103,12 @@ discard block |
||
98 | 103 | if (!$userCard) { |
99 | 104 | $error = true; |
100 | 105 | Msg::add('Такой карты не существует', 'danger'); |
101 | - } elseif ($userCard->user_id != $user->id) { |
|
106 | + } |
|
107 | + elseif ($userCard->user_id != $user->id) { |
|
102 | 108 | $error = true; |
103 | 109 | Msg::add('Это не ваша карта', 'danger'); |
104 | - } else { |
|
110 | + } |
|
111 | + else { |
|
105 | 112 | $cart->card_item_id = $userCard->id; |
106 | 113 | } |
107 | 114 | } |
@@ -272,10 +279,12 @@ discard block |
||
272 | 279 | $item->sales ++; |
273 | 280 | $item->save(); |
274 | 281 | |
275 | - if (empty($_GET['count'])) |
|
276 | - $count = 1; |
|
277 | - else |
|
278 | - $count = (float) $_GET['count']; |
|
282 | + if (empty($_GET['count'])) { |
|
283 | + $count = 1; |
|
284 | + } |
|
285 | + else { |
|
286 | + $count = (float) $_GET['count']; |
|
287 | + } |
|
279 | 288 | |
280 | 289 | $cart = $this->ecommerce->getCurCart(); |
281 | 290 | $stages = Ecommerce\Cart\Stage::getList(); |
@@ -72,12 +72,12 @@ |
||
72 | 72 | { |
73 | 73 | $warehouse = Offer\Warehouse::get([['count', '0', '>'], ['item_offer_id', $this->id]]); |
74 | 74 | if ($warehouse) { |
75 | - $warehouse->count +=(float) $count; |
|
75 | + $warehouse->count += (float) $count; |
|
76 | 76 | $warehouse->save(); |
77 | 77 | } else { |
78 | 78 | $warehouse = Offer\Warehouse::get([['item_offer_id', $this->id]]); |
79 | 79 | if ($warehouse) { |
80 | - $warehouse->count +=(float) $count; |
|
80 | + $warehouse->count += (float) $count; |
|
81 | 81 | $warehouse->save(); |
82 | 82 | } |
83 | 83 | } |
@@ -89,7 +89,8 @@ |
||
89 | 89 | if ($warehouse) { |
90 | 90 | $warehouse->count +=(float) $count; |
91 | 91 | $warehouse->save(); |
92 | - } else { |
|
92 | + } |
|
93 | + else { |
|
93 | 94 | $warehouse = Offer\Warehouse::get([['item_offer_id', $this->id]]); |
94 | 95 | if ($warehouse) { |
95 | 96 | $warehouse->count +=(float) $count; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | static $forms = [ |
40 | 40 | 'manager' => [ |
41 | 41 | 'map' => [ |
42 | - ['price', 'currency_id',], |
|
42 | + ['price', 'currency_id', ], |
|
43 | 43 | ['item_offer_price_type_id', 'item_offer_id'] |
44 | 44 | ] |
45 | 45 | ]]; |
@@ -133,7 +133,7 @@ |
||
133 | 133 | foreach ($cart->cartItems as $cartItem) { |
134 | 134 | $isset = false; |
135 | 135 | foreach ($cItems as $key => $cItem) { |
136 | - if (!($cItem['item_id'] == $cartItem->item_id )) { |
|
136 | + if (!($cItem['item_id'] == $cartItem->item_id)) { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | 139 | $isset = true; |
@@ -15,6 +15,9 @@ |
||
15 | 15 | { |
16 | 16 | public $xml = null; |
17 | 17 | |
18 | + /** |
|
19 | + * @param \SimpleXMLElement $xml |
|
20 | + */ |
|
18 | 21 | public function __construct($xml) |
19 | 22 | { |
20 | 23 | $this->xml = $xml; |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | $payed = true; |
48 | 48 | $date = new \DateTime((string) $reqs['Дата оплаты по 1С']); |
49 | 49 | $cart->payed_date = $date->format('Y-m-d H:i:s'); |
50 | - } elseif ( |
|
50 | + } |
|
51 | + elseif ( |
|
51 | 52 | (!empty($reqs['Отменен']) && $reqs['Отменен'] == 'true') || |
52 | 53 | (!empty($reqs['Дата оплаты по 1С']) && $reqs['Дата оплаты по 1С'] == 'T')) { |
53 | 54 | $cancel = true; |
@@ -57,10 +58,12 @@ discard block |
||
57 | 58 | $cart->payed = $payed; |
58 | 59 | if ($payed && $cart->cart_status_id == 5) { |
59 | 60 | |
60 | - } elseif ($payed && $cart->cart_status_id == 3) { |
|
61 | + } |
|
62 | + elseif ($payed && $cart->cart_status_id == 3) { |
|
61 | 63 | $cart->cart_status_id = 5; |
62 | 64 | $cart->save(); |
63 | - } elseif ($cancel && $cart->cart_status_id == 3) { |
|
65 | + } |
|
66 | + elseif ($cancel && $cart->cart_status_id == 3) { |
|
64 | 67 | $cart->cart_status_id = 4; |
65 | 68 | } |
66 | 69 | if ($cart->warehouse_block && !$payed && !$cancel && !empty($reqs['Проведен']) && $reqs['Проведен'] == 'true') { |
@@ -104,7 +107,8 @@ discard block |
||
104 | 107 | $itemPrice = number_format((string) $item->ЦенаЗаЕдиницу, 2, '.', ''); |
105 | 108 | if (!empty($pricesByPrice[$itemPrice])) { |
106 | 109 | $price = $pricesByPrice[$itemPrice]; |
107 | - } else { |
|
110 | + } |
|
111 | + else { |
|
108 | 112 | $rolePrice = 0; |
109 | 113 | foreach ($siteItem->prices as $priceId => $itemPrice) { |
110 | 114 | if (!$itemPrice->type->cipt_roles) { |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $this->loadLib($rLib); |
26 | 26 | } |
27 | 27 | } |
28 | - if (!empty($className::$files['css']) && (!isset($options['loadCss']) || $options['loadCss'] )) { |
|
28 | + if (!empty($className::$files['css']) && (!isset($options['loadCss']) || $options['loadCss'])) { |
|
29 | 29 | foreach ($className::$files['css'] as $file) { |
30 | 30 | if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) { |
31 | 31 | App::$cur->view->customAsset('css', $file, $libName); |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | foreach ($className::$files['css'] as $file) { |
29 | 29 | if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) { |
30 | 30 | App::$cur->view->customAsset('css', $file, $libName); |
31 | - } else { |
|
31 | + } |
|
32 | + else { |
|
32 | 33 | App::$cur->view->customAsset('css', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName); |
33 | 34 | } |
34 | 35 | } |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | foreach ($className::$files['js'] as $file) { |
38 | 39 | if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) { |
39 | 40 | App::$cur->view->customAsset('js', $file, $libName); |
40 | - } else { |
|
41 | + } |
|
42 | + else { |
|
41 | 43 | App::$cur->view->customAsset('js', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName); |
42 | 44 | } |
43 | 45 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $this->model->_params[$modelName::index()] = 0; |
74 | 74 | } |
75 | 75 | $relOptions['model']::fixPrefix($relOptions['col']); |
76 | - $inputs[$col] = new ActiveForm(new $relOptions['model']([ $relOptions['col'] => &$this->model->_params[$modelName::index()]]), $colPath[2]); |
|
76 | + $inputs[$col] = new ActiveForm(new $relOptions['model']([$relOptions['col'] => &$this->model->_params[$modelName::index()]]), $colPath[2]); |
|
77 | 77 | } |
78 | 78 | $inputs[$col]->parent = $this; |
79 | 79 | } elseif (!empty($modelName::$cols[$col])) { |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | if (is_string($form)) { |
36 | 36 | $this->formName = $form; |
37 | 37 | } |
38 | - } else { |
|
38 | + } |
|
39 | + else { |
|
39 | 40 | $this->model = $model; |
40 | 41 | $this->modelName = get_class($model); |
41 | 42 | if (is_array($form)) { |
@@ -43,7 +44,8 @@ discard block |
||
43 | 44 | throw new \Exception('empty form'); |
44 | 45 | } |
45 | 46 | $this->form = $form; |
46 | - } else { |
|
47 | + } |
|
48 | + else { |
|
47 | 49 | $this->formName = $form; |
48 | 50 | $this->form = \App::$cur->ui->getModelForm($this->modelName, $form); |
49 | 51 | if (empty($this->form)) { |
@@ -57,9 +59,11 @@ discard block |
||
57 | 59 | |
58 | 60 | if (!empty($this->form['name'])) { |
59 | 61 | $this->header = $this->form['name']; |
60 | - } elseif (!empty($modeName::$objectName)) { |
|
62 | + } |
|
63 | + elseif (!empty($modeName::$objectName)) { |
|
61 | 64 | $this->header = $modeName::$objectName; |
62 | - } else { |
|
65 | + } |
|
66 | + else { |
|
63 | 67 | $this->header = $this->modelName; |
64 | 68 | } |
65 | 69 | } |
@@ -76,7 +80,8 @@ discard block |
||
76 | 80 | $colPath = explode(':', $col); |
77 | 81 | if ($this->model->{$colPath[1]}) { |
78 | 82 | $inputs[$col] = new ActiveForm($this->model->{$colPath[1]}, $colPath[2]); |
79 | - } else { |
|
83 | + } |
|
84 | + else { |
|
80 | 85 | $relOptions = $modelName::getRelation($colPath[1]); |
81 | 86 | if (!isset($this->model->_params[$modelName::index()])) { |
82 | 87 | $this->model->_params[$modelName::index()] = 0; |
@@ -85,7 +90,8 @@ discard block |
||
85 | 90 | $inputs[$col] = new ActiveForm(new $relOptions['model']([ $relOptions['col'] => &$this->model->_params[$modelName::index()]]), $colPath[2]); |
86 | 91 | } |
87 | 92 | $inputs[$col]->parent = $this; |
88 | - } elseif (!empty($modelName::$cols[$col])) { |
|
93 | + } |
|
94 | + elseif (!empty($modelName::$cols[$col])) { |
|
89 | 95 | $inputs[$col] = $modelName::$cols[$col]; |
90 | 96 | } |
91 | 97 | } |
@@ -108,7 +114,8 @@ discard block |
||
108 | 114 | $text = 'Новый элемент был успешно добавлен'; |
109 | 115 | \Msg::add($text, 'success'); |
110 | 116 | \Msg::show(); |
111 | - } else { |
|
117 | + } |
|
118 | + else { |
|
112 | 119 | $presets = !empty($this->form['preset']) ? $this->form['preset'] : []; |
113 | 120 | if (!empty($this->form['userGroupPreset'][\Users\User::$cur->group_id])) { |
114 | 121 | $presets = array_merge($presets, $this->form['userGroupPreset'][\Users\User::$cur->group_id]); |
@@ -145,12 +152,14 @@ discard block |
||
145 | 152 | foreach ($presets as $col => $preset) { |
146 | 153 | if (!empty($preset['value'])) { |
147 | 154 | $this->model->$col = $preset['value']; |
148 | - } elseif (!empty($preset['userCol'])) { |
|
155 | + } |
|
156 | + elseif (!empty($preset['userCol'])) { |
|
149 | 157 | if (strpos($preset['userCol'], ':')) { |
150 | 158 | $rel = substr($preset['userCol'], 0, strpos($preset['userCol'], ':')); |
151 | 159 | $param = substr($preset['userCol'], strpos($preset['userCol'], ':') + 1); |
152 | 160 | $this->model->$col = \Users\User::$cur->$rel->$param; |
153 | - } else { |
|
161 | + } |
|
162 | + else { |
|
154 | 163 | $this->model->$col = \Users\User::$cur->{$preset['userCol']}; |
155 | 164 | } |
156 | 165 | } |
@@ -158,7 +167,8 @@ discard block |
||
158 | 167 | if (!$this->parent) { |
159 | 168 | if (!empty($this->form['successText'])) { |
160 | 169 | $text = $this->form['successText']; |
161 | - } else { |
|
170 | + } |
|
171 | + else { |
|
162 | 172 | $text = $this->model->pk() ? 'Изменения были успешно сохранены' : 'Новый элемент был успешно добавлен'; |
163 | 173 | } |
164 | 174 | \Msg::add($text, 'success'); |
@@ -170,7 +180,8 @@ discard block |
||
170 | 180 | } |
171 | 181 | if ($ajax) { |
172 | 182 | \Msg::show(); |
173 | - } elseif (!empty($_GET['redirectUrl'])) { |
|
183 | + } |
|
184 | + elseif (!empty($_GET['redirectUrl'])) { |
|
174 | 185 | \Tools::redirect($_GET['redirectUrl'] . (!empty($_GET['dataManagerHash']) ? '#' . $_GET['dataManagerHash'] : '')); |
175 | 186 | } |
176 | 187 | $successId = $this->model->pk(); |
@@ -196,7 +207,8 @@ discard block |
||
196 | 207 | public function drawCol($colName, $options, $form, $params = []) { |
197 | 208 | if (is_object($options)) { |
198 | 209 | $options->draw(); |
199 | - } else { |
|
210 | + } |
|
211 | + else { |
|
200 | 212 | $inputClassName = '\Ui\ActiveForm\Input\\' . ucfirst($options['type']); |
201 | 213 | $input = new $inputClassName(); |
202 | 214 | $input->form = $form; |
@@ -223,7 +235,8 @@ discard block |
||
223 | 235 | case 'method': |
224 | 236 | if (!empty($inputParams['params'])) { |
225 | 237 | $values = call_user_func_array([\App::$cur->$inputParams['module'], $inputParams['method']], $inputParams['params']); |
226 | - } else { |
|
238 | + } |
|
239 | + else { |
|
227 | 240 | $values = \App::$cur->$inputParams['module']->$inputParams['method'](); |
228 | 241 | } |
229 | 242 | break; |
@@ -254,7 +267,8 @@ discard block |
||
254 | 267 | } |
255 | 268 | if (!empty($params['noEmptyValue'])) { |
256 | 269 | $values = []; |
257 | - } else { |
|
270 | + } |
|
271 | + else { |
|
258 | 272 | $values = [0 => 'Не задано']; |
259 | 273 | } |
260 | 274 | foreach ($items as $key => $item) { |
@@ -265,10 +279,12 @@ discard block |
||
265 | 279 | $values[$key] = $inputParams['showCol']['class']::{$inputParams['showCol']['method']}($item); |
266 | 280 | break; |
267 | 281 | } |
268 | - } else { |
|
282 | + } |
|
283 | + else { |
|
269 | 284 | $values[$key] = $item->$inputParams['showCol']; |
270 | 285 | } |
271 | - } else { |
|
286 | + } |
|
287 | + else { |
|
272 | 288 | $values[$key] = $item->name(); |
273 | 289 | } |
274 | 290 | } |