@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return function ($step = NULL, $params = []) { |
|
| 3 | +return function($step = NULL, $params = []) { |
|
| 4 | 4 | |
| 5 | 5 | $groups = [ |
| 6 | 6 | [ |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * Get all posible directorys for module files |
| 82 | 82 | * |
| 83 | 83 | * @param string $moduleName |
| 84 | - * @return array |
|
| 84 | + * @return string |
|
| 85 | 85 | */ |
| 86 | 86 | public static function getModulePaths($moduleName) |
| 87 | 87 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * Get installed modules for app |
| 132 | 132 | * |
| 133 | 133 | * @param \App $app |
| 134 | - * @param boolean|\App $primary |
|
| 134 | + * @param App $primary |
|
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | 137 | public static function getInstalled($app, $primary = false) |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $this->info = $this->getInfo(); |
| 73 | 73 | $this->config = Config::module($this->moduleName, !empty($this->info['systemConfig'])); |
| 74 | 74 | $that = $this; |
| 75 | - Inji::$inst->listen('Config-change-module-' . $this->app->name . '-' . $this->moduleName, $this->app->name . '-' . $this->moduleName . 'config', function($event) use ($that) { |
|
| 75 | + Inji::$inst->listen('Config-change-module-'.$this->app->name.'-'.$this->moduleName, $this->app->name.'-'.$this->moduleName.'config', function($event) use ($that) { |
|
| 76 | 76 | $that->config = $event['eventObject']; |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | $moduleName = ucfirst($moduleName); |
| 89 | 89 | $paths = []; |
| 90 | 90 | if (App::$cur !== App::$primary) { |
| 91 | - $paths['primaryAppPath'] = App::$primary->path . '/modules/' . $moduleName; |
|
| 91 | + $paths['primaryAppPath'] = App::$primary->path.'/modules/'.$moduleName; |
|
| 92 | 92 | } |
| 93 | - $paths['curAppPath'] = App::$cur->path . '/modules/' . $moduleName; |
|
| 94 | - $paths['systemPath'] = INJI_SYSTEM_DIR . '/modules/' . $moduleName; |
|
| 93 | + $paths['curAppPath'] = App::$cur->path.'/modules/'.$moduleName; |
|
| 94 | + $paths['systemPath'] = INJI_SYSTEM_DIR.'/modules/'.$moduleName; |
|
| 95 | 95 | return $paths; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $moduleName = ucfirst($moduleName); |
| 107 | 107 | $paths = Module::getModulePaths($moduleName); |
| 108 | 108 | foreach ($paths as $path) { |
| 109 | - if (file_exists($path . '/' . $moduleName . '.php')) { |
|
| 109 | + if (file_exists($path.'/'.$moduleName.'.php')) { |
|
| 110 | 110 | return $path; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | foreach ($moduleDirs as $moduleDir) { |
| 160 | 160 | if (is_dir($moduleDir)) { |
| 161 | 161 | foreach (scandir($moduleDir) as $dir) { |
| 162 | - if (preg_match('!Controllers$!', $dir) && is_dir($moduleDir . '/' . $dir)) { |
|
| 163 | - $path = $moduleDir . '/' . $dir; |
|
| 162 | + if (preg_match('!Controllers$!', $dir) && is_dir($moduleDir.'/'.$dir)) { |
|
| 163 | + $path = $moduleDir.'/'.$dir; |
|
| 164 | 164 | foreach (scandir($path) as $file) { |
| 165 | - if (preg_match('!Controller\.php$!', $file) && is_file($path . '/' . $file)) { |
|
| 165 | + if (preg_match('!Controller\.php$!', $file) && is_file($path.'/'.$file)) { |
|
| 166 | 166 | $controllerName = preg_replace('!Controller\.php$!', '', $file); |
| 167 | - $controllers[preg_replace('!Controllers$!', '', $dir)][$controllerName] = $path . '/' . $file; |
|
| 167 | + $controllers[preg_replace('!Controllers$!', '', $dir)][$controllerName] = $path.'/'.$file; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -211,31 +211,31 @@ discard block |
||
| 211 | 211 | $paths = []; |
| 212 | 212 | if (App::$cur != App::$primary) { |
| 213 | 213 | if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { |
| 214 | - $paths['primaryAppAppTypePath_slice'] = App::$primary->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 214 | + $paths['primaryAppAppTypePath_slice'] = App::$primary->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 215 | 215 | if (App::$primary->{$this->moduleName}) { |
| 216 | - $paths['primaryAppAppTypePath_slice'] = App::$primary->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 216 | + $paths['primaryAppAppTypePath_slice'] = App::$primary->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | - $paths['primaryAppAppAppTypePath'] = App::$primary->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 219 | + $paths['primaryAppAppAppTypePath'] = App::$primary->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; |
|
| 220 | 220 | if (App::$primary->{$this->moduleName}) { |
| 221 | - $paths['primaryAppAppTypePath'] = App::$primary->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 221 | + $paths['primaryAppAppTypePath'] = App::$primary->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; |
|
| 222 | 222 | } |
| 223 | - $paths['curAppAppTypePath'] = $this->app->{$this->moduleName}->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 223 | + $paths['curAppAppTypePath'] = $this->app->{$this->moduleName}->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { |
| 227 | - $paths['appAppTypePath_slice'] = $this->app->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 228 | - $paths['appTypePath_slice'] = $this->path . '/' . $this->app->type . 'Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 227 | + $paths['appAppTypePath_slice'] = $this->app->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 228 | + $paths['appTypePath_slice'] = $this->path.'/'.$this->app->type.'Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 229 | 229 | } |
| 230 | - $paths['appAppTypePath'] = $this->app->path . '/modules/' . $this->moduleName . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 231 | - $paths['appTypePath'] = $this->path . '/' . $this->app->type . 'Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 230 | + $paths['appAppTypePath'] = $this->app->path.'/modules/'.$this->moduleName.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; |
|
| 231 | + $paths['appTypePath'] = $this->path.'/'.$this->app->type.'Controllers/'.$this->moduleName.'Controller.php'; |
|
| 232 | 232 | |
| 233 | 233 | if (!empty($this->params[0]) && strtolower($this->params[0]) != strtolower($this->moduleName)) { |
| 234 | - $paths['appUniversalPath_slice'] = $this->app->path . '/modules/' . $this->moduleName . '/Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 235 | - $paths['universalPath_slice'] = $this->path . '/Controllers/' . ucfirst($this->params[0]) . 'Controller.php'; |
|
| 234 | + $paths['appUniversalPath_slice'] = $this->app->path.'/modules/'.$this->moduleName.'/Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 235 | + $paths['universalPath_slice'] = $this->path.'/Controllers/'.ucfirst($this->params[0]).'Controller.php'; |
|
| 236 | 236 | } |
| 237 | - $paths['appUniversalPath'] = $this->app->path . '/modules/' . $this->moduleName . '/Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 238 | - $paths['universalPath'] = $this->path . '/Controllers/' . $this->moduleName . 'Controller.php'; |
|
| 237 | + $paths['appUniversalPath'] = $this->app->path.'/modules/'.$this->moduleName.'/Controllers/'.$this->moduleName.'Controller.php'; |
|
| 238 | + $paths['universalPath'] = $this->path.'/Controllers/'.$this->moduleName.'Controller.php'; |
|
| 239 | 239 | |
| 240 | 240 | return $paths; |
| 241 | 241 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | $controllerName = $this->moduleName; |
| 259 | 259 | $params = $this->params; |
| 260 | 260 | } |
| 261 | - $fullControllerName = $controllerName . 'Controller'; |
|
| 261 | + $fullControllerName = $controllerName.'Controller'; |
|
| 262 | 262 | $controller = new $fullControllerName(); |
| 263 | 263 | $controller->params = $params; |
| 264 | 264 | $controller->module = $this; |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | $paths = Module::getModulePaths($moduleName); |
| 286 | 286 | foreach ($paths as $path) { |
| 287 | - if (file_exists($path . '/info.php')) { |
|
| 288 | - return include $path . '/info.php'; |
|
| 287 | + if (file_exists($path.'/info.php')) { |
|
| 288 | + return include $path.'/info.php'; |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | return []; |
@@ -304,16 +304,16 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $moduleName = $moduleName ? $moduleName : $this->moduleName; |
| 306 | 306 | $modulePaths = Module::getModulePaths($moduleName); |
| 307 | - $modulePaths['templatePath'] = App::$cur->view->template->path . '/modules/' . ucfirst($moduleName); |
|
| 307 | + $modulePaths['templatePath'] = App::$cur->view->template->path.'/modules/'.ucfirst($moduleName); |
|
| 308 | 308 | $snippets = []; |
| 309 | 309 | foreach ($modulePaths as $path) { |
| 310 | - if (file_exists($path . $dir . '/' . $snippetsPath)) { |
|
| 311 | - $snippetsPaths = array_slice(scandir($path . $dir . '/' . $snippetsPath), 2); |
|
| 310 | + if (file_exists($path.$dir.'/'.$snippetsPath)) { |
|
| 311 | + $snippetsPaths = array_slice(scandir($path.$dir.'/'.$snippetsPath), 2); |
|
| 312 | 312 | foreach ($snippetsPaths as $snippetPath) { |
| 313 | - if (is_dir($path . $dir . '/' . $snippetsPath . '/' . $snippetPath)) { |
|
| 314 | - $snippets[$snippetPath] = include $path . $dir . '/' . $snippetsPath . '/' . $snippetPath . '/info.php'; |
|
| 313 | + if (is_dir($path.$dir.'/'.$snippetsPath.'/'.$snippetPath)) { |
|
| 314 | + $snippets[$snippetPath] = include $path.$dir.'/'.$snippetsPath.'/'.$snippetPath.'/info.php'; |
|
| 315 | 315 | } else { |
| 316 | - $snippets[pathinfo($snippetPath, PATHINFO_FILENAME)] = include $path . $dir . '/' . $snippetsPath . '/' . $snippetPath; |
|
| 316 | + $snippets[pathinfo($snippetPath, PATHINFO_FILENAME)] = include $path.$dir.'/'.$snippetsPath.'/'.$snippetPath; |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -335,9 +335,9 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | $extensions = []; |
| 337 | 337 | $modules = Module::getInstalled(App::$cur); |
| 338 | - $method = 'get' . ucfirst($extensionType); |
|
| 338 | + $method = 'get'.ucfirst($extensionType); |
|
| 339 | 339 | foreach ($modules as $module) { |
| 340 | - $extensions = array_merge($extensions, $this->{$method}($request, false, "/extensions/{$this->moduleName}/" . $extensionType, $module)); |
|
| 340 | + $extensions = array_merge($extensions, $this->{$method}($request, false, "/extensions/{$this->moduleName}/".$extensionType, $module)); |
|
| 341 | 341 | } |
| 342 | 342 | return $extensions; |
| 343 | 343 | } |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * Information extractor for col relations path |
| 359 | 359 | * |
| 360 | - * @param string|array $info |
|
| 360 | + * @param string $info |
|
| 361 | 361 | * @return array |
| 362 | 362 | */ |
| 363 | 363 | public static function parseColRecursion($info) |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * Generate params string for col by name |
| 434 | 434 | * |
| 435 | 435 | * @param string $colName |
| 436 | - * @return boolean|string |
|
| 436 | + * @return false|string |
|
| 437 | 437 | */ |
| 438 | 438 | public static function genColParams($colName) |
| 439 | 439 | { |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | /** |
| 574 | 574 | * return relations list |
| 575 | 575 | * |
| 576 | - * @return array |
|
| 576 | + * @return string |
|
| 577 | 577 | */ |
| 578 | 578 | public static function relations() |
| 579 | 579 | { |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * |
| 1066 | 1066 | * @param array $params |
| 1067 | 1067 | * @param array $where |
| 1068 | - * @return boolean |
|
| 1068 | + * @return false|null |
|
| 1069 | 1069 | */ |
| 1070 | 1070 | public static function update($params, $where = []) |
| 1071 | 1071 | { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $relModel = $relations[$colInfo['colParams']['relation']]['model']; |
| 212 | 212 | $relModel = strpos($relModel, '\\') === 0 ? substr($relModel, 1) : $relModel; |
| 213 | 213 | if ($manageHref) { |
| 214 | - $value = $relValue ? "<a href='/admin/" . str_replace('\\', '/view/', $relModel) . "/" . $relValue->pk() . "'>" . $relValue->name() . "</a>" : 'Не задано'; |
|
| 214 | + $value = $relValue ? "<a href='/admin/".str_replace('\\', '/view/', $relModel)."/".$relValue->pk()."'>".$relValue->name()."</a>" : 'Не задано'; |
|
| 215 | 215 | } else { |
| 216 | 216 | $value = $relValue ? $relValue->name() : 'Не задано'; |
| 217 | 217 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | case 'image': |
| 222 | 222 | $file = Files\File::get($item->$colName); |
| 223 | 223 | if ($file) { |
| 224 | - $value = '<img src="' . $file->path . '?resize=60x120" />'; |
|
| 224 | + $value = '<img src="'.$file->path.'?resize=60x120" />'; |
|
| 225 | 225 | } else { |
| 226 | 226 | $value = '<img src="/static/system/images/no-image.png?resize=60x120" />'; |
| 227 | 227 | } |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | if (!is_array($array)) { |
| 262 | - if (!isset($cols[static::colPrefix() . $array]) && isset(static::$cols[$array])) { |
|
| 262 | + if (!isset($cols[static::colPrefix().$array]) && isset(static::$cols[$array])) { |
|
| 263 | 263 | static::createCol($array); |
| 264 | 264 | $cols = static::cols(true); |
| 265 | 265 | } |
| 266 | - if (!isset($cols[$array]) && isset($cols[static::colPrefix() . $array])) { |
|
| 267 | - $array = static::colPrefix() . $array; |
|
| 266 | + if (!isset($cols[$array]) && isset($cols[static::colPrefix().$array])) { |
|
| 267 | + $array = static::colPrefix().$array; |
|
| 268 | 268 | } else { |
| 269 | 269 | static::checkForJoin($array, $rootModel); |
| 270 | 270 | } |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | switch ($searchtype) { |
| 274 | 274 | case 'key': |
| 275 | 275 | foreach ($array as $key => $item) { |
| 276 | - if (!isset($cols[static::colPrefix() . $key]) && isset(static::$cols[$key])) { |
|
| 276 | + if (!isset($cols[static::colPrefix().$key]) && isset(static::$cols[$key])) { |
|
| 277 | 277 | static::createCol($key); |
| 278 | 278 | $cols = static::cols(true); |
| 279 | 279 | } |
| 280 | - if (!isset($cols[$key]) && isset($cols[static::colPrefix() . $key])) { |
|
| 281 | - $array[static::colPrefix() . $key] = $item; |
|
| 280 | + if (!isset($cols[$key]) && isset($cols[static::colPrefix().$key])) { |
|
| 281 | + $array[static::colPrefix().$key] = $item; |
|
| 282 | 282 | unset($array[$key]); |
| 283 | - $key = static::colPrefix() . $key; |
|
| 283 | + $key = static::colPrefix().$key; |
|
| 284 | 284 | } |
| 285 | 285 | if (is_array($array[$key])) { |
| 286 | 286 | static::fixPrefix($array[$key], 'key', $rootModel); |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | break; |
| 292 | 292 | case 'first': |
| 293 | 293 | if (isset($array[0]) && is_string($array[0])) { |
| 294 | - if (!isset($cols[static::colPrefix() . $array[0]]) && isset(static::$cols[$array[0]])) { |
|
| 294 | + if (!isset($cols[static::colPrefix().$array[0]]) && isset(static::$cols[$array[0]])) { |
|
| 295 | 295 | static::createCol($array[0]); |
| 296 | 296 | $cols = static::cols(true); |
| 297 | 297 | } |
| 298 | - if (!isset($cols[$array[0]]) && isset($cols[static::colPrefix() . $array[0]])) { |
|
| 299 | - $array[0] = static::colPrefix() . $array[0]; |
|
| 298 | + if (!isset($cols[$array[0]]) && isset($cols[static::colPrefix().$array[0]])) { |
|
| 299 | + $array[0] = static::colPrefix().$array[0]; |
|
| 300 | 300 | } else { |
| 301 | 301 | static::checkForJoin($array[0], $rootModel); |
| 302 | 302 | } |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | case 'to': |
| 330 | 330 | $relCol = $relations[$rel]['col']; |
| 331 | 331 | static::fixPrefix($relCol); |
| 332 | - $rootModel::$relJoins[$relations[$rel]['model'] . '_' . $rel] = [$relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol]; |
|
| 332 | + $rootModel::$relJoins[$relations[$rel]['model'].'_'.$rel] = [$relations[$rel]['model']::table(), $relations[$rel]['model']::index().' = '.$relCol]; |
|
| 333 | 333 | break; |
| 334 | 334 | case 'one': |
| 335 | 335 | case 'many': |
| 336 | 336 | $relCol = $relations[$rel]['col']; |
| 337 | 337 | $relations[$rel]['model']::fixPrefix($relCol); |
| 338 | - $rootModel::$relJoins[$relations[$rel]['model'] . '_' . $rel] = [$relations[$rel]['model']::table(), static::index() . ' = ' . $relCol]; |
|
| 338 | + $rootModel::$relJoins[$relations[$rel]['model'].'_'.$rel] = [$relations[$rel]['model']::table(), static::index().' = '.$relCol]; |
|
| 339 | 339 | break; |
| 340 | 340 | } |
| 341 | 341 | $relations[$rel]['model']::fixPrefix($col, 'key', $rootModel); |
@@ -376,13 +376,13 @@ discard block |
||
| 376 | 376 | $relCol = $relations[$rel]['col']; |
| 377 | 377 | static::fixPrefix($relCol); |
| 378 | 378 | //$info['modelName'] = $relations[$rel]['model']; |
| 379 | - $info['joins'][$relations[$rel]['model'] . '_' . $rel] = [$relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol]; |
|
| 379 | + $info['joins'][$relations[$rel]['model'].'_'.$rel] = [$relations[$rel]['model']::table(), $relations[$rel]['model']::index().' = '.$relCol]; |
|
| 380 | 380 | break; |
| 381 | 381 | case 'one': |
| 382 | 382 | $relCol = $relations[$rel]['col']; |
| 383 | 383 | $relations[$rel]['model']::fixPrefix($relCol); |
| 384 | 384 | //$info['modelName'] = $relations[$rel]['model']; |
| 385 | - $info['joins'][$relations[$rel]['model'] . '_' . $rel] = [$relations[$rel]['model']::table(), static::index() . ' = ' . $relCol]; |
|
| 385 | + $info['joins'][$relations[$rel]['model'].'_'.$rel] = [$relations[$rel]['model']::table(), static::index().' = '.$relCol]; |
|
| 386 | 386 | break; |
| 387 | 387 | } |
| 388 | 388 | $info = $relations[$rel]['model']::parseColRecursion($info); |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | } else { |
| 401 | 401 | $info['colParams'] = []; |
| 402 | 402 | } |
| 403 | - if (!isset($cols[$info['col']]) && isset($cols[static::colPrefix() . $info['col']])) { |
|
| 404 | - $info['col'] = static::colPrefix() . $info['col']; |
|
| 403 | + if (!isset($cols[$info['col']]) && isset($cols[static::colPrefix().$info['col']])) { |
|
| 404 | + $info['col'] = static::colPrefix().$info['col']; |
|
| 405 | 405 | } |
| 406 | 406 | $info['modelName'] = get_called_class(); |
| 407 | 407 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | if ($params === false) { |
| 508 | 508 | return false; |
| 509 | 509 | } |
| 510 | - return App::$cur->db->addCol(static::table(), static::colPrefix() . $colName, $params); |
|
| 510 | + return App::$cur->db->addCol(static::table(), static::colPrefix().$colName, $params); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | public static function createTable() |
@@ -537,28 +537,28 @@ discard block |
||
| 537 | 537 | return true; |
| 538 | 538 | } |
| 539 | 539 | $cols = [ |
| 540 | - $colPrefix . 'id' => 'pk' |
|
| 540 | + $colPrefix.'id' => 'pk' |
|
| 541 | 541 | ]; |
| 542 | 542 | $className = get_called_class(); |
| 543 | 543 | if (!empty($className::$cols)) { |
| 544 | 544 | foreach ($className::$cols as $colName => $colParams) { |
| 545 | 545 | if ($colName == 'date_create') { |
| 546 | - $cols[$colPrefix . 'date_create'] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; |
|
| 546 | + $cols[$colPrefix.'date_create'] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; |
|
| 547 | 547 | continue; |
| 548 | 548 | } |
| 549 | 549 | $params = $className::genColParams($colName); |
| 550 | 550 | if ($params) { |
| 551 | - $cols[$colPrefix . $colName] = $params; |
|
| 551 | + $cols[$colPrefix.$colName] = $params; |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | - if (empty($cols[$colPrefix . 'date_create'])) { |
|
| 556 | - $cols[$colPrefix . 'date_create'] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; |
|
| 555 | + if (empty($cols[$colPrefix.'date_create'])) { |
|
| 556 | + $cols[$colPrefix.'date_create'] = 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'; |
|
| 557 | 557 | } |
| 558 | 558 | $tableIndexes = []; |
| 559 | 559 | if ($indexes) { |
| 560 | 560 | foreach ($indexes as $indexName => $index) { |
| 561 | - $tableIndexes[] = $index['type'] . ' ' . App::$cur->db->table_prefix . $indexName . ' (' . implode(',', $index['cols']) . ')'; |
|
| 561 | + $tableIndexes[] = $index['type'].' '.App::$cur->db->table_prefix.$indexName.' ('.implode(',', $index['cols']).')'; |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | public static function index() |
| 585 | 585 | { |
| 586 | 586 | |
| 587 | - return static::colPrefix() . 'id'; |
|
| 587 | + return static::colPrefix().'id'; |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | { |
| 597 | 597 | $classPath = explode('\\', get_called_class()); |
| 598 | 598 | $classPath = array_slice($classPath, 1); |
| 599 | - return strtolower(implode('_', $classPath)) . '_'; |
|
| 599 | + return strtolower(implode('_', $classPath)).'_'; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -661,12 +661,12 @@ discard block |
||
| 661 | 661 | case 'to': |
| 662 | 662 | $relCol = $relations[$rel]['col']; |
| 663 | 663 | static::fixPrefix($relCol); |
| 664 | - App::$cur->db->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 664 | + App::$cur->db->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index().' = '.$relCol); |
|
| 665 | 665 | break; |
| 666 | 666 | case 'one': |
| 667 | 667 | $col = $relations[$rel]['col']; |
| 668 | 668 | $relations[$rel]['model']::fixPrefix($col); |
| 669 | - App::$cur->db->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 669 | + App::$cur->db->join($relations[$rel]['model']::table(), static::index().' = '.$col); |
|
| 670 | 670 | break; |
| 671 | 671 | } |
| 672 | 672 | } |
@@ -681,8 +681,8 @@ discard block |
||
| 681 | 681 | } |
| 682 | 682 | if ($param !== null) { |
| 683 | 683 | $cols = static::cols(); |
| 684 | - if (!isset($cols[$col]) && isset($cols[static::colPrefix() . $col])) { |
|
| 685 | - $col = static::colPrefix() . $col; |
|
| 684 | + if (!isset($cols[$col]) && isset($cols[static::colPrefix().$col])) { |
|
| 685 | + $col = static::colPrefix().$col; |
|
| 686 | 686 | } |
| 687 | 687 | App::$cur->db->where($col, $param); |
| 688 | 688 | } else { |
@@ -742,12 +742,12 @@ discard block |
||
| 742 | 742 | case 'to': |
| 743 | 743 | $relCol = $relations[$rel]['col']; |
| 744 | 744 | static::fixPrefix($relCol); |
| 745 | - $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 745 | + $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index().' = '.$relCol); |
|
| 746 | 746 | break; |
| 747 | 747 | case 'one': |
| 748 | 748 | $col = $relations[$rel]['col']; |
| 749 | 749 | $relations[$rel]['model']::fixPrefix($col); |
| 750 | - $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 750 | + $query->join($relations[$rel]['model']::table(), static::index().' = '.$col); |
|
| 751 | 751 | break; |
| 752 | 752 | } |
| 753 | 753 | } |
@@ -1063,12 +1063,12 @@ discard block |
||
| 1063 | 1063 | case 'to': |
| 1064 | 1064 | $relCol = $relations[$rel]['col']; |
| 1065 | 1065 | static::fixPrefix($relCol); |
| 1066 | - $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1066 | + $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index().' = '.$relCol); |
|
| 1067 | 1067 | break; |
| 1068 | 1068 | case 'one': |
| 1069 | 1069 | $col = $relations[$rel]['col']; |
| 1070 | 1070 | $relations[$rel]['model']::fixPrefix($col); |
| 1071 | - $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1071 | + $query->join($relations[$rel]['model']::table(), static::index().' = '.$col); |
|
| 1072 | 1072 | break; |
| 1073 | 1073 | } |
| 1074 | 1074 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
| 1085 | 1085 | } else { |
| 1086 | 1086 | $cols .= '*'; |
| 1087 | 1087 | } |
| 1088 | - $cols .=') as `count`' . (!empty($options['cols']) ? ',' . $options['cols'] : ''); |
|
| 1088 | + $cols .= ') as `count`'.(!empty($options['cols']) ? ','.$options['cols'] : ''); |
|
| 1089 | 1089 | $query->cols = $cols; |
| 1090 | 1090 | if (!empty($options['group'])) { |
| 1091 | 1091 | $query->group($options['group']); |
@@ -1223,25 +1223,25 @@ discard block |
||
| 1223 | 1223 | $itemModel = $class::$treeCategory; |
| 1224 | 1224 | $oldPath = $this->tree_path; |
| 1225 | 1225 | $this->tree_path = $this->getCatalogTree($this); |
| 1226 | - $itemsTable = \App::$cur->db->table_prefix . $itemModel::table(); |
|
| 1227 | - $itemTreeCol = $itemModel::colPrefix() . 'tree_path'; |
|
| 1226 | + $itemsTable = \App::$cur->db->table_prefix.$itemModel::table(); |
|
| 1227 | + $itemTreeCol = $itemModel::colPrefix().'tree_path'; |
|
| 1228 | 1228 | |
| 1229 | - $categoryTreeCol = $this->colPrefix() . 'tree_path'; |
|
| 1230 | - $categoryTable = \App::$cur->db->table_prefix . $this->table(); |
|
| 1229 | + $categoryTreeCol = $this->colPrefix().'tree_path'; |
|
| 1230 | + $categoryTable = \App::$cur->db->table_prefix.$this->table(); |
|
| 1231 | 1231 | if ($oldPath) { |
| 1232 | 1232 | \App::$cur->db->query('UPDATE |
| 1233 | - ' . $categoryTable . ' |
|
| 1233 | + ' . $categoryTable.' |
|
| 1234 | 1234 | SET |
| 1235 | - ' . $categoryTreeCol . ' = REPLACE(' . $categoryTreeCol . ', "' . $oldPath . $this->id . '/' . '", "' . $this->tree_path . $this->id . '/' . '") |
|
| 1236 | - WHERE ' . $categoryTreeCol . ' LIKE "' . $oldPath . $this->id . '/' . '%"'); |
|
| 1235 | + ' . $categoryTreeCol.' = REPLACE('.$categoryTreeCol.', "'.$oldPath.$this->id.'/'.'", "'.$this->tree_path.$this->id.'/'.'") |
|
| 1236 | + WHERE ' . $categoryTreeCol.' LIKE "'.$oldPath.$this->id.'/'.'%"'); |
|
| 1237 | 1237 | |
| 1238 | 1238 | \App::$cur->db->query('UPDATE |
| 1239 | - ' . $itemsTable . ' |
|
| 1239 | + ' . $itemsTable.' |
|
| 1240 | 1240 | SET |
| 1241 | - ' . $itemTreeCol . ' = REPLACE(' . $itemTreeCol . ', "' . $oldPath . $this->id . '/' . '", "' . $this->tree_path . $this->id . '/' . '") |
|
| 1242 | - WHERE ' . $itemTreeCol . ' LIKE "' . $oldPath . $this->id . '/' . '%"'); |
|
| 1241 | + ' . $itemTreeCol.' = REPLACE('.$itemTreeCol.', "'.$oldPath.$this->id.'/'.'", "'.$this->tree_path.$this->id.'/'.'") |
|
| 1242 | + WHERE ' . $itemTreeCol.' LIKE "'.$oldPath.$this->id.'/'.'%"'); |
|
| 1243 | 1243 | } |
| 1244 | - $itemModel::update([$itemTreeCol => $this->tree_path . $this->id . '/'], [$itemModel::colPrefix() . $this->index(), $this->id]); |
|
| 1244 | + $itemModel::update([$itemTreeCol => $this->tree_path.$this->id.'/'], [$itemModel::colPrefix().$this->index(), $this->id]); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
@@ -1256,9 +1256,9 @@ discard block |
||
| 1256 | 1256 | $catalogParent = $catalogClass::get($catalog->parent_id); |
| 1257 | 1257 | if ($catalog && $catalogParent) { |
| 1258 | 1258 | if ($catalogParent->tree_path) { |
| 1259 | - return $catalogParent->tree_path . $catalogParent->id . '/'; |
|
| 1259 | + return $catalogParent->tree_path.$catalogParent->id.'/'; |
|
| 1260 | 1260 | } else { |
| 1261 | - return $this->getCatalogTree($catalogParent) . $catalogParent->id . '/'; |
|
| 1261 | + return $this->getCatalogTree($catalogParent).$catalogParent->id.'/'; |
|
| 1262 | 1262 | } |
| 1263 | 1263 | } |
| 1264 | 1264 | return '/'; |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | $categoryModel = $class::$categoryModel; |
| 1274 | 1274 | $category = $categoryModel::get($this->{$categoryModel::index()}); |
| 1275 | 1275 | if ($category) { |
| 1276 | - $this->tree_path = $category->tree_path . $category->pk() . '/'; |
|
| 1276 | + $this->tree_path = $category->tree_path.$category->pk().'/'; |
|
| 1277 | 1277 | } else { |
| 1278 | 1278 | $this->tree_path = '/'; |
| 1279 | 1279 | } |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | $this->changeCategoryTree(); |
| 1300 | 1300 | } |
| 1301 | 1301 | if (!empty($this->_changedParams) && $this->pk()) { |
| 1302 | - Inji::$inst->event('modelItemParamsChanged-' . get_called_class(), $this); |
|
| 1302 | + Inji::$inst->event('modelItemParamsChanged-'.get_called_class(), $this); |
|
| 1303 | 1303 | } |
| 1304 | 1304 | $this->beforeSave(); |
| 1305 | 1305 | |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | } |
| 1338 | 1338 | $this->_params = $result->fetch(); |
| 1339 | 1339 | if ($new) { |
| 1340 | - Inji::$inst->event('modelCreatedItem-' . get_called_class(), $this); |
|
| 1340 | + Inji::$inst->event('modelCreatedItem-'.get_called_class(), $this); |
|
| 1341 | 1341 | } |
| 1342 | 1342 | $this->afterSave(); |
| 1343 | 1343 | return $this->{$this->index()}; |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | static::fixPrefix($params); |
| 1484 | 1484 | $className = get_called_class(); |
| 1485 | 1485 | foreach ($params as $paramName => $value) { |
| 1486 | - $shortName = preg_replace('!' . $this->colPrefix() . '!', '', $paramName); |
|
| 1486 | + $shortName = preg_replace('!'.$this->colPrefix().'!', '', $paramName); |
|
| 1487 | 1487 | if (!empty($className::$cols[$shortName])) { |
| 1488 | 1488 | switch ($className::$cols[$shortName]['type']) { |
| 1489 | 1489 | case 'decimal': |
@@ -1763,7 +1763,7 @@ discard block |
||
| 1763 | 1763 | { |
| 1764 | 1764 | static::fixPrefix($name); |
| 1765 | 1765 | $className = get_called_class(); |
| 1766 | - $shortName = preg_replace('!' . $this->colPrefix() . '!', '', $name); |
|
| 1766 | + $shortName = preg_replace('!'.$this->colPrefix().'!', '', $name); |
|
| 1767 | 1767 | if (!empty($className::$cols[$shortName])) { |
| 1768 | 1768 | switch ($className::$cols[$shortName]['type']) { |
| 1769 | 1769 | case 'decimal': |
@@ -260,8 +260,7 @@ discard block |
||
| 260 | 260 | } else { |
| 261 | 261 | $value = $item->$colName; |
| 262 | 262 | } |
| 263 | - } |
|
| 264 | - else { |
|
| 263 | + } else { |
|
| 265 | 264 | $value = $item->$colName; |
| 266 | 265 | } |
| 267 | 266 | break; |
@@ -751,17 +750,21 @@ discard block |
||
| 751 | 750 | if (!$query) { |
| 752 | 751 | return []; |
| 753 | 752 | } |
| 754 | - if (!empty($options['where'])) |
|
| 755 | - $query->where($options['where']); |
|
| 753 | + if (!empty($options['where'])) { |
|
| 754 | + $query->where($options['where']); |
|
| 755 | + } |
|
| 756 | 756 | if (!empty($options['group'])) { |
| 757 | 757 | $query->group($options['group']); |
| 758 | 758 | } |
| 759 | - if (!empty($options['order'])) |
|
| 760 | - $query->order($options['order']); |
|
| 761 | - if (!empty($options['join'])) |
|
| 762 | - $query->join($options['join']); |
|
| 763 | - if (!empty($options['distinct'])) |
|
| 764 | - $query->distinct = $options['distinct']; |
|
| 759 | + if (!empty($options['order'])) { |
|
| 760 | + $query->order($options['order']); |
|
| 761 | + } |
|
| 762 | + if (!empty($options['join'])) { |
|
| 763 | + $query->join($options['join']); |
|
| 764 | + } |
|
| 765 | + if (!empty($options['distinct'])) { |
|
| 766 | + $query->distinct = $options['distinct']; |
|
| 767 | + } |
|
| 765 | 768 | |
| 766 | 769 | foreach (static::$relJoins as $join) { |
| 767 | 770 | $query->join($join[0], $join[1]); |
@@ -787,14 +790,14 @@ discard block |
||
| 787 | 790 | } |
| 788 | 791 | static::$needJoin = []; |
| 789 | 792 | |
| 790 | - if (!empty($options['limit'])) |
|
| 791 | - $limit = (int) $options['limit']; |
|
| 792 | - else { |
|
| 793 | + if (!empty($options['limit'])) { |
|
| 794 | + $limit = (int) $options['limit']; |
|
| 795 | + } else { |
|
| 793 | 796 | $limit = 0; |
| 794 | 797 | } |
| 795 | - if (!empty($options['start'])) |
|
| 796 | - $start = (int) $options['start']; |
|
| 797 | - else { |
|
| 798 | + if (!empty($options['start'])) { |
|
| 799 | + $start = (int) $options['start']; |
|
| 800 | + } else { |
|
| 798 | 801 | $start = 0; |
| 799 | 802 | } |
| 800 | 803 | if ($limit || $start) { |
@@ -1061,21 +1064,23 @@ discard block |
||
| 1061 | 1064 | if (!empty($options['where'])) { |
| 1062 | 1065 | static::fixPrefix($options['where'], 'first'); |
| 1063 | 1066 | } |
| 1064 | - if (!empty($options['where'])) |
|
| 1065 | - $query->where($options['where']); |
|
| 1066 | - if (!empty($options['join'])) |
|
| 1067 | - $query->join($options['join']); |
|
| 1067 | + if (!empty($options['where'])) { |
|
| 1068 | + $query->where($options['where']); |
|
| 1069 | + } |
|
| 1070 | + if (!empty($options['join'])) { |
|
| 1071 | + $query->join($options['join']); |
|
| 1072 | + } |
|
| 1068 | 1073 | if (!empty($options['order'])) { |
| 1069 | 1074 | $query->order($options['order']); |
| 1070 | 1075 | } |
| 1071 | - if (!empty($options['limit'])) |
|
| 1072 | - $limit = (int) $options['limit']; |
|
| 1073 | - else { |
|
| 1076 | + if (!empty($options['limit'])) { |
|
| 1077 | + $limit = (int) $options['limit']; |
|
| 1078 | + } else { |
|
| 1074 | 1079 | $limit = 0; |
| 1075 | 1080 | } |
| 1076 | - if (!empty($options['start'])) |
|
| 1077 | - $start = (int) $options['start']; |
|
| 1078 | - else { |
|
| 1081 | + if (!empty($options['start'])) { |
|
| 1082 | + $start = (int) $options['start']; |
|
| 1083 | + } else { |
|
| 1079 | 1084 | $start = 0; |
| 1080 | 1085 | } |
| 1081 | 1086 | if ($limit || $start) { |
@@ -1153,8 +1158,9 @@ discard block |
||
| 1153 | 1158 | |
| 1154 | 1159 | $values = []; |
| 1155 | 1160 | foreach ($cols as $col => $param) { |
| 1156 | - if (isset($params[$col])) |
|
| 1157 | - $values[$col] = $params[$col]; |
|
| 1161 | + if (isset($params[$col])) { |
|
| 1162 | + $values[$col] = $params[$col]; |
|
| 1163 | + } |
|
| 1158 | 1164 | } |
| 1159 | 1165 | if (empty($values)) { |
| 1160 | 1166 | return false; |
@@ -1337,8 +1343,9 @@ discard block |
||
| 1337 | 1343 | $values = []; |
| 1338 | 1344 | |
| 1339 | 1345 | foreach ($this->cols() as $col => $param) { |
| 1340 | - if (isset($this->_params[$col])) |
|
| 1341 | - $values[$col] = $this->_params[$col]; |
|
| 1346 | + if (isset($this->_params[$col])) { |
|
| 1347 | + $values[$col] = $this->_params[$col]; |
|
| 1348 | + } |
|
| 1342 | 1349 | } |
| 1343 | 1350 | if (empty($values) && empty($options['empty'])) { |
| 1344 | 1351 | return false; |
@@ -1498,8 +1505,9 @@ discard block |
||
| 1498 | 1505 | { |
| 1499 | 1506 | |
| 1500 | 1507 | foreach (static::relations() as $relName => $rel) { |
| 1501 | - if ($rel['col'] == $col) |
|
| 1502 | - return $relName; |
|
| 1508 | + if ($rel['col'] == $col) { |
|
| 1509 | + return $relName; |
|
| 1510 | + } |
|
| 1503 | 1511 | } |
| 1504 | 1512 | return NULL; |
| 1505 | 1513 | } |