@@ -216,6 +216,7 @@ |
||
216 | 216 | * @param $number Integer Число на основе которого нужно сформировать окончание |
217 | 217 | * @param $endingsArray Array Массив слов или окончаний для чисел (1, 4, 5), |
218 | 218 | * например array('яблоко', 'яблока', 'яблок') |
219 | + * @param string[] $endingArray |
|
219 | 220 | * @return String |
220 | 221 | */ |
221 | 222 | static function getNumEnding($number, $endingArray) |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | foreach ($params as $key => $param) { |
42 | 42 | if ($param != '') { |
43 | 43 | $params[$key] = urldecode($param); |
44 | - } else { |
|
44 | + } |
|
45 | + else { |
|
45 | 46 | unset($params[$key]); |
46 | 47 | } |
47 | 48 | } |
@@ -55,8 +56,9 @@ discard block |
||
55 | 56 | * @return boolean |
56 | 57 | */ |
57 | 58 | public static function createDir($path) { |
58 | - if (file_exists($path)) |
|
59 | - return true; |
|
59 | + if (file_exists($path)) { |
|
60 | + return true; |
|
61 | + } |
|
60 | 62 | |
61 | 63 | $path = explode('/', $path); |
62 | 64 | $cur = ''; |
@@ -100,10 +102,12 @@ discard block |
||
100 | 102 | return false; |
101 | 103 | } |
102 | 104 | |
103 | - if ($img_width / $max_width > $img_height / $max_height) |
|
104 | - $separator = $img_width / $max_width; |
|
105 | - else |
|
106 | - $separator = $img_height / $max_height; |
|
105 | + if ($img_width / $max_width > $img_height / $max_height) { |
|
106 | + $separator = $img_width / $max_width; |
|
107 | + } |
|
108 | + else { |
|
109 | + $separator = $img_height / $max_height; |
|
110 | + } |
|
107 | 111 | |
108 | 112 | if ($crop === true || $crop == 'q') { |
109 | 113 | if ($img_width > $img_height) { |
@@ -112,7 +116,8 @@ discard block |
||
112 | 116 | $img_width = $img_height; |
113 | 117 | $new_width = $max_width; |
114 | 118 | $new_height = $max_height; |
115 | - } else { |
|
119 | + } |
|
120 | + else { |
|
116 | 121 | $imgX = 0; |
117 | 122 | $imgY = floor(( $img_height - $img_width ) / 2); |
118 | 123 | $img_height = $img_width; |
@@ -122,7 +127,8 @@ discard block |
||
122 | 127 | if ($pos == 'top') { |
123 | 128 | $imgY = 0; |
124 | 129 | } |
125 | - } elseif ($crop == 'c') { |
|
130 | + } |
|
131 | + elseif ($crop == 'c') { |
|
126 | 132 | //Вычисляем некий коэффициент масштабирования |
127 | 133 | $k1 = $img_width / $max_width; |
128 | 134 | $k2 = $img_height / $max_height; |
@@ -138,10 +144,12 @@ discard block |
||
138 | 144 | $imgX = (int) (($ow / 2) - ($img_width / 2) ); |
139 | 145 | if ($pos == 'center') { |
140 | 146 | $imgY = (int) (($oh / 2) - ($img_height / 2)); |
141 | - } else { |
|
147 | + } |
|
148 | + else { |
|
142 | 149 | $imgY = 0; |
143 | 150 | } |
144 | - } else { |
|
151 | + } |
|
152 | + else { |
|
145 | 153 | $imgX = 0; |
146 | 154 | $imgY = 0; |
147 | 155 | $new_width = floor($img_width / $separator); |
@@ -156,7 +164,8 @@ discard block |
||
156 | 164 | if ($img_type == 'jpeg') { |
157 | 165 | imageinterlace($new_res, 1); // чересстрочное формирование изображение |
158 | 166 | imagejpeg($new_res, $img_path, 85); |
159 | - } else { |
|
167 | + } |
|
168 | + else { |
|
160 | 169 | $imageX = "image{$img_type}"; |
161 | 170 | $imageX($new_res, $img_path); |
162 | 171 | } |
@@ -207,7 +216,8 @@ discard block |
||
207 | 216 | } |
208 | 217 | if (!headers_sent()) { |
209 | 218 | header("Location: {$href}"); |
210 | - } else { |
|
219 | + } |
|
220 | + else { |
|
211 | 221 | echo '\'"><script>window.location="' . $href . '";</script>'; |
212 | 222 | } |
213 | 223 | exit("Перенаправление на: <a href = '{$href}'>{$href}</a>"); |
@@ -224,7 +234,8 @@ discard block |
||
224 | 234 | $number = $number % 100; |
225 | 235 | if ($number >= 11 && $number <= 19) { |
226 | 236 | $ending = $endingArray[2]; |
227 | - } else { |
|
237 | + } |
|
238 | + else { |
|
228 | 239 | $i = $number % 10; |
229 | 240 | switch ($i) { |
230 | 241 | case (1): $ending = $endingArray[0]; |
@@ -366,7 +377,8 @@ discard block |
||
366 | 377 | } |
367 | 378 | if (is_dir($from . '/' . $file)) { |
368 | 379 | self::copyFiles($from . '/' . $file, $to . '/' . $file); |
369 | - } else { |
|
380 | + } |
|
381 | + else { |
|
370 | 382 | copy($from . '/' . $file, $to . '/' . $file); |
371 | 383 | } |
372 | 384 | } |
@@ -29,6 +29,9 @@ discard block |
||
29 | 29 | public $params = []; |
30 | 30 | public $distinct = false; |
31 | 31 | |
32 | + /** |
|
33 | + * @param $instance |
|
34 | + */ |
|
32 | 35 | function __construct($instance = null) |
33 | 36 | { |
34 | 37 | if (!$instance) { |
@@ -47,6 +50,9 @@ discard block |
||
47 | 50 | return $this->curInstance->pdo->lastInsertId(); |
48 | 51 | } |
49 | 52 | |
53 | + /** |
|
54 | + * @param string $table |
|
55 | + */ |
|
50 | 56 | public function select($table) |
51 | 57 | { |
52 | 58 | $this->operation = 'SELECT'; |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | public function __construct($instance = null) { |
35 | 35 | if (!$instance) { |
36 | 36 | $this->curInstance = \App::$cur->db->connection; |
37 | - } else { |
|
37 | + } |
|
38 | + else { |
|
38 | 39 | $this->curInstance = $instance; |
39 | 40 | } |
40 | 41 | } |
@@ -79,7 +80,8 @@ discard block |
||
79 | 80 | public function cols($cols) { |
80 | 81 | if (is_array($cols)) { |
81 | 82 | $this->cols = array_merge($this->cols, array_values($cols)); |
82 | - } else { |
|
83 | + } |
|
84 | + else { |
|
83 | 85 | $this->cols[] = $cols; |
84 | 86 | } |
85 | 87 | } |
@@ -90,11 +92,13 @@ discard block |
||
90 | 92 | if (!is_array($item)) { |
91 | 93 | call_user_func_array(array($this, 'join'), $table); |
92 | 94 | break; |
93 | - } else { |
|
95 | + } |
|
96 | + else { |
|
94 | 97 | $this->join($item); |
95 | 98 | } |
96 | 99 | } |
97 | - } else { |
|
100 | + } |
|
101 | + else { |
|
98 | 102 | $this->join[] = [$table, $where, $type, $alias]; |
99 | 103 | } |
100 | 104 | } |
@@ -102,7 +106,8 @@ discard block |
||
102 | 106 | public function where($where = '', $value = '', $operation = false, $concatenation = 'AND') { |
103 | 107 | if (!is_array($where)) { |
104 | 108 | $this->where[] = [$where, $value, $operation, $concatenation]; |
105 | - } else { |
|
109 | + } |
|
110 | + else { |
|
106 | 111 | $this->where[] = $where; |
107 | 112 | } |
108 | 113 | } |
@@ -110,7 +115,8 @@ discard block |
||
110 | 115 | public function having($where = '', $value = '', $operation = false, $concatenation = 'AND') { |
111 | 116 | if (!is_array($where)) { |
112 | 117 | $this->having[] = [$where, $value, $operation, $concatenation]; |
113 | - } else { |
|
118 | + } |
|
119 | + else { |
|
114 | 120 | $this->having[] = $where; |
115 | 121 | } |
116 | 122 | } |
@@ -124,13 +130,17 @@ discard block |
||
124 | 130 | |
125 | 131 | if (!is_array($order)) { |
126 | 132 | $this->order[] = "{$order} {$type}"; |
127 | - } else { |
|
128 | - foreach ($order as $item) |
|
129 | - if (!is_array($item)) { |
|
133 | + } |
|
134 | + else { |
|
135 | + foreach ($order as $item) { |
|
136 | + if (!is_array($item)) { |
|
130 | 137 | call_user_func_array(array($this, 'order'), $order); |
138 | + } |
|
131 | 139 | break; |
132 | - } else |
|
133 | - $this->order($item); |
|
140 | + } |
|
141 | + else { |
|
142 | + $this->order($item); |
|
143 | + } |
|
134 | 144 | } |
135 | 145 | } |
136 | 146 | |
@@ -138,8 +148,9 @@ discard block |
||
138 | 148 | $start = intval($start); |
139 | 149 | $len = intval($len); |
140 | 150 | $this->limit = "LIMIT {$start}"; |
141 | - if ($len !== 0) |
|
142 | - $this->limit .= ",{$len}"; |
|
151 | + if ($len !== 0) { |
|
152 | + $this->limit .= ",{$len}"; |
|
153 | + } |
|
143 | 154 | } |
144 | 155 | |
145 | 156 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') { |
@@ -149,12 +160,15 @@ discard block |
||
149 | 160 | foreach ($joins as $joinAr) { |
150 | 161 | $join .= call_user_func_array([$this, 'buildJoin'], $joinAr); |
151 | 162 | } |
152 | - } else { |
|
163 | + } |
|
164 | + else { |
|
153 | 165 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
154 | - if ($alias) |
|
155 | - $join .= " AS `{$alias}`"; |
|
156 | - if ($where) |
|
157 | - $join .= " ON {$where}"; |
|
166 | + if ($alias) { |
|
167 | + $join .= " AS `{$alias}`"; |
|
168 | + } |
|
169 | + if ($where) { |
|
170 | + $join .= " ON {$where}"; |
|
171 | + } |
|
158 | 172 | } |
159 | 173 | return $join; |
160 | 174 | } |
@@ -173,13 +187,16 @@ discard block |
||
173 | 187 | $operation = '='; |
174 | 188 | } |
175 | 189 | |
176 | - if ($concatenation === false) |
|
177 | - $concatenation = 'AND'; |
|
178 | - elseif ($concatenation === true) |
|
179 | - $concatenation = ''; |
|
190 | + if ($concatenation === false) { |
|
191 | + $concatenation = 'AND'; |
|
192 | + } |
|
193 | + elseif ($concatenation === true) { |
|
194 | + $concatenation = ''; |
|
195 | + } |
|
180 | 196 | |
181 | - if ($this->whereString == NULL) |
|
182 | - $this->whereString = ' WHERE '; |
|
197 | + if ($this->whereString == NULL) { |
|
198 | + $this->whereString = ' WHERE '; |
|
199 | + } |
|
183 | 200 | |
184 | 201 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
185 | 202 | if (is_array($value)) { |
@@ -190,25 +207,31 @@ discard block |
||
190 | 207 | } |
191 | 208 | if (is_string($item)) { |
192 | 209 | $newValue .='"' . $item . '"'; |
193 | - } else { |
|
210 | + } |
|
211 | + else { |
|
194 | 212 | $newValue .=$item; |
195 | 213 | } |
196 | 214 | } |
197 | 215 | $value = '(' . $newValue . ')'; |
198 | - } elseif (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
216 | + } |
|
217 | + elseif (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
199 | 218 | $value = "({$value})"; |
200 | - } elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
219 | + } |
|
220 | + elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
201 | 221 | $value = "\"{$value}\""; |
202 | 222 | } |
203 | - } elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
223 | + } |
|
224 | + elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
204 | 225 | $this->params[] = $value; |
205 | 226 | $value = "?"; |
206 | 227 | } |
207 | 228 | |
208 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
209 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
210 | - else |
|
211 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
229 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
230 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
231 | + } |
|
232 | + else { |
|
233 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
234 | + } |
|
212 | 235 | } |
213 | 236 | else { |
214 | 237 | $i = -1; |
@@ -218,23 +241,27 @@ discard block |
||
218 | 241 | if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(' && $this->whereString != 'WHERE ') { |
219 | 242 | if (!isset($item[3])) { |
220 | 243 | $concatenation = 'AND'; |
221 | - } else { |
|
244 | + } |
|
245 | + else { |
|
222 | 246 | $concatenation = $item[3]; |
223 | 247 | } |
224 | 248 | |
225 | 249 | $this->whereString .= "{$concatenation} "; |
226 | 250 | } |
227 | 251 | |
228 | - if ($this->whereString != NULL) |
|
229 | - $this->whereString .= '('; |
|
230 | - else |
|
231 | - $this->whereString = 'WHERE ('; |
|
252 | + if ($this->whereString != NULL) { |
|
253 | + $this->whereString .= '('; |
|
254 | + } |
|
255 | + else { |
|
256 | + $this->whereString = 'WHERE ('; |
|
257 | + } |
|
232 | 258 | } |
233 | 259 | |
234 | 260 | if (!is_array($item)) { |
235 | 261 | call_user_func_array(array($this, 'buildWhere'), $where); |
236 | 262 | break; |
237 | - } else { |
|
263 | + } |
|
264 | + else { |
|
238 | 265 | $this->buildWhere($item); |
239 | 266 | } |
240 | 267 | if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
@@ -257,13 +284,16 @@ discard block |
||
257 | 284 | if (empty($operation)) { |
258 | 285 | $operation = '='; |
259 | 286 | } |
260 | - if ($concatenation === false) |
|
261 | - $concatenation = 'AND'; |
|
262 | - elseif ($concatenation === true) |
|
263 | - $concatenation = ''; |
|
287 | + if ($concatenation === false) { |
|
288 | + $concatenation = 'AND'; |
|
289 | + } |
|
290 | + elseif ($concatenation === true) { |
|
291 | + $concatenation = ''; |
|
292 | + } |
|
264 | 293 | |
265 | - if ($this->havingString == NULL) |
|
266 | - $this->havingString = ' HAVING '; |
|
294 | + if ($this->havingString == NULL) { |
|
295 | + $this->havingString = ' HAVING '; |
|
296 | + } |
|
267 | 297 | |
268 | 298 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
269 | 299 | if (is_array($value)) { |
@@ -274,25 +304,31 @@ discard block |
||
274 | 304 | } |
275 | 305 | if (is_string($item)) { |
276 | 306 | $newValue .='"' . $item . '"'; |
277 | - } else { |
|
307 | + } |
|
308 | + else { |
|
278 | 309 | $newValue .=$item; |
279 | 310 | } |
280 | 311 | } |
281 | 312 | $value = '(' . $newValue . ')'; |
282 | - } elseif (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
313 | + } |
|
314 | + elseif (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
283 | 315 | $value = "({$value})"; |
284 | - } elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
316 | + } |
|
317 | + elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
285 | 318 | $value = "\"{$value}\""; |
286 | 319 | } |
287 | - } elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
320 | + } |
|
321 | + elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
288 | 322 | $this->params[] = $value; |
289 | 323 | $value = "?"; |
290 | 324 | } |
291 | 325 | |
292 | - if (substr($this->havingString, -1, 1) == '(' || substr($this->havingString, -2, 2) == 'E ') |
|
293 | - $this->havingString .= " {$where} {$operation} {$value} "; |
|
294 | - else |
|
295 | - $this->havingString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
326 | + if (substr($this->havingString, -1, 1) == '(' || substr($this->havingString, -2, 2) == 'E ') { |
|
327 | + $this->havingString .= " {$where} {$operation} {$value} "; |
|
328 | + } |
|
329 | + else { |
|
330 | + $this->havingString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
331 | + } |
|
296 | 332 | } |
297 | 333 | else { |
298 | 334 | $i = -1; |
@@ -302,23 +338,27 @@ discard block |
||
302 | 338 | if ($this->havingString != NULL && substr($this->havingString, -1, 1) != '(' && $this->havingString != 'HAVING ') { |
303 | 339 | if (!isset($item[3])) { |
304 | 340 | $concatenation = 'AND'; |
305 | - } else { |
|
341 | + } |
|
342 | + else { |
|
306 | 343 | $concatenation = $item[3]; |
307 | 344 | } |
308 | 345 | |
309 | 346 | $this->havingString .= "{$concatenation} "; |
310 | 347 | } |
311 | 348 | |
312 | - if ($this->havingString != NULL) |
|
313 | - $this->havingString .= '('; |
|
314 | - else |
|
315 | - $this->havingString = 'HAVING ('; |
|
349 | + if ($this->havingString != NULL) { |
|
350 | + $this->havingString .= '('; |
|
351 | + } |
|
352 | + else { |
|
353 | + $this->havingString = 'HAVING ('; |
|
354 | + } |
|
316 | 355 | } |
317 | 356 | |
318 | 357 | if (!is_array($item)) { |
319 | 358 | call_user_func_array(array($this, 'buildHaving'), $where); |
320 | 359 | break; |
321 | - } else { |
|
360 | + } |
|
361 | + else { |
|
322 | 362 | $this->buildHaving($item); |
323 | 363 | } |
324 | 364 | if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
@@ -376,7 +416,8 @@ discard block |
||
376 | 416 | if (!in_array($item, array('CURRENT_TIMESTAMP'))) { |
377 | 417 | $this->params[] = $item; |
378 | 418 | $updates[] = "`{$key}` = ?"; |
379 | - } else { |
|
419 | + } |
|
420 | + else { |
|
380 | 421 | $updates[] = "`{$key}` = {$item}"; |
381 | 422 | } |
382 | 423 | } |
@@ -83,6 +83,9 @@ |
||
83 | 83 | return null; |
84 | 84 | } |
85 | 85 | |
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
86 | 89 | function colName() |
87 | 90 | { |
88 | 91 | return "{$this->activeForm->requestFormName}[{$this->activeForm->modelName}][{$this->colName}]"; |
@@ -329,6 +329,9 @@ |
||
329 | 329 | return $rows; |
330 | 330 | } |
331 | 331 | |
332 | + /** |
|
333 | + * @param DataManager $dataManager |
|
334 | + */ |
|
332 | 335 | public static function drawCol($item, $colName, $params = [], $dataManager = null, $originalCol = '', $originalItem = null) |
333 | 336 | { |
334 | 337 | $modelName = get_class($item); |
@@ -42,10 +42,12 @@ discard block |
||
42 | 42 | $this->managerOptions = !empty($modelNameOrOptions::$dataManagers[$managerName]) ? $modelNameOrOptions::$dataManagers[$managerName] : []; |
43 | 43 | if (isset($modelNameOrOptions::$objectName)) { |
44 | 44 | $this->name = $modelNameOrOptions::$objectName; |
45 | - } else { |
|
45 | + } |
|
46 | + else { |
|
46 | 47 | $this->name = $modelNameOrOptions; |
47 | 48 | } |
48 | - } else { |
|
49 | + } |
|
50 | + else { |
|
49 | 51 | $this->managerOptions = $modelNameOrOptions; |
50 | 52 | } |
51 | 53 | |
@@ -152,7 +154,8 @@ discard block |
||
152 | 154 | $action['className'] = $key; |
153 | 155 | } |
154 | 156 | $return[$key] = $action; |
155 | - } else { |
|
157 | + } |
|
158 | + else { |
|
156 | 159 | $key = $action; |
157 | 160 | $return[$key] = [ |
158 | 161 | 'className' => $action |
@@ -208,7 +211,8 @@ discard block |
||
208 | 211 | if (is_array($col)) { |
209 | 212 | $colName = $key; |
210 | 213 | $colOptions = $col; |
211 | - } else { |
|
214 | + } |
|
215 | + else { |
|
212 | 216 | $colName = $col; |
213 | 217 | $colOptions = []; |
214 | 218 | } |
@@ -218,7 +222,8 @@ discard block |
||
218 | 222 | } |
219 | 223 | if (empty($colOptions['label']) && !empty($colInfo['label'])) { |
220 | 224 | $colOptions['label'] = $colInfo['label']; |
221 | - } elseif (empty($colOptions['label'])) { |
|
225 | + } |
|
226 | + elseif (empty($colOptions['label'])) { |
|
222 | 227 | $colOptions['label'] = $colName; |
223 | 228 | } |
224 | 229 | $cols[$colName] = $colOptions; |
@@ -267,7 +272,8 @@ discard block |
||
267 | 272 | foreach ($this->managerOptions['userGroupFilter'][\Users\User::$cur->group_id]['getRows'] as $colName => $colOptions) { |
268 | 273 | if (!empty($colOptions['userCol'])) { |
269 | 274 | $queryParams['where'][] = [$colName, \Model::getColValue(\Users\User::$cur, $colOptions['userCol'])]; |
270 | - } elseif (isset($colOptions['value'])) { |
|
275 | + } |
|
276 | + elseif (isset($colOptions['value'])) { |
|
271 | 277 | if (is_array($colOptions['value'])) { |
272 | 278 | foreach ($colOptions['value'] as $key => $value) { |
273 | 279 | if ($key === 'userCol') { |
@@ -318,7 +324,8 @@ discard block |
||
318 | 324 | if ($colInfo['colParams']['type'] == 'dateTime' && !strpos($params['filters'][$col]['max'], ' ')) { |
319 | 325 | |
320 | 326 | $date = $params['filters'][$col]['max'] . ' 23:59:59'; |
321 | - } else { |
|
327 | + } |
|
328 | + else { |
|
322 | 329 | $date = $params['filters'][$col]['max']; |
323 | 330 | } |
324 | 331 | $queryParams['where'][] = [$col, $date, '<=']; |
@@ -362,7 +369,8 @@ discard block |
||
362 | 369 | } |
363 | 370 | if (!empty($params['mode']) && $params['mode'] == 'sort') { |
364 | 371 | $queryParams['order'] = ['weight', 'asc']; |
365 | - } elseif (!empty($params['sortered']) && !empty($this->managerOptions['sortable'])) { |
|
372 | + } |
|
373 | + elseif (!empty($params['sortered']) && !empty($this->managerOptions['sortable'])) { |
|
366 | 374 | foreach ($params['sortered'] as $colName => $sortType) { |
367 | 375 | if ($colName && in_array($colName, $this->managerOptions['sortable'])) { |
368 | 376 | $sortType = in_array($sortType, ['desc', 'asc']) ? $sortType : 'desc'; |
@@ -373,7 +381,8 @@ discard block |
||
373 | 381 | if ($model && !empty($params['relation'])) { |
374 | 382 | $relation = $model::getRelation($params['relation']); |
375 | 383 | $items = $model->$params['relation']($queryParams); |
376 | - } else { |
|
384 | + } |
|
385 | + else { |
|
377 | 386 | $relation = false; |
378 | 387 | $items = $modelName::getList($queryParams); |
379 | 388 | } |
@@ -389,7 +398,8 @@ discard block |
||
389 | 398 | foreach ($this->managerOptions['cols'] as $key => $colName) { |
390 | 399 | if (!empty($params['download'])) { |
391 | 400 | $row[] = \Model::getColValue($item, is_array($colName) ? $key : $colName, true, false); |
392 | - } else { |
|
401 | + } |
|
402 | + else { |
|
393 | 403 | $row[] = DataManager::drawCol($item, is_array($colName) ? $key : $colName, $params, $this); |
394 | 404 | } |
395 | 405 | } |
@@ -418,7 +428,8 @@ discard block |
||
418 | 428 | $col = substr($colName, strpos($colName, ':') + 1); |
419 | 429 | if ($item->$rel) { |
420 | 430 | return DataManager::drawCol($item->$rel, $col, $params, $dataManager, $originalCol, $originalItem); |
421 | - } else { |
|
431 | + } |
|
432 | + else { |
|
422 | 433 | return 'Не указано'; |
423 | 434 | } |
424 | 435 | } |
@@ -441,20 +452,24 @@ discard block |
||
441 | 452 | $href = "<a href ='/admin/" . $item->{$modelName::$cols[$colName]['relation']}->genViewLink() . "'>"; |
442 | 453 | if (!empty($modelName::$cols[$colName]['showCol'])) { |
443 | 454 | $href .= $item->{$modelName::$cols[$colName]['relation']}->{$modelName::$cols[$colName]['showCol']}; |
444 | - } else { |
|
455 | + } |
|
456 | + else { |
|
445 | 457 | |
446 | 458 | $href .= $item->{$modelName::$cols[$colName]['relation']}->name(); |
447 | 459 | } |
448 | 460 | $href .= '</a>'; |
449 | 461 | return $href; |
450 | - } else { |
|
462 | + } |
|
463 | + else { |
|
451 | 464 | return $item->{$modelName::$cols[$colName]['relation']}->name(); |
452 | 465 | } |
453 | - } else { |
|
466 | + } |
|
467 | + else { |
|
454 | 468 | return $item->$colName; |
455 | 469 | } |
456 | 470 | } |
457 | - } else { |
|
471 | + } |
|
472 | + else { |
|
458 | 473 | if (!empty($modelName::$cols[$colName]['view']['type'])) { |
459 | 474 | switch ($modelName::$cols[$colName]['view']['type']) { |
460 | 475 | case 'widget': |
@@ -472,15 +487,18 @@ discard block |
||
472 | 487 | default: |
473 | 488 | return $item->$colName; |
474 | 489 | } |
475 | - } elseif (!empty($modelName::$cols[$colName]['type'])) { |
|
490 | + } |
|
491 | + elseif (!empty($modelName::$cols[$colName]['type'])) { |
|
476 | 492 | if (\App::$cur->name == 'admin' && $originalCol == 'name' || ( $dataManager && !empty($dataManager->managerOptions['colToView']) && $dataManager->managerOptions['colToView'] == $originalCol)) { |
477 | 493 | $formName = $dataManager && !empty($dataManager->managerOptions['editForm']) ? $dataManager->managerOptions['editForm'] : 'manager'; |
478 | 494 | $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/' . str_replace('\\', '/', get_class($originalItem)); |
479 | 495 | return "<a href ='/admin/{$originalItem->genViewLink()}?formName={$formName}&redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; |
480 | - } elseif (\App::$cur->name == 'admin' && $colName == 'name') { |
|
496 | + } |
|
497 | + elseif (\App::$cur->name == 'admin' && $colName == 'name') { |
|
481 | 498 | $redirectUrl = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/admin/' . str_replace('\\', '/', get_class($originalItem)); |
482 | 499 | return "<a href ='/admin/{$item->genViewLink()}?redirectUrl={$redirectUrl}'>{$item->$colName}</a>"; |
483 | - } elseif ($modelName::$cols[$colName]['type'] == 'html') { |
|
500 | + } |
|
501 | + elseif ($modelName::$cols[$colName]['type'] == 'html') { |
|
484 | 502 | $uid = \Tools::randomString(); |
485 | 503 | $script = "<script>inji.onLoad(function(){ |
486 | 504 | var el{$uid}=$('#{$uid}'); |
@@ -509,10 +527,12 @@ discard block |
||
509 | 527 | } |
510 | 528 | })</script>"; |
511 | 529 | return "<div id = '{$uid}' style='max-height:44px;overflow:hidden;'>{$item->$colName}</div>" . $script; |
512 | - } else { |
|
530 | + } |
|
531 | + else { |
|
513 | 532 | return \Model::resloveTypeValue($item, $colName); |
514 | 533 | } |
515 | - } else { |
|
534 | + } |
|
535 | + else { |
|
516 | 536 | return $item->$colName; |
517 | 537 | } |
518 | 538 | } |
@@ -561,7 +581,8 @@ discard block |
||
561 | 581 | foreach ($this->managerOptions['userGroupFilter'][\Users\User::$cur->group_id]['getRows'] as $colName => $colOptions) { |
562 | 582 | if (!empty($colOptions['userCol'])) { |
563 | 583 | $queryParams['where'][] = [$colName, \Model::getColValue(\Users\User::$cur, $colOptions['userCol'])]; |
564 | - } elseif (isset($colOptions['value'])) { |
|
584 | + } |
|
585 | + elseif (isset($colOptions['value'])) { |
|
565 | 586 | if (is_array($colOptions['value'])) { |
566 | 587 | foreach ($colOptions['value'] as $key => $value) { |
567 | 588 | if ($key === 'userCol') { |
@@ -613,7 +634,8 @@ discard block |
||
613 | 634 | if ($colInfo['colParams']['type'] == 'dateTime' && !strpos($params['filters'][$col]['max'], ' ')) { |
614 | 635 | |
615 | 636 | $date = $params['filters'][$col]['max'] . ' 23:59:59'; |
616 | - } else { |
|
637 | + } |
|
638 | + else { |
|
617 | 639 | $date = $params['filters'][$col]['max']; |
618 | 640 | } |
619 | 641 | $queryParams['where'][] = [$col, $date, '<=']; |
@@ -657,7 +679,8 @@ discard block |
||
657 | 679 | } |
658 | 680 | if ($model && !empty($params['relation'])) { |
659 | 681 | $count = $model->$params['relation']($queryParams); |
660 | - } else { |
|
682 | + } |
|
683 | + else { |
|
661 | 684 | $count = $modelName::getCount($queryParams); |
662 | 685 | } |
663 | 686 | $pages = new Pages([ |
@@ -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; |
@@ -116,6 +116,9 @@ discard block |
||
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | + /** |
|
120 | + * @param string $user_mail |
|
121 | + */ |
|
119 | 122 | public function passre($user_mail) { |
120 | 123 | $user = $this->get($user_mail, 'mail'); |
121 | 124 | if (!$user) { |
@@ -400,6 +403,9 @@ discard block |
||
400 | 403 | return $return; |
401 | 404 | } |
402 | 405 | |
406 | + /** |
|
407 | + * @param integer $cat_id |
|
408 | + */ |
|
403 | 409 | public function addUserActivity($user_id, $cat_id, $text = '') { |
404 | 410 | $ua = new Users\Activity([ |
405 | 411 | 'user_id' => $user_id, |
@@ -98,7 +98,8 @@ discard block |
||
98 | 98 | setcookie($this->cookiePrefix . "_user_id", '', 0, "/"); |
99 | 99 | } |
100 | 100 | Tools::redirect('/', 'Этот аккаунт ещё не активирован. <br />Если вы не получали письмо с ссылкой для активации, нажмите на - <a href = "/users/resendActivation/' . $session->user->id . '"><b>повторно выслать ссылку активации</b></a>'); |
101 | - } elseif ($session->user->activation) { |
|
101 | + } |
|
102 | + elseif ($session->user->activation) { |
|
102 | 103 | Msg::add('Этот аккаунт ещё не активирован, не все функции могут быть доступны. <br />Если вы не получали письмо с ссылкой для активации, нажмите на - <a href = "/users/resendActivation/' . $session->user->id . '"><b>повторно выслать ссылку активации</b></a>'); |
103 | 104 | } |
104 | 105 | if (!$session->user->mail && !empty($this->config['noMailNotify'])) { |
@@ -107,7 +108,8 @@ discard block |
||
107 | 108 | Users\User::$cur = $session->user; |
108 | 109 | Users\User::$cur->date_last_active = 'CURRENT_TIMESTAMP'; |
109 | 110 | Users\User::$cur->save(); |
110 | - } else { |
|
111 | + } |
|
112 | + else { |
|
111 | 113 | if (!headers_sent()) { |
112 | 114 | setcookie($this->cookiePrefix . "_user_session_hash", '', 0, "/"); |
113 | 115 | setcookie($this->cookiePrefix . "_user_id", '', 0, "/"); |
@@ -160,7 +162,8 @@ discard block |
||
160 | 162 | if ($user && $this->verifypass($pass, $user->pass) && !$user->blocked) { |
161 | 163 | if (!empty($this->config['needActivation']) && $user->activation) { |
162 | 164 | Tools::redirect('/', 'Этот аккаунт ещё не активирован. <br />Если вы не получали письмо с ссылкой для активации, нажмите на - <a href = "/users/resendActivation/' . $user->id . '"><b>повторно выслать ссылку активации</b></a>'); |
163 | - } elseif ($user->activation) { |
|
165 | + } |
|
166 | + elseif ($user->activation) { |
|
164 | 167 | Msg::add('Этот аккаунт ещё не активирован, не все функции могут быть доступны. <br />Если вы не получали письмо с ссылкой для активации, нажмите на - <a href = "/users/resendActivation/' . $user->id . '"><b>повторно выслать ссылку активации</b></a>'); |
165 | 168 | } |
166 | 169 | if (!$user->mail && !empty($this->config['noMailNotify'])) { |
@@ -179,9 +182,11 @@ discard block |
||
179 | 182 | if (!$noMsg) { |
180 | 183 | if ($user && $user->blocked) { |
181 | 184 | Msg::add('Вы заблокированы', 'danger'); |
182 | - } elseif ($user) { |
|
185 | + } |
|
186 | + elseif ($user) { |
|
183 | 187 | Msg::add('Вы ошиблись при наборе пароля или логина, попробуйте ещё раз или воспользуйтесь <a href = "?passre=1&user_mail=' . $user->mail . '">Восстановлением пароля</a>', 'danger'); |
184 | - } else { |
|
188 | + } |
|
189 | + else { |
|
185 | 190 | Msg::add('Данный почтовый ящик не зарегистрирован в системе', 'danger'); |
186 | 191 | } |
187 | 192 | } |
@@ -204,7 +209,8 @@ discard block |
||
204 | 209 | if (!headers_sent()) { |
205 | 210 | setcookie($this->cookiePrefix . "_user_session_hash", $session->hash, time() + 360000, "/"); |
206 | 211 | setcookie($this->cookiePrefix . "_user_id", $session->user_id, time() + 360000, "/"); |
207 | - } else { |
|
212 | + } |
|
213 | + else { |
|
208 | 214 | Msg::add('Не удалось провести авторизацию. Попробуйте позже', 'info'); |
209 | 215 | } |
210 | 216 | } |
@@ -217,17 +223,22 @@ discard block |
||
217 | 223 | * @return boolean|\User\User |
218 | 224 | */ |
219 | 225 | public function get($idn, $ltype = 'id') { |
220 | - if (!$idn) |
|
221 | - return false; |
|
226 | + if (!$idn) { |
|
227 | + return false; |
|
228 | + } |
|
222 | 229 | |
223 | - if (is_numeric($idn) && $ltype != 'login') |
|
224 | - $user = Users\User::get($idn, 'id'); |
|
225 | - elseif ($ltype == 'login') |
|
226 | - $user = Users\User::get($idn, 'login'); |
|
227 | - else |
|
228 | - $user = Users\User::get($idn, 'mail'); |
|
229 | - if (!$user) |
|
230 | - return []; |
|
230 | + if (is_numeric($idn) && $ltype != 'login') { |
|
231 | + $user = Users\User::get($idn, 'id'); |
|
232 | + } |
|
233 | + elseif ($ltype == 'login') { |
|
234 | + $user = Users\User::get($idn, 'login'); |
|
235 | + } |
|
236 | + else { |
|
237 | + $user = Users\User::get($idn, 'mail'); |
|
238 | + } |
|
239 | + if (!$user) { |
|
240 | + return []; |
|
241 | + } |
|
231 | 242 | |
232 | 243 | return $user; |
233 | 244 | } |
@@ -309,7 +320,8 @@ discard block |
||
309 | 320 | return false; |
310 | 321 | } |
311 | 322 | $pass = $data['user_pass'][0]; |
312 | - } else { |
|
323 | + } |
|
324 | + else { |
|
313 | 325 | $pass = Tools::randomString(10); |
314 | 326 | } |
315 | 327 | |
@@ -355,7 +367,8 @@ discard block |
||
355 | 367 | $text .= 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . $user->id . '/' . $user->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . $user->id . '/' . $user->activation . '</a>'; |
356 | 368 | Tools::sendMail($from, $to, $subject, $text); |
357 | 369 | Msg::add('Вы были зарегистрированы. На указанный почтовый ящик был выслан ваш пароль и ссылка для активации', 'success'); |
358 | - } else { |
|
370 | + } |
|
371 | + else { |
|
359 | 372 | $from = 'noreply@' . INJI_DOMAIN_NAME; |
360 | 373 | $to = $data['user_mail']; |
361 | 374 | $subject = 'Регистрация на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME); |
@@ -387,7 +400,8 @@ discard block |
||
387 | 400 | if (!$userIds && $levels) { |
388 | 401 | $levels[$i] = []; |
389 | 402 | continue; |
390 | - } elseif (!$userIds && !$levels) { |
|
403 | + } |
|
404 | + elseif (!$userIds && !$levels) { |
|
391 | 405 | break; |
392 | 406 | } |
393 | 407 | $usersLevel = \Users\User::getList(['where' => [['parent_id', $userIds, 'IN']]]); |
@@ -11,6 +11,10 @@ |
||
11 | 11 | |
12 | 12 | function indexAction() { |
13 | 13 | |
14 | + /** |
|
15 | + * @param DOMDocument $xml |
|
16 | + * @param string $nodeName |
|
17 | + */ |
|
14 | 18 | function addToXml($xml, $parent, $nodeName, $text) { |
15 | 19 | $node = $parent->appendChild($xml->createElement($nodeName)); |
16 | 20 | $node->appendChild($xml->createTextNode($text)); |
@@ -22,16 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | $sitePath = App::$primary->path; |
24 | 24 | |
25 | - if (!is_uploaded_file($file['tmp_name'])) |
|
26 | - return 0; |
|
25 | + if (!is_uploaded_file($file['tmp_name'])) { |
|
26 | + return 0; |
|
27 | + } |
|
27 | 28 | |
28 | 29 | $fileinfo = pathinfo($file['name']); |
29 | - if (empty($fileinfo['extension'])) |
|
30 | - return 0; |
|
30 | + if (empty($fileinfo['extension'])) { |
|
31 | + return 0; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $type = Files\Type::get($fileinfo['extension'], 'ext'); |
33 | - if (!$type) |
|
34 | - return 0; |
|
35 | + if (!$type) { |
|
36 | + return 0; |
|
37 | + } |
|
35 | 38 | |
36 | 39 | if (!empty($options['accept_group']) && $options['accept_group'] != $type->group) { |
37 | 40 | return 0; |
@@ -47,8 +50,9 @@ discard block |
||
47 | 50 | } |
48 | 51 | $fileObject->name = $fileinfo['filename']; |
49 | 52 | $fileObject->path = $type->type_dir . date('Y-m-d') . '/' . microtime(true) . '.' . $fileinfo['extension']; |
50 | - if ($fileObject->id && file_exists($sitePath . $fileObject->path)) |
|
51 | - unlink($sitePath . $fileObject->path); |
|
53 | + if ($fileObject->id && file_exists($sitePath . $fileObject->path)) { |
|
54 | + unlink($sitePath . $fileObject->path); |
|
55 | + } |
|
52 | 56 | |
53 | 57 | Tools::createDir($sitePath . $type->type_dir . date('Y-m-d') . '/'); |
54 | 58 | |
@@ -84,12 +88,14 @@ discard block |
||
84 | 88 | $sitePath = App::$primary->path; |
85 | 89 | |
86 | 90 | $fileinfo = pathinfo($url); |
87 | - if (empty($fileinfo['extension'])) |
|
88 | - return 0; |
|
91 | + if (empty($fileinfo['extension'])) { |
|
92 | + return 0; |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $type = Files\Type::get($fileinfo['extension'], 'ext'); |
91 | - if (!$type) |
|
92 | - return 0; |
|
96 | + if (!$type) { |
|
97 | + return 0; |
|
98 | + } |
|
93 | 99 | |
94 | 100 | if (!empty($options['accept_group']) && $options['accept_group'] != $type->group) { |
95 | 101 | return 0; |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | } |
106 | 112 | $fileObject->name = $fileinfo['filename']; |
107 | 113 | $fileObject->path = $type->type_dir . date('Y-m-d') . '/' . microtime(true) . '.' . $fileinfo['extension']; |
108 | - if ($fileObject->id && file_exists($sitePath . $fileObject->path)) |
|
109 | - unlink($sitePath . $fileObject->path); |
|
114 | + if ($fileObject->id && file_exists($sitePath . $fileObject->path)) { |
|
115 | + unlink($sitePath . $fileObject->path); |
|
116 | + } |
|
110 | 117 | |
111 | 118 | Tools::createDir($sitePath . $type->type_dir . date('Y-m-d') . '/'); |
112 | 119 |
@@ -24,7 +24,8 @@ |
||
24 | 24 | <?php |
25 | 25 | if ($file->type->group == 'image') { |
26 | 26 | echo "<img class='img-responsive' src ='{$file->path}?resize=200x200' />"; |
27 | - } else { |
|
27 | + } |
|
28 | + else { |
|
28 | 29 | echo "<img class='img-responsive' src ='/static/moduleAsset/Files/images/formats/" . pathinfo($file->path, PATHINFO_EXTENSION) . ".png' />"; |
29 | 30 | } |
30 | 31 | ?> |