diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 89275e896..a90a90fa7 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -47,19 +47,37 @@ class ServiceProvider extends ModuleServiceProvider /* * Define path constants */ - if (!defined('PATH_APP')) define('PATH_APP', app_path()); - if (!defined('PATH_BASE')) define('PATH_BASE', base_path()); - if (!defined('PATH_PUBLIC')) define('PATH_PUBLIC', public_path()); - if (!defined('PATH_STORAGE')) define('PATH_STORAGE', storage_path()); - if (!defined('PATH_PLUGINS')) define('PATH_PLUGINS', base_path() . Config::get('cms.pluginsDir', '/plugins')); + if (!defined('PATH_APP')) { + define('PATH_APP', app_path()); + } + if (!defined('PATH_BASE')) { + define('PATH_BASE', base_path()); + } + if (!defined('PATH_PUBLIC')) { + define('PATH_PUBLIC', public_path()); + } + if (!defined('PATH_STORAGE')) { + define('PATH_STORAGE', storage_path()); + } + if (!defined('PATH_PLUGINS')) { + define('PATH_PLUGINS', base_path() . Config::get('cms.pluginsDir', '/plugins')); + } /* * Register singletons */ - App::singleton('string', function(){ return new \October\Rain\Support\Str; }); - App::singleton('backend.helper', function(){ return new \Backend\Classes\BackendHelper; }); - App::singleton('backend.menu', function() { return \Backend\Classes\NavigationManager::instance(); }); - App::singleton('backend.auth', function() { return \Backend\Classes\AuthManager::instance(); }); + App::singleton('string', function () { + return new \October\Rain\Support\Str; + }); + App::singleton('backend.helper', function () { + return new \Backend\Classes\BackendHelper; + }); + App::singleton('backend.menu', function () { + return \Backend\Classes\NavigationManager::instance(); + }); + App::singleton('backend.auth', function () { + return \Backend\Classes\AuthManager::instance(); + }); /* * Check for CLI or system/updates route and disable any plugin initialization @@ -67,12 +85,14 @@ class ServiceProvider extends ModuleServiceProvider */ $requestPath = \October\Rain\Router\Helper::normalizeUrl(\Request::path()); $systemPath = \October\Rain\Router\Helper::normalizeUrl(Config::get('cms.backendUri') . '/system/updates'); - if (stripos($requestPath, $systemPath) === 0) + if (stripos($requestPath, $systemPath) === 0) { PluginManager::$noInit = true; + } $updateCommands = ['october:up', 'october:update']; - if (App::runningInConsole() && count(array_intersect($updateCommands, Request::server('argv'))) > 0) + if (App::runningInConsole() && count(array_intersect($updateCommands, Request::server('argv'))) > 0) { PluginManager::$noInit = true; + } /* * Register all plugins @@ -83,7 +103,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Error handling for uncaught Exceptions */ - App::error(function(\Exception $exception, $httpCode){ + App::error(function (\Exception $exception, $httpCode) { $handler = new ErrorHandler; return $handler->handleException($exception, $httpCode); }); @@ -91,9 +111,10 @@ class ServiceProvider extends ModuleServiceProvider /* * Write all log events to the database */ - Event::listen('illuminate.log', function($level, $message, $context){ - if (!DbDongle::hasDatabase()) + Event::listen('illuminate.log', function ($level, $message, $context) { + if (!DbDongle::hasDatabase()) { return; + } EventLog::add($message, $level); }); @@ -101,7 +122,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Register basic Twig */ - App::bindShared('twig', function($app) { + App::bindShared('twig', function ($app) { $twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]); $twig->addExtension(new TwigExtension); return $twig; @@ -110,14 +131,14 @@ class ServiceProvider extends ModuleServiceProvider /* * Register .htm extension for Twig views */ - App::make('view')->addExtension('htm', 'twig', function() { + App::make('view')->addExtension('htm', 'twig', function () { return new TwigEngine(App::make('twig')); }); /* * Register Twig that will parse strings */ - App::bindShared('twig.string', function($app) { + App::bindShared('twig.string', function ($app) { $twig = $app['twig']; $twig->setLoader(new Twig_Loader_String); return $twig; @@ -126,31 +147,35 @@ class ServiceProvider extends ModuleServiceProvider /* * Override system mailer with mail settings */ - Event::listen('mailer.beforeRegister', function() { - if (MailSettings::isConfigured()) + Event::listen('mailer.beforeRegister', function () { + if (MailSettings::isConfigured()) { MailSettings::applyConfigValues(); + } }); /* * Override standard Mailer content with template */ - Event::listen('mailer.beforeAddContent', function($mailer, $message, $view, $plain, $data){ - if (MailTemplate::addContentToMailer($message, $view, $data)) + Event::listen('mailer.beforeAddContent', function ($mailer, $message, $view, $plain, $data) { + if (MailTemplate::addContentToMailer($message, $view, $data)) { return false; + } }); /* * Register other module providers */ foreach (Config::get('cms.loadModules', []) as $module) { - if (strtolower(trim($module)) == 'system') continue; + if (strtolower(trim($module)) == 'system') { + continue; + } App::register('\\' . $module . '\ServiceProvider'); } /* * Register navigation */ - BackendMenu::registerCallback(function($manager) { + BackendMenu::registerCallback(function ($manager) { $manager->registerMenuItems('October.System', [ 'system' => [ 'label' => 'system::lang.system.menu_label', @@ -165,7 +190,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Register report widgets */ - WidgetManager::instance()->registerReportWidgets(function($manager){ + WidgetManager::instance()->registerReportWidgets(function ($manager) { $manager->registerReportWidget('System\ReportWidgets\Status', [ 'label' => 'backend::lang.dashboard.status.widget_title_default', 'context' => 'dashboard' @@ -175,18 +200,27 @@ class ServiceProvider extends ModuleServiceProvider /* * Register permissions */ - BackendAuth::registerCallback(function($manager) { + BackendAuth::registerCallback(function ($manager) { $manager->registerPermissions('October.System', [ - 'system.manage_settings' => ['label' => 'system::lang.permissions.manage_system_settings', 'tab' => 'System'], - 'system.manage_updates' => ['label' => 'system::lang.permissions.manage_software_updates', 'tab' => 'System'], - 'system.manage_mail_templates' => ['label' => 'system::lang.permissions.manage_mail_templates', 'tab' => 'System'], + 'system.manage_settings' => [ + 'label' => 'system::lang.permissions.manage_system_settings', + 'tab' => 'System' + ], + 'system.manage_updates' => [ + 'label' => 'system::lang.permissions.manage_software_updates', + 'tab' => 'System' + ], + 'system.manage_mail_templates' => [ + 'label' => 'system::lang.permissions.manage_mail_templates', + 'tab' => 'System' + ], ]); }); /* * Register markup tags */ - MarkupManager::instance()->registerCallback(function($manager){ + MarkupManager::instance()->registerCallback(function ($manager) { $manager->registerFunctions([ // Functions 'post' => 'post', @@ -227,7 +261,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Register settings */ - SettingsManager::instance()->registerCallback(function($manager){ + SettingsManager::instance()->registerCallback(function ($manager) { $manager->registerSettingItems('October.System', [ 'administrators' => [ 'label' => 'backend::lang.user.menu_label', @@ -298,14 +332,18 @@ class ServiceProvider extends ModuleServiceProvider /* * Override clear cache command */ - App::bindShared('command.cache.clear', function($app) { + App::bindShared('command.cache.clear', function ($app) { return new \System\Console\CacheClear($app['cache'], $app['files']); }); /* * Register the sidebar for the System main menu */ - BackendMenu::registerContextSidenavPartial('October.System', 'system', '@/modules/system/partials/_system_sidebar.htm'); + BackendMenu::registerContextSidenavPartial( + 'October.System', + 'system', + '@/modules/system/partials/_system_sidebar.htm' + ); } /** diff --git a/modules/system/aliases.php b/modules/system/aliases.php index 539d54398..ebeb29483 100644 --- a/modules/system/aliases.php +++ b/modules/system/aliases.php @@ -54,4 +54,4 @@ return [ 'SystemException' => 'System\Classes\SystemException', 'ApplicationException' => 'System\Classes\ApplicationException', 'ValidationException' => 'October\Rain\Support\ValidationException', -]; \ No newline at end of file +]; diff --git a/modules/system/behaviors/SettingsModel.php b/modules/system/behaviors/SettingsModel.php index c3228c1f1..cf5cee027 100644 --- a/modules/system/behaviors/SettingsModel.php +++ b/modules/system/behaviors/SettingsModel.php @@ -71,8 +71,9 @@ class SettingsModel extends ModelBehavior */ public function instance() { - if (isset(self::$instances[$this->recordCode])) + if (isset(self::$instances[$this->recordCode])) { return self::$instances[$this->recordCode]; + } if (!$item = $this->getSettingsRecord()) { $this->model->initSettingsData(); @@ -127,8 +128,9 @@ class SettingsModel extends ModelBehavior */ public function getSettingsValue($key, $default = null) { - if (array_key_exists($key, $this->fieldValues)) + if (array_key_exists($key, $this->fieldValues)) { return $this->fieldValues[$key]; + } return $default; } @@ -136,7 +138,9 @@ class SettingsModel extends ModelBehavior /** * Default values to set for this model, override */ - public function initSettingsData(){} + public function initSettingsData() + { + } /** * Populate the field values from the database record. @@ -164,8 +168,9 @@ class SettingsModel extends ModelBehavior public function beforeModelSave() { $this->model->item = $this->recordCode; - if ($this->fieldValues) + if ($this->fieldValues) { $this->model->value = $this->fieldValues; + } } /** @@ -182,8 +187,9 @@ class SettingsModel extends ModelBehavior */ public function setModelAttribute($key, $value) { - if ($this->isKeyAllowed($key)) + if ($this->isKeyAllowed($key)) { return; + } $this->fieldValues[$key] = $value; } @@ -197,14 +203,16 @@ class SettingsModel extends ModelBehavior /* * Let the core columns through */ - if ($key == 'id' || $key == 'value' || $key == 'item') + if ($key == 'id' || $key == 'value' || $key == 'item') { return true; + } /* * Let relations through */ - if ($this->model->hasRelation($key)) + if ($this->model->hasRelation($key)) { return true; + } return false; } diff --git a/modules/system/classes/ApplicationException.php b/modules/system/classes/ApplicationException.php index bdfe601c7..ff4f950a7 100644 --- a/modules/system/classes/ApplicationException.php +++ b/modules/system/classes/ApplicationException.php @@ -9,4 +9,4 @@ */ class ApplicationException extends ExceptionBase { -} \ No newline at end of file +} diff --git a/modules/system/classes/Controller.php b/modules/system/classes/Controller.php index a49caa6f9..bbd5d756a 100644 --- a/modules/system/classes/Controller.php +++ b/modules/system/classes/Controller.php @@ -21,19 +21,18 @@ class Controller extends BaseController */ public function combine($name) { - try { - if (!strpos($name, '-')) - throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name'=>$name])); - - $parts = explode('-', $name); - $cacheId = $parts[0]; - - $combiner = new CombineAssets; - return $combiner->getContents($cacheId); - } - catch (Exception $ex) { - return '/* '.$ex->getMessage().' */'; - } + try { + if (!strpos($name, '-')) { + throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name' => $name])); + } + + $parts = explode('-', $name); + $cacheId = $parts[0]; + + $combiner = new CombineAssets; + return $combiner->getContents($cacheId); + } catch (Exception $ex) { + return '/* '.$ex->getMessage().' */'; + } } - -} \ No newline at end of file +} diff --git a/modules/system/classes/ErrorHandler.php b/modules/system/classes/ErrorHandler.php index 29334ca82..ddc4d0046 100644 --- a/modules/system/classes/ErrorHandler.php +++ b/modules/system/classes/ErrorHandler.php @@ -40,32 +40,34 @@ class ErrorHandler public function handleException(\Exception $proposedException, $httpCode = 500) { // Disable the error handler for test and CLI environment - if (App::runningUnitTests() || App::runningInConsole()) + if (App::runningUnitTests() || App::runningInConsole()) { return; + } // Detect AJAX request and use error 500 - if (Request::ajax()) - return Response::make($proposedException->getMessage(), $httpCode); + if (Request::ajax()) { + return Response::make($proposedException->getMessage(), $httpCode); + } // Clear the output buffer - while (ob_get_level()) + while (ob_get_level()) { ob_end_clean(); + } // Friendly error pages are used - if (Config::get('cms.customErrorPage')) + if (Config::get('cms.customErrorPage')) { return $this->handleCustomError(); + } // If the exception is already our brand, use it. if ($proposedException instanceof BaseException) { $exception = $proposedException; - } // If there is an active mask prepared, use that. - elseif (static::$activeMask !== null) { + } elseif (static::$activeMask !== null) { $exception = static::$activeMask; $exception->setMask($proposedException); - } // Otherwise we should mask it with our own default scent. - else { + } else { $exception = new ApplicationException($proposedException->getMessage(), 0); $exception->setMask($proposedException); } @@ -83,8 +85,9 @@ class ErrorHandler */ public static function applyMask(\Exception $exception) { - if (static::$activeMask !== null) + if (static::$activeMask !== null) { array_push(static::$maskLayers, static::$activeMask); + } static::$activeMask = $exception; } @@ -95,10 +98,11 @@ class ErrorHandler */ public static function removeMask() { - if (count(static::$maskLayers) > 0) + if (count(static::$maskLayers) > 0) { static::$activeMask = array_pop(static::$maskLayers); - else + } else { static::$activeMask = null; + } } /** @@ -112,12 +116,12 @@ class ErrorHandler // Use the default view if no "/error" URL is found. $router = new Router($theme); - if (!$router->findByUrl('/error')) + if (!$router->findByUrl('/error')) { return View::make('cms::error'); + } // Route to the CMS error page. $controller = new Controller($theme); return $controller->run('/error'); } - -} \ No newline at end of file +} diff --git a/modules/system/classes/ExceptionBase.php b/modules/system/classes/ExceptionBase.php index 7112a1923..45a178c72 100644 --- a/modules/system/classes/ExceptionBase.php +++ b/modules/system/classes/ExceptionBase.php @@ -60,7 +60,7 @@ class ExceptionBase extends Exception $this->className = get_called_class(); } - if ($this->errorType === null) { + if ($this->errorType === null) { $this->errorType = 'Undefined'; } @@ -140,8 +140,9 @@ class ExceptionBase extends Exception */ public function getTrueException() { - if ($this->mask !== null) + if ($this->mask !== null) { return $this->mask; + } return $this; } @@ -157,8 +158,9 @@ class ExceptionBase extends Exception */ public function getHighlight() { - if ($this->highlight !== null) + if ($this->highlight !== null) { return $this->highlight; + } if (!$this->fileContent && File::exists($this->file) && is_readable($this->file)) { $this->fileContent = @file($this->file); @@ -167,13 +169,15 @@ class ExceptionBase extends Exception $errorLine = $this->line - 1; $startLine = $errorLine - 6; - if ($startLine < 0) + if ($startLine < 0) { $startLine = 0; + } $endLine = $startLine + 12; $lineNum = count($this->fileContent); - if ($endLine > $lineNum-1) + if ($endLine > $lineNum-1) { $endLine = $lineNum-1; + } $areaLines = array_slice($this->fileContent, $startLine, $endLine - $startLine + 1); @@ -222,8 +226,8 @@ class ExceptionBase extends Exception foreach ($traceInfo as $index => $event) { - $functionName = (isset($event['class']) && strlen($event['class'])) - ? $event['class'].$event['type'].$event['function'] + $functionName = (isset($event['class']) && strlen($event['class'])) + ? $event['class'].$event['type'].$event['function'] : $event['function']; $file = isset($event['file']) ? URL::to(str_replace(public_path(), '', $event['file'])) : null; @@ -261,13 +265,18 @@ class ExceptionBase extends Exception */ $useFilter = false; foreach ($traceInfo as $event) { - if (isset($event['class']) && $event['class'] == 'Illuminate\Exception\Handler' && $event['function'] == 'handleError') { + if ( + isset($event['class']) && + $event['class'] == 'Illuminate\Exception\Handler' && + $event['function'] == 'handleError' + ) { $useFilter = true; } } - if (!$useFilter) + if (!$useFilter) { return $traceInfo; + } $filterResult = []; $pruneResult = true; @@ -275,13 +284,18 @@ class ExceptionBase extends Exception /* * Prune the tail end of the trace from the framework exception handler. */ - if (isset($event['class']) && $event['class'] == 'Illuminate\Exception\Handler' && $event['function'] == 'handleError') { + if ( + isset($event['class']) && + $event['class'] == 'Illuminate\Exception\Handler' && + $event['function'] == 'handleError' + ) { $pruneResult = false; continue; } - if ($pruneResult) + if ($pruneResult) { continue; + } $filterResult[$index] = $event; } @@ -304,42 +318,39 @@ class ExceptionBase extends Exception $items = array(); foreach ($argument as $index => $obj) { - if (is_array($obj)) + if (is_array($obj)) { $value = 'array('.count($obj).')'; - - elseif (is_object($obj)) + } elseif (is_object($obj)) { $value = 'object('.get_class($obj).')'; - - elseif (is_integer($obj)) + } elseif (is_integer($obj)) { $value = $obj; - - elseif ($obj === null) + } elseif ($obj === null) { $value = "null"; - - else + } else { $value = "'".$obj."'"; + } $items[] = $index . ' => ' . $value; } - if (count($items)) + if (count($items)) { $arg = 'array(' . count($argument) . ') [' . implode(', ', $items) . ']'; - else + } else { $arg = 'array(0)'; - } - elseif (is_object($argument)) + } + } elseif (is_object($argument)) { $arg = 'object('.get_class($argument).')'; - elseif ($argument === null) + } elseif ($argument === null) { $arg = "null"; - elseif (is_integer($argument)) + } elseif (is_integer($argument)) { $arg = $argument; - else + } else { $arg = "'".$argument."'"; + } $argsArray[] = $arg; } return implode(', ', $argsArray); } - } diff --git a/modules/system/classes/MarkupManager.php b/modules/system/classes/MarkupManager.php index 37cf11193..01a86e58f 100644 --- a/modules/system/classes/MarkupManager.php +++ b/modules/system/classes/MarkupManager.php @@ -60,12 +60,14 @@ class MarkupManager foreach ($plugins as $id => $plugin) { $items = $plugin->registerMarkupTags(); - if (!is_array($items)) + if (!is_array($items)) { continue; + } foreach ($items as $type => $definitions) { - if (!is_array($definitions)) + if (!is_array($definitions)) { continue; + } $this->registerExtensions($type, $definitions); } @@ -103,23 +105,24 @@ class MarkupManager */ public function registerExtensions($type, array $definitions) { - if (is_null($this->items)) + if (is_null($this->items)) { $this->items = []; + } - if (!array_key_exists($type, $this->items)) + if (!array_key_exists($type, $this->items)) { $this->items[$type] = []; + } foreach ($definitions as $name => $definition) { switch ($type) { case self::EXTENSION_TOKEN_PARSER: $this->items[$type][] = $definition; - break; - + break; case self::EXTENSION_FILTER: case self::EXTENSION_FUNCTION: $this->items[$type][$name] = $definition; - break; + break; } } } @@ -158,11 +161,13 @@ class MarkupManager */ public function listExtensions($type) { - if ($this->items === null) + if ($this->items === null) { $this->loadExtensions(); + } - if (!isset($this->items[$type]) || !is_array($this->items[$type])) + if (!isset($this->items[$type]) || !is_array($this->items[$type])) { return []; + } return $this->items[$type]; } @@ -201,8 +206,9 @@ class MarkupManager */ public function makeTwigFunctions($functions = []) { - if (!is_array($functions)) + if (!is_array($functions)) { $functions = []; + } foreach ($this->listFunctions() as $name => $callable) { @@ -210,15 +216,16 @@ class MarkupManager * Handle a wildcard function */ if (strpos($name, '*') !== false && $this->isWildCallable($callable)) { - $callable = function($name) use ($callable) { + $callable = function ($name) use ($callable) { $arguments = array_slice(func_get_args(), 1); $method = $this->isWildCallable($callable, Str::camel($name)); return call_user_func_array($method, $arguments); }; } - if (!is_callable($callable)) + if (!is_callable($callable)) { throw new ApplicationException(sprintf('The markup function for %s is not callable.', $name)); + } $functions[] = new Twig_SimpleFunction($name, $callable, ['is_safe' => ['html']]); } @@ -233,8 +240,9 @@ class MarkupManager */ public function makeTwigFilters($filters = []) { - if (!is_array($filters)) + if (!is_array($filters)) { $filters = []; + } foreach ($this->listFilters() as $name => $callable) { @@ -242,15 +250,16 @@ class MarkupManager * Handle a wildcard function */ if (strpos($name, '*') !== false && $this->isWildCallable($callable)) { - $callable = function($name) use ($callable) { + $callable = function ($name) use ($callable) { $arguments = array_slice(func_get_args(), 1); $method = $this->isWildCallable($callable, Str::camel($name)); return call_user_func_array($method, $arguments); }; } - if (!is_callable($callable)) + if (!is_callable($callable)) { throw new ApplicationException(sprintf('The markup filter for %s is not callable.', $name)); + } $filters[] = new Twig_SimpleFilter($name, $callable, ['is_safe' => ['html']]); } @@ -265,13 +274,15 @@ class MarkupManager */ public function makeTwigTokenParsers($parsers = []) { - if (!is_array($parsers)) + if (!is_array($parsers)) { $parsers = []; + } $extraParsers = $this->listTokenParsers(); foreach ($extraParsers as $obj) { - if (!$obj instanceof Twig_TokenParser) + if (!$obj instanceof Twig_TokenParser) { continue; + } $parsers[] = $obj; } @@ -290,30 +301,30 @@ class MarkupManager { $isWild = false; - if (is_string($callable) && strpos($callable, '*') !== false) + if (is_string($callable) && strpos($callable, '*') !== false) { $isWild = $replaceWith ? str_replace('*', $replaceWith, $callable) : true; + } if (is_array($callable)) { if (is_string($callable[0]) && strpos($callable[0], '*') !== false) { if ($replaceWith) { $isWild = $callable; $isWild[0] = str_replace('*', $replaceWith, $callable[0]); - } - else + } else { $isWild = true; + } } if (!empty($callable[1]) && strpos($callable[1], '*') !== false) { if ($replaceWith) { $isWild = $isWild ?: $callable; $isWild[1] = str_replace('*', $replaceWith, $callable[1]); - } - else + } else { $isWild = true; + } } } return $isWild; } - -} \ No newline at end of file +} diff --git a/modules/system/classes/ModelBehavior.php b/modules/system/classes/ModelBehavior.php index 73352b21b..2959a0b13 100644 --- a/modules/system/classes/ModelBehavior.php +++ b/modules/system/classes/ModelBehavior.php @@ -39,5 +39,4 @@ class ModelBehavior extends ModelBehaviorBase } } } - -} \ No newline at end of file +} diff --git a/modules/system/classes/PluginBase.php b/modules/system/classes/PluginBase.php index 355ec9c44..a5509104a 100644 --- a/modules/system/classes/PluginBase.php +++ b/modules/system/classes/PluginBase.php @@ -28,12 +28,16 @@ abstract class PluginBase extends ServiceProviderBase /** * Register method, called when the plugin is first registered. */ - public function register() {} + public function register() + { + } /** * Boot method, called right before the request route. */ - public function boot() {} + public function boot() + { + } /** * Registers CMS markup tags introduced by this plugin. @@ -125,10 +129,10 @@ abstract class PluginBase extends ServiceProviderBase public function registerConsoleCommand($key, $class) { $key = 'command.'.$key; - $this->app[$key] = $this->app->share(function($app) use ($class){ + $this->app[$key] = $this->app->share(function ($app) use ($class) { return new $class; }); $this->commands($key); } -} \ No newline at end of file +} diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 9d5616105..a9545d518 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -88,12 +88,14 @@ class PluginManager $pluginClassName = $className.'\Plugin'; // Autoloader failed? - if (!class_exists($pluginClassName)) + if (!class_exists($pluginClassName)) { include_once $classPath.'/Plugin.php'; + } // Not a valid plugin! - if (!class_exists($pluginClassName)) + if (!class_exists($pluginClassName)) { continue; + } $classObj = new $pluginClassName($this->app); $classId = $this->getIdentifier($classObj); @@ -101,8 +103,9 @@ class PluginManager /* * Check for disabled plugins */ - if ($this->isDisabled($classId)) + if ($this->isDisabled($classId)) { $classObj->disabled = true; + } $this->plugins[$classId] = $classObj; $this->pathMap[$classId] = $classPath; @@ -116,15 +119,18 @@ class PluginManager */ public function registerAll() { - if ($this->registered) + if ($this->registered) { return; + } foreach ($this->plugins as $pluginId => $plugin) { - if ($plugin->disabled) + if ($plugin->disabled) { continue; + } - if (!self::$noInit) + if (!self::$noInit) { $plugin->register(); + } $pluginPath = $this->getPluginPath($plugin); $pluginNamespace = strtolower($pluginId); @@ -133,36 +139,41 @@ class PluginManager * Register plugin class autoloaders */ $autoloadPath = $pluginPath . '/vendor/autoload.php'; - if (File::isFile($autoloadPath)) + if (File::isFile($autoloadPath)) { require_once $autoloadPath; + } /* * Register language namespaces */ $langPath = $pluginPath . '/lang'; - if (File::isDirectory($langPath)) + if (File::isDirectory($langPath)) { Lang::addNamespace($pluginNamespace, $langPath); + } /* * Register configuration path */ $configPath = $pluginPath . '/config'; - if (File::isDirectory($configPath)) + if (File::isDirectory($configPath)) { Config::package($pluginNamespace, $configPath, $pluginNamespace); + } /* * Register views path */ $viewsPath = $pluginPath . '/views'; - if (File::isDirectory($viewsPath)) + if (File::isDirectory($viewsPath)) { View::addNamespace($pluginNamespace, $viewsPath); + } /* * Add routes, if available */ $routesFile = $pluginPath . '/routes.php'; - if (File::exists($routesFile)) + if (File::exists($routesFile)) { require $routesFile; + } } $this->registered = true; @@ -173,15 +184,18 @@ class PluginManager */ public function bootAll() { - if ($this->booted) + if ($this->booted) { return; + } foreach ($this->plugins as $plugin) { - if ($plugin->disabled) + if ($plugin->disabled) { continue; + } - if (!self::$noInit) + if (!self::$noInit) { $plugin->boot(); + } } $this->booted = true; @@ -202,8 +216,9 @@ class PluginManager public function getPluginPath($id) { $classId = $this->getIdentifier($id); - if (!isset($this->pathMap[$classId])) + if (!isset($this->pathMap[$classId])) { return null; + } return $this->pathMap[$classId]; } @@ -234,8 +249,9 @@ class PluginManager */ public function findByNamespace($namespace) { - if (!$this->hasPlugin($namespace)) + if (!$this->hasPlugin($namespace)) { return null; + } $classId = $this->getIdentifier($namespace); return $this->plugins[$classId]; @@ -246,11 +262,13 @@ class PluginManager */ public function findByIdentifier($identifier) { - if (!isset($this->plugins[$identifier])) + if (!isset($this->plugins[$identifier])) { $identifier = $this->normalizeIdentifier($identifier); + } - if (!isset($this->plugins[$identifier])) + if (!isset($this->plugins[$identifier])) { return null; + } return $this->plugins[$identifier]; } @@ -290,8 +308,9 @@ class PluginManager $plugins = []; $dirPath = $this->getPath(); - if (!File::isDirectory($dirPath)) + if (!File::isDirectory($dirPath)) { return $plugins; + } $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath)); $it->setMaxDepth(2); @@ -319,8 +338,9 @@ class PluginManager public function getIdentifier($namespace) { $namespace = Str::normalizeClassName($namespace); - if (strpos($namespace, '\\') === null) + if (strpos($namespace, '\\') === null) { return $namespace; + } $parts = explode('\\', $namespace); $slice = array_slice($parts, 1, 2); @@ -336,8 +356,9 @@ class PluginManager public function normalizeIdentifier($identifier) { foreach ($this->plugins as $id => $object) { - if (strtolower($id) == strtolower($identifier)) + if (strtolower($id) == strtolower($identifier)) { return $id; + } } return $identifier; @@ -361,15 +382,15 @@ class PluginManager $path = $this->metaPath.'/disabled.json'; if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { - foreach ($configDisabled as $disabled) + foreach ($configDisabled as $disabled) { $this->disabledPlugins[$disabled] = true; + } } if (File::exists($path)) { $disabled = json_decode(File::get($path), true); $this->disabledPlugins = array_merge($this->disabledPlugins, $disabled); - } - else { + } else { $this->writeDisabled(); } } @@ -382,8 +403,9 @@ class PluginManager public function isDisabled($id) { $code = $this->getIdentifier($id); - if (array_key_exists($code, $this->disabledPlugins)) + if (array_key_exists($code, $this->disabledPlugins)) { return true; + } } /** @@ -403,14 +425,16 @@ class PluginManager public function disablePlugin($id, $isUser = false) { $code = $this->getIdentifier($id); - if (array_key_exists($code, $this->disabledPlugins)) + if (array_key_exists($code, $this->disabledPlugins)) { return false; + } $this->disabledPlugins[$code] = $isUser; $this->writeDisabled(); - if ($pluginObj = $this->findByIdentifier($code)) + if ($pluginObj = $this->findByIdentifier($code)) { $pluginObj->disabled = true; + } return true; } @@ -423,18 +447,21 @@ class PluginManager public function enablePlugin($id, $isUser = false) { $code = $this->getIdentifier($id); - if (!array_key_exists($code, $this->disabledPlugins)) + if (!array_key_exists($code, $this->disabledPlugins)) { return false; + } // Prevent system from enabling plugins disabled by the user - if (!$isUser && $this->disabledPlugins[$code] === true) + if (!$isUser && $this->disabledPlugins[$code] === true) { return false; + } unset($this->disabledPlugins[$code]); $this->writeDisabled(); - if ($pluginObj = $this->findByIdentifier($code)) + if ($pluginObj = $this->findByIdentifier($code)) { $pluginObj->disabled = false; + } return true; } @@ -450,22 +477,24 @@ class PluginManager protected function loadDependencies() { foreach ($this->plugins as $id => $plugin) { - if (!$required = $this->getDependencies($plugin)) + if (!$required = $this->getDependencies($plugin)) { continue; + } $disable = false; foreach ($required as $require) { - if (!$this->hasPlugin($require)) + if (!$this->hasPlugin($require)) { $disable = true; - - elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled) + } elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled) { $disable = true; + } } - if ($disable) + if ($disable) { $this->disablePlugin($id); - else + } else { $this->enablePlugin($id); + } } } @@ -476,11 +505,13 @@ class PluginManager */ public function getDependencies($plugin) { - if (is_string($plugin) && (!$plugin = $this->findByIdentifier($identifer))) + if (is_string($plugin) && (!$plugin = $this->findByIdentifier($identifer))) { return false; + } - if (!isset($plugin->require) || !$plugin->require) + if (!isset($plugin->require) || !$plugin->require) { return null; + } return is_array($plugin->require) ? $plugin->require : [$plugin->require]; } @@ -493,8 +524,9 @@ class PluginManager */ public function sortByDependencies($plugins = null) { - if (!is_array($plugins)) + if (!is_array($plugins)) { $plugins = $this->getPlugins(); + } $result = []; $checklist = $plugins; @@ -502,8 +534,9 @@ class PluginManager $loopCount = 0; while (count($checklist)) { - if (++$loopCount > 999) + if (++$loopCount > 999) { throw new ApplicationException('Too much recursion'); + } foreach ($checklist as $code => $plugin) { @@ -511,7 +544,7 @@ class PluginManager * Get dependencies and remove any aliens */ $depends = $this->getDependencies($plugin) ?: []; - $depends = array_filter($depends, function($pluginCode) use ($plugins) { + $depends = array_filter($depends, function ($pluginCode) use ($plugins) { return isset($plugins[$pluginCode]); }); @@ -528,8 +561,9 @@ class PluginManager * Find dependencies that have not been checked */ $depends = array_diff($depends, $result); - if (count($depends) > 0) + if (count($depends) > 0) { continue; + } /* * All dependencies are checked @@ -542,5 +576,4 @@ class PluginManager return $result; } - -} \ No newline at end of file +} diff --git a/modules/system/classes/SettingsManager.php b/modules/system/classes/SettingsManager.php index d8517c7d8..df880ccea 100644 --- a/modules/system/classes/SettingsManager.php +++ b/modules/system/classes/SettingsManager.php @@ -99,8 +99,9 @@ class SettingsManager foreach ($plugins as $id => $plugin) { $items = $plugin->registerSettings(); - if (!is_array($items)) + if (!is_array($items)) { continue; + } $this->registerSettingItems($id, $items); } @@ -108,7 +109,7 @@ class SettingsManager /* * Sort settings items */ - usort($this->items, function($a, $b) { + usort($this->items, function ($a, $b) { return $a->order - $b->order; }); @@ -122,11 +123,11 @@ class SettingsManager * Process each item in to a category array */ $catItems = []; - foreach ($this->items as $item) - { + foreach ($this->items as $item) { $category = $item->category ?: 'Misc'; - if (!isset($catItems[$category])) + if (!isset($catItems[$category])) { $catItems[$category] = []; + } $catItems[$category][] = $item; } @@ -140,11 +141,13 @@ class SettingsManager */ public function listItems($context = null) { - if ($this->items === null) + if ($this->items === null) { $this->loadItems(); + } - if ($context !== null) + if ($context !== null) { return $this->filterByContext($this->items, $context); + } return $this->items; } @@ -163,12 +166,14 @@ class SettingsManager $filteredCategory = []; foreach ($category as $item) { $itemContext = is_array($item->context) ? $item->context : [$item->context]; - if (in_array($context, $itemContext)) + if (in_array($context, $itemContext)) { $filteredCategory[] = $item; + } } - if (count($filteredCategory)) + if (count($filteredCategory)) { $filteredItems[$categoryName] = $filteredCategory; + } } return $filteredItems; @@ -209,8 +214,9 @@ class SettingsManager */ public function registerSettingItems($owner, array $definitions) { - if (!$this->items) + if (!$this->items) { $this->items = []; + } foreach ($definitions as $code => $definition) { $item = array_merge(self::$itemDefaults, array_merge($definition, [ @@ -228,9 +234,9 @@ class SettingsManager list($author, $plugin) = explode('.', $owner); $uri[] = strtolower($author); $uri[] = strtolower($plugin); - } - else + } else { $uri[] = strtolower($owner); + } $uri[] = strtolower($code); $uri = implode('/', $uri); @@ -264,7 +270,7 @@ class SettingsManager { return (object)[ 'itemCode' => $this->contextItemCode, - 'owner' => $this->contextOwner + 'owner' => $this->contextOwner ]; } @@ -276,15 +282,17 @@ class SettingsManager */ public function findSettingItem($owner, $code) { - if ($this->allItems === null) + if ($this->allItems === null) { $this->loadItems(); + } $owner = strtolower($owner); $code = strtolower($code); foreach ($this->allItems as $item) { - if (strtolower($item->owner) == $owner && strtolower($item->code) == $code) + if (strtolower($item->owner) == $owner && strtolower($item->code) == $code) { return $item; + } } return false; @@ -298,13 +306,14 @@ class SettingsManager */ protected function filterItemPermissions($user, array $items) { - array_filter($items, function($item) use ($user) { - if (!$item->permissions || !count($item->permissions)) + array_filter($items, function ($item) use ($user) { + if (!$item->permissions || !count($item->permissions)) { return true; + } return $user->hasAnyAccess($item->permissions); }); return $items; } -} \ No newline at end of file +} diff --git a/modules/system/classes/SystemException.php b/modules/system/classes/SystemException.php index 1a94ac72d..cad2361cd 100644 --- a/modules/system/classes/SystemException.php +++ b/modules/system/classes/SystemException.php @@ -16,4 +16,4 @@ class SystemException extends ExceptionBase parent::__construct($message, $code, $previous); Log::error($this); } -} \ No newline at end of file +} diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 7ac9dc4ab..0c8fd3761 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -78,8 +78,9 @@ class UpdateManager /* * Ensure temp directory exists */ - if (!File::isDirectory($this->tempDirectory)) + if (!File::isDirectory($this->tempDirectory)) { File::makeDirectory($this->tempDirectory, 0777, true); + } } /** @@ -98,8 +99,9 @@ class UpdateManager * Update modules */ $modules = Config::get('cms.loadModules', []); - foreach ($modules as $module) + foreach ($modules as $module) { $this->migrateModule($module); + } /* * Update plugins @@ -117,8 +119,9 @@ class UpdateManager */ if ($firstUp) { $modules = Config::get('cms.loadModules', []); - foreach ($modules as $module) + foreach ($modules as $module) { $this->seedModule($module); + } } return $this; @@ -136,22 +139,23 @@ class UpdateManager * Already know about updates, never retry. */ $oldCount = Parameters::get('system::update.count'); - if ($oldCount > 0) + if ($oldCount > 0) { return $oldCount; + } /* * Retry period not passed, skipping. */ if (!$force && ($retryTimestamp = Parameters::get('system::update.retry'))) { - if (Carbon::createFromTimeStamp($retryTimestamp)->isFuture()) + if (Carbon::createFromTimeStamp($retryTimestamp)->isFuture()) { return $oldCount; + } } try { $result = $this->requestUpdateList(); $newCount = array_get($result, 'update', 0); - } - catch (Exception $ex) { + } catch (Exception $ex) { $newCount = 0; } @@ -211,8 +215,9 @@ class UpdateManager */ $themes = []; foreach (array_get($result, 'themes', []) as $code => $info) { - if (!$this->isThemeInstalled($code)) + if (!$this->isThemeInstalled($code)) { $themes[$code] = $info; + } } $result['themes'] = $themes; @@ -265,7 +270,9 @@ class UpdateManager $this->note($note); } - if ($count == 0) break; + if ($count == 0) { + break; + } } Schema::dropIfExists('migrations'); @@ -310,8 +317,9 @@ class UpdateManager public function seedModule($module) { $className = '\\'.$module.'\Database\Seeds\DatabaseSeeder'; - if (!class_exists($className)) + if (!class_exists($className)) { return; + } $seeder = App::make($className); $seeder->run(); @@ -340,8 +348,9 @@ class UpdateManager { $filePath = $this->getFilePath('core'); - if (!Zip::extract($filePath, $this->baseDirectory)) + if (!Zip::extract($filePath, $this->baseDirectory)) { throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath])); + } @unlink($filePath); @@ -437,8 +446,9 @@ class UpdateManager $fileCode = $name . $hash; $filePath = $this->getFilePath($fileCode); - if (!Zip::extract($filePath, $this->baseDirectory . '/plugins/')) + if (!Zip::extract($filePath, $this->baseDirectory . '/plugins/')) { throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath])); + } @unlink($filePath); } @@ -467,8 +477,9 @@ class UpdateManager $fileCode = $name . $hash; $filePath = $this->getFilePath($fileCode); - if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) + if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) { throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath])); + } $this->setThemeInstalled($name); @unlink($filePath); @@ -541,12 +552,13 @@ class UpdateManager */ public function requestServerData($uri, $postData = []) { - $result = Http::post($this->createServerUrl($uri), function($http) use ($postData) { + $result = Http::post($this->createServerUrl($uri), function ($http) use ($postData) { $this->applyHttpAttributes($http, $postData); }); - if ($result->code == 404) + if ($result->code == 404) { throw new ApplicationException(Lang::get('system::lang.server.response_not_found')); + } if ($result->code != 200) { throw new ApplicationException( @@ -560,13 +572,13 @@ class UpdateManager try { $resultData = @json_decode($result->body, true); - } - catch (Exception $ex) { + } catch (Exception $ex) { throw new ApplicationException(Lang::get('system::lang.server.response_invalid')); } - if ($resultData === false || (is_string($resultData) && !strlen($resultData))) + if ($resultData === false || (is_string($resultData) && !strlen($resultData))) { throw new ApplicationException(Lang::get('system::lang.server.response_invalid')); + } return $resultData; } @@ -587,13 +599,14 @@ class UpdateManager $postData['project'] = $projectId; } - $result = Http::post($this->createServerUrl($uri), function($http) use ($postData, $filePath) { + $result = Http::post($this->createServerUrl($uri), function ($http) use ($postData, $filePath) { $this->applyHttpAttributes($http, $postData); $http->toFile($filePath); }); - if ($result->code != 200) + if ($result->code != 200) { throw new ApplicationException(File::get($filePath)); + } if (md5_file($filePath) != $expectedHash) { @unlink($filePath); @@ -631,8 +644,9 @@ class UpdateManager protected function createServerUrl($uri) { $gateway = Config::get('cms.updateServer', 'http://octobercms.com/api'); - if (substr($gateway, -1) != '/') + if (substr($gateway, -1) != '/') { $gateway .= '/'; + } return $gateway . $uri; } @@ -653,8 +667,9 @@ class UpdateManager $http->header('Rest-Sign', $this->createSignature($postData, $this->secret)); } - if ($credentials = Config::get('cms.updateAuth')) + if ($credentials = Config::get('cms.updateAuth')) { $http->auth($credentials); + } $http->noRedirect(); $http->data($postData); @@ -678,5 +693,4 @@ class UpdateManager { return base64_encode(hash_hmac('sha512', http_build_query($data, '', '&'), base64_decode($secret), true)); } - } diff --git a/modules/system/classes/VersionManager.php b/modules/system/classes/VersionManager.php index 1a0d6c641..962c42a9f 100644 --- a/modules/system/classes/VersionManager.php +++ b/modules/system/classes/VersionManager.php @@ -74,8 +74,9 @@ class VersionManager { $code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin); - if (!$this->hasVersionFile($code)) + if (!$this->hasVersionFile($code)) { return false; + } $currentVersion = $this->getLatestFileVersion($code); $databaseVersion = $this->getDatabaseVersion($code); @@ -102,8 +103,7 @@ class VersionManager if (is_array($details)) { $comment = array_shift($details); $scripts = $details; - } - else { + } else { $comment = $details; $scripts = []; } @@ -112,8 +112,9 @@ class VersionManager * Apply scripts, if any */ foreach ($scripts as $script) { - if ($this->hasDatabaseHistory($code, $version, $script)) + if ($this->hasDatabaseHistory($code, $version, $script)) { continue; + } $this->applyDatabaseScript($code, $version, $script); } @@ -121,8 +122,9 @@ class VersionManager /* * Register the comment and update the version */ - if (!$this->hasDatabaseHistory($code, $version)) + if (!$this->hasDatabaseHistory($code, $version)) { $this->applyDatabaseComment($code, $version, $comment); + } $this->setDatabaseVersion($code, $version); @@ -136,24 +138,32 @@ class VersionManager { $code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin); - if (!$this->hasVersionFile($code)) + if (!$this->hasVersionFile($code)) { return false; + } $pluginHistory = $this->getDatabaseHistory($code); $pluginHistory = array_reverse($pluginHistory); foreach ($pluginHistory as $history) { - if ($history->type == self::HISTORY_TYPE_COMMENT) + if ($history->type == self::HISTORY_TYPE_COMMENT) { $this->removeDatabaseComment($code, $history->version); - elseif ($history->type == self::HISTORY_TYPE_SCRIPT) + } elseif ($history->type == self::HISTORY_TYPE_SCRIPT) { $this->removeDatabaseScript($code, $history->version, $history->detail); + } } $this->setDatabaseVersion($code); - if (isset($this->fileVersions[$code])) unset($this->fileVersions[$code]); - if (isset($this->databaseVersions[$code])) unset($this->databaseVersions[$code]); - if (isset($this->databaseHistory[$code])) unset($this->databaseHistory[$code]); + if (isset($this->fileVersions[$code])) { + unset($this->fileVersions[$code]); + } + if (isset($this->databaseVersions[$code])) { + unset($this->databaseVersions[$code]); + } + if (isset($this->databaseHistory[$code])) { + unset($this->databaseHistory[$code]); + } return true; } @@ -165,12 +175,14 @@ class VersionManager public function purgePlugin($pluginCode) { $versions = Db::table('system_plugin_versions')->where('code', $pluginCode); - if ($countVersions = $versions->count()) + if ($countVersions = $versions->count()) { $versions->delete(); + } $history = Db::table('system_plugin_history')->where('code', $pluginCode); - if ($countHistory = $history->count()) + if ($countHistory = $history->count()) { $history->delete(); + } return (($countHistory + $countVersions) > 0) ? true : false; } @@ -185,10 +197,11 @@ class VersionManager protected function getLatestFileVersion($code) { $versionInfo = $this->getFileVersions($code); - if (!$versionInfo) + if (!$versionInfo) { return self::NO_VERSION_VALUE; + } - $latest = trim(key(array_slice($versionInfo, -1 , 1))); + $latest = trim(key(array_slice($versionInfo, -1, 1))); return $latest; } @@ -197,8 +210,9 @@ class VersionManager */ protected function getNewFileVersions($code, $version = null) { - if ($version === null) + if ($version === null) { $version = self::NO_VERSION_VALUE; + } $versions = $this->getFileVersions($code); $position = array_search($version, array_keys($versions)); @@ -210,14 +224,15 @@ class VersionManager */ protected function getFileVersions($code) { - if ($this->fileVersions !== null && array_key_exists($code, $this->fileVersions)) + if ($this->fileVersions !== null && array_key_exists($code, $this->fileVersions)) { return $this->fileVersions[$code]; + } $versionFile = $this->getVersionFile($code); $versionInfo = Yaml::parseFile($versionFile); if ($versionInfo) { - uksort($versionInfo, function($a, $b){ + uksort($versionInfo, function ($a, $b) { return version_compare($a, $b); }); } @@ -257,7 +272,10 @@ class VersionManager } if (!isset($this->databaseVersions[$code])) { - $this->databaseVersions[$code] = Db::table('system_plugin_versions')->where('code', $code)->pluck('version'); + $this->databaseVersions[$code] = Db::table('system_plugin_versions') + ->where('code', $code) + ->pluck('version') + ; } return (isset($this->databaseVersions[$code])) @@ -278,14 +296,12 @@ class VersionManager 'version' => $version, 'created_at' => new Carbon ]); - } - elseif ($version && $currentVersion){ + } elseif ($version && $currentVersion) { Db::table('system_plugin_versions')->where('code', $code)->update([ 'version' => $version, 'created_at' => new Carbon ]); - } - elseif ($currentVersion) { + } elseif ($currentVersion) { Db::table('system_plugin_versions')->where('code', $code)->delete(); } @@ -362,8 +378,9 @@ class VersionManager */ protected function getDatabaseHistory($code) { - if ($this->databaseHistory !== null && array_key_exists($code, $this->databaseHistory)) + if ($this->databaseHistory !== null && array_key_exists($code, $this->databaseHistory)) { return $this->databaseHistory[$code]; + } $historyInfo = Db::table('system_plugin_history')->where('code', $code)->get(); return $this->databaseHistory[$code] = $historyInfo; @@ -375,18 +392,22 @@ class VersionManager protected function hasDatabaseHistory($code, $version, $script = null) { $historyInfo = $this->getDatabaseHistory($code); - if (!$historyInfo) + if (!$historyInfo) { return false; + } foreach ($historyInfo as $history) { - if ($history->version != $version) + if ($history->version != $version) { continue; + } - if ($history->type == self::HISTORY_TYPE_COMMENT && !$script) + if ($history->type == self::HISTORY_TYPE_COMMENT && !$script) { return true; + } - if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script) + if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script) { return true; + } } return false; @@ -425,4 +446,4 @@ class VersionManager $this->notes = []; return $this; } -} \ No newline at end of file +} diff --git a/modules/system/console/CacheClear.php b/modules/system/console/CacheClear.php index 3676f6512..995e986be 100644 --- a/modules/system/console/CacheClear.php +++ b/modules/system/console/CacheClear.php @@ -55,8 +55,8 @@ class CacheClear extends ClearCommand $command = App::make('System\Console\CacheClear'); $command->setLaravel(App::make('app')); $command->fire(); + } catch (\Exception $ex) { + } - catch (\Exception $ex) {} } - -} \ No newline at end of file +} diff --git a/modules/system/console/OctoberDown.php b/modules/system/console/OctoberDown.php index 0c0185975..253f2db35 100644 --- a/modules/system/console/OctoberDown.php +++ b/modules/system/console/OctoberDown.php @@ -33,13 +33,15 @@ class OctoberDown extends Command */ public function fire() { - if (!$this->confirmToProceed('This will DESTROY all database tables.')) + if (!$this->confirmToProceed('This will DESTROY all database tables.')) { return; + } $manager = UpdateManager::instance()->resetNotes()->uninstall(); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } } /** @@ -66,7 +68,8 @@ class OctoberDown extends Command */ protected function getDefaultConfirmCallback() { - return function() { return true; }; + return function () { + return true; + }; } - -} \ No newline at end of file +} diff --git a/modules/system/console/OctoberUp.php b/modules/system/console/OctoberUp.php index 9a12da19a..228a0fcb6 100644 --- a/modules/system/console/OctoberUp.php +++ b/modules/system/console/OctoberUp.php @@ -35,8 +35,9 @@ class OctoberUp extends Command $this->output->writeln('Migrating application and plugins...'); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } } /** @@ -54,5 +55,4 @@ class OctoberUp extends Command { return []; } - -} \ No newline at end of file +} diff --git a/modules/system/console/OctoberUpdate.php b/modules/system/console/OctoberUpdate.php index 8d95e71ef..d2a3883d1 100644 --- a/modules/system/console/OctoberUpdate.php +++ b/modules/system/console/OctoberUpdate.php @@ -65,8 +65,7 @@ class OctoberUpdate extends Command if ($updates == 0) { $this->output->writeln('No new updates found'); return; - } - else { + } else { $this->output->writeln(sprintf('Found %s new %s!', $updates, Str::plural('update', $updates))); } @@ -125,5 +124,4 @@ class OctoberUpdate extends Command ['plugins', null, InputOption::VALUE_NONE, 'Update plugin files only.'], ]; } - } diff --git a/modules/system/console/OctoberUtil.php b/modules/system/console/OctoberUtil.php index 4a09bb911..9854c02f4 100644 --- a/modules/system/console/OctoberUtil.php +++ b/modules/system/console/OctoberUtil.php @@ -79,11 +79,13 @@ class OctoberUtil extends Command protected function utilPurgeThumbs() { - if (!$uploadsDir = Config::get('cms.uploadsDir')) + if (!$uploadsDir = Config::get('cms.uploadsDir')) { return $this->error('No uploads directory defined in config (cms.uploadsDir)'); + } - if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.')) + if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.')) { return; + } $uploadsDir = base_path() . $uploadsDir; $totalCount = 0; @@ -92,7 +94,7 @@ class OctoberUtil extends Command * Recursive function to scan the directory for files beginning * with "thumb_" and repeat itself on directories. */ - $purgeFunc = function($targetDir) use (&$purgeFunc, &$totalCount) { + $purgeFunc = function ($targetDir) use (&$purgeFunc, &$totalCount) { if ($files = File::glob($targetDir.'/thumb_*')) { foreach ($files as $file) { $this->info('Purged: '. basename($file)); @@ -110,10 +112,10 @@ class OctoberUtil extends Command $purgeFunc($uploadsDir); - if ($totalCount > 0) + if ($totalCount > 0) { $this->comment(sprintf('Successfully deleted %s thumbs', $totalCount)); - else + } else { $this->comment('No thumbs found to delete'); + } } - -} \ No newline at end of file +} diff --git a/modules/system/console/PluginInstall.php b/modules/system/console/PluginInstall.php index ce59f4f6d..9538d1140 100644 --- a/modules/system/console/PluginInstall.php +++ b/modules/system/console/PluginInstall.php @@ -57,8 +57,9 @@ class PluginInstall extends Command PluginManager::instance()->loadPlugins(); $manager->updatePlugin($code); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } } /** @@ -80,5 +81,4 @@ class PluginInstall extends Command { return []; } - -} \ No newline at end of file +} diff --git a/modules/system/console/PluginRefresh.php b/modules/system/console/PluginRefresh.php index 9f7e2c899..45be43384 100644 --- a/modules/system/console/PluginRefresh.php +++ b/modules/system/console/PluginRefresh.php @@ -42,15 +42,17 @@ class PluginRefresh extends Command $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } $manager->resetNotes(); $this->output->writeln('Reinstalling plugin...'); $manager->updatePlugin($pluginName); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } } /** @@ -72,5 +74,4 @@ class PluginRefresh extends Command { return []; } - -} \ No newline at end of file +} diff --git a/modules/system/console/PluginRemove.php b/modules/system/console/PluginRemove.php index cae780827..fbf95307f 100644 --- a/modules/system/console/PluginRemove.php +++ b/modules/system/console/PluginRemove.php @@ -43,11 +43,13 @@ class PluginRemove extends Command $pluginName = $this->argument('name'); $pluginName = $pluginManager->normalizeIdentifier($pluginName); - if (!$pluginManager->hasPlugin($pluginName)) + if (!$pluginManager->hasPlugin($pluginName)) { return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName)); + } - if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) + if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) { return; + } /* * Rollback plugin @@ -55,8 +57,9 @@ class PluginRemove extends Command $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); - foreach ($manager->getNotes() as $note) + foreach ($manager->getNotes() as $note) { $this->output->writeln($note); + } /* * Delete from file system @@ -95,7 +98,8 @@ class PluginRemove extends Command */ protected function getDefaultConfirmCallback() { - return function() { return true; }; + return function () { + return true; + }; } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/EventLogs.php b/modules/system/controllers/EventLogs.php index 8e30a8e8d..bc50755cd 100644 --- a/modules/system/controllers/EventLogs.php +++ b/modules/system/controllers/EventLogs.php @@ -48,5 +48,4 @@ class EventLogs extends Controller Flash::success(Lang::get('system::lang.event_log.empty_success')); return $this->listRefresh(); } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/MailLayouts.php b/modules/system/controllers/MailLayouts.php index 572f0f43d..17885ce76 100644 --- a/modules/system/controllers/MailLayouts.php +++ b/modules/system/controllers/MailLayouts.php @@ -37,5 +37,4 @@ class MailLayouts extends Controller BackendMenu::setContext('October.System', 'system', 'settings'); SettingsManager::setContext('October.System', 'mail_templates'); } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/MailTemplates.php b/modules/system/controllers/MailTemplates.php index 4b8b5a04f..0ff8d5281 100644 --- a/modules/system/controllers/MailTemplates.php +++ b/modules/system/controllers/MailTemplates.php @@ -45,7 +45,11 @@ class MailTemplates extends Controller public function index() { - /* @todo Remove line if year >= 2015 */ if (!\System\Models\MailLayout::whereCode('default')->count()) { \Eloquent::unguard(); with(new \System\Database\Seeds\SeedSetupMailLayouts)->run(); } + /* @todo Remove lines if year >= 2015 */ + if (!\System\Models\MailLayout::whereCode('default')->count()) { + \Eloquent::unguard(); + with(new \System\Database\Seeds\SeedSetupMailLayouts)->run(); + } MailTemplate::syncAll(); $this->asExtension('ListController')->index(); @@ -67,16 +71,14 @@ class MailTemplates extends Controller 'email' => $user->email, 'name' => $user->full_name, ]; - Mail::send($model->code, [], function($message) use ($vars) { + Mail::send($model->code, [], function ($message) use ($vars) { extract($vars); $message->to($email, $name); }); Flash::success('The test message has been successfully sent.'); - } - catch (Exception $ex) { + } catch (Exception $ex) { Flash::error($ex->getMessage()); } } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/RequestLogs.php b/modules/system/controllers/RequestLogs.php index 6c461e2e5..23b4f4f18 100644 --- a/modules/system/controllers/RequestLogs.php +++ b/modules/system/controllers/RequestLogs.php @@ -48,5 +48,4 @@ class RequestLogs extends Controller Flash::success(Lang::get('system::lang.request_log.empty_success')); return $this->listRefresh(); } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/Settings.php b/modules/system/controllers/Settings.php index 0e5e98601..56777beb4 100644 --- a/modules/system/controllers/Settings.php +++ b/modules/system/controllers/Settings.php @@ -62,8 +62,9 @@ class Settings extends Controller $this->vars['parentLabel'] = Lang::get('system::lang.settings.menu_label'); try { - if (!$item = $this->findSettingItem($author, $plugin, $code)) + if (!$item = $this->findSettingItem($author, $plugin, $code)) { throw new ApplicationException(Lang::get('system::lang.settings.not_found')); + } $this->pageTitle = $item->label; @@ -74,8 +75,7 @@ class Settings extends Controller $model = $this->createModel($item); $this->initWidgets($model); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); } } @@ -111,8 +111,9 @@ class Settings extends Controller */ public function formRender($options = []) { - if (!$this->formWidget) + if (!$this->formWidget) { throw new ApplicationException(Lang::get('backend::lang.form.behavior_not_ready')); + } return $this->formWidget->render($options); } @@ -138,9 +139,9 @@ class Settings extends Controller */ protected function createModel($item) { - if (!isset($item->class) || !strlen($item->class)) + if (!isset($item->class) || !strlen($item->class)) { throw new ApplicationException(Lang::get('system::lang.settings.missing_model')); - + } $class = $item->class; $model = $class::instance(); @@ -166,5 +167,4 @@ class Settings extends Controller return $item; } - -} \ No newline at end of file +} diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index a0996ab9b..6d795a065 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -77,17 +77,21 @@ class Updates extends Controller */ public function listInjectRowClass($record, $definition = null) { - if ($record->disabledByConfig) + if ($record->disabledByConfig) { return 'hidden'; + } - if ($record->orphaned || $record->is_disabled) + if ($record->orphaned || $record->is_disabled) { return 'safe disabled'; + } - if ($definition != 'manage') + if ($definition != 'manage') { return; + } - if ($record->disabledBySystem) + if ($record->disabledBySystem) { return 'negative'; + } return 'positive'; } @@ -100,20 +104,25 @@ class Updates extends Controller /* * Address timeout limits */ - if (!ini_get('safe_mode')) + if (!ini_get('safe_mode')) { set_time_limit(3600); + } $manager = UpdateManager::instance(); $stepCode = post('code'); switch ($stepCode) { case 'downloadCore': - if ($this->disableCoreUpdates) return; + if ($this->disableCoreUpdates) { + return; + } $manager->downloadCore(post('hash')); break; case 'extractCore': - if ($this->disableCoreUpdates) return; + if ($this->disableCoreUpdates) { + return; + } $manager->extractCore(post('hash'), post('build')); break; @@ -170,8 +179,7 @@ class Updates extends Controller $this->vars['hasUpdates'] = array_get($result, 'update', false); $this->vars['pluginList'] = array_get($result, 'plugins', []); $this->vars['themeList'] = array_get($result, 'themes', []); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); } @@ -217,8 +225,7 @@ class Updates extends Controller ]; $this->vars['updateSteps'] = $updateSteps; - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); } @@ -236,10 +243,14 @@ class Updates extends Controller $core = [$coreHash, $coreBuild]; $plugins = post('plugins', []); - if (!is_array($plugins)) $plugins = []; + if (!is_array($plugins)) { + $plugins = []; + } $themes = post('themes', []); - if (!is_array($themes)) $themes = []; + if (!is_array($themes)) { + $themes = []; + } /* * Update steps @@ -255,8 +266,7 @@ class Updates extends Controller ]; $this->vars['updateSteps'] = $updateSteps; - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); } @@ -265,14 +275,17 @@ class Updates extends Controller protected function buildUpdateSteps($core, $plugins, $themes) { - if (!is_array($core)) + if (!is_array($core)) { $core = [null, null]; + } - if (!is_array($plugins)) + if (!is_array($plugins)) { $plugins = []; + } - if (!is_array($themes)) + if (!is_array($themes)) { $themes = []; + } $updateSteps = []; list($coreHash, $coreBuild) = $core; @@ -357,8 +370,9 @@ class Updates extends Controller public function onAttachProject() { try { - if (!$projectId = post('project_id')) + if (!$projectId = post('project_id')) { throw new ApplicationException(Lang::get('system::lang.project.id.missing')); + } $manager = UpdateManager::instance(); $result = $manager->requestProjectDetails($projectId); @@ -370,8 +384,7 @@ class Updates extends Controller ]); return $this->onForceUpdate(); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); return $this->makePartial('project_form'); } @@ -399,14 +412,16 @@ class Updates extends Controller public function onInstallPlugin() { try { - if (!$code = post('code')) + if (!$code = post('code')) { throw new ApplicationException(Lang::get('system::lang.install.missing_plugin_name')); + } $manager = UpdateManager::instance(); $result = $manager->requestPluginDetails($code); - if (!isset($result['code']) || !isset($result['hash'])) + if (!isset($result['code']) || !isset($result['hash'])) { throw new ApplicationException(Lang::get('system::lang.server.response_invalid')); + } $name = $result['code']; $hash = $result['hash']; @@ -428,8 +443,7 @@ class Updates extends Controller $this->vars['updateSteps'] = $updateSteps; return $this->makePartial('execute'); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); return $this->makePartial('plugin_form'); } @@ -444,8 +458,9 @@ class Updates extends Controller if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $objectId) { - if (!$object = PluginVersion::find($objectId)) + if (!$object = PluginVersion::find($objectId)) { continue; + } /* * Rollback plugin @@ -478,8 +493,9 @@ class Updates extends Controller $manager = UpdateManager::instance(); foreach ($checkedIds as $objectId) { - if (!$object = PluginVersion::find($objectId)) + if (!$object = PluginVersion::find($objectId)) { continue; + } /* * Refresh plugin @@ -499,8 +515,7 @@ class Updates extends Controller { try { $this->vars['checked'] = post('checked'); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->handleError($ex); } return $this->makePartial('disable_form'); @@ -514,13 +529,15 @@ class Updates extends Controller $manager = PluginManager::instance(); foreach ($checkedIds as $objectId) { - if (!$object = PluginVersion::find($objectId)) + if (!$object = PluginVersion::find($objectId)) { continue; + } - if ($disable) + if ($disable) { $manager->disablePlugin($object->code, true); - else + } else { $manager->enablePlugin($object->code, true); + } $object->is_disabled = $disable; $object->save(); @@ -528,12 +545,12 @@ class Updates extends Controller } - if ($disable) + if ($disable) { Flash::success(Lang::get('system::lang.plugins.disable_success')); - else + } else { Flash::success(Lang::get('system::lang.plugins.enable_success')); + } return Redirect::to(Backend::url('system/updates/manage')); } - -} \ No newline at end of file +} diff --git a/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php b/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php index f7b92aa43..3daa8efe2 100644 --- a/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php +++ b/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php @@ -8,8 +8,7 @@ class DbDeferredBindings extends Migration public function up() { - Schema::create('deferred_bindings', function(Blueprint $table) - { + Schema::create('deferred_bindings', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('master_type')->index(); @@ -26,5 +25,4 @@ class DbDeferredBindings extends Migration { Schema::dropIfExists('deferred_bindings'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php b/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php index 641fa36c0..35fea40cd 100644 --- a/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php +++ b/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php @@ -8,8 +8,7 @@ class DbSystemFiles extends Migration public function up() { - Schema::create('system_files', function(Blueprint $table) - { + Schema::create('system_files', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('disk_name'); @@ -31,5 +30,4 @@ class DbSystemFiles extends Migration { Schema::dropIfExists('system_files'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php b/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php index 3cfe13e2d..270784081 100644 --- a/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php +++ b/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php @@ -8,8 +8,7 @@ class DbSystemPluginVersions extends Migration public function up() { - Schema::create('system_plugin_versions', function(Blueprint $table) - { + Schema::create('system_plugin_versions', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('code')->index(); @@ -22,5 +21,4 @@ class DbSystemPluginVersions extends Migration { Schema::dropIfExists('system_plugin_versions'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php b/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php index 41f60654e..522e27aa7 100644 --- a/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php +++ b/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php @@ -8,8 +8,7 @@ class DbSystemPluginHistory extends Migration public function up() { - Schema::create('system_plugin_history', function(Blueprint $table) - { + Schema::create('system_plugin_history', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('code')->index(); @@ -24,5 +23,4 @@ class DbSystemPluginHistory extends Migration { Schema::dropIfExists('system_plugin_history'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php b/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php index b370125eb..a61043cf5 100644 --- a/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php +++ b/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php @@ -3,12 +3,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class DbSystemSettings extends Migration +class DbSystemSettings extends Migration { public function up() { - Schema::create('system_settings', function($table) - { + Schema::create('system_settings', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('item')->nullable()->index(); diff --git a/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php b/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php index 89c5520ce..9ba0d1274 100644 --- a/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php +++ b/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php @@ -7,8 +7,7 @@ class DbSystemParameters extends Migration { public function up() { - Schema::create('system_parameters', function($table) - { + Schema::create('system_parameters', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('namespace', 100); diff --git a/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php b/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php index 634e00cd7..d8a9bc784 100644 --- a/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php +++ b/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php @@ -8,18 +8,15 @@ class DbSystemAddDisabledFlag extends Migration public function up() { - Schema::table('system_plugin_versions', function(Blueprint $table) - { + Schema::table('system_plugin_versions', function (Blueprint $table) { $table->boolean('is_disabled')->default(0); }); } public function down() { - Schema::table('system_plugin_versions', function($table) - { + Schema::table('system_plugin_versions', function (Blueprint $table) { $table->dropColumn('is_disabled'); }); } - } diff --git a/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php b/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php index 53fdc6d29..2c455355c 100644 --- a/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php +++ b/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php @@ -8,8 +8,7 @@ class DbSystemMailTemplates extends Migration public function up() { - Schema::create('system_mail_templates', function(Blueprint $table) - { + Schema::create('system_mail_templates', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('code')->nullable(); @@ -27,5 +26,4 @@ class DbSystemMailTemplates extends Migration { Schema::dropIfExists('system_mail_templates'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php b/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php index d8259a029..a6580f4a3 100644 --- a/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php +++ b/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php @@ -8,8 +8,7 @@ class DbSystemMailLayouts extends Migration public function up() { - Schema::create('system_mail_layouts', function(Blueprint $table) - { + Schema::create('system_mail_layouts', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('name')->nullable(); @@ -26,5 +25,4 @@ class DbSystemMailLayouts extends Migration { Schema::dropIfExists('system_mail_layouts'); } - } diff --git a/modules/system/database/migrations/2013_10_01_000010_Db_Cron_Queue.php b/modules/system/database/migrations/2013_10_01_000010_Db_Cron_Queue.php index 33e42b6d7..0720b97e8 100644 --- a/modules/system/database/migrations/2013_10_01_000010_Db_Cron_Queue.php +++ b/modules/system/database/migrations/2013_10_01_000010_Db_Cron_Queue.php @@ -8,8 +8,7 @@ class DbCronQueue extends Migration public function up() { - Schema::create('cron_queue', function(Blueprint $table) - { + Schema::create('cron_queue', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->integer('delay')->default(0); @@ -24,5 +23,4 @@ class DbCronQueue extends Migration { Schema::dropIfExists('cron_queue'); } - } diff --git a/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php b/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php index abebefa58..739a8dd99 100644 --- a/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php +++ b/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php @@ -8,8 +8,7 @@ class DbSystemEventLogs extends Migration public function up() { - Schema::create('system_event_logs', function(Blueprint $table) - { + Schema::create('system_event_logs', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('level')->nullable()->index(); @@ -23,5 +22,4 @@ class DbSystemEventLogs extends Migration { Schema::dropIfExists('system_event_logs'); } - } diff --git a/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php b/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php index 7d31258c3..168f3d1bc 100644 --- a/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php +++ b/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php @@ -8,8 +8,7 @@ class DbSystemRequestLogs extends Migration public function up() { - Schema::create('system_request_logs', function(Blueprint $table) - { + Schema::create('system_request_logs', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->integer('status_code')->nullable(); @@ -24,5 +23,4 @@ class DbSystemRequestLogs extends Migration { Schema::dropIfExists('system_request_logs'); } - } diff --git a/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php b/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php index 66592ac6f..3342db939 100644 --- a/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php +++ b/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php @@ -13,8 +13,7 @@ class DbSystemSessions extends Migration */ public function up() { - Schema::create('sessions', function(Blueprint $table) - { + Schema::create('sessions', function (Blueprint $table) { $table->string('id')->unique(); $table->text('payload')->nullable(); $table->integer('last_activity')->nullable(); @@ -30,5 +29,4 @@ class DbSystemSessions extends Migration { Schema::dropIfExists('sessions'); } - } diff --git a/modules/system/database/seeds/DatabaseSeeder.php b/modules/system/database/seeds/DatabaseSeeder.php index 56fdd7588..f2f924b13 100644 --- a/modules/system/database/seeds/DatabaseSeeder.php +++ b/modules/system/database/seeds/DatabaseSeeder.php @@ -17,5 +17,4 @@ class DatabaseSeeder extends Seeder $this->call('System\Database\Seeds\SeedSetupMailLayouts'); } - -} \ No newline at end of file +} diff --git a/modules/system/database/seeds/SeedSetupMailLayouts.php b/modules/system/database/seeds/SeedSetupMailLayouts.php index 126e6ce2a..020645286 100644 --- a/modules/system/database/seeds/SeedSetupMailLayouts.php +++ b/modules/system/database/seeds/SeedSetupMailLayouts.php @@ -75,5 +75,4 @@ This is an automatic message. Please do not reply to it. 'content_text' => $text, ]); } - -} \ No newline at end of file +} diff --git a/modules/system/lang/de/lang.php b/modules/system/lang/de/lang.php index 16a95f080..31a6446d5 100644 --- a/modules/system/lang/de/lang.php +++ b/modules/system/lang/de/lang.php @@ -139,4 +139,4 @@ return [ 'zip' => [ 'extract_failed' => "Konnte Core-Datei ':file' nicht entpacken.", ], -]; \ No newline at end of file +]; diff --git a/modules/system/lang/de/validation.php b/modules/system/lang/de/validation.php index 894e01caf..838649d6d 100644 --- a/modules/system/lang/de/validation.php +++ b/modules/system/lang/de/validation.php @@ -2,97 +2,97 @@ return array( - /* - |-------------------------------------------------------------------------- - | Validation Language Lines - |-------------------------------------------------------------------------- - | - | The following language lines contain the default error messages used by - | the validator class. Some of these rules have multiple versions such - | such as the size rules. Feel free to tweak each of these messages. - | - */ + /* + |-------------------------------------------------------------------------- + | Validation Language Lines + |-------------------------------------------------------------------------- + | + | The following language lines contain the default error messages used by + | the validator class. Some of these rules have multiple versions such + | such as the size rules. Feel free to tweak each of these messages. + | + */ - "accepted" => ":attribute muss bestätigt werden.", - "active_url" => ":attribute ist keine gültige URL.", - "after" => ":attribute muss ein Datum nach :date sein.", - "alpha" => ":attribute darf nur Buchstaben enthalten.", - "alpha_dash" => ":attribute darf nur Buchstaben, Ziffern und Bindestriche enthalten.", - "alpha_num" => ":attribute darf nur Buchstaben und Ziffern enthalten.", - "array" => ":attribute muss ein Array sein.", - "before" => ":attribute muss ein Datum vor :date sein.", - "between" => array( - "numeric" => ":attribute muss zwischen :min und :max liegen.", - "file" => ":attribute muss zwischen :min und :max kilobytes groß sein.", - "string" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.", - "array" => ":attribute-Elementanzahl muss zwischen :min und :max liegen.", - ), - "confirmed" => "Bestätigung zu :attribute stimmt nicht überein", - "date" => ":attribute ist kein gültiges Datum.", - "date_format" => ":attribute hat kein gültiges Datumsformat :format.", - "different" => ":attribute und :other müssen sich unterscheiden.", - "digits" => "Das :attribute benötigt :digits Zeichen.", - "digits_between" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.", - "email" => "Format von :attribute ist ungültig.", - "exists" => "Das ausgewählte Attribut :attribute ist ungültig.", - "image" => ":attribute muss ein Bild sein.", - "in" => "Das ausgewählte Attribut :attribute ist ungültig.", - "integer" => ":attribute muss eine Ganzzahl (integer) sein.", - "ip" => ":attribute muss eine gültige IP-Adresse sein.", - "max" => array( - "numeric" => ":attribute darf nicht größer als :max sein.", - "file" => ":attribute darf nicht größer als :max kilobytes sein.", - "string" => "Dateiname von :attribute darf nicht mehr als :max Zeichen haben.", - "array" => ":attribute darf nicht mehr als :max Elemente besitzen.", - ), - "mimes" => ":attribute muss eine Datei des Typs: :values sein.", - "min" => array( - "numeric" => ":attribute muss mindestens :min sein.", - "file" => ":attribute darf nicht kleiner als :min kilobytes sein.", - "string" => "Dateiname von :attribute darf nicht weniger als :min Zeichen haben.", - "array" => ":attribute darf nicht weniger als :min Elemente besitzen.", - ), - "not_in" => "Das ausgewählte Attribut :attribute ist ungültig.", - "numeric" => ":attribute muss eine Zahl sein.", - "regex" => "Format von :attribute ist ungültig.", - "required" => ":attribute wird benötigt.", - "required_if" => ":attribute wird benötigt, wenn :other den Wert :value hat.", - "required_with" => ":attribute wird benötigt, wenn :values existiert.", - "required_without" => ":attribute wird benötigt, wenn :values nicht existiert.", - "same" => ":attribute und :other müssen übereinstimmen.", - "size" => array( - "numeric" => ":attribute muss :size groß sein.", - "file" => ":attribute muss :size kilobytes groß sein.", - "string" => "Name von :attribute muss :size Zeichen beinhalten.", - "array" => ":attribute muss :size Elemente beinhalten.", - ), - "unique" => ":attribute muss eindeutig sein.", - "url" => "Format von :attribute ist ungültig.", + "accepted" => ":attribute muss bestätigt werden.", + "active_url" => ":attribute ist keine gültige URL.", + "after" => ":attribute muss ein Datum nach :date sein.", + "alpha" => ":attribute darf nur Buchstaben enthalten.", + "alpha_dash" => ":attribute darf nur Buchstaben, Ziffern und Bindestriche enthalten.", + "alpha_num" => ":attribute darf nur Buchstaben und Ziffern enthalten.", + "array" => ":attribute muss ein Array sein.", + "before" => ":attribute muss ein Datum vor :date sein.", + "between" => array( + "numeric" => ":attribute muss zwischen :min und :max liegen.", + "file" => ":attribute muss zwischen :min und :max kilobytes groß sein.", + "string" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.", + "array" => ":attribute-Elementanzahl muss zwischen :min und :max liegen.", + ), + "confirmed" => "Bestätigung zu :attribute stimmt nicht überein", + "date" => ":attribute ist kein gültiges Datum.", + "date_format" => ":attribute hat kein gültiges Datumsformat :format.", + "different" => ":attribute und :other müssen sich unterscheiden.", + "digits" => "Das :attribute benötigt :digits Zeichen.", + "digits_between" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.", + "email" => "Format von :attribute ist ungültig.", + "exists" => "Das ausgewählte Attribut :attribute ist ungültig.", + "image" => ":attribute muss ein Bild sein.", + "in" => "Das ausgewählte Attribut :attribute ist ungültig.", + "integer" => ":attribute muss eine Ganzzahl (integer) sein.", + "ip" => ":attribute muss eine gültige IP-Adresse sein.", + "max" => array( + "numeric" => ":attribute darf nicht größer als :max sein.", + "file" => ":attribute darf nicht größer als :max kilobytes sein.", + "string" => "Dateiname von :attribute darf nicht mehr als :max Zeichen haben.", + "array" => ":attribute darf nicht mehr als :max Elemente besitzen.", + ), + "mimes" => ":attribute muss eine Datei des Typs: :values sein.", + "min" => array( + "numeric" => ":attribute muss mindestens :min sein.", + "file" => ":attribute darf nicht kleiner als :min kilobytes sein.", + "string" => "Dateiname von :attribute darf nicht weniger als :min Zeichen haben.", + "array" => ":attribute darf nicht weniger als :min Elemente besitzen.", + ), + "not_in" => "Das ausgewählte Attribut :attribute ist ungültig.", + "numeric" => ":attribute muss eine Zahl sein.", + "regex" => "Format von :attribute ist ungültig.", + "required" => ":attribute wird benötigt.", + "required_if" => ":attribute wird benötigt, wenn :other den Wert :value hat.", + "required_with" => ":attribute wird benötigt, wenn :values existiert.", + "required_without" => ":attribute wird benötigt, wenn :values nicht existiert.", + "same" => ":attribute und :other müssen übereinstimmen.", + "size" => array( + "numeric" => ":attribute muss :size groß sein.", + "file" => ":attribute muss :size kilobytes groß sein.", + "string" => "Name von :attribute muss :size Zeichen beinhalten.", + "array" => ":attribute muss :size Elemente beinhalten.", + ), + "unique" => ":attribute muss eindeutig sein.", + "url" => "Format von :attribute ist ungültig.", - /* - |-------------------------------------------------------------------------- - | Custom Validation Language Lines - |-------------------------------------------------------------------------- - | - | Here you may specify custom validation messages for attributes using the - | convention "attribute.rule" to name the lines. This makes it quick to - | specify a specific custom language line for a given attribute rule. - | - */ + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ - 'custom' => array(), + 'custom' => array(), - /* - |-------------------------------------------------------------------------- - | Custom Validation Attributes - |-------------------------------------------------------------------------- - | - | The following language lines are used to swap attribute place-holders - | with something more reader friendly such as E-Mail Address instead - | of "email". This simply helps us make messages a little cleaner. - | - */ + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap attribute place-holders + | with something more reader friendly such as E-Mail Address instead + | of "email". This simply helps us make messages a little cleaner. + | + */ - 'attributes' => array(), + 'attributes' => array(), ); diff --git a/modules/system/lang/es-ar/lang.php b/modules/system/lang/es-ar/lang.php index 9e66b7480..75396e9aa 100644 --- a/modules/system/lang/es-ar/lang.php +++ b/modules/system/lang/es-ar/lang.php @@ -237,4 +237,4 @@ return [ 'manage_other_administrators' => 'Gestionar otros administradores', 'view_the_dashboard' => 'Ver el Tablero' ] -]; \ No newline at end of file +]; diff --git a/modules/system/lang/es-ar/validation.php b/modules/system/lang/es-ar/validation.php index 39db8a462..783396d13 100644 --- a/modules/system/lang/es-ar/validation.php +++ b/modules/system/lang/es-ar/validation.php @@ -95,4 +95,4 @@ return array( 'attributes' => array(), -); \ No newline at end of file +); diff --git a/modules/system/lang/nl/lang.php b/modules/system/lang/nl/lang.php index b66c03f53..1584b2bb8 100644 --- a/modules/system/lang/nl/lang.php +++ b/modules/system/lang/nl/lang.php @@ -237,4 +237,4 @@ return [ 'manage_other_administrators' => 'Beheer mede-beheerders', 'view_the_dashboard' => 'Bekijk het dashboard' ] -]; \ No newline at end of file +]; diff --git a/modules/system/lang/sv/lang.php b/modules/system/lang/sv/lang.php index 0d4b45306..8f79658ec 100644 --- a/modules/system/lang/sv/lang.php +++ b/modules/system/lang/sv/lang.php @@ -139,4 +139,4 @@ return [ 'zip' => [ 'extract_failed' => "Kunde inte packa upp core-fil ':file'.", ], -]; \ No newline at end of file +]; diff --git a/modules/system/lang/tr/validation.php b/modules/system/lang/tr/validation.php index c40becc52..3c9086dae 100644 --- a/modules/system/lang/tr/validation.php +++ b/modules/system/lang/tr/validation.php @@ -105,4 +105,4 @@ return array( 'attributes' => array(), -); \ No newline at end of file +); diff --git a/modules/system/models/EventLog.php b/modules/system/models/EventLog.php index ec37b3fd5..f23cb81a9 100644 --- a/modules/system/models/EventLog.php +++ b/modules/system/models/EventLog.php @@ -35,8 +35,9 @@ class EventLog extends Model $record->message = $message; $record->level = $level; - if ($details !== null) + if ($details !== null) { $record->details = (array) $details; + } $record->save(); @@ -60,10 +61,10 @@ class EventLog extends Model */ public function getSummaryAttribute() { - if (preg_match("/with message '(.+)' in/", $this->message, $match)) + if (preg_match("/with message '(.+)' in/", $this->message, $match)) { return $match[1]; + } return Str::limit($this->message, 100); } - -} \ No newline at end of file +} diff --git a/modules/system/models/File.php b/modules/system/models/File.php index 4bcfe3b22..d6e621bb1 100644 --- a/modules/system/models/File.php +++ b/modules/system/models/File.php @@ -27,10 +27,11 @@ class File extends FileBase public function getStorageDirectory() { $uploadsDir = Config::get('cms.uploadsDir'); - if ($this->isPublic()) + if ($this->isPublic()) { return base_path() . $uploadsDir . '/public/'; - else + } else { return base_path() . $uploadsDir . '/protected/'; + } } /** @@ -39,9 +40,10 @@ class File extends FileBase public function getPublicDirectory() { $uploadsDir = Config::get('cms.uploadsDir'); - if ($this->isPublic()) + if ($this->isPublic()) { return Request::getBasePath() . $uploadsDir . '/public/'; - else + } else { return Request::getBasePath() . $uploadsDir . '/protected/'; + } } } diff --git a/modules/system/models/MailLayout.php b/modules/system/models/MailLayout.php index 9024f5272..99af49b87 100644 --- a/modules/system/models/MailLayout.php +++ b/modules/system/models/MailLayout.php @@ -26,8 +26,8 @@ class MailLayout extends Model public function beforeDelete() { - if ($this->is_locked) + if ($this->is_locked) { throw new ApplicationException('Cannot delete this template because it is locked'); - + } } -} \ No newline at end of file +} diff --git a/modules/system/models/MailSettings.php b/modules/system/models/MailSettings.php index 87cd1203f..ef5c2ef97 100644 --- a/modules/system/models/MailSettings.php +++ b/modules/system/models/MailSettings.php @@ -61,8 +61,7 @@ class MailSettings extends Model if ($settings->smtp_authorization) { $config->set('mail.username', $settings->smtp_user); $config->set('mail.password', $settings->smtp_password); - } - else { + } else { $config->set('mail.username', null); $config->set('mail.password', null); } @@ -78,4 +77,4 @@ class MailSettings extends Model break; } } -} \ No newline at end of file +} diff --git a/modules/system/models/MailTemplate.php b/modules/system/models/MailTemplate.php index 85fd63e56..c5fba664c 100644 --- a/modules/system/models/MailTemplate.php +++ b/modules/system/models/MailTemplate.php @@ -55,18 +55,21 @@ class MailTemplate extends Model * Clean up non-customized templates */ foreach ($dbTemplates as $code => $is_custom) { - if ($is_custom) + if ($is_custom) { continue; + } - if (!array_key_exists($code, $templates)) + if (!array_key_exists($code, $templates)) { self::whereCode($code)->delete(); + } } /* * Create new templates */ - if (count($newTemplates)) + if (count($newTemplates)) { $categories = MailLayout::lists('id', 'code'); + } foreach ($newTemplates as $code => $description) { $sections = self::getTemplateSections($code); @@ -99,13 +102,14 @@ class MailTemplate extends Model public static function addContentToMailer($message, $code, $data) { if (!isset(self::$cache[$code])) { - if (!$template = self::whereCode($code)->first()) + if (!$template = self::whereCode($code)->first()) { return false; + } self::$cache[$code] = $template; - } - else + } else { $template = self::$cache[$code]; + } /* * Get Twig to load from a string @@ -158,8 +162,9 @@ class MailTemplate extends Model $plugins = PluginManager::instance()->getPlugins(); foreach ($plugins as $pluginId => $pluginObj) { $templates = $pluginObj->registerMailTemplates(); - if (!is_array($templates)) + if (!is_array($templates)) { continue; + } $this->registerMailTemplates($templates); } @@ -171,8 +176,9 @@ class MailTemplate extends Model */ public function listRegisteredTemplates() { - if (self::$registeredTemplates === null) + if (self::$registeredTemplates === null) { $this->loadRegisteredTemplates(); + } return self::$registeredTemplates; } @@ -199,9 +205,10 @@ class MailTemplate extends Model */ public function registerMailTemplates(array $definitions) { - if (!static::$registeredTemplates) + if (!static::$registeredTemplates) { static::$registeredTemplates = []; + } static::$registeredTemplates = array_merge(static::$registeredTemplates, $definitions); } -} \ No newline at end of file +} diff --git a/modules/system/models/Parameters.php b/modules/system/models/Parameters.php index eb141eff2..de75ed071 100644 --- a/modules/system/models/Parameters.php +++ b/modules/system/models/Parameters.php @@ -36,12 +36,14 @@ class Parameters extends Model */ public static function get($key, $default = null) { - if (array_key_exists($key, static::$cache)) + if (array_key_exists($key, static::$cache)) { return static::$cache[$key]; + } $record = static::findRecord($key)->first(); - if (!$record) + if (!$record) { return static::$cache[$key] = $default; + } return static::$cache[$key] = $record->value; } @@ -93,5 +95,4 @@ class Parameters extends Model return $query; } - -} \ No newline at end of file +} diff --git a/modules/system/models/PluginVersion.php b/modules/system/models/PluginVersion.php index 073c3419a..b6eb920b8 100644 --- a/modules/system/models/PluginVersion.php +++ b/modules/system/models/PluginVersion.php @@ -56,18 +56,18 @@ class PluginVersion extends Model $this->{$attribute} = Lang::get($info); } - if ($this->is_disabled) + if ($this->is_disabled) { $manager->disablePlugin($this->code, true); - else + } else { $manager->enablePlugin($this->code, true); + } $this->disabledBySystem = $pluginObj->disabled; if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { $this->disabledByConfig = in_array($this->code, $configDisabled); } - } - else { + } else { $this->name = $this->code; $this->description = Lang::get('system::lang.plugins.unknown_plugin'); $this->orphaned = true; @@ -90,5 +90,4 @@ class PluginVersion extends Model ? self::$versionCache[$pluginCode] : null; } - -} \ No newline at end of file +} diff --git a/modules/system/models/RequestLog.php b/modules/system/models/RequestLog.php index ca2859b39..a2cc31b24 100644 --- a/modules/system/models/RequestLog.php +++ b/modules/system/models/RequestLog.php @@ -47,12 +47,10 @@ class RequestLog extends Model if (!$record->exists) { $record->count = 1; $record->save(); - } - else { + } else { $record->increment('count'); } return $record; } - -} \ No newline at end of file +} diff --git a/modules/system/providers.php b/modules/system/providers.php index 4e3b26f89..d4b4eb790 100644 --- a/modules/system/providers.php +++ b/modules/system/providers.php @@ -45,4 +45,4 @@ return [ */ 'Indatus\Dispatcher\ServiceProvider', -]; \ No newline at end of file +]; diff --git a/modules/system/reportwidgets/Status.php b/modules/system/reportwidgets/Status.php index 31f31f0eb..a78065fdd 100644 --- a/modules/system/reportwidgets/Status.php +++ b/modules/system/reportwidgets/Status.php @@ -20,8 +20,7 @@ class Status extends ReportWidgetBase { try { $this->loadData(); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->vars['error'] = $ex->getMessage(); } @@ -46,4 +45,4 @@ class Status extends ReportWidgetBase $manager = UpdateManager::instance(); $this->vars['updates'] = $manager->check(); } -} \ No newline at end of file +} diff --git a/modules/system/routes.php b/modules/system/routes.php index 343340be0..4cf0d0b53 100644 --- a/modules/system/routes.php +++ b/modules/system/routes.php @@ -3,7 +3,7 @@ /* * Register System routes before all user routes. */ -App::before(function($request) { +App::before(function ($request) { /* * Combine JavaScript and StyleSheet assets diff --git a/modules/system/traits/AssetMaker.php b/modules/system/traits/AssetMaker.php index 5d404db44..2fc6b3386 100644 --- a/modules/system/traits/AssetMaker.php +++ b/modules/system/traits/AssetMaker.php @@ -35,22 +35,27 @@ trait AssetMaker */ public function makeAssets($type = null) { - if ($type != null) $type = strtolower($type); + if ($type != null) { + $type = strtolower($type); + } $result = null; $reserved = ['build']; $pathCache = []; - if ($type == null || $type == 'css'){ + if ($type == null || $type == 'css') { foreach ($this->assets['css'] as $asset) { /* * Prevent duplicates */ $path = $this->getAssetEntryBuildPath($asset); - if (isset($pathCache[$path])) continue; + if (isset($pathCache[$path])) { + continue; + } $pathCache[$path] = true; - $attributes = HTML::attributes(array_merge([ + $attributes = HTML::attributes(array_merge( + [ 'rel' => 'stylesheet', 'href' => $path ], @@ -61,17 +66,20 @@ trait AssetMaker } } - if ($type == null || $type == 'rss'){ + if ($type == null || $type == 'rss') { foreach ($this->assets['rss'] as $asset) { /* * Prevent duplicates */ $path = $this->getAssetEntryBuildPath($asset); - if (isset($pathCache[$path])) continue; + if (isset($pathCache[$path])) { + continue; + } $pathCache[$path] = true; - $attributes = HTML::attributes(array_merge([ + $attributes = HTML::attributes(array_merge( + [ 'rel' => 'alternate', 'href' => $path, 'title' => 'RSS', @@ -91,10 +99,13 @@ trait AssetMaker * Prevent duplicates */ $path = $this->getAssetEntryBuildPath($asset); - if (isset($pathCache[$path])) continue; + if (isset($pathCache[$path])) { + continue; + } $pathCache[$path] = true; - $attributes = HTML::attributes(array_merge([ + $attributes = HTML::attributes(array_merge( + [ 'src' => $path ], array_except($asset['attributes'], $reserved) @@ -118,16 +129,19 @@ trait AssetMaker { $jsPath = $this->getAssetPath($name); - if (isset($this->controller)) + if (isset($this->controller)) { $this->controller->addJs($jsPath, $attributes); + } - if (is_string($attributes)) + if (is_string($attributes)) { $attributes = ['build' => $attributes]; + } $jsPath = $this->getAssetScheme($jsPath); - if (!in_array($jsPath, $this->assets['js'])) + if (!in_array($jsPath, $this->assets['js'])) { $this->assets['js'][] = ['path' => $jsPath, 'attributes' => $attributes]; + } } /** @@ -141,16 +155,19 @@ trait AssetMaker { $cssPath = $this->getAssetPath($name); - if (isset($this->controller)) + if (isset($this->controller)) { $this->controller->addCss($cssPath, $attributes); + } - if (is_string($attributes)) + if (is_string($attributes)) { $attributes = ['build' => $attributes]; + } $cssPath = $this->getAssetScheme($cssPath); - if (!in_array($cssPath, $this->assets['css'])) + if (!in_array($cssPath, $this->assets['css'])) { $this->assets['css'][] = ['path' => $cssPath, 'attributes' => $attributes]; + } } /** @@ -164,16 +181,19 @@ trait AssetMaker { $rssPath = $this->getAssetPath($name); - if (isset($this->controller)) + if (isset($this->controller)) { $this->controller->addRss($rssPath, $attributes); + } - if (is_string($attributes)) + if (is_string($attributes)) { $attributes = ['build' => $attributes]; + } $rssPath = $this->getAssetScheme($rssPath); - if (!in_array($rssPath, $this->assets['rss'])) + if (!in_array($rssPath, $this->assets['rss'])) { $this->assets['rss'][] = ['path' => $rssPath, 'attributes' => $attributes]; + } } /** @@ -202,22 +222,27 @@ trait AssetMaker */ public function getAssetPath($fileName, $assetPath = null) { - if (preg_match("/(\/\/|http|https)/", $fileName)) + if (preg_match("/(\/\/|http|https)/", $fileName)) { return $fileName; + } - if (!$assetPath) + if (!$assetPath) { $assetPath = $this->assetPath; + } - if (substr($fileName, 0, 1) == '/' || $assetPath === null) + if (substr($fileName, 0, 1) == '/' || $assetPath === null) { return $fileName; + } - if (!is_array($assetPath)) + if (!is_array($assetPath)) { $assetPath = [$assetPath]; + } foreach ($assetPath as $path) { $_fileName = $path . '/' . $fileName; - if (File::isFile(PATH_BASE . '/' . $_fileName)) + if (File::isFile(PATH_BASE . '/' . $_fileName)) { break; + } } return $_fileName; @@ -243,10 +268,11 @@ trait AssetMaker if (isset($asset['attributes']['build'])) { $build = $asset['attributes']['build']; - if ($build == 'core') + if ($build == 'core') { $build = 'v' . Parameters::get('system::core.build', 1); - elseif ($pluginVersion = PluginVersion::getVersion($build)) + } elseif ($pluginVersion = PluginVersion::getVersion($build)) { $build = 'v' . $pluginVersion; + } $path .= '?' . $build; } @@ -261,13 +287,14 @@ trait AssetMaker */ protected function getAssetScheme($asset) { - if (preg_match("/(\/\/|http|https)/", $asset)) + if (preg_match("/(\/\/|http|https)/", $asset)) { return $asset; + } - if (substr($asset, 0, 1) == '/') + if (substr($asset, 0, 1) == '/') { $asset = Request::getBasePath() . $asset; + } return $asset; } - } diff --git a/modules/system/traits/ConfigMaker.php b/modules/system/traits/ConfigMaker.php index 7c0d40be7..904b4d0d1 100644 --- a/modules/system/traits/ConfigMaker.php +++ b/modules/system/traits/ConfigMaker.php @@ -33,27 +33,28 @@ trait ConfigMaker */ if (is_object($configFile)) { $config = $configFile; - } - /* * Embedded config */ - elseif (is_array($configFile)) { + } elseif (is_array($configFile)) { $config = $this->makeConfigFromArray($configFile); - } - /* * Process config from file contents */ - else { + } else { - if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) + if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) { $configFile = $this->controller->getConfigPath($configFile); - else + } else { $configFile = $this->getConfigPath($configFile); + } - if (!File::isFile($configFile)) - throw new SystemException(Lang::get('system::lang.config.not_found', ['file' => $configFile, 'location' => get_called_class()])); + if (!File::isFile($configFile)) { + throw new SystemException(Lang::get( + 'system::lang.config.not_found', + ['file' => $configFile, 'location' => get_called_class()] + )); + } $config = Yaml::parse(File::get($configFile)); @@ -63,7 +64,9 @@ trait ConfigMaker $publicFile = File::localToPublic($configFile); if ($results = Event::fire('system.extendConfigFile', [$publicFile, $config])) { foreach ($results as $result) { - if (!is_array($result)) continue; + if (!is_array($result)) { + continue; + } $config = array_merge($config, $result); } } @@ -75,8 +78,12 @@ trait ConfigMaker * Validate required configuration */ foreach ($requiredConfig as $property) { - if (!property_exists($config, $property)) - throw new SystemException(Lang::get('system::lang.config.required', ['property' => $property, 'location' => get_called_class()])); + if (!property_exists($config, $property)) { + throw new SystemException(Lang::get( + 'system::lang.config.required', + ['property' => $property, 'location' => get_called_class()] + )); + } } return $config; @@ -92,8 +99,9 @@ trait ConfigMaker { $object = new stdClass(); - if (!is_array($configArray)) + if (!is_array($configArray)) { return $object; + } foreach ($configArray as $name => $value) { $_name = camel_case($name); @@ -113,24 +121,29 @@ trait ConfigMaker */ public function getConfigPath($fileName, $configPath = null) { - if (!isset($this->configPath)) + if (!isset($this->configPath)) { $this->configPath = $this->guessConfigPath(); + } - if (!$configPath) + if (!$configPath) { $configPath = $this->configPath; + } $fileName = File::symbolizePath($fileName, $fileName); - if (File::isLocalPath($fileName) || realpath($fileName) !== false) + if (File::isLocalPath($fileName) || realpath($fileName) !== false) { return $fileName; + } - if (!is_array($configPath)) + if (!is_array($configPath)) { $configPath = [$configPath]; + } foreach ($configPath as $path) { $_fileName = $path . '/' . $fileName; - if (File::isFile($_fileName)) + if (File::isFile($_fileName)) { break; + } } return $_fileName; @@ -160,5 +173,4 @@ trait ConfigMaker $guessedPath = $classFile ? $classFile . '/' . $classFolder . $suffix : null; return $guessedPath; } - -} \ No newline at end of file +} diff --git a/modules/system/traits/PropertyContainer.php b/modules/system/traits/PropertyContainer.php index 6bc0a6fe4..40528e7a4 100644 --- a/modules/system/traits/PropertyContainer.php +++ b/modules/system/traits/PropertyContainer.php @@ -96,4 +96,4 @@ trait PropertyContainer { return []; } -} \ No newline at end of file +} diff --git a/modules/system/traits/ViewMaker.php b/modules/system/traits/ViewMaker.php index c74859d4c..6771a8a33 100644 --- a/modules/system/traits/ViewMaker.php +++ b/modules/system/traits/ViewMaker.php @@ -49,16 +49,18 @@ trait ViewMaker */ public function makePartial($partial, $params = [], $throwException = true) { - if (!File::isPathSymbol($partial) && realpath($partial) === false) + if (!File::isPathSymbol($partial) && realpath($partial) === false) { $partial = '_' . strtolower($partial) . '.htm'; + } $partialPath = $this->getViewPath($partial); if (!File::isFile($partialPath)) { - if ($throwException) + if ($throwException) { throw new SystemException(Lang::get('backend::lang.partial.not_found', ['name' => $partialPath])); - else + } else { return false; + } } return $this->makeFileContents($partialPath, $params); @@ -85,8 +87,9 @@ trait ViewMaker */ public function makeViewContent($contents, $layout = null) { - if ($this->suppressLayout || $this->layout == '') + if ($this->suppressLayout || $this->layout == '') { return $contents; + } // Append any undefined block content to the body block Block::set('undefinedBlock', $contents); @@ -105,16 +108,18 @@ trait ViewMaker public function makeLayout($name = null, $params = [], $throwException = true) { $layout = ($name === null) ? $this->layout : $name; - if ($layout == '') + if ($layout == '') { return; + } $layoutPath = $this->getViewPath($layout . '.htm', $this->layoutPath); if (!File::isFile($layoutPath)) { - if ($throwException) + if ($throwException) { throw new SystemException(Lang::get('cms::lang.layout.not_found', ['name' => $layoutPath])); - else + } else { return false; + } } return $this->makeFileContents($layoutPath, $params); @@ -128,8 +133,9 @@ trait ViewMaker */ public function makeLayoutPartial($partial, $params = []) { - if (!File::isLocalPath($partial) && !File::isPathSymbol($partial)) + if (!File::isLocalPath($partial) && !File::isPathSymbol($partial)) { $partial = '_' . strtolower($partial); + } return $this->makeLayout($partial, $params); } @@ -144,24 +150,29 @@ trait ViewMaker */ public function getViewPath($fileName, $viewPath = null) { - if (!isset($this->viewPath)) + if (!isset($this->viewPath)) { $this->viewPath = $this->guessViewPath(); + } - if (!$viewPath) + if (!$viewPath) { $viewPath = $this->viewPath; + } $fileName = File::symbolizePath($fileName, $fileName); - if (File::isLocalPath($fileName) || realpath($fileName) !== false) + if (File::isLocalPath($fileName) || realpath($fileName) !== false) { return $fileName; + } - if (!is_array($viewPath)) + if (!is_array($viewPath)) { $viewPath = [$viewPath]; + } foreach ($viewPath as $path) { $_fileName = $path . '/' . $fileName; - if (File::isFile($_fileName)) + if (File::isFile($_fileName)) { break; + } } return $_fileName; @@ -176,11 +187,13 @@ trait ViewMaker */ public function makeFileContents($filePath, $extraParams = []) { - if (!strlen($filePath) || !File::isFile($filePath)) + if (!strlen($filePath) || !File::isFile($filePath)) { return; + } - if (!is_array($extraParams)) + if (!is_array($extraParams)) { $extraParams = []; + } $vars = array_merge($this->vars, $extraParams); @@ -216,4 +229,4 @@ trait ViewMaker $guessedPath = $classFile ? $classFile . '/' . $classFolder . $suffix : null; return ($isPublic) ? File::localToPublic($guessedPath) : $guessedPath; } -} \ No newline at end of file +} diff --git a/modules/system/twig/Engine.php b/modules/system/twig/Engine.php index 92f3dcfa0..f776f63a7 100644 --- a/modules/system/twig/Engine.php +++ b/modules/system/twig/Engine.php @@ -29,5 +29,4 @@ class Engine implements EngineInterface $template = $this->environment->loadTemplate($path); return $template->render($vars); } - -} \ No newline at end of file +} diff --git a/modules/system/twig/Extension.php b/modules/system/twig/Extension.php index 22ec306f1..4b59b3ea2 100644 --- a/modules/system/twig/Extension.php +++ b/modules/system/twig/Extension.php @@ -102,5 +102,4 @@ class Extension extends Twig_Extension { return URL::to($url); } - -} \ No newline at end of file +} diff --git a/modules/system/twig/Loader.php b/modules/system/twig/Loader.php index c34733066..73f4302e2 100644 --- a/modules/system/twig/Loader.php +++ b/modules/system/twig/Loader.php @@ -32,15 +32,18 @@ class Loader implements Twig_LoaderInterface { $finder = App::make('view')->getFinder(); - if (isset($this->cache[$name])) + if (isset($this->cache[$name])) { return $this->cache[$name]; + } - if (File::isFile($name)) + if (File::isFile($name)) { return $this->cache[$name] = $name; + } $view = $name; - if (File::extension($view) == $this->extension) + if (File::extension($view) == $this->extension) { $view = substr($view, 0, -strlen($this->extension)); + } $path = $finder->find($view); return $this->cache[$name] = $path; @@ -71,9 +74,8 @@ class Loader implements Twig_LoaderInterface try { $this->findTemplate($name); return true; - } - catch (Exception $exception) { + } catch (Exception $exception) { return false; } } -} \ No newline at end of file +}