@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | function parseWarehouse($warehouseCount) { |
| 27 | 27 | $count = $warehouseCount['@attributes']['КоличествоНаСкладе']; |
| 28 | - $objectId = \App::$cur->migrations->findObject((string)$warehouseCount['@attributes']['ИдСклада'], 'Ecommerce\Warehouse'); |
|
| 28 | + $objectId = \App::$cur->migrations->findObject((string) $warehouseCount['@attributes']['ИдСклада'], 'Ecommerce\Warehouse'); |
|
| 29 | 29 | if ($objectId) { |
| 30 | 30 | $modelName = get_class($this->model); |
| 31 | 31 | $warehouse = \Ecommerce\Item\Offer\Warehouse::get([[$modelName::index(), $this->model->pk()], [\Ecommerce\Warehouse::index(), $objectId->object_id]]); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | //walk know pathes |
| 28 | 28 | foreach ($this->map->paths(['where' => ['path', $this->curPath]]) as $path) { |
| 29 | 29 | if (defined('mdebug')) { |
| 30 | - echo $path->item ; |
|
| 30 | + echo $path->item; |
|
| 31 | 31 | } |
| 32 | 32 | if (isset($this->data[$path->item])) { |
| 33 | 33 | if ($path->type == 'container') { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $walked = []; |
| 49 | 49 | foreach ($this->object->params as $param) { |
| 50 | - if(defined('mdebug')){ |
|
| 50 | + if (defined('mdebug')) { |
|
| 51 | 51 | echo " -> param ($param->id,$param->type,$param->value) "; |
| 52 | 52 | } |
| 53 | 53 | if ($model && $param->type && $param->type != 'item_key') { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $parser->parentObject = $this; |
| 60 | 60 | $parser->parentModel = $model; |
| 61 | 61 | $parser->walker = $this->walker; |
| 62 | - if(defined('mdebug')){ |
|
| 62 | + if (defined('mdebug')) { |
|
| 63 | 63 | echo " -> objectParse "; |
| 64 | 64 | } |
| 65 | 65 | $parser->parse(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $parser->param = $param; |
| 75 | 75 | $parser->model = $model; |
| 76 | 76 | $parser->object = $this; |
| 77 | - if(defined('mdebug')){ |
|
| 77 | + if (defined('mdebug')) { |
|
| 78 | 78 | echo " -> parser ($parserName) "; |
| 79 | 79 | } |
| 80 | 80 | $parser->parse(); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $walked = []; |
| 49 | 49 | foreach ($this->object->params as $param) { |
| 50 | - if(defined('mdebug')){ |
|
| 50 | + if(defined('mdebug')) { |
|
| 51 | 51 | echo " -> param ($param->id,$param->type,$param->value) "; |
| 52 | 52 | } |
| 53 | 53 | if ($model && $param->type && $param->type != 'item_key') { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $parser->parentObject = $this; |
| 60 | 60 | $parser->parentModel = $model; |
| 61 | 61 | $parser->walker = $this->walker; |
| 62 | - if(defined('mdebug')){ |
|
| 62 | + if(defined('mdebug')) { |
|
| 63 | 63 | echo " -> objectParse "; |
| 64 | 64 | } |
| 65 | 65 | $parser->parse(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $parser->param = $param; |
| 75 | 75 | $parser->model = $model; |
| 76 | 76 | $parser->object = $this; |
| 77 | - if(defined('mdebug')){ |
|
| 77 | + if(defined('mdebug')) { |
|
| 78 | 78 | echo " -> parser ($parserName) "; |
| 79 | 79 | } |
| 80 | 80 | $parser->parse(); |
@@ -233,7 +233,7 @@ |
||
| 233 | 233 | * Getting items with params |
| 234 | 234 | * |
| 235 | 235 | * @param array $params |
| 236 | - * @return array |
|
| 236 | + * @return Model[] |
|
| 237 | 237 | */ |
| 238 | 238 | public function getItems($params = []) { |
| 239 | 239 | $selectOptions = Ecommerce\OptionsParser::parse($params); |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | $favs = !empty($_COOKIE['ecommerce_favitems']) ? json_decode($_COOKIE['ecommerce_favitems'], true) : []; |
| 17 | 17 | if ($favs) { |
| 18 | 18 | foreach ($favs as $itemId) { |
| 19 | - $fav = \Ecommerce\Favorite::get([['user_id', Users\User::$cur->id], ['item_id', (int)$itemId]]); |
|
| 19 | + $fav = \Ecommerce\Favorite::get([['user_id', Users\User::$cur->id], ['item_id', (int) $itemId]]); |
|
| 20 | 20 | if (!$fav) { |
| 21 | - $item = \Ecommerce\Item::get((int)$itemId); |
|
| 21 | + $item = \Ecommerce\Item::get((int) $itemId); |
|
| 22 | 22 | if ($item) { |
| 23 | 23 | $fav = new \Ecommerce\Favorite([ |
| 24 | 24 | 'user_id' => Users\User::$cur->id, |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | public function getCurCart($create = true) { |
| 181 | 181 | $cart = false; |
| 182 | 182 | if (!empty($_SESSION['cart']['cart_id'])) { |
| 183 | - $cart = Ecommerce\Cart::get((int)$_SESSION['cart']['cart_id']); |
|
| 183 | + $cart = Ecommerce\Cart::get((int) $_SESSION['cart']['cart_id']); |
|
| 184 | 184 | } |
| 185 | 185 | if (!$cart && $create) { |
| 186 | 186 | $cart = new Ecommerce\Cart(); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $path = trim(implode('/', $args)); |
| 18 | 18 | |
| 19 | 19 | if (is_numeric($path)) { |
| 20 | - $material = Materials\Material::get([['id', (int)$path], ['date_publish', null, 'IS NOT']]); |
|
| 20 | + $material = Materials\Material::get([['id', (int) $path], ['date_publish', null, 'IS NOT']]); |
|
| 21 | 21 | } |
| 22 | 22 | if (!$material && $args) { |
| 23 | 23 | foreach ($args as $key => $alias) { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | if ($category) { |
| 43 | 43 | $where = [ |
| 44 | 44 | ['category_id', $category->id], |
| 45 | - ['id', (int)$args[count($args) - 1]], |
|
| 45 | + ['id', (int) $args[count($args) - 1]], |
|
| 46 | 46 | ['date_publish', null, 'IS NOT'] |
| 47 | 47 | ]; |
| 48 | 48 | } else { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $path = trim(implode('/', $args)); |
| 76 | 76 | $category = null; |
| 77 | 77 | if (is_numeric($path)) { |
| 78 | - $category = Materials\Category::get((int)$path); |
|
| 78 | + $category = Materials\Category::get((int) $path); |
|
| 79 | 79 | } |
| 80 | 80 | if (!$category) { |
| 81 | 81 | foreach ($args as $alias) { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $material = false; |
| 111 | 111 | if ($alias) { |
| 112 | 112 | if (is_numeric($alias)) { |
| 113 | - $material = Materials\Material::get([['id', (int)$alias], ['date_publish', null, 'IS NOT']]); |
|
| 113 | + $material = Materials\Material::get([['id', (int) $alias], ['date_publish', null, 'IS NOT']]); |
|
| 114 | 114 | } |
| 115 | 115 | if (!$material) { |
| 116 | 116 | $material = Materials\Material::get([['alias', $alias], ['date_publish', null, 'IS NOT']]); |
@@ -71,8 +71,8 @@ |
||
| 71 | 71 | $where[] = ['data', $_GET['data']]; |
| 72 | 72 | } |
| 73 | 73 | $pays = Money\Pay::getList(['where' => $where, 'order' => ['date_create', 'DESC']]); |
| 74 | - if(count($pays)===1){ |
|
| 75 | - Tools::redirect('/money/merchants/pay/'.current($pays)->id); |
|
| 74 | + if (count($pays) === 1) { |
|
| 75 | + Tools::redirect('/money/merchants/pay/' . current($pays)->id); |
|
| 76 | 76 | } |
| 77 | 77 | $this->view->page(['content' => 'pays', 'data' => compact('bread', 'pays')]); |
| 78 | 78 | } else { |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $where[] = ['data', $_GET['data']]; |
| 72 | 72 | } |
| 73 | 73 | $pays = Money\Pay::getList(['where' => $where, 'order' => ['date_create', 'DESC']]); |
| 74 | - if(count($pays)===1){ |
|
| 74 | + if(count($pays)===1) { |
|
| 75 | 75 | Tools::redirect('/money/merchants/pay/'.current($pays)->id); |
| 76 | 76 | } |
| 77 | 77 | $this->view->page(['content' => 'pays', 'data' => compact('bread', 'pays')]); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | )); |
| 34 | 34 | $context = stream_context_create($options); |
| 35 | 35 | echo "<style>.tmg {margin:0 auto}</style>"; |
| 36 | - echo file_get_contents("http://{$config['domain']}.paykeeper.ru/order/inline/", FALSE, $context); |
|
| 36 | + echo file_get_contents("http://{$config['domain']}.paykeeper.ru/order/inline/", false, $context); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | 'distinct' => false, |
| 71 | 71 | 'join' => [], |
| 72 | 72 | 'order' => [], |
| 73 | - 'start' => isset($options['start']) ? (int)$options['start'] : 0, |
|
| 73 | + 'start' => isset($options['start']) ? (int) $options['start'] : 0, |
|
| 74 | 74 | 'key' => isset($options['key']) ? $options['key'] : null, |
| 75 | - 'limit' => !empty($options['count']) ? (int)$options['count'] : 0, |
|
| 75 | + 'limit' => !empty($options['count']) ? (int) $options['count'] : 0, |
|
| 76 | 76 | ]; |
| 77 | 77 | |
| 78 | 78 | //only not deleted items |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | if (!empty(\App::$cur->Ecommerce->config['view_filter']['options'])) { |
| 135 | 135 | foreach (\App::$cur->Ecommerce->config['view_filter']['options'] as $optionId => $optionValue) { |
| 136 | 136 | $selectOptions['join'][] = [Item\Param::table(), Item::index() . ' = ' . 'option' . $optionId . '.' . Item\Param::colPrefix() . Item::index() . ' AND ' . |
| 137 | - 'option' . $optionId . '.' . Item\Param::colPrefix() . Item\Option::index() . ' = "' . (int)$optionId . '" AND ' . |
|
| 138 | - 'option' . $optionId . '.' . Item\Param::colPrefix() . 'value = "' . (int)$optionValue . '"', |
|
| 137 | + 'option' . $optionId . '.' . Item\Param::colPrefix() . Item\Option::index() . ' = "' . (int) $optionId . '" AND ' . |
|
| 138 | + 'option' . $optionId . '.' . Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"', |
|
| 139 | 139 | 'inner', 'option' . $optionId]; |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | break; |
| 155 | 155 | case 'badge': |
| 156 | - $selectOptions['where'][] = ['item_badge_id', (int)$filter]; |
|
| 156 | + $selectOptions['where'][] = ['item_badge_id', (int) $filter]; |
|
| 157 | 157 | break; |
| 158 | 158 | case 'price': |
| 159 | 159 | $colName = Item\Offer\Price::colPrefix() . 'price'; |
| 160 | 160 | if (!empty($filter['min'])) { |
| 161 | - $selectOptions['where'][] = [$colName, (float)$filter['min'], '>=']; |
|
| 161 | + $selectOptions['where'][] = [$colName, (float) $filter['min'], '>=']; |
|
| 162 | 162 | } |
| 163 | 163 | if (!empty($filter['max'])) { |
| 164 | - $selectOptions['where'][] = [$colName, (float)$filter['max'], '<=']; |
|
| 164 | + $selectOptions['where'][] = [$colName, (float) $filter['max'], '<=']; |
|
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | case 'options': |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | if ($filter) { |
| 181 | 181 | foreach ($filter as $optionId => $optionValue) { |
| 182 | - $optionId = (int)$optionId; |
|
| 182 | + $optionId = (int) $optionId; |
|
| 183 | 183 | if (is_array($optionValue)) { |
| 184 | 184 | $optionValueArr = []; |
| 185 | 185 | foreach ($optionValue as $val) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue); |
| 191 | 191 | } |
| 192 | 192 | $selectOptions['join'][] = [$table, $itemIndex . ' = ' . 'option' . $optionId . '.' . $paramPrefix . $itemIndex . ' AND ' . |
| 193 | - 'option' . $optionId . '.' . $paramPrefix . $optionIndex . ' = "' . (int)$optionId . '" AND ' . |
|
| 193 | + 'option' . $optionId . '.' . $paramPrefix . $optionIndex . ' = "' . (int) $optionId . '" AND ' . |
|
| 194 | 194 | 'option' . $optionId . '.' . $paramPrefix . 'value ' . $qstr . '', |
| 195 | 195 | 'inner', 'option' . $optionId]; |
| 196 | 196 | } |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | continue; |
| 213 | 213 | } |
| 214 | 214 | $category = Category::get($categoryId); |
| 215 | - $where[] = ['tree_path', $category->tree_path . (int)$categoryId . '/%', 'LIKE', $first ? 'AND' : 'OR']; |
|
| 215 | + $where[] = ['tree_path', $category->tree_path . (int) $categoryId . '/%', 'LIKE', $first ? 'AND' : 'OR']; |
|
| 216 | 216 | $first = false; |
| 217 | 217 | } |
| 218 | 218 | $selectOptions['where'][] = $where; |
| 219 | 219 | } else { |
| 220 | 220 | $category = Category::get($options['parent']); |
| 221 | 221 | if ($category) { |
| 222 | - $selectOptions['where'][] = ['tree_path', $category->tree_path . (int)$options['parent'] . '/%', 'LIKE']; |
|
| 222 | + $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE']; |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | ['user_id', $userId], |
| 66 | 66 | ['hash', $hash] |
| 67 | 67 | ]); |
| 68 | - if(!$session){ |
|
| 68 | + if (!$session) { |
|
| 69 | 69 | if (!headers_sent()) { |
| 70 | 70 | setcookie($this->cookiePrefix . "_user_session_hash", '', 0, "/"); |
| 71 | 71 | setcookie($this->cookiePrefix . "_user_id", '', 0, "/"); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ['user_id', $userId], |
| 66 | 66 | ['hash', $hash] |
| 67 | 67 | ]); |
| 68 | - if(!$session){ |
|
| 68 | + if(!$session) { |
|
| 69 | 69 | if (!headers_sent()) { |
| 70 | 70 | setcookie($this->cookiePrefix . "_user_session_hash", '', 0, "/"); |
| 71 | 71 | setcookie($this->cookiePrefix . "_user_id", '', 0, "/"); |
@@ -243,17 +243,20 @@ discard block |
||
| 243 | 243 | * @return boolean|\Users\User |
| 244 | 244 | */ |
| 245 | 245 | public function get($idn, $ltype = 'id') { |
| 246 | - if (!$idn) |
|
| 247 | - return false; |
|
| 246 | + if (!$idn) { |
|
| 247 | + return false; |
|
| 248 | + } |
|
| 248 | 249 | |
| 249 | - if (is_numeric($idn) && $ltype != 'login') |
|
| 250 | - $user = Users\User::get($idn, 'id'); |
|
| 251 | - elseif ($ltype == 'login') |
|
| 252 | - $user = Users\User::get($idn, 'login'); |
|
| 253 | - else |
|
| 254 | - $user = Users\User::get($idn, 'mail'); |
|
| 255 | - if (!$user) |
|
| 256 | - return []; |
|
| 250 | + if (is_numeric($idn) && $ltype != 'login') { |
|
| 251 | + $user = Users\User::get($idn, 'id'); |
|
| 252 | + } elseif ($ltype == 'login') { |
|
| 253 | + $user = Users\User::get($idn, 'login'); |
|
| 254 | + } else { |
|
| 255 | + $user = Users\User::get($idn, 'mail'); |
|
| 256 | + } |
|
| 257 | + if (!$user) { |
|
| 258 | + return []; |
|
| 259 | + } |
|
| 257 | 260 | |
| 258 | 261 | return $user; |
| 259 | 262 | } |