@@ -11,13 +11,14 @@ |
||
11 | 11 | '', |
12 | 12 | '' |
13 | 13 | ]); |
14 | -if (!empty($templates['app']['installed'])) |
|
14 | +if (!empty($templates['app']['installed'])) { |
|
15 | 15 | foreach ($templates['app']['installed'] as $template => $name) { |
16 | 16 | $table->addRow([ |
17 | 17 | $name, |
18 | 18 | (empty($templates['app']['current']) || $templates['app']['current'] != $template) ? '<a href = "/admin/view/setDefault/' . $template . '">Установить по умолчанию</a>' : 'Тема по умолчанию', |
19 | 19 | '<a href = "/admin/view/editTemplate/' . $template . '">Редактировать</a>' |
20 | 20 | ]); |
21 | +} |
|
21 | 22 | } |
22 | 23 | $table->draw(); |
23 | 24 | ?> |
24 | 25 | \ No newline at end of file |
@@ -36,8 +36,9 @@ |
||
36 | 36 | $params = json_decode($widget->widget_params, true); |
37 | 37 | if ($params) { |
38 | 38 | foreach ($params as $param) { |
39 | - if (!isset($widgetCode[$i])) |
|
40 | - break; |
|
39 | + if (!isset($widgetCode[$i])) { |
|
40 | + break; |
|
41 | + } |
|
41 | 42 | if ($param['type'] == 'select') { |
42 | 43 | $item = $param['model']::get($widgetCode[$i++]); |
43 | 44 | if ($item) { |
@@ -35,10 +35,11 @@ |
||
35 | 35 | ?> |
36 | 36 | </select> |
37 | 37 | <?php |
38 | -if (false) |
|
38 | +if (false) { |
|
39 | 39 | foreach ($widgets as $widget) { |
40 | 40 | if ($widget->widget_params) { |
41 | 41 | $params = json_decode($widget->widget_params, true); |
42 | +} |
|
42 | 43 | if ($params) { |
43 | 44 | echo "<div id = 'params{$widget->widget_id}' class = 'widgetParams' style='display:none;'>"; |
44 | 45 | echo "<h3>Параметры</h3>"; |
@@ -13,20 +13,22 @@ |
||
13 | 13 | static function genArray($data, $level = 0) |
14 | 14 | { |
15 | 15 | $return = ''; |
16 | - if ($level == 0) |
|
17 | - $return = "["; |
|
16 | + if ($level == 0) { |
|
17 | + $return = "["; |
|
18 | + } |
|
18 | 19 | foreach ($data as $key => $item) { |
19 | 20 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => "; |
20 | - if (!is_array($item)) |
|
21 | - $return .= "'{$item}',"; |
|
22 | - else { |
|
21 | + if (!is_array($item)) { |
|
22 | + $return .= "'{$item}',"; |
|
23 | + } else { |
|
23 | 24 | $return .= "["; |
24 | 25 | $return .= rtrim(self::genArray($item, $level + 1), ','); |
25 | 26 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],"; |
26 | 27 | } |
27 | 28 | } |
28 | - if ($level == 0) |
|
29 | - $return = rtrim($return, ',') . "\n];"; |
|
29 | + if ($level == 0) { |
|
30 | + $return = rtrim($return, ',') . "\n];"; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | return $return; |
32 | 34 | } |
@@ -47,8 +47,9 @@ |
||
47 | 47 | return self::$_configs['custom'][$path]; |
48 | 48 | } |
49 | 49 | |
50 | - if (!file_exists($path)) |
|
51 | - return []; |
|
50 | + if (!file_exists($path)) { |
|
51 | + return []; |
|
52 | + } |
|
52 | 53 | |
53 | 54 | return self::$_configs['custom'][$path] = include $path; |
54 | 55 | } |
@@ -685,17 +685,21 @@ discard block |
||
685 | 685 | */ |
686 | 686 | public static function get_list($options = []) |
687 | 687 | { |
688 | - if (!empty($options['where'])) |
|
689 | - App::$cur->db->where($options['where']); |
|
688 | + if (!empty($options['where'])) { |
|
689 | + App::$cur->db->where($options['where']); |
|
690 | + } |
|
690 | 691 | if (!empty($options['group'])) { |
691 | 692 | App::$cur->db->group($options['group']); |
692 | 693 | } |
693 | - if (!empty($options['order'])) |
|
694 | - App::$cur->db->order($options['order']); |
|
695 | - if (!empty($options['join'])) |
|
696 | - App::$cur->db->join($options['join']); |
|
697 | - if (!empty($options['distinct'])) |
|
698 | - App::$cur->db->distinct = $options['distinct']; |
|
694 | + if (!empty($options['order'])) { |
|
695 | + App::$cur->db->order($options['order']); |
|
696 | + } |
|
697 | + if (!empty($options['join'])) { |
|
698 | + App::$cur->db->join($options['join']); |
|
699 | + } |
|
700 | + if (!empty($options['distinct'])) { |
|
701 | + App::$cur->db->distinct = $options['distinct']; |
|
702 | + } |
|
699 | 703 | |
700 | 704 | foreach (static::$relJoins as $join) { |
701 | 705 | App::$cur->db->join($join[0], $join[1]); |
@@ -721,14 +725,14 @@ discard block |
||
721 | 725 | } |
722 | 726 | static::$needJoin = []; |
723 | 727 | |
724 | - if (!empty($options['limit'])) |
|
725 | - $limit = (int) $options['limit']; |
|
726 | - else { |
|
728 | + if (!empty($options['limit'])) { |
|
729 | + $limit = (int) $options['limit']; |
|
730 | + } else { |
|
727 | 731 | $limit = 0; |
728 | 732 | } |
729 | - if (!empty($options['start'])) |
|
730 | - $start = (int) $options['start']; |
|
731 | - else { |
|
733 | + if (!empty($options['start'])) { |
|
734 | + $start = (int) $options['start']; |
|
735 | + } else { |
|
732 | 736 | $start = 0; |
733 | 737 | } |
734 | 738 | if ($limit || $start) { |
@@ -983,21 +987,23 @@ discard block |
||
983 | 987 | if (!empty($options['where'])) { |
984 | 988 | static::fixPrefix($options['where'], 'first'); |
985 | 989 | } |
986 | - if (!empty($options['where'])) |
|
987 | - App::$cur->db->where($options['where']); |
|
988 | - if (!empty($options['join'])) |
|
989 | - App::$cur->db->join($options['join']); |
|
990 | + if (!empty($options['where'])) { |
|
991 | + App::$cur->db->where($options['where']); |
|
992 | + } |
|
993 | + if (!empty($options['join'])) { |
|
994 | + App::$cur->db->join($options['join']); |
|
995 | + } |
|
990 | 996 | if (!empty($options['order'])) { |
991 | 997 | App::$cur->db->order($options['order']); |
992 | 998 | } |
993 | - if (!empty($options['limit'])) |
|
994 | - $limit = (int) $options['limit']; |
|
995 | - else { |
|
999 | + if (!empty($options['limit'])) { |
|
1000 | + $limit = (int) $options['limit']; |
|
1001 | + } else { |
|
996 | 1002 | $limit = 0; |
997 | 1003 | } |
998 | - if (!empty($options['start'])) |
|
999 | - $start = (int) $options['start']; |
|
1000 | - else { |
|
1004 | + if (!empty($options['start'])) { |
|
1005 | + $start = (int) $options['start']; |
|
1006 | + } else { |
|
1001 | 1007 | $start = 0; |
1002 | 1008 | } |
1003 | 1009 | if ($limit || $start) { |
@@ -1075,8 +1081,9 @@ discard block |
||
1075 | 1081 | |
1076 | 1082 | $values = []; |
1077 | 1083 | foreach ($cols as $col => $param) { |
1078 | - if (isset($params[$col])) |
|
1079 | - $values[$col] = $params[$col]; |
|
1084 | + if (isset($params[$col])) { |
|
1085 | + $values[$col] = $params[$col]; |
|
1086 | + } |
|
1080 | 1087 | } |
1081 | 1088 | if (empty($values)) { |
1082 | 1089 | return false; |
@@ -1259,8 +1266,9 @@ discard block |
||
1259 | 1266 | $values = []; |
1260 | 1267 | |
1261 | 1268 | foreach ($this->cols() as $col => $param) { |
1262 | - if (isset($this->_params[$col])) |
|
1263 | - $values[$col] = $this->_params[$col]; |
|
1269 | + if (isset($this->_params[$col])) { |
|
1270 | + $values[$col] = $this->_params[$col]; |
|
1271 | + } |
|
1264 | 1272 | } |
1265 | 1273 | if (empty($values) && empty($options['empty'])) { |
1266 | 1274 | return false; |
@@ -1420,8 +1428,9 @@ discard block |
||
1420 | 1428 | { |
1421 | 1429 | |
1422 | 1430 | foreach (static::relations() as $relName => $rel) { |
1423 | - if ($rel['col'] == $col) |
|
1424 | - return $relName; |
|
1431 | + if ($rel['col'] == $col) { |
|
1432 | + return $relName; |
|
1433 | + } |
|
1425 | 1434 | } |
1426 | 1435 | return NULL; |
1427 | 1436 | } |
@@ -1577,8 +1586,9 @@ discard block |
||
1577 | 1586 | App::$cur->db->where($relation['relTablePrefix'] . $this->index(), $this->pk()); |
1578 | 1587 | App::$cur->db->where($relation['relTablePrefix'] . $relation['model']::index(), $objectId); |
1579 | 1588 | $isset = App::$cur->db->select($relation['relTable'])->fetch_assoc(); |
1580 | - if ($isset) |
|
1581 | - return true; |
|
1589 | + if ($isset) { |
|
1590 | + return true; |
|
1591 | + } |
|
1582 | 1592 | |
1583 | 1593 | App::$cur->db->insert($relation['relTable'], [ |
1584 | 1594 | $relation['relTablePrefix'] . $this->index() => $this->{$this->index()}, |
@@ -140,8 +140,9 @@ discard block |
||
140 | 140 | |
141 | 141 | private function parseRaw($source) |
142 | 142 | { |
143 | - if (!$source) |
|
144 | - return []; |
|
143 | + if (!$source) { |
|
144 | + return []; |
|
145 | + } |
|
145 | 146 | |
146 | 147 | preg_match_all("|{([^}]+)}|", $source, $result); |
147 | 148 | return $result[1]; |
@@ -327,10 +328,11 @@ discard block |
||
327 | 328 | $this->ResolveCssHref($css, $type, $hrefs); |
328 | 329 | continue; |
329 | 330 | } |
330 | - if (strpos($css, '//') !== false) |
|
331 | - $href = $css; |
|
332 | - else |
|
333 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
331 | + if (strpos($css, '//') !== false) { |
|
332 | + $href = $css; |
|
333 | + } else { |
|
334 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
335 | + } |
|
334 | 336 | $hrefs[$href] = $href; |
335 | 337 | } |
336 | 338 | break; |
@@ -340,10 +342,11 @@ discard block |
||
340 | 342 | $this->ResolveCssHref($css, $type, $hrefs); |
341 | 343 | continue; |
342 | 344 | } |
343 | - if (strpos($css, '://') !== false) |
|
344 | - $href = $css; |
|
345 | - else |
|
346 | - $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
345 | + if (strpos($css, '://') !== false) { |
|
346 | + $href = $css; |
|
347 | + } else { |
|
348 | + $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
349 | + } |
|
347 | 350 | $hrefs[$href] = $href; |
348 | 351 | } |
349 | 352 | break; |
@@ -353,10 +356,11 @@ discard block |
||
353 | 356 | $this->ResolveCssHref($css, $type, $hrefs); |
354 | 357 | continue; |
355 | 358 | } |
356 | - if (strpos($css, '//') !== false) |
|
357 | - $href = $css; |
|
358 | - else |
|
359 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
359 | + if (strpos($css, '//') !== false) { |
|
360 | + $href = $css; |
|
361 | + } else { |
|
362 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
363 | + } |
|
360 | 364 | $hrefs[$href] = $href; |
361 | 365 | } |
362 | 366 | break; |
@@ -410,8 +414,9 @@ discard block |
||
410 | 414 | $noParsedScripts = []; |
411 | 415 | foreach ($scripts as $script) { |
412 | 416 | if (is_string($script)) { |
413 | - if (!empty($urls[$script])) |
|
414 | - continue; |
|
417 | + if (!empty($urls[$script])) { |
|
418 | + continue; |
|
419 | + } |
|
415 | 420 | |
416 | 421 | $path = $this->app->staticLoader->parsePath($script); |
417 | 422 | if (file_exists($path)) { |
@@ -422,8 +427,9 @@ discard block |
||
422 | 427 | $noParsedScripts[$script] = $script; |
423 | 428 | } |
424 | 429 | } elseif (!empty($script['file'])) { |
425 | - if (!empty($urls[$script['file']])) |
|
426 | - continue; |
|
430 | + if (!empty($urls[$script['file']])) { |
|
431 | + continue; |
|
432 | + } |
|
427 | 433 | |
428 | 434 | $path = $this->app->staticLoader->parsePath($script['file']); |
429 | 435 | if (file_exists($path)) { |
@@ -482,12 +488,14 @@ discard block |
||
482 | 488 | $this->genScriptArray($js, $type, $resultArray); |
483 | 489 | continue; |
484 | 490 | } |
485 | - if (strpos($js, '//') !== false) |
|
486 | - $href = $js; |
|
487 | - else |
|
488 | - $href = $this->getHref('js', $js); |
|
489 | - if (!$href) |
|
490 | - continue; |
|
491 | + if (strpos($js, '//') !== false) { |
|
492 | + $href = $js; |
|
493 | + } else { |
|
494 | + $href = $this->getHref('js', $js); |
|
495 | + } |
|
496 | + if (!$href) { |
|
497 | + continue; |
|
498 | + } |
|
491 | 499 | |
492 | 500 | $resultArray[] = $href; |
493 | 501 | } |
@@ -498,10 +506,11 @@ discard block |
||
498 | 506 | $this->genScriptArray($js, $type, $resultArray); |
499 | 507 | continue; |
500 | 508 | } |
501 | - if (strpos($js, '//') !== false) |
|
502 | - $href = $js; |
|
503 | - else |
|
504 | - $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
509 | + if (strpos($js, '//') !== false) { |
|
510 | + $href = $js; |
|
511 | + } else { |
|
512 | + $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
513 | + } |
|
505 | 514 | $resultArray[] = $href; |
506 | 515 | } |
507 | 516 | break; |
@@ -517,8 +526,9 @@ discard block |
||
517 | 526 | $asset = []; |
518 | 527 | } |
519 | 528 | $asset['file'] = $this->getHref('js', $js); |
520 | - if (!$asset['file']) |
|
521 | - continue; |
|
529 | + if (!$asset['file']) { |
|
530 | + continue; |
|
531 | + } |
|
522 | 532 | $resultArray[] = $asset; |
523 | 533 | } |
524 | 534 | break; |
@@ -568,8 +578,9 @@ discard block |
||
568 | 578 | $paramArray = true; |
569 | 579 | } |
570 | 580 | } |
571 | - if (!$paramArray) |
|
572 | - $lineParams = ':' . implode(':', $_params); |
|
581 | + if (!$paramArray) { |
|
582 | + $lineParams = ':' . implode(':', $_params); |
|
583 | + } |
|
573 | 584 | } |
574 | 585 | } |
575 | 586 | echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n"; |
@@ -270,10 +270,11 @@ |
||
270 | 270 | $item->sales ++; |
271 | 271 | $item->save(); |
272 | 272 | |
273 | - if (empty($_GET['count'])) |
|
274 | - $count = 1; |
|
275 | - else |
|
276 | - $count = (float) $_GET['count']; |
|
273 | + if (empty($_GET['count'])) { |
|
274 | + $count = 1; |
|
275 | + } else { |
|
276 | + $count = (float) $_GET['count']; |
|
277 | + } |
|
277 | 278 | |
278 | 279 | $cart = $this->ecommerce->getCurCart(); |
279 | 280 |
@@ -126,12 +126,14 @@ discard block |
||
126 | 126 | if (!is_array($order)) { |
127 | 127 | $this->order[] = "{$order} {$type}"; |
128 | 128 | } else { |
129 | - foreach ($order as $item) |
|
130 | - if (!is_array($item)) { |
|
129 | + foreach ($order as $item) { |
|
130 | + if (!is_array($item)) { |
|
131 | 131 | call_user_func_array(array($this, 'order'), $order); |
132 | + } |
|
132 | 133 | break; |
133 | - } else |
|
134 | - $this->order($item); |
|
134 | + } else { |
|
135 | + $this->order($item); |
|
136 | + } |
|
135 | 137 | } |
136 | 138 | } |
137 | 139 | |
@@ -140,8 +142,9 @@ discard block |
||
140 | 142 | $start = intval($start); |
141 | 143 | $len = intval($len); |
142 | 144 | $this->limit = "LIMIT {$start}"; |
143 | - if ($len !== 0) |
|
144 | - $this->limit .= ",{$len}"; |
|
145 | + if ($len !== 0) { |
|
146 | + $this->limit .= ",{$len}"; |
|
147 | + } |
|
145 | 148 | } |
146 | 149 | |
147 | 150 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') |
@@ -154,10 +157,12 @@ discard block |
||
154 | 157 | } |
155 | 158 | } else { |
156 | 159 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
157 | - if ($alias) |
|
158 | - $join .= " AS `{$alias}`"; |
|
159 | - if ($where) |
|
160 | - $join .= " ON {$where}"; |
|
160 | + if ($alias) { |
|
161 | + $join .= " AS `{$alias}`"; |
|
162 | + } |
|
163 | + if ($where) { |
|
164 | + $join .= " ON {$where}"; |
|
165 | + } |
|
161 | 166 | } |
162 | 167 | return $join; |
163 | 168 | } |
@@ -177,31 +182,33 @@ discard block |
||
177 | 182 | $operation = '='; |
178 | 183 | } |
179 | 184 | |
180 | - if ($concatenation === false) |
|
181 | - $concatenation = 'AND'; |
|
182 | - elseif ($concatenation === true) |
|
183 | - $concatenation = ''; |
|
185 | + if ($concatenation === false) { |
|
186 | + $concatenation = 'AND'; |
|
187 | + } elseif ($concatenation === true) { |
|
188 | + $concatenation = ''; |
|
189 | + } |
|
184 | 190 | |
185 | - if ($this->whereString == NULL) |
|
186 | - $this->whereString = ' WHERE '; |
|
191 | + if ($this->whereString == NULL) { |
|
192 | + $this->whereString = ' WHERE '; |
|
193 | + } |
|
187 | 194 | |
188 | 195 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
189 | - if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) |
|
190 | - $value = "({$value})"; |
|
191 | - elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) |
|
192 | - $value = "\"{$value}\""; |
|
193 | - } |
|
194 | - elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
196 | + if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
197 | + $value = "({$value})"; |
|
198 | + } elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
199 | + $value = "\"{$value}\""; |
|
200 | + } |
|
201 | + } elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
195 | 202 | $this->params[] = $value; |
196 | 203 | $value = "?"; |
197 | 204 | } |
198 | 205 | |
199 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
200 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
201 | - else |
|
202 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
203 | - } |
|
204 | - else { |
|
206 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
207 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
208 | + } else { |
|
209 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
210 | + } |
|
211 | + } else { |
|
205 | 212 | $i = -1; |
206 | 213 | while (isset($where[++$i])) { |
207 | 214 | $item = $where[$i]; |
@@ -216,28 +223,32 @@ discard block |
||
216 | 223 | $this->whereString .= "{$concatenation} "; |
217 | 224 | } |
218 | 225 | |
219 | - if ($this->whereString != NULL) |
|
220 | - $this->whereString .= '('; |
|
221 | - else |
|
222 | - $this->whereString = 'WHERE ('; |
|
226 | + if ($this->whereString != NULL) { |
|
227 | + $this->whereString .= '('; |
|
228 | + } else { |
|
229 | + $this->whereString = 'WHERE ('; |
|
230 | + } |
|
223 | 231 | } |
224 | 232 | |
225 | 233 | if (!is_array($item)) { |
226 | 234 | call_user_func_array(array($this, 'buildWhere'), $where); |
227 | 235 | break; |
228 | 236 | } else { |
229 | - if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') |
|
230 | - if (!isset($item[3])) |
|
237 | + if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') { |
|
238 | + if (!isset($item[3])) |
|
231 | 239 | $concatenation = 'AND'; |
232 | - else |
|
233 | - $concatenation = $item[3]; |
|
234 | - elseif (substr($this->whereString, -1, 1) != '(') |
|
235 | - $this->whereString = 'WHERE '; |
|
240 | + } else { |
|
241 | + $concatenation = $item[3]; |
|
242 | + } |
|
243 | + elseif (substr($this->whereString, -1, 1) != '(') { |
|
244 | + $this->whereString = 'WHERE '; |
|
245 | + } |
|
236 | 246 | |
237 | 247 | $this->buildWhere($item); |
238 | 248 | } |
239 | - if (!isset($where[$i + 1]) && isset($where[$i - 1])) |
|
240 | - $this->whereString .= ') '; |
|
249 | + if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
|
250 | + $this->whereString .= ') '; |
|
251 | + } |
|
241 | 252 | } |
242 | 253 | } |
243 | 254 | } |