@@ -58,6 +58,10 @@ |
||
| 58 | 58 | self::command('install', false, $path); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | + /** |
|
| 62 | + * @param string $command |
|
| 63 | + * @param string $path |
|
| 64 | + */ |
|
| 61 | 65 | static function command($command, $needOutput = true, $path = null) |
| 62 | 66 | { |
| 63 | 67 | include_once 'composer/vendor/autoload.php'; |
@@ -24,7 +24,8 @@ |
||
| 24 | 24 | $code .= '$' . $this->name . ' = '; |
| 25 | 25 | if (is_array($this->value)) { |
| 26 | 26 | $code .= \CodeGenerator::genArray($this->value); |
| 27 | - } else { |
|
| 27 | + } |
|
| 28 | + else { |
|
| 28 | 29 | $code .= '"' . str_replace('"', '\"', $this->value) . '";'; |
| 29 | 30 | } |
| 30 | 31 | return $code; |
@@ -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 | } |
@@ -45,6 +45,10 @@ |
||
| 45 | 45 | return $modelCols; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | + /** |
|
| 49 | + * @param string $colPrefix |
|
| 50 | + * @param string $tableName |
|
| 51 | + */ |
|
| 48 | 52 | function parseColsForTable($cols, $colPrefix, $tableName) |
| 49 | 53 | { |
| 50 | 54 | |
@@ -87,7 +87,8 @@ |
||
| 87 | 87 | foreach ($this->currencies as $merchantCurrency) { |
| 88 | 88 | if ($merchantCurrency->currency_id == $pay->currency_id) { |
| 89 | 89 | $allowCurrencies[] = ['type' => 'primary', 'currency' => $merchantCurrency->currency]; |
| 90 | - } else { |
|
| 90 | + } |
|
| 91 | + else { |
|
| 91 | 92 | $transfer = Currency\ExchangeRate::get([['currency_id', $merchantCurrency->currency_id], ['target_currency_id', $pay->currency_id]]); |
| 92 | 93 | if ($transfer) { |
| 93 | 94 | $allowCurrencies[] = ['type' => 'transfer', 'currency' => $merchantCurrency->currency, 'transfer' => $transfer]; |
@@ -23,6 +23,9 @@ |
||
| 23 | 23 | public $attributes = []; |
| 24 | 24 | public $indexCol = null; |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string[] $cols |
|
| 28 | + */ |
|
| 26 | 29 | function setCols($cols) |
| 27 | 30 | { |
| 28 | 31 | $this->cols = $cols; |
@@ -147,6 +147,9 @@ discard block |
||
| 147 | 147 | return $result[1]; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | + /** |
|
| 151 | + * @param string $source |
|
| 152 | + */ |
|
| 150 | 153 | function parseSource($source) |
| 151 | 154 | { |
| 152 | 155 | $tags = $this->parseRaw($source); |
@@ -190,6 +193,9 @@ discard block |
||
| 190 | 193 | return substr($source, ( $pos + strlen($rawTag) + 2)); |
| 191 | 194 | } |
| 192 | 195 | |
| 196 | + /** |
|
| 197 | + * @param string $type |
|
| 198 | + */ |
|
| 193 | 199 | function getHref($type, $params) |
| 194 | 200 | { |
| 195 | 201 | $href = ''; |
@@ -531,6 +537,9 @@ discard block |
||
| 531 | 537 | echo round(( microtime(true) - INJI_TIME_START), 4); |
| 532 | 538 | } |
| 533 | 539 | |
| 540 | + /** |
|
| 541 | + * @param string $type |
|
| 542 | + */ |
|
| 534 | 543 | function customAsset($type, $asset, $lib = false) |
| 535 | 544 | { |
| 536 | 545 | if (!$lib) { |
@@ -549,6 +558,9 @@ discard block |
||
| 549 | 558 | } |
| 550 | 559 | } |
| 551 | 560 | |
| 561 | + /** |
|
| 562 | + * @param string $lineParams |
|
| 563 | + */ |
|
| 552 | 564 | function widget($_widgetName, $_params = [], $lineParams = null) |
| 553 | 565 | { |
| 554 | 566 | $_paths = $this->getWidgetPaths($_widgetName); |
@@ -59,7 +59,8 @@ discard block |
||
| 59 | 59 | $source = str_replace('</body>', '{BODYEND}</body>', $source); |
| 60 | 60 | } |
| 61 | 61 | $this->parseSource($source); |
| 62 | - } else { |
|
| 62 | + } |
|
| 63 | + else { |
|
| 63 | 64 | $this->content(); |
| 64 | 65 | } |
| 65 | 66 | } |
@@ -80,7 +81,8 @@ discard block |
||
| 80 | 81 | //set content |
| 81 | 82 | if (!empty($params['content'])) { |
| 82 | 83 | $this->template->setContent($params['content']); |
| 83 | - } elseif (!$this->template->contentPath) { |
|
| 84 | + } |
|
| 85 | + elseif (!$this->template->contentPath) { |
|
| 84 | 86 | $this->template->setContent(); |
| 85 | 87 | } |
| 86 | 88 | //set data |
@@ -98,7 +100,8 @@ discard block |
||
| 98 | 100 | } |
| 99 | 101 | if (!file_exists($this->template->contentPath)) { |
| 100 | 102 | echo 'Content not found'; |
| 101 | - } else { |
|
| 103 | + } |
|
| 104 | + else { |
|
| 102 | 105 | extract($this->contentData); |
| 103 | 106 | include $this->template->contentPath; |
| 104 | 107 | } |
@@ -126,15 +129,17 @@ discard block |
||
| 126 | 129 | } |
| 127 | 130 | if (!$data) { |
| 128 | 131 | echo 'Content not found'; |
| 129 | - } else { |
|
| 132 | + } |
|
| 133 | + else { |
|
| 130 | 134 | extract($this->contentData); |
| 131 | 135 | include $data['contentPath']; |
| 132 | 136 | } |
| 133 | 137 | } |
| 134 | 138 | |
| 135 | 139 | private function parseRaw($source) { |
| 136 | - if (!$source) |
|
| 137 | - return []; |
|
| 140 | + if (!$source) { |
|
| 141 | + return []; |
|
| 142 | + } |
|
| 138 | 143 | |
| 139 | 144 | preg_match_all("|{([^}]+)}|", $source, $result); |
| 140 | 145 | return $result[1]; |
@@ -185,9 +190,11 @@ discard block |
||
| 185 | 190 | $href = ''; |
| 186 | 191 | if (is_string($params)) { |
| 187 | 192 | $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params; |
| 188 | - } elseif (empty($params['template']) && !empty($params['file'])) { |
|
| 193 | + } |
|
| 194 | + elseif (empty($params['template']) && !empty($params['file'])) { |
|
| 189 | 195 | $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params['file']; |
| 190 | - } elseif (!empty($params['template']) && !empty($params['file'])) { |
|
| 196 | + } |
|
| 197 | + elseif (!empty($params['template']) && !empty($params['file'])) { |
|
| 191 | 198 | $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}"; |
| 192 | 199 | } |
| 193 | 200 | return $href; |
@@ -225,9 +232,11 @@ discard block |
||
| 225 | 232 | |
| 226 | 233 | if (!empty($this->template->config['favicon']) && file_exists($this->template->path . "/{$this->template->config['favicon']}")) { |
| 227 | 234 | echo " <link rel='shortcut icon' href='/templates/{$this->template->name}/{$this->template->config['favicon']}' />"; |
| 228 | - } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) { |
|
| 235 | + } |
|
| 236 | + elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) { |
|
| 229 | 237 | echo " <link rel='shortcut icon' href='/static/images/{$this->template->config['favicon']}' />"; |
| 230 | - } elseif (file_exists($this->app->path . '/static/images/favicon.ico')) { |
|
| 238 | + } |
|
| 239 | + elseif (file_exists($this->app->path . '/static/images/favicon.ico')) { |
|
| 231 | 240 | echo " <link rel='shortcut icon' href='/static/images/favicon.ico' />"; |
| 232 | 241 | } |
| 233 | 242 | |
@@ -267,7 +276,8 @@ discard block |
||
| 267 | 276 | $this->loadedCss[$href] = $href; |
| 268 | 277 | $urls[$href] = $path; |
| 269 | 278 | $timeStr.=filemtime($path); |
| 270 | - } else { |
|
| 279 | + } |
|
| 280 | + else { |
|
| 271 | 281 | echo "\n <link href='{$href}' rel='stylesheet' type='text/css' />"; |
| 272 | 282 | } |
| 273 | 283 | } |
@@ -311,10 +321,12 @@ discard block |
||
| 311 | 321 | $this->ResolveCssHref($css, $type, $hrefs); |
| 312 | 322 | continue; |
| 313 | 323 | } |
| 314 | - if (strpos($css, '//') !== false) |
|
| 315 | - $href = $css; |
|
| 316 | - else |
|
| 317 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 324 | + if (strpos($css, '//') !== false) { |
|
| 325 | + $href = $css; |
|
| 326 | + } |
|
| 327 | + else { |
|
| 328 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 329 | + } |
|
| 318 | 330 | $hrefs[$href] = $href; |
| 319 | 331 | } |
| 320 | 332 | break; |
@@ -324,10 +336,12 @@ discard block |
||
| 324 | 336 | $this->ResolveCssHref($css, $type, $hrefs); |
| 325 | 337 | continue; |
| 326 | 338 | } |
| 327 | - if (strpos($css, '://') !== false) |
|
| 328 | - $href = $css; |
|
| 329 | - else |
|
| 330 | - $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
| 339 | + if (strpos($css, '://') !== false) { |
|
| 340 | + $href = $css; |
|
| 341 | + } |
|
| 342 | + else { |
|
| 343 | + $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
| 344 | + } |
|
| 331 | 345 | $hrefs[$href] = $href; |
| 332 | 346 | } |
| 333 | 347 | break; |
@@ -337,10 +351,12 @@ discard block |
||
| 337 | 351 | $this->ResolveCssHref($css, $type, $hrefs); |
| 338 | 352 | continue; |
| 339 | 353 | } |
| 340 | - if (strpos($css, '//') !== false) |
|
| 341 | - $href = $css; |
|
| 342 | - else |
|
| 343 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 354 | + if (strpos($css, '//') !== false) { |
|
| 355 | + $href = $css; |
|
| 356 | + } |
|
| 357 | + else { |
|
| 358 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 359 | + } |
|
| 344 | 360 | $hrefs[$href] = $href; |
| 345 | 361 | } |
| 346 | 362 | break; |
@@ -360,7 +376,8 @@ discard block |
||
| 360 | 376 | foreach ($this->app->config['site']['metatags'] as $meta) { |
| 361 | 377 | if (!empty($meta['name'])) { |
| 362 | 378 | $metas['metaName:' . $meta['name']] = $meta; |
| 363 | - } elseif (!empty($meta['property'])) { |
|
| 379 | + } |
|
| 380 | + elseif (!empty($meta['property'])) { |
|
| 364 | 381 | $metas['metaProperty:' . $meta['property']] = $meta; |
| 365 | 382 | } |
| 366 | 383 | } |
@@ -374,7 +391,8 @@ discard block |
||
| 374 | 391 | public function addMetaTag($meta) { |
| 375 | 392 | if (!empty($meta['name'])) { |
| 376 | 393 | $this->dynMetas['metaName:' . $meta['name']] = $meta; |
| 377 | - } elseif (!empty($meta['property'])) { |
|
| 394 | + } |
|
| 395 | + elseif (!empty($meta['property'])) { |
|
| 378 | 396 | $this->dynMetas['metaProperty:' . $meta['property']] = $meta; |
| 379 | 397 | } |
| 380 | 398 | } |
@@ -391,20 +409,24 @@ discard block |
||
| 391 | 409 | $noParsedScripts = []; |
| 392 | 410 | foreach ($scripts as $script) { |
| 393 | 411 | if (is_string($script)) { |
| 394 | - if (!empty($urls[$script])) |
|
| 395 | - continue; |
|
| 412 | + if (!empty($urls[$script])) { |
|
| 413 | + continue; |
|
| 414 | + } |
|
| 396 | 415 | |
| 397 | 416 | $path = $this->app->staticLoader->parsePath($script); |
| 398 | 417 | if (file_exists($path)) { |
| 399 | 418 | $nativeUrl[$script] = $script; |
| 400 | 419 | $urls[$script] = $path; |
| 401 | 420 | $timeStr.=filemtime($path); |
| 402 | - } else { |
|
| 421 | + } |
|
| 422 | + else { |
|
| 403 | 423 | $noParsedScripts[$script] = $script; |
| 404 | 424 | } |
| 405 | - } elseif (!empty($script['file'])) { |
|
| 406 | - if (!empty($urls[$script['file']])) |
|
| 407 | - continue; |
|
| 425 | + } |
|
| 426 | + elseif (!empty($script['file'])) { |
|
| 427 | + if (!empty($urls[$script['file']])) { |
|
| 428 | + continue; |
|
| 429 | + } |
|
| 408 | 430 | |
| 409 | 431 | $path = $this->app->staticLoader->parsePath($script['file']); |
| 410 | 432 | if (file_exists($path)) { |
@@ -414,7 +436,8 @@ discard block |
||
| 414 | 436 | $onLoadModules[$script['name']] = $script['name']; |
| 415 | 437 | } |
| 416 | 438 | $timeStr.=filemtime($path); |
| 417 | - } else { |
|
| 439 | + } |
|
| 440 | + else { |
|
| 418 | 441 | $noParsedScripts[$script] = $script; |
| 419 | 442 | } |
| 420 | 443 | } |
@@ -461,12 +484,15 @@ discard block |
||
| 461 | 484 | $this->genScriptArray($js, $type, $resultArray); |
| 462 | 485 | continue; |
| 463 | 486 | } |
| 464 | - if (strpos($js, '//') !== false) |
|
| 465 | - $href = $js; |
|
| 466 | - else |
|
| 467 | - $href = $this->getHref('js', $js); |
|
| 468 | - if (!$href) |
|
| 469 | - continue; |
|
| 487 | + if (strpos($js, '//') !== false) { |
|
| 488 | + $href = $js; |
|
| 489 | + } |
|
| 490 | + else { |
|
| 491 | + $href = $this->getHref('js', $js); |
|
| 492 | + } |
|
| 493 | + if (!$href) { |
|
| 494 | + continue; |
|
| 495 | + } |
|
| 470 | 496 | |
| 471 | 497 | $resultArray[] = $href; |
| 472 | 498 | } |
@@ -477,10 +503,12 @@ discard block |
||
| 477 | 503 | $this->genScriptArray($js, $type, $resultArray); |
| 478 | 504 | continue; |
| 479 | 505 | } |
| 480 | - if (strpos($js, '//') !== false) |
|
| 481 | - $href = $js; |
|
| 482 | - else |
|
| 483 | - $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
| 506 | + if (strpos($js, '//') !== false) { |
|
| 507 | + $href = $js; |
|
| 508 | + } |
|
| 509 | + else { |
|
| 510 | + $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
| 511 | + } |
|
| 484 | 512 | $resultArray[] = $href; |
| 485 | 513 | } |
| 486 | 514 | break; |
@@ -492,12 +520,14 @@ discard block |
||
| 492 | 520 | continue; |
| 493 | 521 | } |
| 494 | 522 | $asset = $js; |
| 495 | - } else { |
|
| 523 | + } |
|
| 524 | + else { |
|
| 496 | 525 | $asset = []; |
| 497 | 526 | } |
| 498 | 527 | $asset['file'] = $this->getHref('js', $js); |
| 499 | - if (!$asset['file']) |
|
| 500 | - continue; |
|
| 528 | + if (!$asset['file']) { |
|
| 529 | + continue; |
|
| 530 | + } |
|
| 501 | 531 | $resultArray[] = $asset; |
| 502 | 532 | } |
| 503 | 533 | break; |
@@ -507,7 +537,8 @@ discard block |
||
| 507 | 537 | public function customAsset($type, $asset, $lib = false) { |
| 508 | 538 | if (!$lib) { |
| 509 | 539 | $this->dynAssets[$type][] = $asset; |
| 510 | - } else { |
|
| 540 | + } |
|
| 541 | + else { |
|
| 511 | 542 | $this->libAssets[$type][$lib][] = $asset; |
| 512 | 543 | } |
| 513 | 544 | } |
@@ -516,10 +547,12 @@ discard block |
||
| 516 | 547 | if ($add && !empty($this->app->config['site']['name'])) { |
| 517 | 548 | if ($title) { |
| 518 | 549 | $this->title = $title . ' - ' . $this->app->config['site']['name']; |
| 519 | - } else { |
|
| 550 | + } |
|
| 551 | + else { |
|
| 520 | 552 | $this->title = $this->app->config['site']['name']; |
| 521 | 553 | } |
| 522 | - } else { |
|
| 554 | + } |
|
| 555 | + else { |
|
| 523 | 556 | $this->title = $title; |
| 524 | 557 | } |
| 525 | 558 | } |
@@ -542,8 +575,9 @@ discard block |
||
| 542 | 575 | $paramArray = true; |
| 543 | 576 | } |
| 544 | 577 | } |
| 545 | - if (!$paramArray) |
|
| 546 | - $lineParams = ':' . implode(':', $_params); |
|
| 578 | + if (!$paramArray) { |
|
| 579 | + $lineParams = ':' . implode(':', $_params); |
|
| 580 | + } |
|
| 547 | 581 | } |
| 548 | 582 | } |
| 549 | 583 | echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n"; |
@@ -570,7 +604,8 @@ discard block |
||
| 570 | 604 | $paths[$pathName] = $path . '/widgets/' . $widgetName[1] . '.php'; |
| 571 | 605 | } |
| 572 | 606 | return $paths; |
| 573 | - } else { |
|
| 607 | + } |
|
| 608 | + else { |
|
| 574 | 609 | $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '/' . $widgetName . '.php'; |
| 575 | 610 | $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '.php'; |
| 576 | 611 | |
@@ -31,6 +31,9 @@ |
||
| 31 | 31 | return $return; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $path |
|
| 36 | + */ |
|
| 34 | 37 | static function parseClass($path) |
| 35 | 38 | { |
| 36 | 39 | $code = file_get_contents($path); |
@@ -12,20 +12,23 @@ |
||
| 12 | 12 | |
| 13 | 13 | public static function genArray($data, $level = 0) { |
| 14 | 14 | $return = ''; |
| 15 | - if ($level == 0) |
|
| 16 | - $return = "["; |
|
| 15 | + if ($level == 0) { |
|
| 16 | + $return = "["; |
|
| 17 | + } |
|
| 17 | 18 | foreach ($data as $key => $item) { |
| 18 | 19 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => "; |
| 19 | - if (!is_array($item)) |
|
| 20 | - $return .= "'{$item}',"; |
|
| 20 | + if (!is_array($item)) { |
|
| 21 | + $return .= "'{$item}',"; |
|
| 22 | + } |
|
| 21 | 23 | else { |
| 22 | 24 | $return .= "["; |
| 23 | 25 | $return .= rtrim(self::genArray($item, $level + 1), ','); |
| 24 | 26 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],"; |
| 25 | 27 | } |
| 26 | 28 | } |
| 27 | - if ($level == 0) |
|
| 28 | - $return = rtrim($return, ',') . "\n];"; |
|
| 29 | + if ($level == 0) { |
|
| 30 | + $return = rtrim($return, ',') . "\n];"; |
|
| 31 | + } |
|
| 29 | 32 | |
| 30 | 33 | return $return; |
| 31 | 34 | } |
@@ -52,8 +52,9 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | static function get($clean = false) |
| 54 | 54 | { |
| 55 | - if (empty($_SESSION['_INJI_MSG'])) |
|
| 56 | - return []; |
|
| 55 | + if (empty($_SESSION['_INJI_MSG'])) { |
|
| 56 | + return []; |
|
| 57 | + } |
|
| 57 | 58 | $msgs = $_SESSION['_INJI_MSG']; |
| 58 | 59 | if ($clean) { |
| 59 | 60 | $_SESSION['_INJI_MSG'] = []; |
@@ -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}]"; |