From f869c7d26817f980616d5fc202133338b322efa8 Mon Sep 17 00:00:00 2001 From: flynsarmy Date: Thu, 23 Oct 2014 20:32:55 +1000 Subject: [PATCH 1/6] Make dump show object type --- modules/cms/twig/DebugExtension.php | 50 ++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index d6982bf95..fcfb6731b 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -12,6 +12,7 @@ use October\Rain\Database\Model; class DebugExtension extends Twig_Extension { const PAGE_CAPTION = 'Page variables'; + const ARRAY_CAPTION = 'Array variables'; const OBJECT_CAPTION = 'Object variables'; const COMPONENT_CAPTION = 'Component variables'; @@ -100,11 +101,20 @@ class DebugExtension extends Twig_Extension $this->variablePrefix = false; for ($i = 2; $i < $count; $i++) { $var = func_get_arg($i); - $caption = $var instanceof ComponentBase - ? static::COMPONENT_CAPTION - : static::OBJECT_CAPTION; + $subcaption = null; - $result .= $this->dump($var, $caption); + if ( $var instanceof ComponentBase ) + $caption = static::COMPONENT_CAPTION; + elseif ( is_array($var) ) + $caption = static::ARRAY_CAPTION; + else + { + $caption = static::OBJECT_CAPTION; + $subcaption = get_class($var); + } + + + $result .= $this->dump($var, $caption, $subcaption); } } @@ -126,9 +136,10 @@ class DebugExtension extends Twig_Extension * * @param mixed $variable Variable to dump * @param string $caption Caption of the dump + * @param string $subcaption Subcaption of the dump * @return void */ - public function dump($variables = null, $caption = null) + public function dump($variables = null, $caption = null, $subcaption = null) { $this->commentMap = []; $this->zebra = 1; @@ -148,7 +159,7 @@ class DebugExtension extends Twig_Extension $output[] = ''; if ($caption) { - $output[] = $this->makeTableHeader($caption); + $output[] = $this->makeTableHeader($caption, $subcaption); } foreach ($variables as $key => $item) { @@ -164,13 +175,18 @@ class DebugExtension extends Twig_Extension /** * Builds the HTML used for the table header. * @param string $caption + * @param string $subcaption * @return string */ - protected function makeTableHeader($caption) + protected function makeTableHeader($caption, $subcaption = null) { $output = []; $output[] = ''; - $output[] = ''; return implode(PHP_EOL, $output); } @@ -499,6 +515,24 @@ class DebugExtension extends Twig_Extension ]); } + /** + * Get the CSS string for the output subheader + * + * @return string + */ + protected function getSubheaderCss() + { + return $this->arrayToCss([ + 'font-size' => '12px', + 'font-weight' => 'normal', + 'font-style' => 'italic', + 'margin' => '0', + 'padding' => '0', + 'background-color' => '#7B8892', + 'color' => '#FFF', + ]); + } + /** * Convert a key/value pair array into a CSS string * From 3a936f6b4e442480de93891a5cf52fb59698e9e6 Mon Sep 17 00:00:00 2001 From: Reizinixc Date: Fri, 24 Oct 2014 07:32:51 +0700 Subject: [PATCH 2/6] Fix typo in app/config/cms.php Sepcific -> Specific --- app/config/cms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/cms.php b/app/config/cms.php index 4d0138734..088b9de3d 100644 --- a/app/config/cms.php +++ b/app/config/cms.php @@ -26,7 +26,7 @@ return array( /* |-------------------------------------------------------------------------- - | Sepcific plugins to disable + | Specific plugins to disable |-------------------------------------------------------------------------- | | Specify plugin codes which will always be disabled in the application. From a8daa5b4a72d16c7347b7d64909722d7c8a91247 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 24 Oct 2014 17:38:24 +1100 Subject: [PATCH 3/6] Fixes the system settings icon --- modules/backend/controllers/Index.php | 3 +-- modules/system/ServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/backend/controllers/Index.php b/modules/backend/controllers/Index.php index 06d392dc6..fcb66108f 100644 --- a/modules/backend/controllers/Index.php +++ b/modules/backend/controllers/Index.php @@ -3,7 +3,6 @@ use BackendMenu; use Backend\Classes\Controller; use Backend\Widgets\ReportContainer; -use Backend\Traits\InspectableContainer; /** * Dashboard controller @@ -14,7 +13,7 @@ use Backend\Traits\InspectableContainer; */ class Index extends Controller { - use InspectableContainer; + use \Backend\Traits\InspectableContainer; public $requiredPermissions = ['backend.access_dashboard']; diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 1ef3a3ea7..85f38db1b 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -179,7 +179,7 @@ class ServiceProvider extends ModuleServiceProvider $manager->registerMenuItems('October.System', [ 'system' => [ 'label' => 'system::lang.settings.menu_label', - 'icon' => 'icon-tune', + 'icon' => 'icon-cog', 'url' => Backend::url('system/settings'), 'permissions' => ['backend.manage_users', 'system.*'], 'order' => 1000 From 49982b51edc501f4ad66a2ea62e855cb5df955db Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 24 Oct 2014 17:45:11 +1100 Subject: [PATCH 4/6] Clean up code, add listExtendColumns override --- modules/backend/behaviors/ListController.php | 84 ++++++++++++-------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 67ac8d2e5..1cba33666 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -117,42 +117,38 @@ class ListController extends ControllerBehavior $columnConfig = $this->makeConfig($listConfig->list); $columnConfig->model = $model; $columnConfig->alias = $definition; - if (isset($listConfig->recordUrl)) { - $columnConfig->recordUrl = $listConfig->recordUrl; - } - if (isset($listConfig->recordOnClick)) { - $columnConfig->recordOnClick = $listConfig->recordOnClick; - } - if (isset($listConfig->recordsPerPage)) { - $columnConfig->recordsPerPage = $listConfig->recordsPerPage; - } - if (isset($listConfig->noRecordsMessage)) { - $columnConfig->noRecordsMessage = $listConfig->noRecordsMessage; - } - if (isset($listConfig->defaultSort)) { - $columnConfig->defaultSort = $listConfig->defaultSort; - } - if (isset($listConfig->showSorting)) { - $columnConfig->showSorting = $listConfig->showSorting; - } - if (isset($listConfig->showSetup)) { - $columnConfig->showSetup = $listConfig->showSetup; - } - if (isset($listConfig->showCheckboxes)) { - $columnConfig->showCheckboxes = $listConfig->showCheckboxes; - } - if (isset($listConfig->showTree)) { - $columnConfig->showTree = $listConfig->showTree; - } - if (isset($listConfig->treeExpanded)) { - $columnConfig->treeExpanded = $listConfig->treeExpanded; - } - $widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig); - $widget->bindToController(); /* - * Extensibility helpers + * Prepare the columns configuration */ + $configFieldsToTransfer = [ + 'recordUrl', + 'recordOnClick', + 'recordsPerPage', + 'noRecordsMessage', + 'defaultSort', + 'showSorting', + 'showSetup', + 'showCheckboxes', + 'showTree', + 'treeExpanded', + ]; + + foreach ($configFieldsToTransfer as $field) { + if (isset($listConfig->{$field})) { + $columnConfig->{$field} = $listConfig->{$field}; + } + } + + /* + * List Widget with extensibility + */ + $widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig); + + $widget->bindEvent('list.extendColumns', function () use ($widget) { + $this->controller->listExtendColumns($widget); + }); + $widget->bindEvent('list.extendQueryBefore', function ($query) use ($definition) { $this->controller->listExtendQueryBefore($query, $definition); }); @@ -173,6 +169,8 @@ class ListController extends ControllerBehavior return $this->controller->listOverrideHeaderValue($column->columnName, $definition); }); + $widget->bindToController(); + /* * Prepare the toolbar widget (optional) */ @@ -306,6 +304,24 @@ class ListController extends ControllerBehavior // Overrides // + /** + * Called before the list columns are defined. + * @param Backend\Widgets\List $host The hosting list widget + * @return void + */ + // public function listExtendColumnsBefore($host) + // { + // } + + /** + * Called after the list columns are defined. + * @param Backend\Widgets\List $host The hosting list widget + * @return void + */ + public function listExtendColumns($host) + { + } + /** * Controller override: Extend supplied model * @param Model $model @@ -366,7 +382,7 @@ class ListController extends ControllerBehavior } /** - * Static helper for extending form fields. + * Static helper for extending list columns. * @param callable $callback * @return void */ From 38f8aab27c110337e4bd8dbd5d3a6897d99efb6b Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 24 Oct 2014 19:00:44 +1100 Subject: [PATCH 5/6] Comply PSR --- modules/cms/twig/DebugExtension.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index fcfb6731b..f12d5e337 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -103,17 +103,17 @@ class DebugExtension extends Twig_Extension $var = func_get_arg($i); $subcaption = null; - if ( $var instanceof ComponentBase ) + if ($var instanceof ComponentBase) { $caption = static::COMPONENT_CAPTION; - elseif ( is_array($var) ) + } + elseif (is_array($var)) { $caption = static::ARRAY_CAPTION; - else - { + } + else { $caption = static::OBJECT_CAPTION; $subcaption = get_class($var); } - $result .= $this->dump($var, $caption, $subcaption); } } @@ -184,8 +184,11 @@ class DebugExtension extends Twig_Extension $output[] = ''; $output[] = ''; return implode(PHP_EOL, $output); From 688d8c95defe73cc8afc60fecbe01e24743111f8 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 24 Oct 2014 19:01:30 +1100 Subject: [PATCH 6/6] Comply PSR --- modules/cms/twig/DebugExtension.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index f12d5e337..698a4ec59 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -105,11 +105,9 @@ class DebugExtension extends Twig_Extension if ($var instanceof ComponentBase) { $caption = static::COMPONENT_CAPTION; - } - elseif (is_array($var)) { + } elseif (is_array($var)) { $caption = static::ARRAY_CAPTION; - } - else { + } else { $caption = static::OBJECT_CAPTION; $subcaption = get_class($var); }
'.$caption.''; + $output[] = ''; + $output[] = $caption; + if ($subcaption) + $output[] = '
'.$subcaption.'
'; + $output[] = ''; $output[] = '
'; $output[] = $caption; - if ($subcaption) + + if ($subcaption) { $output[] = '
'.$subcaption.'
'; + } + $output[] = ''; $output[] = '