@@ -2,27 +2,45 @@ |
||
2 | 2 | <form action = '' method = 'POST' enctype="multipart/form-data"> |
3 | 3 | <div class ="form-group"> |
4 | 4 | <label>Название сайта</label> |
5 | - <input class ="form-control" type = 'text' name = 'site_name' value = '<?php if (!empty(\App::$primary->config['site']['name'])) echo \App::$primary->config['site']['name']; ?>' /> |
|
5 | + <input class ="form-control" type = 'text' name = 'site_name' value = '<?php if (!empty(\App::$primary->config['site']['name'])) { |
|
6 | + echo \App::$primary->config['site']['name']; |
|
7 | +} |
|
8 | +?>' /> |
|
6 | 9 | </div> |
7 | 10 | <div class ="form-group"> |
8 | 11 | <label>Название компании</label> |
9 | - <input class ="form-control" type = 'text' name = 'company_name' value = '<?php if (!empty(\App::$primary->config['site']['company_name'])) echo \App::$primary->config['site']['company_name']; ?>' /> |
|
12 | + <input class ="form-control" type = 'text' name = 'company_name' value = '<?php if (!empty(\App::$primary->config['site']['company_name'])) { |
|
13 | + echo \App::$primary->config['site']['company_name']; |
|
14 | +} |
|
15 | +?>' /> |
|
10 | 16 | </div> |
11 | 17 | <div class ="form-group"> |
12 | 18 | <label>Основной домен</label> |
13 | - <input class ="form-control" type = 'text' name = 'site_domain' value = '<?php if (!empty(\App::$primary->config['site']['domain'])) echo \App::$primary->config['site']['domain']; ?>' /> |
|
19 | + <input class ="form-control" type = 'text' name = 'site_domain' value = '<?php if (!empty(\App::$primary->config['site']['domain'])) { |
|
20 | + echo \App::$primary->config['site']['domain']; |
|
21 | +} |
|
22 | +?>' /> |
|
14 | 23 | </div> |
15 | 24 | <div class ="form-group"> |
16 | 25 | <label>Контактный email</label> |
17 | - <input class ="form-control" type = 'text' name = 'site_email' value = '<?php if (!empty(\App::$primary->config['site']['email'])) echo \App::$primary->config['site']['email']; ?>' /> |
|
26 | + <input class ="form-control" type = 'text' name = 'site_email' value = '<?php if (!empty(\App::$primary->config['site']['email'])) { |
|
27 | + echo \App::$primary->config['site']['email']; |
|
28 | +} |
|
29 | +?>' /> |
|
18 | 30 | </div> |
19 | 31 | <div class ="form-group"> |
20 | 32 | <label>Ключевые слова</label> |
21 | - <input class ="form-control" type = 'text' name = 'site_keywords' value = '<?php if (!empty(\App::$primary->config['site']['keywords'])) echo \App::$primary->config['site']['keywords']; ?>' /> |
|
33 | + <input class ="form-control" type = 'text' name = 'site_keywords' value = '<?php if (!empty(\App::$primary->config['site']['keywords'])) { |
|
34 | + echo \App::$primary->config['site']['keywords']; |
|
35 | +} |
|
36 | +?>' /> |
|
22 | 37 | </div> |
23 | 38 | <div class ="form-group"> |
24 | 39 | <label>Краткое описание сайта</label> |
25 | - <input class ="form-control" type = 'text' name = 'site_description' value = '<?php if (!empty(\App::$primary->config['site']['description'])) echo \App::$primary->config['site']['description']; ?>' /> |
|
40 | + <input class ="form-control" type = 'text' name = 'site_description' value = '<?php if (!empty(\App::$primary->config['site']['description'])) { |
|
41 | + echo \App::$primary->config['site']['description']; |
|
42 | +} |
|
43 | +?>' /> |
|
26 | 44 | </div> |
27 | 45 | <?php |
28 | 46 | $form = new Ui\Form(); |
@@ -271,10 +271,11 @@ |
||
271 | 271 | $item->sales ++; |
272 | 272 | $item->save(); |
273 | 273 | |
274 | - if (empty($_GET['count'])) |
|
275 | - $count = 1; |
|
276 | - else |
|
277 | - $count = (float) $_GET['count']; |
|
274 | + if (empty($_GET['count'])) { |
|
275 | + $count = 1; |
|
276 | + } else { |
|
277 | + $count = (float) $_GET['count']; |
|
278 | + } |
|
278 | 279 | |
279 | 280 | $cart = $this->ecommerce->getCurCart(); |
280 | 281 | $stages = Ecommerce\Cart\Stage::getList(); |
@@ -29,14 +29,18 @@ |
||
29 | 29 | */ |
30 | 30 | public function init($connect_options) { |
31 | 31 | extract($connect_options); |
32 | - if (isset($db_name)) |
|
33 | - $this->db_name = $db_name; |
|
34 | - if (isset($encoding)) |
|
35 | - $this->encoding = $encoding; |
|
36 | - if (isset($table_prefix)) |
|
37 | - $this->table_prefix = $table_prefix; |
|
38 | - if (isset($noConnectAbort)) |
|
39 | - $this->noConnectAbort = $noConnectAbort; |
|
32 | + if (isset($db_name)) { |
|
33 | + $this->db_name = $db_name; |
|
34 | + } |
|
35 | + if (isset($encoding)) { |
|
36 | + $this->encoding = $encoding; |
|
37 | + } |
|
38 | + if (isset($table_prefix)) { |
|
39 | + $this->table_prefix = $table_prefix; |
|
40 | + } |
|
41 | + if (isset($noConnectAbort)) { |
|
42 | + $this->noConnectAbort = $noConnectAbort; |
|
43 | + } |
|
40 | 44 | |
41 | 45 | $dsn = "mysql:host=$host;port=$port;dbname=$db_name;charset=$encoding"; |
42 | 46 | $dt = new \DateTime(); |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | * @return boolean |
56 | 56 | */ |
57 | 57 | public static function createDir($path) { |
58 | - if (file_exists($path)) |
|
59 | - return true; |
|
58 | + if (file_exists($path)) { |
|
59 | + return true; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | $path = explode('/', $path); |
62 | 63 | $cur = ''; |
@@ -100,10 +101,11 @@ discard block |
||
100 | 101 | return false; |
101 | 102 | } |
102 | 103 | |
103 | - if ($img_width / $max_width > $img_height / $max_height) |
|
104 | - $separator = $img_width / $max_width; |
|
105 | - else |
|
106 | - $separator = $img_height / $max_height; |
|
104 | + if ($img_width / $max_width > $img_height / $max_height) { |
|
105 | + $separator = $img_width / $max_width; |
|
106 | + } else { |
|
107 | + $separator = $img_height / $max_height; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | if ($crop === true || $crop == 'q') { |
109 | 111 | if ($img_width > $img_height) { |
@@ -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 |
@@ -730,22 +730,27 @@ discard block |
||
730 | 730 | if (!$query) { |
731 | 731 | return []; |
732 | 732 | } |
733 | - if (!empty($options['where'])) |
|
734 | - $query->where($options['where']); |
|
735 | - if (!empty($options['cols'])) |
|
736 | - $query->cols = $options['cols']; |
|
733 | + if (!empty($options['where'])) { |
|
734 | + $query->where($options['where']); |
|
735 | + } |
|
736 | + if (!empty($options['cols'])) { |
|
737 | + $query->cols = $options['cols']; |
|
738 | + } |
|
737 | 739 | if (!empty($options['group'])) { |
738 | 740 | $query->group($options['group']); |
739 | 741 | } |
740 | 742 | if (!empty($options['having'])) { |
741 | 743 | $query->having($options['having']); |
742 | 744 | } |
743 | - if (!empty($options['order'])) |
|
744 | - $query->order($options['order']); |
|
745 | - if (!empty($options['join'])) |
|
746 | - $query->join($options['join']); |
|
747 | - if (!empty($options['distinct'])) |
|
748 | - $query->distinct = $options['distinct']; |
|
745 | + if (!empty($options['order'])) { |
|
746 | + $query->order($options['order']); |
|
747 | + } |
|
748 | + if (!empty($options['join'])) { |
|
749 | + $query->join($options['join']); |
|
750 | + } |
|
751 | + if (!empty($options['distinct'])) { |
|
752 | + $query->distinct = $options['distinct']; |
|
753 | + } |
|
749 | 754 | |
750 | 755 | foreach (static::$relJoins as $join) { |
751 | 756 | $query->join($join[0], $join[1]); |
@@ -771,14 +776,14 @@ discard block |
||
771 | 776 | } |
772 | 777 | static::$needJoin = []; |
773 | 778 | |
774 | - if (!empty($options['limit'])) |
|
775 | - $limit = (int) $options['limit']; |
|
776 | - else { |
|
779 | + if (!empty($options['limit'])) { |
|
780 | + $limit = (int) $options['limit']; |
|
781 | + } else { |
|
777 | 782 | $limit = 0; |
778 | 783 | } |
779 | - if (!empty($options['start'])) |
|
780 | - $start = (int) $options['start']; |
|
781 | - else { |
|
784 | + if (!empty($options['start'])) { |
|
785 | + $start = (int) $options['start']; |
|
786 | + } else { |
|
782 | 787 | $start = 0; |
783 | 788 | } |
784 | 789 | if ($limit || $start) { |
@@ -1045,21 +1050,23 @@ discard block |
||
1045 | 1050 | if (!empty($options['group'])) { |
1046 | 1051 | static::fixPrefix($options['group'], 'first'); |
1047 | 1052 | } |
1048 | - if (!empty($options['where'])) |
|
1049 | - $query->where($options['where']); |
|
1050 | - if (!empty($options['join'])) |
|
1051 | - $query->join($options['join']); |
|
1053 | + if (!empty($options['where'])) { |
|
1054 | + $query->where($options['where']); |
|
1055 | + } |
|
1056 | + if (!empty($options['join'])) { |
|
1057 | + $query->join($options['join']); |
|
1058 | + } |
|
1052 | 1059 | if (!empty($options['order'])) { |
1053 | 1060 | $query->order($options['order']); |
1054 | 1061 | } |
1055 | - if (!empty($options['limit'])) |
|
1056 | - $limit = (int) $options['limit']; |
|
1057 | - else { |
|
1062 | + if (!empty($options['limit'])) { |
|
1063 | + $limit = (int) $options['limit']; |
|
1064 | + } else { |
|
1058 | 1065 | $limit = 0; |
1059 | 1066 | } |
1060 | - if (!empty($options['start'])) |
|
1061 | - $start = (int) $options['start']; |
|
1062 | - else { |
|
1067 | + if (!empty($options['start'])) { |
|
1068 | + $start = (int) $options['start']; |
|
1069 | + } else { |
|
1063 | 1070 | $start = 0; |
1064 | 1071 | } |
1065 | 1072 | if ($limit || $start) { |
@@ -1136,8 +1143,9 @@ discard block |
||
1136 | 1143 | |
1137 | 1144 | $values = []; |
1138 | 1145 | foreach ($cols as $col => $param) { |
1139 | - if (isset($params[$col])) |
|
1140 | - $values[$col] = $params[$col]; |
|
1146 | + if (isset($params[$col])) { |
|
1147 | + $values[$col] = $params[$col]; |
|
1148 | + } |
|
1141 | 1149 | } |
1142 | 1150 | if (empty($values)) { |
1143 | 1151 | return false; |
@@ -1474,8 +1482,9 @@ discard block |
||
1474 | 1482 | public static function findRelation($col) { |
1475 | 1483 | |
1476 | 1484 | foreach (static::relations() as $relName => $rel) { |
1477 | - if ($rel['col'] == $col) |
|
1478 | - return $relName; |
|
1485 | + if ($rel['col'] == $col) { |
|
1486 | + return $relName; |
|
1487 | + } |
|
1479 | 1488 | } |
1480 | 1489 | return NULL; |
1481 | 1490 | } |
@@ -125,12 +125,14 @@ discard block |
||
125 | 125 | if (!is_array($order)) { |
126 | 126 | $this->order[] = "{$order} {$type}"; |
127 | 127 | } else { |
128 | - foreach ($order as $item) |
|
129 | - if (!is_array($item)) { |
|
128 | + foreach ($order as $item) { |
|
129 | + if (!is_array($item)) { |
|
130 | 130 | call_user_func_array(array($this, 'order'), $order); |
131 | + } |
|
131 | 132 | break; |
132 | - } else |
|
133 | - $this->order($item); |
|
133 | + } else { |
|
134 | + $this->order($item); |
|
135 | + } |
|
134 | 136 | } |
135 | 137 | } |
136 | 138 | |
@@ -138,8 +140,9 @@ discard block |
||
138 | 140 | $start = intval($start); |
139 | 141 | $len = intval($len); |
140 | 142 | $this->limit = "LIMIT {$start}"; |
141 | - if ($len !== 0) |
|
142 | - $this->limit .= ",{$len}"; |
|
143 | + if ($len !== 0) { |
|
144 | + $this->limit .= ",{$len}"; |
|
145 | + } |
|
143 | 146 | } |
144 | 147 | |
145 | 148 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') { |
@@ -151,10 +154,12 @@ discard block |
||
151 | 154 | } |
152 | 155 | } else { |
153 | 156 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
154 | - if ($alias) |
|
155 | - $join .= " AS `{$alias}`"; |
|
156 | - if ($where) |
|
157 | - $join .= " ON {$where}"; |
|
157 | + if ($alias) { |
|
158 | + $join .= " AS `{$alias}`"; |
|
159 | + } |
|
160 | + if ($where) { |
|
161 | + $join .= " ON {$where}"; |
|
162 | + } |
|
158 | 163 | } |
159 | 164 | return $join; |
160 | 165 | } |
@@ -173,13 +178,15 @@ discard block |
||
173 | 178 | $operation = '='; |
174 | 179 | } |
175 | 180 | |
176 | - if ($concatenation === false) |
|
177 | - $concatenation = 'AND'; |
|
178 | - elseif ($concatenation === true) |
|
179 | - $concatenation = ''; |
|
181 | + if ($concatenation === false) { |
|
182 | + $concatenation = 'AND'; |
|
183 | + } elseif ($concatenation === true) { |
|
184 | + $concatenation = ''; |
|
185 | + } |
|
180 | 186 | |
181 | - if ($this->whereString == NULL) |
|
182 | - $this->whereString = ' WHERE '; |
|
187 | + if ($this->whereString == NULL) { |
|
188 | + $this->whereString = ' WHERE '; |
|
189 | + } |
|
183 | 190 | |
184 | 191 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
185 | 192 | if (is_array($value)) { |
@@ -205,12 +212,12 @@ discard block |
||
205 | 212 | $value = "?"; |
206 | 213 | } |
207 | 214 | |
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} "; |
|
212 | - } |
|
213 | - else { |
|
215 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
216 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
217 | + } else { |
|
218 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
219 | + } |
|
220 | + } else { |
|
214 | 221 | $i = -1; |
215 | 222 | while (isset($where[++$i])) { |
216 | 223 | $item = $where[$i]; |
@@ -225,10 +232,11 @@ discard block |
||
225 | 232 | $this->whereString .= "{$concatenation} "; |
226 | 233 | } |
227 | 234 | |
228 | - if ($this->whereString != NULL) |
|
229 | - $this->whereString .= '('; |
|
230 | - else |
|
231 | - $this->whereString = 'WHERE ('; |
|
235 | + if ($this->whereString != NULL) { |
|
236 | + $this->whereString .= '('; |
|
237 | + } else { |
|
238 | + $this->whereString = 'WHERE ('; |
|
239 | + } |
|
232 | 240 | } |
233 | 241 | |
234 | 242 | if (!is_array($item)) { |
@@ -257,13 +265,15 @@ discard block |
||
257 | 265 | if (empty($operation)) { |
258 | 266 | $operation = '='; |
259 | 267 | } |
260 | - if ($concatenation === false) |
|
261 | - $concatenation = 'AND'; |
|
262 | - elseif ($concatenation === true) |
|
263 | - $concatenation = ''; |
|
268 | + if ($concatenation === false) { |
|
269 | + $concatenation = 'AND'; |
|
270 | + } elseif ($concatenation === true) { |
|
271 | + $concatenation = ''; |
|
272 | + } |
|
264 | 273 | |
265 | - if ($this->havingString == NULL) |
|
266 | - $this->havingString = ' HAVING '; |
|
274 | + if ($this->havingString == NULL) { |
|
275 | + $this->havingString = ' HAVING '; |
|
276 | + } |
|
267 | 277 | |
268 | 278 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
269 | 279 | if (is_array($value)) { |
@@ -289,12 +299,12 @@ discard block |
||
289 | 299 | $value = "?"; |
290 | 300 | } |
291 | 301 | |
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} "; |
|
296 | - } |
|
297 | - else { |
|
302 | + if (substr($this->havingString, -1, 1) == '(' || substr($this->havingString, -2, 2) == 'E ') { |
|
303 | + $this->havingString .= " {$where} {$operation} {$value} "; |
|
304 | + } else { |
|
305 | + $this->havingString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
306 | + } |
|
307 | + } else { |
|
298 | 308 | $i = -1; |
299 | 309 | while (isset($where[++$i])) { |
300 | 310 | $item = $where[$i]; |
@@ -309,10 +319,11 @@ discard block |
||
309 | 319 | $this->havingString .= "{$concatenation} "; |
310 | 320 | } |
311 | 321 | |
312 | - if ($this->havingString != NULL) |
|
313 | - $this->havingString .= '('; |
|
314 | - else |
|
315 | - $this->havingString = 'HAVING ('; |
|
322 | + if ($this->havingString != NULL) { |
|
323 | + $this->havingString .= '('; |
|
324 | + } else { |
|
325 | + $this->havingString = 'HAVING ('; |
|
326 | + } |
|
316 | 327 | } |
317 | 328 | |
318 | 329 | if (!is_array($item)) { |
@@ -217,17 +217,20 @@ |
||
217 | 217 | * @return boolean|\User\User |
218 | 218 | */ |
219 | 219 | public function get($idn, $ltype = 'id') { |
220 | - if (!$idn) |
|
221 | - return false; |
|
220 | + if (!$idn) { |
|
221 | + return false; |
|
222 | + } |
|
222 | 223 | |
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 []; |
|
224 | + if (is_numeric($idn) && $ltype != 'login') { |
|
225 | + $user = Users\User::get($idn, 'id'); |
|
226 | + } elseif ($ltype == 'login') { |
|
227 | + $user = Users\User::get($idn, 'login'); |
|
228 | + } else { |
|
229 | + $user = Users\User::get($idn, 'mail'); |
|
230 | + } |
|
231 | + if (!$user) { |
|
232 | + return []; |
|
233 | + } |
|
231 | 234 | |
232 | 235 | return $user; |
233 | 236 | } |