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. 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 */ 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/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index d6982bf95..698a4ec59 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,18 @@ 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 +134,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 +157,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 +173,21 @@ 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 +516,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 * 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
'.$caption.''; + $output[] = ''; + $output[] = $caption; + + if ($subcaption) { + $output[] = '
'.$subcaption.'
'; + } + + $output[] = ''; $output[] = '