@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * Information extractor for col relations path |
359 | 359 | * |
360 | - * @param string|array $info |
|
360 | + * @param string $info |
|
361 | 361 | * @return array |
362 | 362 | */ |
363 | 363 | public static function parseColRecursion($info) |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * Generate params string for col by name |
434 | 434 | * |
435 | 435 | * @param string $colName |
436 | - * @return boolean|string |
|
436 | + * @return false|string |
|
437 | 437 | */ |
438 | 438 | public static function genColParams($colName) |
439 | 439 | { |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * return relations list |
575 | 575 | * |
576 | - * @return array |
|
576 | + * @return string |
|
577 | 577 | */ |
578 | 578 | public static function relations() |
579 | 579 | { |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * |
1066 | 1066 | * @param array $params |
1067 | 1067 | * @param array $where |
1068 | - * @return boolean |
|
1068 | + * @return false|null |
|
1069 | 1069 | */ |
1070 | 1070 | public static function update($params, $where = []) |
1071 | 1071 | { |
@@ -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); |
@@ -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 | } |
@@ -173,34 +178,37 @@ discard block |
||
173 | 178 | public function buildWhere($where = '', $value = '', $operation = false, $concatenation = 'AND') |
174 | 179 | { |
175 | 180 | if (!is_array($where)) { |
176 | - if (!$operation) |
|
177 | - $operation = '='; |
|
181 | + if (!$operation) { |
|
182 | + $operation = '='; |
|
183 | + } |
|
178 | 184 | |
179 | - if ($concatenation === false) |
|
180 | - $concatenation = 'AND'; |
|
181 | - elseif ($concatenation === true) |
|
182 | - $concatenation = ''; |
|
185 | + if ($concatenation === false) { |
|
186 | + $concatenation = 'AND'; |
|
187 | + } elseif ($concatenation === true) { |
|
188 | + $concatenation = ''; |
|
189 | + } |
|
183 | 190 | |
184 | - if ($this->whereString == NULL) |
|
185 | - $this->whereString = ' WHERE '; |
|
191 | + if ($this->whereString == NULL) { |
|
192 | + $this->whereString = ' WHERE '; |
|
193 | + } |
|
186 | 194 | |
187 | 195 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
188 | - if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) |
|
189 | - $value = "({$value})"; |
|
190 | - elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) |
|
191 | - $value = "\"{$value}\""; |
|
192 | - } |
|
193 | - 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'))) { |
|
194 | 202 | $this->params[] = $value; |
195 | 203 | $value = "?"; |
196 | 204 | } |
197 | 205 | |
198 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
199 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
200 | - else |
|
201 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
202 | - } |
|
203 | - 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 { |
|
204 | 212 | $i = -1; |
205 | 213 | while (isset($where[++$i])) { |
206 | 214 | $item = $where[$i]; |
@@ -215,28 +223,32 @@ discard block |
||
215 | 223 | $this->whereString .= "{$concatenation} "; |
216 | 224 | } |
217 | 225 | |
218 | - if ($this->whereString != NULL) |
|
219 | - $this->whereString .= '('; |
|
220 | - else |
|
221 | - $this->whereString = 'WHERE ('; |
|
226 | + if ($this->whereString != NULL) { |
|
227 | + $this->whereString .= '('; |
|
228 | + } else { |
|
229 | + $this->whereString = 'WHERE ('; |
|
230 | + } |
|
222 | 231 | } |
223 | 232 | |
224 | 233 | if (!is_array($item)) { |
225 | 234 | call_user_func_array(array($this, 'buildWhere'), $where); |
226 | 235 | break; |
227 | 236 | } else { |
228 | - if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') |
|
229 | - if (!isset($item[3])) |
|
237 | + if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') { |
|
238 | + if (!isset($item[3])) |
|
230 | 239 | $concatenation = 'AND'; |
231 | - else |
|
232 | - $concatenation = $item[3]; |
|
233 | - elseif (substr($this->whereString, -1, 1) != '(') |
|
234 | - $this->whereString = 'WHERE '; |
|
240 | + } else { |
|
241 | + $concatenation = $item[3]; |
|
242 | + } |
|
243 | + elseif (substr($this->whereString, -1, 1) != '(') { |
|
244 | + $this->whereString = 'WHERE '; |
|
245 | + } |
|
235 | 246 | |
236 | 247 | $this->buildWhere($item); |
237 | 248 | } |
238 | - if (!isset($where[$i + 1]) && isset($where[$i - 1])) |
|
239 | - $this->whereString .= ') '; |
|
249 | + if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
|
250 | + $this->whereString .= ') '; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | } |
242 | 254 | } |
@@ -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 |