From 23f6d75416a1bc620c508adb5a8d93dd03764b7f Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sun, 19 Oct 2014 10:58:18 +1100 Subject: [PATCH] Peer review of #679 --- modules/backend/classes/Controller.php | 4 ++-- modules/backend/classes/FormWidgetBase.php | 2 +- modules/backend/models/BrandSettings.php | 4 +++- modules/backend/widgets/Form.php | 4 ++++ modules/cms/classes/Controller.php | 10 ++++---- modules/cms/widgets/ComponentList.php | 28 ++++++++++++---------- modules/cms/widgets/TemplateList.php | 6 ++--- modules/system/ServiceProvider.php | 6 ++--- modules/system/classes/Controller.php | 6 +++-- 9 files changed, 41 insertions(+), 29 deletions(-) diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index 9ece22a09..b47b940ee 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -456,7 +456,7 @@ class Controller extends Extendable } } else { /* - * Process page specific handler (index_onSomething) { + * Process page specific handler (index_onSomething) */ $pageHandler = $this->action . '_' . $handler; @@ -466,7 +466,7 @@ class Controller extends Extendable } /* - * Process page global handler (onSomething) { + * Process page global handler (onSomething) */ if ($this->methodExists($handler)) { $result = call_user_func_array([$this, $handler], $this->params); diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index 7ffee815b..39cf80d66 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -76,7 +76,7 @@ abstract class FormWidgetBase extends WidgetBase * This step should be removed if year >= 2015. */ if (isset($configuration->options)) { - $configuration = array_merge($configuration->options, (array)$configuration); + $configuration = array_merge($configuration->options, (array) $configuration); } parent::__construct($controller, $configuration); diff --git a/modules/backend/models/BrandSettings.php b/modules/backend/models/BrandSettings.php index 0061c3042..c6dc998f7 100644 --- a/modules/backend/models/BrandSettings.php +++ b/modules/backend/models/BrandSettings.php @@ -85,8 +85,10 @@ class BrandSettings extends Model ]); $parser->parse( - File::get(PATH_BASE.'/modules/backend/models/brandsettings/custom.less').self::get('custom_css') + File::get(PATH_BASE.'/modules/backend/models/brandsettings/custom.less') + . self::get('custom_css') ); + $css = $parser->getCss(); return $css; diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index c9851b21e..bdb6dadca 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -502,15 +502,18 @@ class Form extends WidgetBase * Simple field type */ if (is_string($config)) { + if ($this->isFormWidget($config) !== false) { $field->displayAs('widget', ['widget' => $config]); } else { $field->displayAs($config); } + /* * Defined field type */ } else { + $fieldType = isset($config['type']) ? $config['type'] : null; if (!is_string($fieldType) && !is_null($fieldType)) { throw new ApplicationException(Lang::get( @@ -528,6 +531,7 @@ class Form extends WidgetBase } $field->displayAs($fieldType, $config); + } /* diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index 0c4bca326..a1246fdd1 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -495,10 +495,12 @@ class Controller extends BaseController return Response::make($ex->getMessage(), 500); } - return Response::make( - sprintf('"%s" on line %s of %s', $ex->getMessage(), $ex->getLine(), $ex->getFile()), - 500 - ); + return Response::make(sprintf( + '"%s" on line %s of %s', + $ex->getMessage(), + $ex->getLine(), + $ex->getFile() + ), 500); } } diff --git a/modules/cms/widgets/ComponentList.php b/modules/cms/widgets/ComponentList.php index 20556bf0c..9124a286e 100644 --- a/modules/cms/widgets/ComponentList.php +++ b/modules/cms/widgets/ComponentList.php @@ -92,15 +92,19 @@ class ComponentList extends WidgetBase } $pluginDetails = $plugin->pluginDetails(); - $pluginName = isset($pluginDetails['name']) ? - $pluginDetails['name'] : - Lang::get('system::lang.plugin.unnamed'); - $pluginIcon = isset($pluginDetails['icon']) ? - $pluginDetails['icon'] : - 'icon-puzzle-piece'; - $pluginDescription = isset($pluginDetails['description']) ? - $pluginDetails['description'] : - null; + + $pluginName = isset($pluginDetails['name']) + ? $pluginDetails['name'] + : Lang::get('system::lang.plugin.unnamed'); + + $pluginIcon = isset($pluginDetails['icon']) + ? $pluginDetails['icon'] + : 'icon-puzzle-piece'; + + $pluginDescription = isset($pluginDetails['description']) + ? $pluginDetails['description'] + : null; + $pluginClass = get_class($plugin); $pluginItems = []; @@ -120,9 +124,9 @@ class ComponentList extends WidgetBase 'className' => get_class($component), 'pluginIcon' => $pluginIcon, 'alias' => $alias, - 'name' => $componentInfo->duplicateAlias ? - $componentInfo->className : - $componentInfo->alias + 'name' => $componentInfo->duplicateAlias + ? $componentInfo->className + : $componentInfo->alias ]; if ($searchWords && !$this->itemMatchesSearch($searchWords, $item)) { diff --git a/modules/cms/widgets/TemplateList.php b/modules/cms/widgets/TemplateList.php index 453b660da..d218a1dc9 100644 --- a/modules/cms/widgets/TemplateList.php +++ b/modules/cms/widgets/TemplateList.php @@ -283,10 +283,8 @@ class TemplateList extends WidgetBase if (Str::contains(Str::lower($item->title), $word)) { return true; } - } else { - if (Str::contains(Str::lower($item->fileName), $word)) { - return true; - } + } elseif (Str::contains(Str::lower($item->fileName), $word)) { + return true; } if (Str::contains(Str::lower($item->description), $word) && strlen($item->description)) { diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index a90a90fa7..7b205999b 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -202,15 +202,15 @@ class ServiceProvider extends ModuleServiceProvider */ BackendAuth::registerCallback(function ($manager) { $manager->registerPermissions('October.System', [ - 'system.manage_settings' => [ + 'system.manage_settings' => [ 'label' => 'system::lang.permissions.manage_system_settings', 'tab' => 'System' ], - 'system.manage_updates' => [ + 'system.manage_updates' => [ 'label' => 'system::lang.permissions.manage_software_updates', 'tab' => 'System' ], - 'system.manage_mail_templates' => [ + 'system.manage_mail_templates' => [ 'label' => 'system::lang.permissions.manage_mail_templates', 'tab' => 'System' ], diff --git a/modules/system/classes/Controller.php b/modules/system/classes/Controller.php index bbd5d756a..f632eccac 100644 --- a/modules/system/classes/Controller.php +++ b/modules/system/classes/Controller.php @@ -22,15 +22,17 @@ 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().' */'; }