| @@ -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'; | 
| @@ -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) | 
| @@ -58,8 +58,9 @@ discard block | ||
| 58 | 58 | */ | 
| 59 | 59 | static function createDir($path) | 
| 60 | 60 |      { | 
| 61 | - if (file_exists($path)) | |
| 62 | - return true; | |
| 61 | +        if (file_exists($path)) { | |
| 62 | + return true; | |
| 63 | + } | |
| 63 | 64 | |
| 64 | 65 |          $path = explode('/', $path); | 
| 65 | 66 | $cur = ''; | 
| @@ -101,10 +102,11 @@ discard block | ||
| 101 | 102 |          $imagecreatefromX = "imagecreatefrom{$img_type}"; | 
| 102 | 103 | $src_res = $imagecreatefromX($img_path); | 
| 103 | 104 | |
| 104 | - if ($img_width / $max_width > $img_height / $max_height) | |
| 105 | - $separator = $img_width / $max_width; | |
| 106 | - else | |
| 107 | - $separator = $img_height / $max_height; | |
| 105 | +        if ($img_width / $max_width > $img_height / $max_height) { | |
| 106 | + $separator = $img_width / $max_width; | |
| 107 | +        } else { | |
| 108 | + $separator = $img_height / $max_height; | |
| 109 | + } | |
| 108 | 110 | |
| 109 | 111 |          if ($crop === true || $crop == 'q') { | 
| 110 | 112 |              if ($img_width > $img_height) { | 
| @@ -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'; | 
| @@ -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,13 +182,15 @@ 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 | 196 |                  if (is_array($value)) { | 
| @@ -209,12 +216,12 @@ discard block | ||
| 209 | 216 | $value = "?"; | 
| 210 | 217 | } | 
| 211 | 218 | |
| 212 | -            if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') | |
| 213 | -                $this->whereString .= " {$where} {$operation} {$value} "; | |
| 214 | - else | |
| 215 | -                $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; | |
| 216 | - } | |
| 217 | -        else { | |
| 219 | +            if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { | |
| 220 | +                            $this->whereString .= " {$where} {$operation} {$value} "; | |
| 221 | +            } else { | |
| 222 | +                            $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; | |
| 223 | + } | |
| 224 | +        } else { | |
| 218 | 225 | $i = -1; | 
| 219 | 226 |              while (isset($where[++$i])) { | 
| 220 | 227 | $item = $where[$i]; | 
| @@ -229,10 +236,11 @@ discard block | ||
| 229 | 236 |                          $this->whereString .= "{$concatenation} "; | 
| 230 | 237 | } | 
| 231 | 238 | |
| 232 | - if ($this->whereString != NULL) | |
| 233 | -                        $this->whereString .= '('; | |
| 234 | - else | |
| 235 | -                        $this->whereString = 'WHERE ('; | |
| 239 | +                    if ($this->whereString != NULL) { | |
| 240 | +                                            $this->whereString .= '('; | |
| 241 | +                    } else { | |
| 242 | +                                            $this->whereString = 'WHERE ('; | |
| 243 | + } | |
| 236 | 244 | } | 
| 237 | 245 | |
| 238 | 246 |                  if (!is_array($item)) { | 
| @@ -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 | |
| @@ -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); | 
| @@ -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"; | 
| @@ -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); | 
| @@ -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 | } | 
| @@ -79,10 +79,12 @@ discard block | ||
| 79 | 79 |              if (!empty($log['status'])) { | 
| 80 | 80 |                  echo "<tr class = '{$log['status']}'><td>{$log['name']}</td><td>{$log['status']}</td></tr>"; | 
| 81 | 81 |              } else { | 
| 82 | - if (empty($log['end'])) | |
| 83 | - $log['end'] = microtime(true); | |
| 84 | - if (empty($log['start'])) | |
| 85 | - $log['start'] = microtime(true); | |
| 82 | +                if (empty($log['end'])) { | |
| 83 | + $log['end'] = microtime(true); | |
| 84 | + } | |
| 85 | +                if (empty($log['start'])) { | |
| 86 | + $log['start'] = microtime(true); | |
| 87 | + } | |
| 86 | 88 |                  echo "<tr><td>{$log['name']}</td><td" . (round(($log['end'] - $log['start']), 5) > 0.1 ? ' class ="danger"' : '') . ">" . round(($log['end'] - $log['start']), 5) . "</td></tr>"; | 
| 87 | 89 | } | 
| 88 | 90 | } | 
| @@ -93,12 +95,13 @@ discard block | ||
| 93 | 95 | function convertSize($size) | 
| 94 | 96 |      { | 
| 95 | 97 | |
| 96 | - if ($size < 1024) | |
| 97 | - return $size . "B"; | |
| 98 | - elseif ($size < 1048576) | |
| 99 | - return round($size / 1024, 2) . "KB"; | |
| 100 | - else | |
| 101 | - return round($size / 1048576, 2) . "MB"; | |
| 98 | +        if ($size < 1024) { | |
| 99 | + return $size . "B"; | |
| 100 | +        } elseif ($size < 1048576) { | |
| 101 | + return round($size / 1024, 2) . "KB"; | |
| 102 | +        } else { | |
| 103 | + return round($size / 1048576, 2) . "MB"; | |
| 104 | + } | |
| 102 | 105 | } | 
| 103 | 106 | |
| 104 | 107 | function __destruct() | 
| @@ -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'] = []; |