| @@ -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'; | 
| @@ -19,7 +19,7 @@ discard block | ||
| 19 | 19 | ; | 
| 20 | 20 |              self::initComposer('./'); | 
| 21 | 21 | } | 
| 22 | -        if (!file_exists(App::$primary->path . '/vendor/autoload.php')) { | |
| 22 | +        if (!file_exists(App::$primary->path.'/vendor/autoload.php')) { | |
| 23 | 23 | self::initComposer(); | 
| 24 | 24 | } | 
| 25 | 25 | } | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 |              if (!file_exists('composer/composer.phar')) { | 
| 32 | 32 |                  file_put_contents('composer/composerInstall.php', file_get_contents('https://getcomposer.org/installer')); | 
| 33 | 33 | $argv = ['install', '--install-dir', 'composer/']; | 
| 34 | -                header("Location: " . filter_input(INPUT_SERVER, 'REQUEST_URI')); | |
| 34 | +                header("Location: ".filter_input(INPUT_SERVER, 'REQUEST_URI')); | |
| 35 | 35 | include_once 'composer/composerInstall.php'; | 
| 36 | 36 | } | 
| 37 | 37 |              $composer = new Phar('composer/composer.phar'); | 
| @@ -42,18 +42,18 @@ discard block | ||
| 42 | 42 | public static function initComposer($path = '') | 
| 43 | 43 |      { | 
| 44 | 44 |          if (!$path) { | 
| 45 | - $path = App::$primary->path . '/'; | |
| 45 | + $path = App::$primary->path.'/'; | |
| 46 | 46 | } | 
| 47 | -        if (!file_exists($path . 'composer.json')) { | |
| 47 | +        if (!file_exists($path.'composer.json')) { | |
| 48 | 48 | $json = [ | 
| 49 | - "name" => get_current_user() . "/" . App::$primary->name, | |
| 49 | + "name" => get_current_user()."/".App::$primary->name, | |
| 50 | 50 | "config" => [ | 
| 51 | 51 | "cache-dir" => "./composerCache/" | 
| 52 | 52 | ], | 
| 53 | 53 | "authors" => [ | 
| 54 | 54 | [ | 
| 55 | 55 | "name" => get_current_user(), | 
| 56 | - "email" => get_current_user() . "@" . INJI_DOMAIN_NAME | |
| 56 | + "email" => get_current_user()."@".INJI_DOMAIN_NAME | |
| 57 | 57 | ] | 
| 58 | 58 | ], | 
| 59 | 59 | "require" => [ | 
| @@ -61,7 +61,7 @@ discard block | ||
| 61 | 61 | ] | 
| 62 | 62 | ]; | 
| 63 | 63 | Tools::createDir($path); | 
| 64 | - file_put_contents($path . 'composer.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); | |
| 64 | + file_put_contents($path.'composer.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); | |
| 65 | 65 | } | 
| 66 | 66 |          self::command('install', false, $path); | 
| 67 | 67 | } | 
| @@ -74,8 +74,8 @@ discard block | ||
| 74 | 74 |          } else { | 
| 75 | 75 | $output = null; | 
| 76 | 76 | } | 
| 77 | -        $path = str_replace('\\', '/', $path === null ? App::$primary->path . '/' : $path); | |
| 78 | - $input = new Symfony\Component\Console\Input\StringInput($command . ' -d ' . $path); | |
| 77 | +        $path = str_replace('\\', '/', $path === null ? App::$primary->path.'/' : $path); | |
| 78 | + $input = new Symfony\Component\Console\Input\StringInput($command.' -d '.$path); | |
| 79 | 79 | $app = new Composer\Console\Application(); | 
| 80 | 80 | $app->setAutoExit(false); | 
| 81 | 81 | $dir = getcwd(); | 
| @@ -86,10 +86,10 @@ discard block | ||
| 86 | 86 | public static function requirePackage($packageName, $version = '', $path = '') | 
| 87 | 87 |      { | 
| 88 | 88 |          if (!$path) { | 
| 89 | - $path = App::$primary->path . '/'; | |
| 89 | + $path = App::$primary->path.'/'; | |
| 90 | 90 | } | 
| 91 | -        if (file_exists($path . 'composer.lock')) { | |
| 92 | - $lockFile = json_decode(file_get_contents($path . 'composer.lock'), true); | |
| 91 | +        if (file_exists($path.'composer.lock')) { | |
| 92 | + $lockFile = json_decode(file_get_contents($path.'composer.lock'), true); | |
| 93 | 93 | } | 
| 94 | 94 |          if (!empty($lockFile['packages'])) { | 
| 95 | 95 |              foreach ($lockFile['packages'] as $package) { | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | } | 
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | -        ComposerCmd::command('require ' . $packageName . ($version ? ':' . $version : ''), false, $path); | |
| 102 | +        ComposerCmd::command('require '.$packageName.($version ? ':'.$version : ''), false, $path); | |
| 103 | 103 | return true; | 
| 104 | 104 | } | 
| 105 | 105 | |
| @@ -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'; | 
| @@ -190,15 +190,15 @@ discard block | ||
| 190 | 190 | $newValue = ''; | 
| 191 | 191 |                      foreach ($value as $item) { | 
| 192 | 192 |                          if ($newValue) { | 
| 193 | - $newValue.=','; | |
| 193 | + $newValue .= ','; | |
| 194 | 194 | } | 
| 195 | 195 |                          if (is_string($item)) { | 
| 196 | - $newValue .='"' . $item . '"'; | |
| 196 | + $newValue .= '"'.$item.'"'; | |
| 197 | 197 |                          } else { | 
| 198 | - $newValue .=$item; | |
| 198 | + $newValue .= $item; | |
| 199 | 199 | } | 
| 200 | 200 | } | 
| 201 | -                    $value = '(' . $newValue . ')'; | |
| 201 | +                    $value = '('.$newValue.')'; | |
| 202 | 202 |                  } elseif (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) | 
| 203 | 203 |                      $value = "({$value})"; | 
| 204 | 204 |                  elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) | 
| @@ -262,8 +262,8 @@ discard block | ||
| 262 | 262 | |
| 263 | 263 |          switch ($this->operation) { | 
| 264 | 264 | case 'SELECT': | 
| 265 | - $query .= ' ' . ($this->distinct ? 'DISTINCT' : ''); | |
| 266 | -                $query .= ' ' . (!$this->cols ? '*' : ((is_array($this->cols) ? implode(',', $this->cols) : $this->cols))); | |
| 265 | + $query .= ' '.($this->distinct ? 'DISTINCT' : ''); | |
| 266 | +                $query .= ' '.(!$this->cols ? '*' : ((is_array($this->cols) ? implode(',', $this->cols) : $this->cols))); | |
| 267 | 267 | case 'DELETE': | 
| 268 | 268 | $query .= ' FROM'; | 
| 269 | 269 | break; | 
| @@ -280,9 +280,9 @@ discard block | ||
| 280 | 280 | $this->params = array_merge($this->params, array_values($this->cols)); | 
| 281 | 281 | $colsStr = ''; | 
| 282 | 282 |                  if ($this->cols) { | 
| 283 | -                    $colsStr = '`' . implode('`,`', array_keys($this->cols)) . '`'; | |
| 283 | +                    $colsStr = '`'.implode('`,`', array_keys($this->cols)).'`'; | |
| 284 | 284 | } | 
| 285 | -                $query .= ' (' . $colsStr . ') VALUES (' . rtrim(str_repeat('?,', count($this->cols)), ',') . ')'; | |
| 285 | +                $query .= ' ('.$colsStr.') VALUES ('.rtrim(str_repeat('?,', count($this->cols)), ',').')'; | |
| 286 | 286 | break; | 
| 287 | 287 | case 'CREATE TABLE': | 
| 288 | 288 |                  $query .= " ("; | 
| @@ -294,7 +294,7 @@ discard block | ||
| 294 | 294 | } | 
| 295 | 295 | $query = rtrim($query, ','); | 
| 296 | 296 |                  if ($this->indexes) { | 
| 297 | -                    $query .= ', ' . implode(',', $this->indexes); | |
| 297 | +                    $query .= ', '.implode(',', $this->indexes); | |
| 298 | 298 | } | 
| 299 | 299 | $query .= ") ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"; | 
| 300 | 300 | break; | 
| @@ -309,23 +309,23 @@ discard block | ||
| 309 | 309 | } | 
| 310 | 310 | } | 
| 311 | 311 |                  $update = implode(',', $updates); | 
| 312 | -                $query .=" SET {$update}"; | |
| 312 | +                $query .= " SET {$update}"; | |
| 313 | 313 | case 'SELECT': | 
| 314 | 314 | case 'DELETE': | 
| 315 | 315 | $this->buildWhere($this->where); | 
| 316 | 316 |                  if ($this->whereString) { | 
| 317 | - $query .= ' ' . $this->whereString; | |
| 317 | + $query .= ' '.$this->whereString; | |
| 318 | 318 | } | 
| 319 | 319 | break; | 
| 320 | 320 | } | 
| 321 | 321 |          if ($this->group) { | 
| 322 | -            $query .= ' GROUP BY ' . implode(',', $this->group); | |
| 322 | +            $query .= ' GROUP BY '.implode(',', $this->group); | |
| 323 | 323 | } | 
| 324 | 324 |          if ($this->order) { | 
| 325 | -            $query .= ' ORDER BY ' . implode(',', $this->order); | |
| 325 | +            $query .= ' ORDER BY '.implode(',', $this->order); | |
| 326 | 326 | } | 
| 327 | 327 |          if ($this->limit) { | 
| 328 | - $query .= ' ' . $this->limit; | |
| 328 | + $query .= ' '.$this->limit; | |
| 329 | 329 | } | 
| 330 | 330 | return ['query' => $query, 'params' => $this->params]; | 
| 331 | 331 | } | 
| @@ -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 | |
| @@ -13,19 +13,19 @@ discard block | ||
| 13 | 13 | public function createBlankModule($name, $codeName) | 
| 14 | 14 |      { | 
| 15 | 15 | $codeName = ucfirst($codeName); | 
| 16 | - Tools::createDir(App::$primary->path . '/modules/' . $codeName); | |
| 16 | + Tools::createDir(App::$primary->path.'/modules/'.$codeName); | |
| 17 | 17 | ob_start(); | 
| 18 | - include $this->path . '/tpls/BlankModule.php'; | |
| 18 | + include $this->path.'/tpls/BlankModule.php'; | |
| 19 | 19 | $moduleCode = ob_get_contents(); | 
| 20 | 20 | ob_end_clean(); | 
| 21 | - file_put_contents(App::$primary->path . '/modules/' . $codeName . '/' . $codeName . '.php', $moduleCode); | |
| 22 | - file_put_contents(App::$primary->path . '/modules/' . $codeName . '/info.php', "<?php\nreturn " . CodeGenerator::genArray(['name' => $name])); | |
| 23 | - file_put_contents(App::$primary->path . '/modules/' . $codeName . '/generatorHash.php', "<?php\nreturn " . CodeGenerator::genArray([$codeName . '.php' => md5($moduleCode)])); | |
| 21 | + file_put_contents(App::$primary->path.'/modules/'.$codeName.'/'.$codeName.'.php', $moduleCode); | |
| 22 | + file_put_contents(App::$primary->path.'/modules/'.$codeName.'/info.php', "<?php\nreturn ".CodeGenerator::genArray(['name' => $name])); | |
| 23 | + file_put_contents(App::$primary->path.'/modules/'.$codeName.'/generatorHash.php', "<?php\nreturn ".CodeGenerator::genArray([$codeName.'.php' => md5($moduleCode)])); | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | public function parseColsForModel($cols = []) | 
| 27 | 27 |      { | 
| 28 | - $modelCols = [ 'labels' => [], 'cols' => [], 'relations' => []]; | |
| 28 | + $modelCols = ['labels' => [], 'cols' => [], 'relations' => []]; | |
| 29 | 29 |          foreach ($cols as $col) { | 
| 30 | 30 | $modelCols['labels'][$col['code']] = $col['label']; | 
| 31 | 31 | $colType = !empty($col['type']['primary']) ? $col['type']['primary'] : $col['type']; | 
| @@ -50,11 +50,11 @@ discard block | ||
| 50 | 50 | |
| 51 | 51 | $colsExist = App::$cur->db->getTableCols($tableName); | 
| 52 | 52 | $tableCols = []; | 
| 53 | -        if (empty($colsExist[$colPrefix . 'id'])) { | |
| 54 | - $tableCols[$colPrefix . 'id'] = 'pk'; | |
| 53 | +        if (empty($colsExist[$colPrefix.'id'])) { | |
| 54 | + $tableCols[$colPrefix.'id'] = 'pk'; | |
| 55 | 55 | } | 
| 56 | 56 |          foreach ($cols as $col) { | 
| 57 | -            if (!empty($colsExist[$colPrefix . $col['code']])) { | |
| 57 | +            if (!empty($colsExist[$colPrefix.$col['code']])) { | |
| 58 | 58 | continue; | 
| 59 | 59 | } | 
| 60 | 60 | $colType = !empty($col['type']['primary']) ? $col['type']['primary'] : $col['type']; | 
| @@ -62,23 +62,23 @@ discard block | ||
| 62 | 62 | case 'image': | 
| 63 | 63 | case 'number': | 
| 64 | 64 | case 'relation': | 
| 65 | - $tableCols[$colPrefix . $col['code']] = 'int(11) NOT NULL'; | |
| 65 | + $tableCols[$colPrefix.$col['code']] = 'int(11) NOT NULL'; | |
| 66 | 66 | break; | 
| 67 | 67 | case 'decimal': | 
| 68 | - $tableCols[$colPrefix . $col['code']] = 'decimal(11,2) NOT NULL'; | |
| 68 | + $tableCols[$colPrefix.$col['code']] = 'decimal(11,2) NOT NULL'; | |
| 69 | 69 | break; | 
| 70 | 70 | case 'dateTime': | 
| 71 | - $tableCols[$colPrefix . $col['code']] = 'timestamp NOT NULL'; | |
| 71 | + $tableCols[$colPrefix.$col['code']] = 'timestamp NOT NULL'; | |
| 72 | 72 | break; | 
| 73 | 73 | case 'currentDateTime': | 
| 74 | - $tableCols[$colPrefix . $col['code']] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; | |
| 74 | + $tableCols[$colPrefix.$col['code']] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; | |
| 75 | 75 | break; | 
| 76 | 76 | case 'text': | 
| 77 | - $tableCols[$colPrefix . $col['code']] = 'varchar(255) NOT NULL'; | |
| 77 | + $tableCols[$colPrefix.$col['code']] = 'varchar(255) NOT NULL'; | |
| 78 | 78 | break; | 
| 79 | 79 | case 'textarea': | 
| 80 | 80 | default: | 
| 81 | - $tableCols[$colPrefix . $col['code']] = 'text NOT NULL'; | |
| 81 | + $tableCols[$colPrefix.$col['code']] = 'text NOT NULL'; | |
| 82 | 82 | break; | 
| 83 | 83 | } | 
| 84 | 84 | } | 
| @@ -94,8 +94,8 @@ discard block | ||
| 94 | 94 | $modelCols = $this->parseColsForModel(); | 
| 95 | 95 |          if (!empty($options['cols'])) { | 
| 96 | 96 | $modelCols = $this->parseColsForModel($options['cols']); | 
| 97 | - $tableName = strtolower($module) . '_' . strtolower($codeName); | |
| 98 | - $tableCols = $this->parseColsForTable($options['cols'], strtolower($codeName) . '_', $tableName); | |
| 97 | + $tableName = strtolower($module).'_'.strtolower($codeName); | |
| 98 | + $tableCols = $this->parseColsForTable($options['cols'], strtolower($codeName).'_', $tableName); | |
| 99 | 99 |              if (App::$cur->db->tableExist($tableName)) { | 
| 100 | 100 |                  foreach ($tableCols as $colKey => $params) { | 
| 101 | 101 | App::$cur->db->add_col($tableName, $colKey, $params); | 
| @@ -107,15 +107,15 @@ discard block | ||
| 107 | 107 |          $class->addProperty('objectName', $name, true); | 
| 108 | 108 |          $class->addProperty('cols', $modelCols['cols'], true); | 
| 109 | 109 |          $class->addProperty('labels', $modelCols['labels'], true); | 
| 110 | -        $class->addMethod('relations', 'return ' . CodeGenerator::genArray($modelCols['relations']), [], true); | |
| 111 | -        $modelCode = "<?php \n\nnamespace {$module};\n\n" . $class->generate(); | |
| 110 | +        $class->addMethod('relations', 'return '.CodeGenerator::genArray($modelCols['relations']), [], true); | |
| 111 | +        $modelCode = "<?php \n\nnamespace {$module};\n\n".$class->generate(); | |
| 112 | 112 | |
| 113 | 113 | $modulePath = Module::getModulePath($module); | 
| 114 | - Tools::createDir($modulePath . '/models'); | |
| 115 | - file_put_contents($modulePath . '/models/' . $codeName . '.php', $modelCode); | |
| 116 | - $config = Config::custom($modulePath . '/generatorHash.php'); | |
| 117 | - $config['models/' . $codeName . '.php'] = md5($modelCode); | |
| 118 | - Config::save($modulePath . '/generatorHash.php', $config); | |
| 114 | + Tools::createDir($modulePath.'/models'); | |
| 115 | + file_put_contents($modulePath.'/models/'.$codeName.'.php', $modelCode); | |
| 116 | + $config = Config::custom($modulePath.'/generatorHash.php'); | |
| 117 | + $config['models/'.$codeName.'.php'] = md5($modelCode); | |
| 118 | + Config::save($modulePath.'/generatorHash.php', $config); | |
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | 121 | public function install($module, $params = []) | 
| @@ -135,7 +135,7 @@ discard block | ||
| 135 | 135 | |
| 136 | 136 | $type = 'modules'; | 
| 137 | 137 | |
| 138 | - $path = INJI_SYSTEM_DIR . '/modules/'; | |
| 138 | + $path = INJI_SYSTEM_DIR.'/modules/'; | |
| 139 | 139 | $location = 'modules'; | 
| 140 | 140 | |
| 141 | 141 | $config[$location][] = $module; | 
| @@ -148,8 +148,8 @@ discard block | ||
| 148 | 148 | } | 
| 149 | 149 | } | 
| 150 | 150 |          Config::save('app', $config, null, App::$primary); | 
| 151 | -        if (file_exists($path . $module . '/install_script.php')) { | |
| 152 | - $installFunction = include $path . $module . '/install_script.php'; | |
| 151 | +        if (file_exists($path.$module.'/install_script.php')) { | |
| 152 | + $installFunction = include $path.$module.'/install_script.php'; | |
| 153 | 153 | $installFunction(1, $params); | 
| 154 | 154 | } | 
| 155 | 155 | } | 
| @@ -178,8 +178,8 @@ discard block | ||
| 178 | 178 | $info = Modules::getInfo($module); | 
| 179 | 179 | $moduleName = !empty($info['name']) ? $info['name'] : $module; | 
| 180 | 180 |              foreach ($modelsNames as $modelName) { | 
| 181 | - $fullModelName = $module . '\\' . $modelName; | |
| 182 | - $models[$fullModelName] = $moduleName . ' - ' . ($fullModelName::$objectName ? $fullModelName::$objectName : $modelName); | |
| 181 | + $fullModelName = $module.'\\'.$modelName; | |
| 182 | + $models[$fullModelName] = $moduleName.' - '.($fullModelName::$objectName ? $fullModelName::$objectName : $modelName); | |
| 183 | 183 | } | 
| 184 | 184 | } | 
| 185 | 185 |          foreach (App::$primary->config['modules'] as $configModule) { | 
| @@ -190,9 +190,9 @@ discard block | ||
| 190 | 190 | $info = Modules::getInfo($configModule); | 
| 191 | 191 | $moduleName = !empty($info['name']) ? $info['name'] : $configModule; | 
| 192 | 192 |              foreach ($modelsNames as $modelName) { | 
| 193 | - $fullModelName = $configModule . '\\' . $modelName; | |
| 193 | + $fullModelName = $configModule.'\\'.$modelName; | |
| 194 | 194 | Router::loadClass($fullModelName); | 
| 195 | - $models[$fullModelName] = $moduleName . ' - ' . ($fullModelName::$objectName ? $fullModelName::$objectName : $modelName); | |
| 195 | + $models[$fullModelName] = $moduleName.' - '.($fullModelName::$objectName ? $fullModelName::$objectName : $modelName); | |
| 196 | 196 | } | 
| 197 | 197 | } | 
| 198 | 198 | return $models; | 
| @@ -201,16 +201,16 @@ discard block | ||
| 201 | 201 | public function getModelsList($module, $dir = '') | 
| 202 | 202 |      { | 
| 203 | 203 | $modulePath = Module::getModulePath($module); | 
| 204 | - $path = rtrim($modulePath . '/models/' . $dir, '/'); | |
| 204 | + $path = rtrim($modulePath.'/models/'.$dir, '/'); | |
| 205 | 205 | $models = []; | 
| 206 | 206 |          if (file_exists($path)) { | 
| 207 | 207 |              foreach (array_slice(scandir($path), 2) as $file) { | 
| 208 | 208 | $modelLastName = pathinfo($file, PATHINFO_FILENAME); | 
| 209 | -                if (is_dir($path . '/' . $file)) { | |
| 210 | - $models = array_merge($models, $this->getModelsList($module, $dir . '/' . $modelLastName)); | |
| 209 | +                if (is_dir($path.'/'.$file)) { | |
| 210 | + $models = array_merge($models, $this->getModelsList($module, $dir.'/'.$modelLastName)); | |
| 211 | 211 | } | 
| 212 | -                $nameSpace = trim(preg_replace('!/' . $modelLastName . '$!', '', $dir), '/'); | |
| 213 | -                $models[] = trim(str_replace('/', '\\', $nameSpace) . '\\' . $modelLastName, '\\'); | |
| 212 | +                $nameSpace = trim(preg_replace('!/'.$modelLastName.'$!', '', $dir), '/'); | |
| 213 | +                $models[] = trim(str_replace('/', '\\', $nameSpace).'\\'.$modelLastName, '\\'); | |
| 214 | 214 | } | 
| 215 | 215 | } | 
| 216 | 216 | return $models; | 
| @@ -219,30 +219,30 @@ discard block | ||
| 219 | 219 | public function createController($module, $controllerType) | 
| 220 | 220 |      { | 
| 221 | 221 | $modulePath = Module::getModulePath($module); | 
| 222 | - $path = $modulePath . '/' . $controllerType . '/' . $module . 'Controller.php'; | |
| 222 | + $path = $modulePath.'/'.$controllerType.'/'.$module.'Controller.php'; | |
| 223 | 223 | $class = new CodeGenerator\ClassGenerator(); | 
| 224 | - $class->name = $module . 'Controller'; | |
| 224 | + $class->name = $module.'Controller'; | |
| 225 | 225 | $class->extends = 'Controller'; | 
| 226 | - $controllerCode = "<?php\n\n" . $class->generate(); | |
| 226 | + $controllerCode = "<?php\n\n".$class->generate(); | |
| 227 | 227 | Tools::createDir(pathinfo($path, PATHINFO_DIRNAME)); | 
| 228 | 228 | file_put_contents($path, $controllerCode); | 
| 229 | - $config = Config::custom($modulePath . '/generatorHash.php'); | |
| 230 | - $config[$controllerType . '/' . $module . 'Controller.php'] = md5($controllerCode); | |
| 231 | - Config::save($modulePath . '/generatorHash.php', $config); | |
| 229 | + $config = Config::custom($modulePath.'/generatorHash.php'); | |
| 230 | + $config[$controllerType.'/'.$module.'Controller.php'] = md5($controllerCode); | |
| 231 | + Config::save($modulePath.'/generatorHash.php', $config); | |
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 | public function addActionToController($module, $type, $controller, $url) | 
| 235 | 235 |      { | 
| 236 | 236 | $modulePath = Module::getModulePath($module); | 
| 237 | - $path = Modules::getModulePath($module) . '/' . $type . '/' . $controller . '.php'; | |
| 237 | + $path = Modules::getModulePath($module).'/'.$type.'/'.$controller.'.php'; | |
| 238 | 238 | $class = CodeGenerator::parseClass($path); | 
| 239 | - $class->addMethod($url . 'Action'); | |
| 240 | - $controllerCode = "<?php\n\n" . $class->generate(); | |
| 239 | + $class->addMethod($url.'Action'); | |
| 240 | + $controllerCode = "<?php\n\n".$class->generate(); | |
| 241 | 241 | Tools::createDir(pathinfo($path, PATHINFO_DIRNAME)); | 
| 242 | 242 | file_put_contents($path, $controllerCode); | 
| 243 | - $config = Config::custom($modulePath . '/generatorHash.php'); | |
| 244 | - $config[$type . '/' . $module . 'Controller.php'] = md5($controllerCode); | |
| 245 | - Config::save($modulePath . '/generatorHash.php', $config); | |
| 243 | + $config = Config::custom($modulePath.'/generatorHash.php'); | |
| 244 | + $config[$type.'/'.$module.'Controller.php'] = md5($controllerCode); | |
| 245 | + Config::save($modulePath.'/generatorHash.php', $config); | |
| 246 | 246 | } | 
| 247 | 247 | |
| 248 | 248 | } | 
| @@ -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"; | 
| @@ -37,17 +37,17 @@ discard block | ||
| 37 | 37 |          if (!empty($this->config[$this->app->type]['current'])) { | 
| 38 | 38 | $templateName = $this->config[$this->app->type]['current']; | 
| 39 | 39 |              if (!empty($this->config[$this->app->type]['installed'][$templateName]['location'])) { | 
| 40 | - $this->templatesPath = App::$primary->path . "/templates"; | |
| 40 | + $this->templatesPath = App::$primary->path."/templates"; | |
| 41 | 41 | } | 
| 42 | 42 | } | 
| 43 | 43 |          if (!$this->templatesPath) { | 
| 44 | - $this->templatesPath = $this->app->path . "/templates"; | |
| 44 | + $this->templatesPath = $this->app->path."/templates"; | |
| 45 | 45 | } | 
| 46 | 46 | $this->template = \View\Template::get($templateName, $this->app, $this->templatesPath); | 
| 47 | 47 |          if (!$this->template) { | 
| 48 | 48 | $this->template = new \View\Template([ | 
| 49 | 49 | 'name' => 'default', | 
| 50 | - 'path' => $this->templatesPath . '/default', | |
| 50 | + 'path' => $this->templatesPath.'/default', | |
| 51 | 51 | 'app' => $this->app | 
| 52 | 52 | ]); | 
| 53 | 53 | } | 
| @@ -164,7 +164,7 @@ discard block | ||
| 164 | 164 | case 'WIDGET': | 
| 165 | 165 | $source = $this->cutTag($source, $rawTag); | 
| 166 | 166 | $params = array_slice($tag, 2); | 
| 167 | -                    $this->widget($tag[1], ['params' => $params], ':' . implode(':', $params)); | |
| 167 | +                    $this->widget($tag[1], ['params' => $params], ':'.implode(':', $params)); | |
| 168 | 168 | break; | 
| 169 | 169 | case 'HEAD': | 
| 170 | 170 | $source = $this->cutTag($source, $rawTag); | 
| @@ -187,18 +187,18 @@ discard block | ||
| 187 | 187 |      { | 
| 188 | 188 | $pos = strpos($source, $rawTag) - 1; | 
| 189 | 189 | echo substr($source, 0, $pos); | 
| 190 | - return substr($source, ( $pos + strlen($rawTag) + 2)); | |
| 190 | + return substr($source, ($pos + strlen($rawTag) + 2)); | |
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | 193 | public function getHref($type, $params) | 
| 194 | 194 |      { | 
| 195 | 195 | $href = ''; | 
| 196 | 196 |          if (is_string($params)) { | 
| 197 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params; | |
| 197 | + $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$params; | |
| 198 | 198 |          } elseif (empty($params['template']) && !empty($params['file'])) { | 
| 199 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params['file']; | |
| 199 | + $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$params['file']; | |
| 200 | 200 |          } elseif (!empty($params['template']) && !empty($params['file'])) { | 
| 201 | -            $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}"; | |
| 201 | +            $href = $this->app->templatesPath."/{$this->template->name}/{$type}/{$params['file']}"; | |
| 202 | 202 | } | 
| 203 | 203 | return $href; | 
| 204 | 204 | } | 
| @@ -235,16 +235,16 @@ discard block | ||
| 235 | 235 | |
| 236 | 236 |          echo "<title>{$this->title}</title>\n"; | 
| 237 | 237 | |
| 238 | -        if (!empty($this->template->config['favicon']) && file_exists($this->template->path . "/{$this->template->config['favicon']}")) { | |
| 238 | +        if (!empty($this->template->config['favicon']) && file_exists($this->template->path."/{$this->template->config['favicon']}")) { | |
| 239 | 239 |              echo "        <link rel='shortcut icon' href='/templates/{$this->template->name}/{$this->template->config['favicon']}' />"; | 
| 240 | -        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path . "/static/images/{$this->template->config['favicon']}")) { | |
| 240 | +        } elseif (!empty($this->template->config['favicon']) && file_exists($this->app->path."/static/images/{$this->template->config['favicon']}")) { | |
| 241 | 241 |              echo "        <link rel='shortcut icon' href='/static/images/{$this->template->config['favicon']}' />"; | 
| 242 | -        } elseif (file_exists($this->app->path . '/static/images/favicon.ico')) { | |
| 242 | +        } elseif (file_exists($this->app->path.'/static/images/favicon.ico')) { | |
| 243 | 243 | echo " <link rel='shortcut icon' href='/static/images/favicon.ico' />"; | 
| 244 | 244 | } | 
| 245 | 245 | |
| 246 | 246 |          foreach ($this->getMetaTags() as $meta) { | 
| 247 | -            echo "\n        " . Html::el('meta', $meta, '', null); | |
| 247 | +            echo "\n        ".Html::el('meta', $meta, '', null); | |
| 248 | 248 | } | 
| 249 | 249 | |
| 250 | 250 |          if (!empty(Inji::$config['assets']['js'])) { | 
| @@ -255,7 +255,7 @@ discard block | ||
| 255 | 255 | |
| 256 | 256 | $this->checkNeedLibs(); | 
| 257 | 257 | $this->parseCss(); | 
| 258 | - echo "\n <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '' ) . "/static/system/js/Inji.js") . "'></script>"; | |
| 258 | + echo "\n <script src='".Statics::file(($this->app->type != 'app' ? '/'.$this->app->name : '')."/static/system/js/Inji.js")."'></script>"; | |
| 259 | 259 | } | 
| 260 | 260 | |
| 261 | 261 | public function parseCss() | 
| @@ -279,25 +279,25 @@ discard block | ||
| 279 | 279 |              if (file_exists($path)) { | 
| 280 | 280 | $this->loadedCss[$href] = $href; | 
| 281 | 281 | $urls[$href] = $path; | 
| 282 | - $timeStr.=filemtime($path); | |
| 282 | + $timeStr .= filemtime($path); | |
| 283 | 283 |              } else { | 
| 284 | 284 |                  echo "\n        <link href='{$href}' rel='stylesheet' type='text/css' />"; | 
| 285 | 285 | } | 
| 286 | 286 | } | 
| 287 | 287 | $timeMd5 = md5($timeStr); | 
| 288 | 288 |          $cacheDir = Cache::getDir('static'); | 
| 289 | -        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.css')) { | |
| 289 | +        if (!file_exists($cacheDir.'/all'.$timeMd5.'.css')) { | |
| 290 | 290 |              foreach ($urls as $primaryUrl => $url) { | 
| 291 | 291 | $source = file_get_contents($url); | 
| 292 | 292 | $rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/')); | 
| 293 | 293 | $levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/')); | 
| 294 | -                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source); | |
| 295 | -                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source); | |
| 296 | -                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source); | |
| 297 | -                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source); | |
| 294 | +                $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1'.$levelUpPath, $source); | |
| 295 | +                $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1'.$rootPath, $source); | |
| 296 | +                $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1'.$rootPath.'/$2', $source); | |
| 297 | +                $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url('.$rootPath.'/$1$2', $source); | |
| 298 | 298 | $cssAll .= $source; | 
| 299 | 299 | } | 
| 300 | - file_put_contents($cacheDir . '/all' . $timeMd5 . '.css', $cssAll); | |
| 300 | + file_put_contents($cacheDir.'/all'.$timeMd5.'.css', $cssAll); | |
| 301 | 301 | } | 
| 302 | 302 |          echo "\n        <link href='/{$cacheDir}/all{$timeMd5}.css' rel='stylesheet' type='text/css' />"; | 
| 303 | 303 | } | 
| @@ -329,7 +329,7 @@ discard block | ||
| 329 | 329 | if (strpos($css, '//') !== false) | 
| 330 | 330 | $href = $css; | 
| 331 | 331 | else | 
| 332 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; | |
| 332 | + $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$css; | |
| 333 | 333 | $hrefs[$href] = $href; | 
| 334 | 334 | } | 
| 335 | 335 | break; | 
| @@ -342,7 +342,7 @@ discard block | ||
| 342 | 342 | if (strpos($css, '://') !== false) | 
| 343 | 343 | $href = $css; | 
| 344 | 344 | else | 
| 345 | -                        $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; | |
| 345 | +                        $href = $this->app->templatesPath."/{$this->template->name}/css/{$css}"; | |
| 346 | 346 | $hrefs[$href] = $href; | 
| 347 | 347 | } | 
| 348 | 348 | break; | 
| @@ -355,7 +355,7 @@ discard block | ||
| 355 | 355 | if (strpos($css, '//') !== false) | 
| 356 | 356 | $href = $css; | 
| 357 | 357 | else | 
| 358 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; | |
| 358 | + $href = ($this->app->type != 'app' ? '/'.$this->app->name : '').$css; | |
| 359 | 359 | $hrefs[$href] = $href; | 
| 360 | 360 | } | 
| 361 | 361 | break; | 
| @@ -375,9 +375,9 @@ discard block | ||
| 375 | 375 |          if (!empty($this->app->config['site']['metatags'])) { | 
| 376 | 376 |              foreach ($this->app->config['site']['metatags'] as $meta) { | 
| 377 | 377 |                  if (!empty($meta['name'])) { | 
| 378 | - $metas['metaName:' . $meta['name']] = $meta; | |
| 378 | + $metas['metaName:'.$meta['name']] = $meta; | |
| 379 | 379 |                  } elseif (!empty($meta['property'])) { | 
| 380 | - $metas['metaProperty:' . $meta['property']] = $meta; | |
| 380 | + $metas['metaProperty:'.$meta['property']] = $meta; | |
| 381 | 381 | } | 
| 382 | 382 | } | 
| 383 | 383 | } | 
| @@ -390,9 +390,9 @@ discard block | ||
| 390 | 390 | public function addMetaTag($meta) | 
| 391 | 391 |      { | 
| 392 | 392 |          if (!empty($meta['name'])) { | 
| 393 | - $this->dynMetas['metaName:' . $meta['name']] = $meta; | |
| 393 | + $this->dynMetas['metaName:'.$meta['name']] = $meta; | |
| 394 | 394 |          } elseif (!empty($meta['property'])) { | 
| 395 | - $this->dynMetas['metaProperty:' . $meta['property']] = $meta; | |
| 395 | + $this->dynMetas['metaProperty:'.$meta['property']] = $meta; | |
| 396 | 396 | } | 
| 397 | 397 | } | 
| 398 | 398 | |
| @@ -416,7 +416,7 @@ discard block | ||
| 416 | 416 |                  if (file_exists($path)) { | 
| 417 | 417 | $nativeUrl[$script] = $script; | 
| 418 | 418 | $urls[$script] = $path; | 
| 419 | - $timeStr.=filemtime($path); | |
| 419 | + $timeStr .= filemtime($path); | |
| 420 | 420 |                  } else { | 
| 421 | 421 | $noParsedScripts[$script] = $script; | 
| 422 | 422 | } | 
| @@ -431,7 +431,7 @@ discard block | ||
| 431 | 431 |                      if (!empty($script['name'])) { | 
| 432 | 432 | $onLoadModules[$script['name']] = $script['name']; | 
| 433 | 433 | } | 
| 434 | - $timeStr.=filemtime($path); | |
| 434 | + $timeStr .= filemtime($path); | |
| 435 | 435 |                  } else { | 
| 436 | 436 | $noParsedScripts[$script] = $script; | 
| 437 | 437 | } | 
| @@ -440,20 +440,20 @@ discard block | ||
| 440 | 440 | |
| 441 | 441 | $timeMd5 = md5($timeStr); | 
| 442 | 442 |          $cacheDir = Cache::getDir('static'); | 
| 443 | -        if (!file_exists($cacheDir . '/all' . $timeMd5 . '.js')) { | |
| 443 | +        if (!file_exists($cacheDir.'/all'.$timeMd5.'.js')) { | |
| 444 | 444 |              foreach ($urls as $url) { | 
| 445 | - $scriptAll .= ';' . file_get_contents($url); | |
| 445 | + $scriptAll .= ';'.file_get_contents($url); | |
| 446 | 446 | } | 
| 447 | - file_put_contents($cacheDir . '/all' . $timeMd5 . '.js', $scriptAll); | |
| 447 | + file_put_contents($cacheDir.'/all'.$timeMd5.'.js', $scriptAll); | |
| 448 | 448 | } | 
| 449 | 449 | $options = [ | 
| 450 | 450 | 'scripts' => array_values($noParsedScripts), | 
| 451 | 451 | 'compresedScripts' => $nativeUrl, | 
| 452 | 452 | 'styles' => [], | 
| 453 | - 'appRoot' => $this->app->type == 'app' ? '/' : '/' . $this->app->name . '/', | |
| 453 | + 'appRoot' => $this->app->type == 'app' ? '/' : '/'.$this->app->name.'/', | |
| 454 | 454 | 'onLoadModules' => $onLoadModules | 
| 455 | 455 | ]; | 
| 456 | - $options['scripts'][] = '/' . $cacheDir . '/all' . $timeMd5 . '.js'; | |
| 456 | + $options['scripts'][] = '/'.$cacheDir.'/all'.$timeMd5.'.js'; | |
| 457 | 457 |          $this->widget('View\bodyEnd', compact('options')); | 
| 458 | 458 | } | 
| 459 | 459 | |
| @@ -500,7 +500,7 @@ discard block | ||
| 500 | 500 | if (strpos($js, '//') !== false) | 
| 501 | 501 | $href = $js; | 
| 502 | 502 | else | 
| 503 | -                        $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; | |
| 503 | +                        $href = $this->app->templatesPath."/{$this->template->name}/js/{$js}"; | |
| 504 | 504 | $resultArray[] = $href; | 
| 505 | 505 | } | 
| 506 | 506 | break; | 
| @@ -537,7 +537,7 @@ discard block | ||
| 537 | 537 |      { | 
| 538 | 538 |          if ($add && !empty($this->app->config['site']['name'])) { | 
| 539 | 539 |              if ($title) { | 
| 540 | - $this->title = $title . ' - ' . $this->app->config['site']['name']; | |
| 540 | + $this->title = $title.' - '.$this->app->config['site']['name']; | |
| 541 | 541 |              } else { | 
| 542 | 542 | $this->title = $this->app->config['site']['name']; | 
| 543 | 543 | } | 
| @@ -566,7 +566,7 @@ discard block | ||
| 566 | 566 | } | 
| 567 | 567 | } | 
| 568 | 568 | if (!$paramArray) | 
| 569 | -                    $lineParams = ':' . implode(':', $_params); | |
| 569 | +                    $lineParams = ':'.implode(':', $_params); | |
| 570 | 570 | } | 
| 571 | 571 | } | 
| 572 | 572 |          echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n"; | 
| @@ -585,24 +585,24 @@ discard block | ||
| 585 | 585 |          if (strpos($widgetName, '\\')) { | 
| 586 | 586 |              $widgetName = explode('\\', $widgetName); | 
| 587 | 587 | |
| 588 | - $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '/' . $widgetName[1] . '.php'; | |
| 589 | - $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName[0] . '/' . $widgetName[1] . '.php'; | |
| 588 | + $paths['templatePath_widgetDir'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName[0].'/'.$widgetName[1].'/'.$widgetName[1].'.php'; | |
| 589 | + $paths['templatePath'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName[0].'/'.$widgetName[1].'.php'; | |
| 590 | 590 | App::$cur->$widgetName[0]; | 
| 591 | 591 | $modulePaths = Module::getModulePaths(ucfirst($widgetName[0])); | 
| 592 | 592 |              foreach ($modulePaths as $pathName => $path) { | 
| 593 | - $paths[$pathName . '_widgetDir'] = $path . '/widgets/' . $widgetName[1] . '/' . $widgetName[1] . '.php'; | |
| 594 | - $paths[$pathName] = $path . '/widgets/' . $widgetName[1] . '.php'; | |
| 593 | + $paths[$pathName.'_widgetDir'] = $path.'/widgets/'.$widgetName[1].'/'.$widgetName[1].'.php'; | |
| 594 | + $paths[$pathName] = $path.'/widgets/'.$widgetName[1].'.php'; | |
| 595 | 595 | } | 
| 596 | 596 | return $paths; | 
| 597 | 597 |          } else { | 
| 598 | - $paths['templatePath_widgetDir'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '/' . $widgetName . '.php'; | |
| 599 | - $paths['templatePath'] = $this->templatesPath . '/' . $this->template->name . '/widgets/' . $widgetName . '.php'; | |
| 598 | + $paths['templatePath_widgetDir'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName.'/'.$widgetName.'.php'; | |
| 599 | + $paths['templatePath'] = $this->templatesPath.'/'.$this->template->name.'/widgets/'.$widgetName.'.php'; | |
| 600 | 600 | |
| 601 | - $paths['curAppPath_widgetDir'] = $this->app->path . '/widgets/' . $widgetName . '/' . $widgetName . '.php'; | |
| 602 | - $paths['curAppPath'] = $this->app->path . '/widgets/' . $widgetName . '.php'; | |
| 601 | + $paths['curAppPath_widgetDir'] = $this->app->path.'/widgets/'.$widgetName.'/'.$widgetName.'.php'; | |
| 602 | + $paths['curAppPath'] = $this->app->path.'/widgets/'.$widgetName.'.php'; | |
| 603 | 603 | |
| 604 | - $paths['systemPath_widgetDir'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '/' . $widgetName . '.php'; | |
| 605 | - $paths['systemPath'] = INJI_SYSTEM_DIR . '/widgets/' . $widgetName . '.php'; | |
| 604 | + $paths['systemPath_widgetDir'] = INJI_SYSTEM_DIR.'/widgets/'.$widgetName.'/'.$widgetName.'.php'; | |
| 605 | + $paths['systemPath'] = INJI_SYSTEM_DIR.'/widgets/'.$widgetName.'.php'; | |
| 606 | 606 | } | 
| 607 | 607 | return $paths; | 
| 608 | 608 | } | 
| @@ -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 | } | 
| @@ -16,17 +16,17 @@ | ||
| 16 | 16 | if ($level == 0) | 
| 17 | 17 | $return = "["; | 
| 18 | 18 |          foreach ($data as $key => $item) { | 
| 19 | -            $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => "; | |
| 19 | +            $return .= "\n".str_repeat(' ', ($level * 4 + 4))."'{$key}' => "; | |
| 20 | 20 | if (!is_array($item)) | 
| 21 | 21 |                  $return .= "'{$item}',"; | 
| 22 | 22 |              else { | 
| 23 | 23 | $return .= "["; | 
| 24 | 24 | $return .= rtrim(self::genArray($item, $level + 1), ','); | 
| 25 | -                $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],"; | |
| 25 | +                $return .= "\n".str_repeat(' ', ($level * 4 + 4))."],"; | |
| 26 | 26 | } | 
| 27 | 27 | } | 
| 28 | 28 | if ($level == 0) | 
| 29 | - $return = rtrim($return, ',') . "\n];"; | |
| 29 | + $return = rtrim($return, ',')."\n];"; | |
| 30 | 30 | |
| 31 | 31 | return $return; | 
| 32 | 32 | } | 
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 |          $html = "<{$tag}"; | 
| 25 | 25 |          if ($attributes && is_array($attributes)) { | 
| 26 | 26 |              foreach ($attributes as $key => $value) { | 
| 27 | -                $html .=" {$key} = '"; | |
| 27 | +                $html .= " {$key} = '"; | |
| 28 | 28 |                  if (!is_array($value)) { | 
| 29 | 29 | $html .= addcslashes($value, "'"); | 
| 30 | 30 |                  } else { | 
| @@ -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() | 
| @@ -83,22 +83,22 @@ | ||
| 83 | 83 | $log['end'] = microtime(true); | 
| 84 | 84 | if (empty($log['start'])) | 
| 85 | 85 | $log['start'] = microtime(true); | 
| 86 | -                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>"; | |
| 86 | +                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 | 87 | } | 
| 88 | 88 | } | 
| 89 | - echo '<tr><th>Summary</th><th>' . round(( microtime(true) - $this->startTime), 5) . '</th></tr>'; | |
| 90 | -        echo '<tr><th>Memory</th><th>' . $this->convertSize(memory_get_peak_usage()) . ' of ' . ini_get('memory_limit') . '</th></tr></table></div>'; | |
| 89 | + echo '<tr><th>Summary</th><th>'.round((microtime(true) - $this->startTime), 5).'</th></tr>'; | |
| 90 | +        echo '<tr><th>Memory</th><th>'.$this->convertSize(memory_get_peak_usage()).' of '.ini_get('memory_limit').'</th></tr></table></div>'; | |
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | public function convertSize($size) | 
| 94 | 94 |      { | 
| 95 | 95 | |
| 96 | 96 | if ($size < 1024) | 
| 97 | - return $size . "B"; | |
| 97 | + return $size."B"; | |
| 98 | 98 | elseif ($size < 1048576) | 
| 99 | - return round($size / 1024, 2) . "KB"; | |
| 99 | + return round($size / 1024, 2)."KB"; | |
| 100 | 100 | else | 
| 101 | - return round($size / 1048576, 2) . "MB"; | |
| 101 | + return round($size / 1048576, 2)."MB"; | |
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | 104 | public function __destruct() | 
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 |              if (!empty($_SESSION['_INJI_MSG'])) { | 
| 23 | 23 |                  foreach ($_SESSION['_INJI_MSG'] as $key => $msg) { | 
| 24 | 24 |                      if ($msg['text'] == $text) { | 
| 25 | - $msg['count'] ++; | |
| 25 | + $msg['count']++; | |
| 26 | 26 | return true; | 
| 27 | 27 | } | 
| 28 | 28 | } | 
| @@ -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'] = []; |