From 069f31dbff6a8f772b5763946bb45b96bb323d70 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 10:42:36 +0000 Subject: [PATCH 01/49] Added support for pre/post appending view paths --- modules/system/traits/ViewMaker.php | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/system/traits/ViewMaker.php b/modules/system/traits/ViewMaker.php index 8407e4e033..627e780dd9 100644 --- a/modules/system/traits/ViewMaker.php +++ b/modules/system/traits/ViewMaker.php @@ -43,8 +43,11 @@ trait ViewMaker /** * Prepends a path on the available view path locations. + * + * @param array|string $path + * @return void */ - public function addViewPath(string|array $path): void + public function prependViewPath(array|string $path): void { $this->viewPath = (array) $this->viewPath; @@ -55,6 +58,33 @@ public function addViewPath(string|array $path): void } } + /** + * Append a path on the available view path locations. + * + * @param array|string $path + * @return void + */ + public function appendViewPath(array|string $path): void + { + $this->viewPath = (array) $this->viewPath; + + if (is_array($path)) { + $this->viewPath = array_merge($this->viewPath, $path); + } else { + $this->viewPath[] = $path; + } + } + + /** + * Prepends a path on the available view path locations. + * + * @deprecated Use prependViewPath() + */ + public function addViewPath(string|array $path): void + { + $this->prependViewPath($path); + } + /** * Returns the active view path locations. */ From f3706b8122e3d9fd976edfb827fecdbf430e3216 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 10:43:21 +0000 Subject: [PATCH 02/49] Added default view files for forms and lists behaviours --- modules/backend/behaviors/FormController.php | 5 ++ modules/backend/behaviors/ListController.php | 5 ++ .../behaviors/formcontroller/create.php | 53 ++++++++++++++++ .../behaviors/formcontroller/preview.php | 24 ++++++++ .../behaviors/formcontroller/update.php | 61 +++++++++++++++++++ .../listcontroller/_list_toolbar.php | 26 ++++++++ .../behaviors/listcontroller/index.php | 1 + 7 files changed, 175 insertions(+) create mode 100644 modules/backend/behaviors/formcontroller/create.php create mode 100644 modules/backend/behaviors/formcontroller/preview.php create mode 100644 modules/backend/behaviors/formcontroller/update.php create mode 100644 modules/backend/behaviors/listcontroller/_list_toolbar.php create mode 100644 modules/backend/behaviors/listcontroller/index.php diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index ae58bb475f..11fc7d70ac 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -106,6 +106,11 @@ public function __construct($controller) */ $this->config = $this->makeConfig($controller->formConfig ?: $this->formConfig, $this->requiredConfig); $this->config->modelClass = Str::normalizeClassName($this->config->modelClass); + + /* + * Set default view path + */ + $this->controller->appendViewPath($this->guessViewPath()); } /** diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index d9b25f712a..d060e94b37 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -93,6 +93,11 @@ public function __construct($controller) * Build configuration */ $this->setConfig($this->listDefinitions[$this->primaryDefinition], $this->requiredConfig); + + /* + * Set default view path + */ + $this->controller->appendViewPath($this->guessViewPath()); } /** diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/create.php new file mode 100644 index 0000000000..e3835510c5 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create.php @@ -0,0 +1,53 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController->getConfig(); +?> + + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + or + +
+
+ + + + + +

fatalError) ?>

+

+ + diff --git a/modules/backend/behaviors/formcontroller/preview.php b/modules/backend/behaviors/formcontroller/preview.php new file mode 100644 index 0000000000..da239d591f --- /dev/null +++ b/modules/backend/behaviors/formcontroller/preview.php @@ -0,0 +1,24 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController->getConfig(); +?> + + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + + +

fatalError) ?>

+

+ + diff --git a/modules/backend/behaviors/formcontroller/update.php b/modules/backend/behaviors/formcontroller/update.php new file mode 100644 index 0000000000..3773eb8f4b --- /dev/null +++ b/modules/backend/behaviors/formcontroller/update.php @@ -0,0 +1,61 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController->getConfig(); +?> + + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + or + +
+
+ + + + + +

fatalError) ?>

+

+ + diff --git a/modules/backend/behaviors/listcontroller/_list_toolbar.php b/modules/backend/behaviors/listcontroller/_list_toolbar.php new file mode 100644 index 0000000000..453354c11d --- /dev/null +++ b/modules/backend/behaviors/listcontroller/_list_toolbar.php @@ -0,0 +1,26 @@ +getClassExtension(\Backend\Behaviors\ListController::class); +$listConfig = $listController->getConfig(); +?> + +
+ + trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?> + + + +
diff --git a/modules/backend/behaviors/listcontroller/index.php b/modules/backend/behaviors/listcontroller/index.php new file mode 100644 index 0000000000..ea43a3636c --- /dev/null +++ b/modules/backend/behaviors/listcontroller/index.php @@ -0,0 +1 @@ +listRender() ?> From 67ef0eb9bc263bedd2b59ab6ce48c5a93f39afab Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 10:49:41 +0000 Subject: [PATCH 03/49] Added --stubs option to create controller command --- modules/backend/console/CreateController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/backend/console/CreateController.php b/modules/backend/console/CreateController.php index 1528815323..5a40960fbd 100644 --- a/modules/backend/console/CreateController.php +++ b/modules/backend/console/CreateController.php @@ -20,6 +20,7 @@ class CreateController extends BaseScaffoldCommand protected $signature = 'create:controller {plugin : The name of the plugin. (eg: Winter.Blog)} {controller : The name of the controller to generate. (eg: Posts)} + {--stubs : Create view files for local overwrites.} {--force : Overwrite existing files with generated files.} {--model= : Defines the model name to use. If not provided, the singular name of the controller is used.} {--sidebar : Create stubs for form-with-sidebar layout} @@ -45,10 +46,8 @@ class CreateController extends BaseScaffoldCommand * @var array A mapping of stub to generated file. */ protected $stubs = [ - 'scaffold/controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.php', 'scaffold/controller/config_form.stub' => 'controllers/{{lower_name}}/config_form.yaml', 'scaffold/controller/config_list.stub' => 'controllers/{{lower_name}}/config_list.yaml', - 'scaffold/controller/index.stub' => 'controllers/{{lower_name}}/index.php', 'scaffold/controller/controller.stub' => 'controllers/{{studly_name}}.php', ]; @@ -69,11 +68,16 @@ protected function prepareVars(): array $vars['model'] = $model; $vars['sidebar'] = $this->option('sidebar'); - $layout = $this->option('sidebar') ? 'sidebar' : 'standard'; + if ($this->option('stubs')) { + $this->stubs['scaffold/controller/index.stub'] = 'controllers/{{lower_name}}/index.php'; + $this->stubs['scaffold/controller/_list_toolbar.stub'] = 'controllers/{{lower_name}}/_list_toolbar.php'; - $this->stubs["scaffold/controller/{$layout}/create.stub"] = 'controllers/{{lower_name}}/create.php'; - $this->stubs["scaffold/controller/{$layout}/update.stub"] = 'controllers/{{lower_name}}/update.php'; - $this->stubs["scaffold/controller/{$layout}/preview.stub"] = 'controllers/{{lower_name}}/preview.php'; + $layout = $this->option('sidebar') ? 'sidebar' : 'standard'; + + $this->stubs["scaffold/controller/{$layout}/create.stub"] = 'controllers/{{lower_name}}/create.php'; + $this->stubs["scaffold/controller/{$layout}/update.stub"] = 'controllers/{{lower_name}}/update.php'; + $this->stubs["scaffold/controller/{$layout}/preview.stub"] = 'controllers/{{lower_name}}/preview.php'; + } return $vars; } From 22d04efa4424ddec8cc2c2f80fde209442d8be93 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 10:53:34 +0000 Subject: [PATCH 04/49] Added code styling fixes --- modules/backend/behaviors/formcontroller/create.php | 6 ------ modules/backend/behaviors/formcontroller/preview.php | 4 ---- modules/backend/behaviors/formcontroller/update.php | 6 ------ 3 files changed, 16 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/create.php index e3835510c5..ce9c7ee7cc 100644 --- a/modules/backend/behaviors/formcontroller/create.php +++ b/modules/backend/behaviors/formcontroller/create.php @@ -11,9 +11,7 @@ fatalError): ?> - 'layout']) ?> -
formRender() ?>
@@ -42,12 +40,8 @@ class="btn btn-default"> - - -

fatalError) ?>

- diff --git a/modules/backend/behaviors/formcontroller/preview.php b/modules/backend/behaviors/formcontroller/preview.php index da239d591f..467b1f1528 100644 --- a/modules/backend/behaviors/formcontroller/preview.php +++ b/modules/backend/behaviors/formcontroller/preview.php @@ -11,14 +11,10 @@ fatalError): ?> -
formRenderPreview() ?>
- -

fatalError) ?>

- diff --git a/modules/backend/behaviors/formcontroller/update.php b/modules/backend/behaviors/formcontroller/update.php index 3773eb8f4b..5422391e92 100644 --- a/modules/backend/behaviors/formcontroller/update.php +++ b/modules/backend/behaviors/formcontroller/update.php @@ -11,9 +11,7 @@ fatalError): ?> - 'layout']) ?> -
formRender() ?>
@@ -50,12 +48,8 @@ class="wn-icon-trash-o btn-icon danger pull-right" - - -

fatalError) ?>

- From 3feecb6221a1539f0b171993fd94d80928315f0f Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 12:29:46 +0000 Subject: [PATCH 05/49] Added fix for hardcoded link --- modules/backend/behaviors/formcontroller/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/create.php index ce9c7ee7cc..5ef97d45fb 100644 --- a/modules/backend/behaviors/formcontroller/create.php +++ b/modules/backend/behaviors/formcontroller/create.php @@ -36,7 +36,7 @@ class="btn btn-default"> - or + or From 8b65ce09b4d59daa6154cfc1d6ee79800e806e9f Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Mon, 17 Feb 2025 07:40:43 -0600 Subject: [PATCH 06/49] Update modules/backend/behaviors/listcontroller/_list_toolbar.php Co-authored-by: Marc Jauvin --- modules/backend/behaviors/listcontroller/_list_toolbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/behaviors/listcontroller/_list_toolbar.php b/modules/backend/behaviors/listcontroller/_list_toolbar.php index 453354c11d..5ba126ef63 100644 --- a/modules/backend/behaviors/listcontroller/_list_toolbar.php +++ b/modules/backend/behaviors/listcontroller/_list_toolbar.php @@ -5,7 +5,7 @@
trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?> From 41f1fb538f8817b18dec37be96da1776744ecf5b Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 17 Feb 2025 15:01:47 +0000 Subject: [PATCH 07/49] Added support for default reorder views --- modules/backend/behaviors/ReorderController.php | 5 +++++ .../reordercontroller/_reorder_toolbar.php | 11 +++++++++++ .../backend/behaviors/reordercontroller/reorder.php | 13 +++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 modules/backend/behaviors/reordercontroller/_reorder_toolbar.php create mode 100644 modules/backend/behaviors/reordercontroller/reorder.php diff --git a/modules/backend/behaviors/ReorderController.php b/modules/backend/behaviors/ReorderController.php index 20cd3460ff..7d13386e11 100644 --- a/modules/backend/behaviors/ReorderController.php +++ b/modules/backend/behaviors/ReorderController.php @@ -91,6 +91,11 @@ public function __construct($controller) * Populate from config */ $this->nameFrom = $this->getConfig('nameFrom', $this->nameFrom); + + /* + * Set default view path + */ + $this->controller->appendViewPath($this->guessViewPath()); } // diff --git a/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php b/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php new file mode 100644 index 0000000000..9985cdc82b --- /dev/null +++ b/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php @@ -0,0 +1,11 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController?->getConfig(); +?> + +
+ + + +
+ diff --git a/modules/backend/behaviors/reordercontroller/reorder.php b/modules/backend/behaviors/reordercontroller/reorder.php new file mode 100644 index 0000000000..8c0b9e4233 --- /dev/null +++ b/modules/backend/behaviors/reordercontroller/reorder.php @@ -0,0 +1,13 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController?->getConfig(); +?> + + + + + +reorderRender() ?> From 8f216a2a186d47d5513285e99e6f5926692d638e Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:13:00 +0000 Subject: [PATCH 08/49] Added support for import export behaviour defaults --- .../behaviors/ImportExportController.php | 5 ++ .../behaviors/formcontroller/create.php | 47 ------------------- 2 files changed, 5 insertions(+), 47 deletions(-) delete mode 100644 modules/backend/behaviors/formcontroller/create.php diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 057a0758a3..5974897414 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -138,6 +138,11 @@ public function __construct($controller) if ($this->exportOptionsFormWidget = $this->makeExportOptionsFormWidget()) { $this->exportOptionsFormWidget->bindToController(); } + + /* + * Set default view path + */ + $this->controller->appendViewPath($this->guessViewPath()); } // diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/create.php deleted file mode 100644 index 5ef97d45fb..0000000000 --- a/modules/backend/behaviors/formcontroller/create.php +++ /dev/null @@ -1,47 +0,0 @@ -getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController->getConfig(); -?> - - - - - -fatalError): ?> - 'layout']) ?> -
- formRender() ?> -
- -
-
- - - - or - -
-
- - -

fatalError) ?>

-

- From fe85e22c54011753e104e9453fa59e95d20151d4 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:13:17 +0000 Subject: [PATCH 09/49] Added default value for bodyClass --- modules/backend/classes/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index bb413249fe..53d70038d4 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -95,7 +95,7 @@ class Controller extends ControllerBase /** * @var string Body class property used for customising the layout on a controller basis. */ - public $bodyClass; + public $bodyClass = ''; /** * @var array Default methods which cannot be called as actions. From b77d2839957d1cb1e88bf30da5ff5bcacc4ca8ef Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:13:55 +0000 Subject: [PATCH 10/49] Added self generating breadcrumb partial --- modules/backend/layouts/_breadcrumb.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 modules/backend/layouts/_breadcrumb.php diff --git a/modules/backend/layouts/_breadcrumb.php b/modules/backend/layouts/_breadcrumb.php new file mode 100644 index 0000000000..e5f7b64313 --- /dev/null +++ b/modules/backend/layouts/_breadcrumb.php @@ -0,0 +1,14 @@ +sideMenu[$context->sideMenuCode ?? null] ?? null; +?> + + + From b0bbed0fbbf7fde0da143f868568cf816511f33d Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:14:24 +0000 Subject: [PATCH 11/49] Added default partials for behaviours --- .../behaviors/formcontroller/create.php | 27 +++++++ .../formcontroller/create/_fancy.php | 14 ++++ .../formcontroller/create/_sidebar.php | 61 ++++++++++++++++ .../formcontroller/create/_standard.php | 39 +++++++++++ .../formcontroller/create/fancy/_toolbar.php | 11 +++ .../behaviors/formcontroller/preview.php | 37 ++++++---- .../formcontroller/preview/_fancy.php | 14 ++++ .../formcontroller/preview/_sidebar.php | 61 ++++++++++++++++ .../formcontroller/preview/_standard.php | 12 ++++ .../formcontroller/preview/fancy/_toolbar.php | 1 + .../behaviors/formcontroller/update.php | 70 ++++++------------- .../formcontroller/update/_fancy.php | 14 ++++ .../formcontroller/update/_sidebar.php | 61 ++++++++++++++++ .../formcontroller/update/_standard.php | 50 +++++++++++++ .../formcontroller/update/fancy/_toolbar.php | 18 +++++ .../importexportcontroller/export.php | 24 +++++++ .../importexportcontroller/import.php | 24 +++++++ 17 files changed, 474 insertions(+), 64 deletions(-) create mode 100644 modules/backend/behaviors/formcontroller/create.php create mode 100644 modules/backend/behaviors/formcontroller/create/_fancy.php create mode 100644 modules/backend/behaviors/formcontroller/create/_sidebar.php create mode 100644 modules/backend/behaviors/formcontroller/create/_standard.php create mode 100644 modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php create mode 100644 modules/backend/behaviors/formcontroller/preview/_fancy.php create mode 100644 modules/backend/behaviors/formcontroller/preview/_sidebar.php create mode 100644 modules/backend/behaviors/formcontroller/preview/_standard.php create mode 100644 modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php create mode 100644 modules/backend/behaviors/formcontroller/update/_fancy.php create mode 100644 modules/backend/behaviors/formcontroller/update/_sidebar.php create mode 100644 modules/backend/behaviors/formcontroller/update/_standard.php create mode 100644 modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php create mode 100644 modules/backend/behaviors/importexportcontroller/export.php create mode 100644 modules/backend/behaviors/importexportcontroller/import.php diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/create.php new file mode 100644 index 0000000000..308d711d6b --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create.php @@ -0,0 +1,27 @@ +getClassExtension(\Backend\Behaviors\FormController::class); +$formConfig = $formController->getConfig(); + +// Decide which layout we should be rendering +$layout = $this->formLayout ?? $formConfig->formLayout ?? null; +if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { + $layout = 'standard'; +} + +// If required, set the appropriate body classes +$this->bodyClass = match ($layout) { + 'fancy' => 'fancy-layout compact-container breadcrumb-flush breadcrumb-fancy', + 'sidebar' => 'compact-container', + default => '', +}; + +// Define layout mode view path for inclusion +$this->appendViewPath(sprintf('%s/create/%s', __DIR__, $layout)); + +// Render the form layout +echo $this->makePartial(sprintf('create/%s.php', $layout), [ + 'formController' => $formController, + 'formConfig' => $formConfig, +]); diff --git a/modules/backend/behaviors/formcontroller/create/_fancy.php b/modules/backend/behaviors/formcontroller/create/_fancy.php new file mode 100644 index 0000000000..f6b0008f00 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create/_fancy.php @@ -0,0 +1,14 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> +
+ formRender() ?> +
+ + +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/create/_sidebar.php b/modules/backend/behaviors/formcontroller/create/_sidebar.php new file mode 100644 index 0000000000..79798a74d5 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create/_sidebar.php @@ -0,0 +1,61 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + + +
+ +
+ formRenderOutsideFields() ?> + formRenderPrimaryTabs() ?> +
+ +
+
+ + + + or + +
+
+ +
+ + + +
formRenderSecondaryTabs() ?>
+ + + + 'layout stretch']) ?> + makeLayout('form-with-sidebar') ?> + + + + +
+ +
+
+

fatalError)) ?>

+

+
+ diff --git a/modules/backend/behaviors/formcontroller/create/_standard.php b/modules/backend/behaviors/formcontroller/create/_standard.php new file mode 100644 index 0000000000..6fb1e1babe --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create/_standard.php @@ -0,0 +1,39 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> +
+ formRender() ?> +
+ +
+
+ + + + or + +
+
+ + +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php new file mode 100644 index 0000000000..3d420b403f --- /dev/null +++ b/modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php @@ -0,0 +1,11 @@ + diff --git a/modules/backend/behaviors/formcontroller/preview.php b/modules/backend/behaviors/formcontroller/preview.php index 467b1f1528..29d64847e4 100644 --- a/modules/backend/behaviors/formcontroller/preview.php +++ b/modules/backend/behaviors/formcontroller/preview.php @@ -1,20 +1,27 @@ getClassExtension(\Backend\Behaviors\FormController::class); $formConfig = $formController->getConfig(); -?> - - - +// Decide which layout we should be rendering +$layout = $this->formLayout ?? $formConfig->formLayout ?? null; +if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { + $layout = 'standard'; +} + +// If required, set the appropriate body classes +$this->bodyClass = match ($layout) { + 'fancy' => 'fancy-layout compact-container breadcrumb-flush breadcrumb-fancy', + 'sidebar' => 'compact-container', + default => '', +}; + +// Define layout mode view path for inclusion +$this->appendViewPath(sprintf('%s/preview/%s', __DIR__, $layout)); -fatalError): ?> -
- formRenderPreview() ?> -
- -

fatalError) ?>

-

- +// Render the form layout +echo $this->makePartial(sprintf('preview/%s.php', $layout), [ + 'formController' => $formController, + 'formConfig' => $formConfig, +]); diff --git a/modules/backend/behaviors/formcontroller/preview/_fancy.php b/modules/backend/behaviors/formcontroller/preview/_fancy.php new file mode 100644 index 0000000000..e7f9176c01 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/preview/_fancy.php @@ -0,0 +1,14 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/preview/_sidebar.php b/modules/backend/behaviors/formcontroller/preview/_sidebar.php new file mode 100644 index 0000000000..79798a74d5 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/preview/_sidebar.php @@ -0,0 +1,61 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + + +
+ +
+ formRenderOutsideFields() ?> + formRenderPrimaryTabs() ?> +
+ +
+
+ + + + or + +
+
+ +
+ + + +
formRenderSecondaryTabs() ?>
+ + + + 'layout stretch']) ?> + makeLayout('form-with-sidebar') ?> + + + + +
+ +
+
+

fatalError)) ?>

+

+
+ diff --git a/modules/backend/behaviors/formcontroller/preview/_standard.php b/modules/backend/behaviors/formcontroller/preview/_standard.php new file mode 100644 index 0000000000..4098a0fe0d --- /dev/null +++ b/modules/backend/behaviors/formcontroller/preview/_standard.php @@ -0,0 +1,12 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> +
+ formRenderPreview() ?> +
+ +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php new file mode 100644 index 0000000000..94212553b3 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php @@ -0,0 +1 @@ +
diff --git a/modules/backend/behaviors/formcontroller/update.php b/modules/backend/behaviors/formcontroller/update.php index 5422391e92..fe9fe58210 100644 --- a/modules/backend/behaviors/formcontroller/update.php +++ b/modules/backend/behaviors/formcontroller/update.php @@ -1,55 +1,27 @@ getClassExtension(\Backend\Behaviors\FormController::class); $formConfig = $formController->getConfig(); -?> - - - +// Decide which layout we should be rendering +$layout = $this->formLayout ?? $formConfig->formLayout ?? null; +if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { + $layout = 'standard'; +} + +// If required, set the appropriate body classes +$this->bodyClass .= match ($layout) { + 'fancy' => ' fancy-layout compact-container breadcrumb-flush breadcrumb-fancy', + 'sidebar' => ' compact-container', + default => '', +}; -fatalError): ?> - 'layout']) ?> -
- formRender() ?> -
+// Define layout mode view path for inclusion +$this->appendViewPath(sprintf('%s/update/%s', __DIR__, $layout)); -
-
- - - - - or - -
-
- - -

fatalError) ?>

-

- +// Render the form layout +echo $this->makePartial(sprintf('update/%s.php', $layout), [ + 'formController' => $formController, + 'formConfig' => $formConfig, +]); diff --git a/modules/backend/behaviors/formcontroller/update/_fancy.php b/modules/backend/behaviors/formcontroller/update/_fancy.php new file mode 100644 index 0000000000..f6b0008f00 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/update/_fancy.php @@ -0,0 +1,14 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> +
+ formRender() ?> +
+ + +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/update/_sidebar.php b/modules/backend/behaviors/formcontroller/update/_sidebar.php new file mode 100644 index 0000000000..79798a74d5 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/update/_sidebar.php @@ -0,0 +1,61 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + + +
+ +
+ formRenderOutsideFields() ?> + formRenderPrimaryTabs() ?> +
+ +
+
+ + + + or + +
+
+ +
+ + + +
formRenderSecondaryTabs() ?>
+ + + + 'layout stretch']) ?> + makeLayout('form-with-sidebar') ?> + + + + +
+ +
+
+

fatalError)) ?>

+

+
+ diff --git a/modules/backend/behaviors/formcontroller/update/_standard.php b/modules/backend/behaviors/formcontroller/update/_standard.php new file mode 100644 index 0000000000..bf53c27202 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/update/_standard.php @@ -0,0 +1,50 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + or + +
+
+ + + + +

fatalError) ?>

+

+ diff --git a/modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php new file mode 100644 index 0000000000..0e9d06b118 --- /dev/null +++ b/modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php @@ -0,0 +1,18 @@ + diff --git a/modules/backend/behaviors/importexportcontroller/export.php b/modules/backend/behaviors/importexportcontroller/export.php new file mode 100644 index 0000000000..6c0be77f72 --- /dev/null +++ b/modules/backend/behaviors/importexportcontroller/export.php @@ -0,0 +1,24 @@ + + makeLayoutPartial('breadcrumb') ?> + + + 'layout']) ?> + +
+ exportRender() ?> +
+ +
+
+ +
+
+ + diff --git a/modules/backend/behaviors/importexportcontroller/import.php b/modules/backend/behaviors/importexportcontroller/import.php new file mode 100644 index 0000000000..f40d5b8d23 --- /dev/null +++ b/modules/backend/behaviors/importexportcontroller/import.php @@ -0,0 +1,24 @@ + + makeLayoutPartial('breadcrumb') ?> + + + 'layout']) ?> + +
+ importRender() ?> +
+ +
+
+ +
+
+ + From 0807dd4b013240745c231e96b4f75a69ca6c422d Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:15:07 +0000 Subject: [PATCH 12/49] Added self generating breadcumb for controller stubs --- .../backend/console/scaffold/controller/sidebar/create.stub | 5 +---- .../backend/console/scaffold/controller/sidebar/preview.stub | 5 +---- .../backend/console/scaffold/controller/sidebar/update.stub | 5 +---- .../backend/console/scaffold/controller/standard/create.stub | 5 +---- .../console/scaffold/controller/standard/preview.stub | 5 +---- .../backend/console/scaffold/controller/standard/update.stub | 5 +---- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/modules/backend/console/scaffold/controller/sidebar/create.stub b/modules/backend/console/scaffold/controller/sidebar/create.stub index cfce78fa9c..9e2bbd9cec 100644 --- a/modules/backend/console/scaffold/controller/sidebar/create.stub +++ b/modules/backend/console/scaffold/controller/sidebar/create.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle)) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> diff --git a/modules/backend/console/scaffold/controller/sidebar/preview.stub b/modules/backend/console/scaffold/controller/sidebar/preview.stub index 6014bd4585..952038c6ac 100644 --- a/modules/backend/console/scaffold/controller/sidebar/preview.stub +++ b/modules/backend/console/scaffold/controller/sidebar/preview.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle)) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> diff --git a/modules/backend/console/scaffold/controller/sidebar/update.stub b/modules/backend/console/scaffold/controller/sidebar/update.stub index bd5677411b..232997fa41 100644 --- a/modules/backend/console/scaffold/controller/sidebar/update.stub +++ b/modules/backend/console/scaffold/controller/sidebar/update.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle)) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> diff --git a/modules/backend/console/scaffold/controller/standard/create.stub b/modules/backend/console/scaffold/controller/standard/create.stub index 8836705591..6a91048591 100644 --- a/modules/backend/console/scaffold/controller/standard/create.stub +++ b/modules/backend/console/scaffold/controller/standard/create.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> diff --git a/modules/backend/console/scaffold/controller/standard/preview.stub b/modules/backend/console/scaffold/controller/standard/preview.stub index fbd3d7457d..d50dd41212 100644 --- a/modules/backend/console/scaffold/controller/standard/preview.stub +++ b/modules/backend/console/scaffold/controller/standard/preview.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> diff --git a/modules/backend/console/scaffold/controller/standard/update.stub b/modules/backend/console/scaffold/controller/standard/update.stub index 61e9a0d1c5..67c5a51734 100644 --- a/modules/backend/console/scaffold/controller/standard/update.stub +++ b/modules/backend/console/scaffold/controller/standard/update.stub @@ -1,8 +1,5 @@ -
    -
  • -
  • pageTitle) ?>
  • -
+ makeLayoutPartial('breadcrumb') ?> fatalError): ?> From cae770417032d8bc26496089dcbe4dee7d36eb9d Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:15:27 +0000 Subject: [PATCH 13/49] Added import export lang keys --- modules/backend/lang/en/lang.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 5c1a96f55b..99e9585854 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -518,6 +518,8 @@ 'number_all' => 'all numbers', ], 'import_export' => [ + 'export' => 'Export', + 'import' => 'Import', 'upload_csv_file' => '1. Upload a CSV file', 'import_file' => 'Import file', 'row' => 'Row :row', From 2a13527a507ed6f67ff8a8c645afed0665c7552c Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:17:37 +0000 Subject: [PATCH 14/49] Added fix for code styling --- modules/backend/behaviors/formcontroller/create/_sidebar.php | 2 -- modules/backend/behaviors/formcontroller/preview/_sidebar.php | 2 -- modules/backend/behaviors/formcontroller/update/_sidebar.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/create/_sidebar.php b/modules/backend/behaviors/formcontroller/create/_sidebar.php index 79798a74d5..fe3ba6eb29 100644 --- a/modules/backend/behaviors/formcontroller/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/create/_sidebar.php @@ -3,7 +3,6 @@ fatalError): ?> -
@@ -49,7 +48,6 @@ class="btn btn-default"> makeLayout('form-with-sidebar') ?> -
diff --git a/modules/backend/behaviors/formcontroller/preview/_sidebar.php b/modules/backend/behaviors/formcontroller/preview/_sidebar.php index 79798a74d5..fe3ba6eb29 100644 --- a/modules/backend/behaviors/formcontroller/preview/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/preview/_sidebar.php @@ -3,7 +3,6 @@ fatalError): ?> -
@@ -49,7 +48,6 @@ class="btn btn-default"> makeLayout('form-with-sidebar') ?> -
diff --git a/modules/backend/behaviors/formcontroller/update/_sidebar.php b/modules/backend/behaviors/formcontroller/update/_sidebar.php index 79798a74d5..fe3ba6eb29 100644 --- a/modules/backend/behaviors/formcontroller/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/update/_sidebar.php @@ -3,7 +3,6 @@ fatalError): ?> -
@@ -49,7 +48,6 @@ class="btn btn-default"> makeLayout('form-with-sidebar') ?> -
From 2f616e0f8e9e31669b546b83af159c0e8cc51e00 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Tue, 18 Feb 2025 17:43:26 +0000 Subject: [PATCH 15/49] Added fixes for reorder partials --- .../reordercontroller/_reorder_toolbar.php | 16 +++++----------- .../behaviors/reordercontroller/reorder.php | 16 ++++------------ 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php b/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php index 9985cdc82b..6320a60db7 100644 --- a/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php +++ b/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php @@ -1,11 +1,5 @@ -getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController?->getConfig(); -?> - -
- - - -
- + diff --git a/modules/backend/behaviors/reordercontroller/reorder.php b/modules/backend/behaviors/reordercontroller/reorder.php index 8c0b9e4233..92925d4425 100644 --- a/modules/backend/behaviors/reordercontroller/reorder.php +++ b/modules/backend/behaviors/reordercontroller/reorder.php @@ -1,13 +1,5 @@ -getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController?->getConfig(); -?> - - - - - + + makeLayoutPartial('breadcrumb') ?> + + reorderRender() ?> From 5102170d58f414b3d773c24dc3a6068df26d3e94 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 21 Feb 2025 16:16:54 -0600 Subject: [PATCH 16/49] Move controllerbehavior default views to /views --- modules/backend/behaviors/FormController.php | 5 ----- modules/backend/behaviors/ImportExportController.php | 5 ----- modules/backend/behaviors/ListController.php | 5 ----- modules/backend/behaviors/ReorderController.php | 5 ----- .../backend/behaviors/formcontroller/{ => views}/create.php | 0 .../behaviors/formcontroller/{ => views}/create/_fancy.php | 0 .../behaviors/formcontroller/{ => views}/create/_sidebar.php | 0 .../formcontroller/{ => views}/create/_standard.php | 0 .../formcontroller/{ => views}/create/fancy/_toolbar.php | 0 .../backend/behaviors/formcontroller/{ => views}/preview.php | 0 .../behaviors/formcontroller/{ => views}/preview/_fancy.php | 0 .../formcontroller/{ => views}/preview/_sidebar.php | 0 .../formcontroller/{ => views}/preview/_standard.php | 0 .../formcontroller/{ => views}/preview/fancy/_toolbar.php | 0 .../backend/behaviors/formcontroller/{ => views}/update.php | 0 .../behaviors/formcontroller/{ => views}/update/_fancy.php | 0 .../behaviors/formcontroller/{ => views}/update/_sidebar.php | 0 .../formcontroller/{ => views}/update/_standard.php | 0 .../formcontroller/{ => views}/update/fancy/_toolbar.php | 0 .../behaviors/importexportcontroller/{ => views}/export.php | 0 .../behaviors/importexportcontroller/{ => views}/import.php | 0 .../behaviors/listcontroller/{ => views}/_list_toolbar.php | 0 .../backend/behaviors/listcontroller/{ => views}/index.php | 0 .../reordercontroller/{ => views}/_reorder_toolbar.php | 0 .../behaviors/reordercontroller/{ => views}/reorder.php | 0 modules/backend/classes/ControllerBehavior.php | 3 +++ 26 files changed, 3 insertions(+), 20 deletions(-) rename modules/backend/behaviors/formcontroller/{ => views}/create.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/create/_fancy.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/create/_sidebar.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/create/_standard.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/create/fancy/_toolbar.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/preview.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/preview/_fancy.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/preview/_sidebar.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/preview/_standard.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/preview/fancy/_toolbar.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/update.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/update/_fancy.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/update/_sidebar.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/update/_standard.php (100%) rename modules/backend/behaviors/formcontroller/{ => views}/update/fancy/_toolbar.php (100%) rename modules/backend/behaviors/importexportcontroller/{ => views}/export.php (100%) rename modules/backend/behaviors/importexportcontroller/{ => views}/import.php (100%) rename modules/backend/behaviors/listcontroller/{ => views}/_list_toolbar.php (100%) rename modules/backend/behaviors/listcontroller/{ => views}/index.php (100%) rename modules/backend/behaviors/reordercontroller/{ => views}/_reorder_toolbar.php (100%) rename modules/backend/behaviors/reordercontroller/{ => views}/reorder.php (100%) diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index 11fc7d70ac..ae58bb475f 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -106,11 +106,6 @@ public function __construct($controller) */ $this->config = $this->makeConfig($controller->formConfig ?: $this->formConfig, $this->requiredConfig); $this->config->modelClass = Str::normalizeClassName($this->config->modelClass); - - /* - * Set default view path - */ - $this->controller->appendViewPath($this->guessViewPath()); } /** diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 5974897414..057a0758a3 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -138,11 +138,6 @@ public function __construct($controller) if ($this->exportOptionsFormWidget = $this->makeExportOptionsFormWidget()) { $this->exportOptionsFormWidget->bindToController(); } - - /* - * Set default view path - */ - $this->controller->appendViewPath($this->guessViewPath()); } // diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index d060e94b37..d9b25f712a 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -93,11 +93,6 @@ public function __construct($controller) * Build configuration */ $this->setConfig($this->listDefinitions[$this->primaryDefinition], $this->requiredConfig); - - /* - * Set default view path - */ - $this->controller->appendViewPath($this->guessViewPath()); } /** diff --git a/modules/backend/behaviors/ReorderController.php b/modules/backend/behaviors/ReorderController.php index 7d13386e11..20cd3460ff 100644 --- a/modules/backend/behaviors/ReorderController.php +++ b/modules/backend/behaviors/ReorderController.php @@ -91,11 +91,6 @@ public function __construct($controller) * Populate from config */ $this->nameFrom = $this->getConfig('nameFrom', $this->nameFrom); - - /* - * Set default view path - */ - $this->controller->appendViewPath($this->guessViewPath()); } // diff --git a/modules/backend/behaviors/formcontroller/create.php b/modules/backend/behaviors/formcontroller/views/create.php similarity index 100% rename from modules/backend/behaviors/formcontroller/create.php rename to modules/backend/behaviors/formcontroller/views/create.php diff --git a/modules/backend/behaviors/formcontroller/create/_fancy.php b/modules/backend/behaviors/formcontroller/views/create/_fancy.php similarity index 100% rename from modules/backend/behaviors/formcontroller/create/_fancy.php rename to modules/backend/behaviors/formcontroller/views/create/_fancy.php diff --git a/modules/backend/behaviors/formcontroller/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/create/_sidebar.php rename to modules/backend/behaviors/formcontroller/views/create/_sidebar.php diff --git a/modules/backend/behaviors/formcontroller/create/_standard.php b/modules/backend/behaviors/formcontroller/views/create/_standard.php similarity index 100% rename from modules/backend/behaviors/formcontroller/create/_standard.php rename to modules/backend/behaviors/formcontroller/views/create/_standard.php diff --git a/modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/create/fancy/_toolbar.php rename to modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php diff --git a/modules/backend/behaviors/formcontroller/preview.php b/modules/backend/behaviors/formcontroller/views/preview.php similarity index 100% rename from modules/backend/behaviors/formcontroller/preview.php rename to modules/backend/behaviors/formcontroller/views/preview.php diff --git a/modules/backend/behaviors/formcontroller/preview/_fancy.php b/modules/backend/behaviors/formcontroller/views/preview/_fancy.php similarity index 100% rename from modules/backend/behaviors/formcontroller/preview/_fancy.php rename to modules/backend/behaviors/formcontroller/views/preview/_fancy.php diff --git a/modules/backend/behaviors/formcontroller/preview/_sidebar.php b/modules/backend/behaviors/formcontroller/views/preview/_sidebar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/preview/_sidebar.php rename to modules/backend/behaviors/formcontroller/views/preview/_sidebar.php diff --git a/modules/backend/behaviors/formcontroller/preview/_standard.php b/modules/backend/behaviors/formcontroller/views/preview/_standard.php similarity index 100% rename from modules/backend/behaviors/formcontroller/preview/_standard.php rename to modules/backend/behaviors/formcontroller/views/preview/_standard.php diff --git a/modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/preview/fancy/_toolbar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/preview/fancy/_toolbar.php rename to modules/backend/behaviors/formcontroller/views/preview/fancy/_toolbar.php diff --git a/modules/backend/behaviors/formcontroller/update.php b/modules/backend/behaviors/formcontroller/views/update.php similarity index 100% rename from modules/backend/behaviors/formcontroller/update.php rename to modules/backend/behaviors/formcontroller/views/update.php diff --git a/modules/backend/behaviors/formcontroller/update/_fancy.php b/modules/backend/behaviors/formcontroller/views/update/_fancy.php similarity index 100% rename from modules/backend/behaviors/formcontroller/update/_fancy.php rename to modules/backend/behaviors/formcontroller/views/update/_fancy.php diff --git a/modules/backend/behaviors/formcontroller/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/update/_sidebar.php rename to modules/backend/behaviors/formcontroller/views/update/_sidebar.php diff --git a/modules/backend/behaviors/formcontroller/update/_standard.php b/modules/backend/behaviors/formcontroller/views/update/_standard.php similarity index 100% rename from modules/backend/behaviors/formcontroller/update/_standard.php rename to modules/backend/behaviors/formcontroller/views/update/_standard.php diff --git a/modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php similarity index 100% rename from modules/backend/behaviors/formcontroller/update/fancy/_toolbar.php rename to modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php diff --git a/modules/backend/behaviors/importexportcontroller/export.php b/modules/backend/behaviors/importexportcontroller/views/export.php similarity index 100% rename from modules/backend/behaviors/importexportcontroller/export.php rename to modules/backend/behaviors/importexportcontroller/views/export.php diff --git a/modules/backend/behaviors/importexportcontroller/import.php b/modules/backend/behaviors/importexportcontroller/views/import.php similarity index 100% rename from modules/backend/behaviors/importexportcontroller/import.php rename to modules/backend/behaviors/importexportcontroller/views/import.php diff --git a/modules/backend/behaviors/listcontroller/_list_toolbar.php b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php similarity index 100% rename from modules/backend/behaviors/listcontroller/_list_toolbar.php rename to modules/backend/behaviors/listcontroller/views/_list_toolbar.php diff --git a/modules/backend/behaviors/listcontroller/index.php b/modules/backend/behaviors/listcontroller/views/index.php similarity index 100% rename from modules/backend/behaviors/listcontroller/index.php rename to modules/backend/behaviors/listcontroller/views/index.php diff --git a/modules/backend/behaviors/reordercontroller/_reorder_toolbar.php b/modules/backend/behaviors/reordercontroller/views/_reorder_toolbar.php similarity index 100% rename from modules/backend/behaviors/reordercontroller/_reorder_toolbar.php rename to modules/backend/behaviors/reordercontroller/views/_reorder_toolbar.php diff --git a/modules/backend/behaviors/reordercontroller/reorder.php b/modules/backend/behaviors/reordercontroller/views/reorder.php similarity index 100% rename from modules/backend/behaviors/reordercontroller/reorder.php rename to modules/backend/behaviors/reordercontroller/views/reorder.php diff --git a/modules/backend/classes/ControllerBehavior.php b/modules/backend/classes/ControllerBehavior.php index 9b7dbee165..9effeb7285 100644 --- a/modules/backend/classes/ControllerBehavior.php +++ b/modules/backend/classes/ControllerBehavior.php @@ -68,6 +68,9 @@ public function __construct($controller) if (is_array($this->actions)) { $this->hideAction(array_diff(get_class_methods(get_class($this)), $this->actions)); } + + // Include this behavior's default views in the controller's view paths + $this->controller->appendViewPath($this->guessViewPath('/views')); } /** From 3fe07ef14f51a910e94ace24fdadf77b81661109 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 26 Feb 2025 16:35:26 -0600 Subject: [PATCH 17/49] Update modules/backend/behaviors/reordercontroller/views/reorder.php --- modules/backend/behaviors/reordercontroller/views/reorder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/behaviors/reordercontroller/views/reorder.php b/modules/backend/behaviors/reordercontroller/views/reorder.php index 92925d4425..fc56b60337 100644 --- a/modules/backend/behaviors/reordercontroller/views/reorder.php +++ b/modules/backend/behaviors/reordercontroller/views/reorder.php @@ -1,5 +1,5 @@ makeLayoutPartial('breadcrumb') ?> - + reorderRender() ?> From 41f643b9b64025c18c7edcd0f9bcf6a96171d179 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 26 Feb 2025 17:18:21 -0600 Subject: [PATCH 18/49] Switch to new prependViewPath() method --- modules/backend/classes/Controller.php | 2 +- modules/backend/widgets/Lists.php | 2 +- modules/system/tests/traits/ViewMakerTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index 53d70038d4..5324fe76df 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -671,7 +671,7 @@ protected function runAjaxHandler($handler) */ protected function runAjaxHandlerForWidget($widget, $handler) { - $this->addViewPath($widget->getViewPaths()); + $this->prependViewPath($widget->getViewPaths()); $result = call_user_func_array([$widget, $handler], array_values($this->params)); diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index e34da43664..d6a1eac2aa 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -238,7 +238,7 @@ public function init() } if ($this->customViewPath) { - $this->addViewPath($this->customViewPath); + $this->prependViewPath($this->customViewPath); } $this->validateModel(); diff --git a/modules/system/tests/traits/ViewMakerTest.php b/modules/system/tests/traits/ViewMakerTest.php index 3dab780e76..ca32d757df 100644 --- a/modules/system/tests/traits/ViewMakerTest.php +++ b/modules/system/tests/traits/ViewMakerTest.php @@ -47,9 +47,9 @@ public function testViewPaths() $this->normalizePath($path) ); - // Test addViewPath() & getViewPaths() + // Test prependViewPath() & getViewPaths() $overridePath = "~/{$this->relativePath}override"; - $this->stub->addViewPath($overridePath); + $this->stub->prependViewPath($overridePath); $this->assertEquals( [ $this->normalizePath($overridePath), From 5d0b9cabc1ae10ac7360833c9beb5d550f3babc7 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 26 Feb 2025 17:46:21 -0600 Subject: [PATCH 19/49] Automatically set BackendMenu context from controller path Credit to @sephyld. Replaces #1311. Closes #1269. --- modules/backend/classes/Controller.php | 44 +++++++++++++++---- .../scaffold/controller/controller.stub | 7 +-- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index 5324fe76df..441b677bc1 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -2,16 +2,17 @@ namespace Backend\Classes; -use Lang; -use View; -use Flash; -use Config; -use Request; -use Backend; -use Redirect; -use Response; +use Illuminate\Support\Facades\Lang; +use Illuminate\Support\Facades\View; +use Winter\Storm\Support\Facades\Flash; +use Winter\Storm\Support\Facades\Config; +use Illuminate\Support\Facades\Request; +use Backend\Facades\Backend; +use Backend\Facades\BackendMenu; +use Illuminate\Support\Facades\Redirect; +use Illuminate\Support\Facades\Response; use Exception; -use BackendAuth; +use Backend\Facades\BackendAuth; use Backend\Models\UserPreference; use Backend\Models\Preference as BackendPreference; use Backend\Widgets\MediaManager; @@ -199,6 +200,26 @@ public static function __callStatic($name, $params) return self::extendableCallStatic($name, $params); } + /** + * Set the navigation context based on the current action & parameters + */ + protected function setNavigationContext(?string $action = null, array $params = []): void + { + $context = BackendMenu::getContext(); + + // @TODO: Support detecting module controllers as well + $currentClass = explode('\\', get_class($this)); + $author = $currentClass[0]; + $plugin = $currentClass[1]; + $controller = $currentClass[count($currentClass) - 1]; + + $owner = $context->owner ?? "$author.$plugin"; + $mainMenuCode = $context->mainMenuCode ?? strtolower($plugin); + $sideMenuCode = $context->sideMenuCode ?? strtolower($controller); + + BackendMenu::setContext($owner, $mainMenuCode, $sideMenuCode); + } + /** * Execute the controller action. * @param string $action The action name. @@ -281,6 +302,11 @@ public function run($action = null, $params = []) BackendPreference::setAppLocale(); BackendPreference::setAppFallbackLocale(); + /* + * Set the navigation context + */ + $this->setNavigationContext($action, $params); + /* * Execute AJAX event */ diff --git a/modules/backend/console/scaffold/controller/controller.stub b/modules/backend/console/scaffold/controller/controller.stub index 1d0b5c8cda..5859fd506b 100644 --- a/modules/backend/console/scaffold/controller/controller.stub +++ b/modules/backend/console/scaffold/controller/controller.stub @@ -22,15 +22,12 @@ class {{ studly_name }} extends Controller protected $requiredPermissions = [ '{{ lower_author }}.{{ lower_plugin }}.{{ lower_name }}.manage_all', ]; +{% if sidebar %} public function __construct() { parent::__construct(); - - BackendMenu::setContext('{{ plugin_code }}', '{{ lower_plugin }}', '{{ lower_name }}'); - {% if sidebar %} - $this->bodyClass = 'compact-container'; - {% endif -%} } +{% endif -%} } From e0e6cb9701d24c22335018f06f10cf68003084b8 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 26 Feb 2025 18:20:54 -0600 Subject: [PATCH 20/49] Tweaks to the default views based on migrating Winter.Blog --- .../formcontroller/views/create/_fancy.php | 16 ++-- .../formcontroller/views/create/_sidebar.php | 8 +- .../formcontroller/views/create/_standard.php | 58 +++++++------- .../views/create/fancy/_toolbar.php | 12 +-- .../formcontroller/views/update/_fancy.php | 16 ++-- .../formcontroller/views/update/_sidebar.php | 24 +++--- .../formcontroller/views/update/_standard.php | 80 ++++++++++--------- .../views/update/fancy/_toolbar.php | 46 +++++++++-- modules/backend/lang/en/lang.php | 1 + 9 files changed, 161 insertions(+), 100 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/views/create/_fancy.php b/modules/backend/behaviors/formcontroller/views/create/_fancy.php index f6b0008f00..2358dfc9d0 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_fancy.php +++ b/modules/backend/behaviors/formcontroller/views/create/_fancy.php @@ -3,11 +3,17 @@ fatalError): ?> - 'layout']) ?> -
- formRender() ?> -
- +
+ 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?> +
+ +

fatalError) ?>

diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index fe3ba6eb29..de444cc9fb 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -5,7 +5,6 @@ fatalError): ?>
-
formRenderOutsideFields() ?> formRenderPrimaryTabs() ?> @@ -35,7 +34,6 @@ class="btn btn-default">
-
@@ -44,7 +42,11 @@ class="btn btn-default"> - 'layout stretch']) ?> + 'layout stretch', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> makeLayout('form-with-sidebar') ?> diff --git a/modules/backend/behaviors/formcontroller/views/create/_standard.php b/modules/backend/behaviors/formcontroller/views/create/_standard.php index 6fb1e1babe..bd917cf32b 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/create/_standard.php @@ -3,35 +3,39 @@ fatalError): ?> - 'layout']) ?> -
- formRender() ?> -
+ 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?> +
-
-
- - - - or - +
+
+ + + + or + +
-

fatalError) ?>

diff --git a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php index 3d420b403f..156d53da1d 100644 --- a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php @@ -1,11 +1,13 @@ diff --git a/modules/backend/behaviors/formcontroller/views/update/_fancy.php b/modules/backend/behaviors/formcontroller/views/update/_fancy.php index f6b0008f00..2358dfc9d0 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_fancy.php +++ b/modules/backend/behaviors/formcontroller/views/update/_fancy.php @@ -3,11 +3,17 @@ fatalError): ?> - 'layout']) ?> -
- formRender() ?> -
- +
+ 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?> +
+ +

fatalError) ?>

diff --git a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php index fe3ba6eb29..f1009b2901 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php @@ -5,7 +5,6 @@ fatalError): ?>
-
formRenderOutsideFields() ?> formRenderPrimaryTabs() ?> @@ -16,26 +15,29 @@ or
-
@@ -44,7 +46,11 @@ class="btn btn-default"> - 'layout stretch']) ?> + 'layout stretch', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> makeLayout('form-with-sidebar') ?> diff --git a/modules/backend/behaviors/formcontroller/views/update/_standard.php b/modules/backend/behaviors/formcontroller/views/update/_standard.php index bf53c27202..50ce12f29d 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/update/_standard.php @@ -3,47 +3,51 @@ fatalError): ?> - 'layout']) ?> - -
- formRender() ?> -
- -
-
- - - - - or - + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?>
-
+
+
+ + + + + or + +
+
-

fatalError) ?>

diff --git a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php index 0e9d06b118..2a9cf0686e 100644 --- a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php @@ -1,18 +1,48 @@
+ - + data-hotkey="ctrl+s, cmd+s" + > + + + + + + + url): ?> + + + + + + + +
diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 99e9585854..92888d965d 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -252,6 +252,7 @@ 'form' => [ 'create_title' => 'New :name', 'update_title' => 'Edit :name', + 'preview' => 'Preview', 'preview_title' => 'Preview :name', 'create_success' => ':name created', 'update_success' => ':name updated', From d6449e87723fd98475cf9df142a3509c2ef9bf6d Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 5 Mar 2025 15:02:03 -0600 Subject: [PATCH 21/49] Improve breadcrumb generation logic to take into account settings contexts --- modules/backend/layouts/_breadcrumb.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/backend/layouts/_breadcrumb.php b/modules/backend/layouts/_breadcrumb.php index e5f7b64313..c9f5755392 100644 --- a/modules/backend/layouts/_breadcrumb.php +++ b/modules/backend/layouts/_breadcrumb.php @@ -2,12 +2,20 @@ $menu = \Backend\Facades\BackendMenu::getActiveMainMenuItem(); $context = \Backend\Facades\BackendMenu::getContext(); $sideMenu = $menu->sideMenu[$context->sideMenuCode ?? null] ?? null; +$settingsManager = \System\Classes\SettingsManager::instance(); +$settingsContext = $settingsManager->getContext(); +$settingsItem = null; +if ($settingsContext) { + $settingsItem = $settingsManager->findSettingItem($settingsContext->owner, $settingsContext->itemCode); +} ?> From b4c66d619d65ffda8f82071dfdec696861e96d68 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 5 Mar 2025 15:20:01 -0600 Subject: [PATCH 22/49] Update the changemonitor status after the AJAX requests complete --- .../backend/behaviors/formcontroller/views/create/_sidebar.php | 2 ++ .../backend/behaviors/formcontroller/views/create/_standard.php | 2 ++ .../backend/behaviors/formcontroller/views/update/_sidebar.php | 1 + .../backend/behaviors/formcontroller/views/update/_standard.php | 2 ++ .../behaviors/formcontroller/views/update/fancy/_toolbar.php | 1 + 5 files changed, 8 insertions(+) diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index de444cc9fb..6eeb77b6fa 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -17,6 +17,7 @@ data-request="onSave" data-hotkey="ctrl+s, cmd+s" data-load-indicator=" trans($formConfig->name)])); ?>" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-primary"> @@ -26,6 +27,7 @@ class="btn btn-primary"> data-request-data="close:1" data-hotkey="ctrl+enter, cmd+enter" data-load-indicator=" trans($formConfig->name)])); ?>" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-default"> diff --git a/modules/backend/behaviors/formcontroller/views/create/_standard.php b/modules/backend/behaviors/formcontroller/views/create/_standard.php index bd917cf32b..cd5147dfdf 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/create/_standard.php @@ -19,6 +19,7 @@ data-request="onSave" data-hotkey="ctrl+s, cmd+s" data-load-indicator=" trans($formConfig->name)])); ?>" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-primary"> @@ -28,6 +29,7 @@ class="btn btn-primary"> data-request-data="close:1" data-hotkey="ctrl+enter, cmd+enter" data-load-indicator=" trans($formConfig->name)])); ?>" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-default"> diff --git a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php index f1009b2901..6f72d907c8 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php @@ -29,6 +29,7 @@ class="btn btn-primary" data-request-data="close:1" data-hotkey="ctrl+enter, cmd+enter" data-load-indicator="" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-default" > diff --git a/modules/backend/behaviors/formcontroller/views/update/_standard.php b/modules/backend/behaviors/formcontroller/views/update/_standard.php index 50ce12f29d..2fe5361e21 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/update/_standard.php @@ -31,6 +31,7 @@ class="btn btn-primary" data-request-data="close:1" data-hotkey="ctrl+enter, cmd+enter" data-load-indicator="" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" class="btn btn-default" > @@ -40,6 +41,7 @@ class="btn btn-default" class="wn-icon-trash-o btn-icon danger pull-right" data-request="onDelete" data-load-indicator=" trans($formConfig->name)])); ?>" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" data-request-confirm=""> diff --git a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php index 2a9cf0686e..65184fa279 100644 --- a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php @@ -42,6 +42,7 @@ class="btn btn-default empty wn-icon-trash-o" data-request="onDelete" title="" data-load-indicator="" + data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" data-request-confirm="" data-control="delete-button" > From 143dfe495078b870fb3f32893e9ebd0289a049be Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 5 Mar 2025 15:34:32 -0600 Subject: [PATCH 23/49] Add top padding to form buttons container & remove buttons from the sidebar preview view --- .../formcontroller/views/create/_sidebar.php | 2 +- .../formcontroller/views/create/_standard.php | 2 +- .../formcontroller/views/preview/_sidebar.php | 27 ------------------- .../formcontroller/views/update/_sidebar.php | 2 +- .../formcontroller/views/update/_standard.php | 2 +- 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index 6eeb77b6fa..6c8b44e0ac 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -10,7 +10,7 @@ formRenderPrimaryTabs() ?>
-
+
-
+
- - - or - -
-
-
diff --git a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php index 6f72d907c8..331f9c7625 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php @@ -10,7 +10,7 @@ formRenderPrimaryTabs() ?>
-
+
-
+
- - - - -
-
- -
- - - -
formRenderSecondaryTabs() ?>
- - - - 'layout stretch']) ?> - makeLayout('form-with-sidebar') ?> - - - - -
- -
-
-

fatalError)) ?>

-

-
- diff --git a/modules/backend/controllers/users/index.php b/modules/backend/controllers/users/index.php deleted file mode 100644 index ea43a3636c..0000000000 --- a/modules/backend/controllers/users/index.php +++ /dev/null @@ -1 +0,0 @@ -listRender() ?> diff --git a/modules/system/controllers/maillayouts/create.php b/modules/system/controllers/maillayouts/create.php deleted file mode 100644 index fcde00a9d3..0000000000 --- a/modules/system/controllers/maillayouts/create.php +++ /dev/null @@ -1,50 +0,0 @@ - -
    -
  • -
  • pageTitle)) ?>
  • -
- - -fatalError): ?> - - 'layout']) ?> - -
- formRender() ?> -
- -
-
- - - - - -
-
- - - - - -

fatalError)) ?>

-

- - diff --git a/modules/system/controllers/mailpartials/create.php b/modules/system/controllers/mailpartials/create.php deleted file mode 100644 index 78942e0c18..0000000000 --- a/modules/system/controllers/mailpartials/create.php +++ /dev/null @@ -1,50 +0,0 @@ - -
    -
  • -
  • pageTitle)) ?>
  • -
- - -fatalError): ?> - - 'layout']) ?> - -
- formRender() ?> -
- -
-
- - - - - -
-
- - - - - -

fatalError)) ?>

-

- - diff --git a/modules/system/controllers/mailtemplates/create.php b/modules/system/controllers/mailtemplates/create.php deleted file mode 100644 index 19995235af..0000000000 --- a/modules/system/controllers/mailtemplates/create.php +++ /dev/null @@ -1,50 +0,0 @@ - -
    -
  • -
  • pageTitle)) ?>
  • -
- - -fatalError): ?> - - 'layout']) ?> - -
- formRender() ?> -
- -
-
- - - - - -
-
- - - - - -

fatalError)) ?>

-

- - From ce48714ecbd3f2ca407bd355c34595f4fd45b6f9 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 5 Mar 2025 15:37:57 -0600 Subject: [PATCH 25/49] Add localized "or" string --- .../backend/behaviors/formcontroller/views/create/_sidebar.php | 2 +- .../backend/behaviors/formcontroller/views/create/_standard.php | 2 +- .../backend/behaviors/formcontroller/views/update/_sidebar.php | 2 +- .../backend/behaviors/formcontroller/views/update/_standard.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index 6c8b44e0ac..5608ec75f9 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -32,7 +32,7 @@ class="btn btn-default"> - or +
diff --git a/modules/backend/behaviors/formcontroller/views/create/_standard.php b/modules/backend/behaviors/formcontroller/views/create/_standard.php index 6366538792..3cc308eee8 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/create/_standard.php @@ -34,7 +34,7 @@ class="btn btn-default"> - or +
diff --git a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php index 331f9c7625..d5a35dd34c 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php @@ -35,7 +35,7 @@ class="btn btn-default" - or +
diff --git a/modules/backend/behaviors/formcontroller/views/update/_standard.php b/modules/backend/behaviors/formcontroller/views/update/_standard.php index 8d37d3378b..91dc44bba5 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/update/_standard.php @@ -45,7 +45,7 @@ class="wn-icon-trash-o btn-icon danger pull-right" data-request-confirm=""> - or +
From 8689e4003af935eb795eadf9c88d7883cb812ceb Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 5 Mar 2025 15:40:05 -0600 Subject: [PATCH 26/49] Add data-browser-validate to all form saving buttons --- .../backend/behaviors/formcontroller/views/create/_sidebar.php | 2 ++ .../backend/behaviors/formcontroller/views/create/_standard.php | 2 ++ .../behaviors/formcontroller/views/create/fancy/_toolbar.php | 1 + .../backend/behaviors/formcontroller/views/update/_sidebar.php | 2 ++ .../backend/behaviors/formcontroller/views/update/_standard.php | 2 ++ .../behaviors/formcontroller/views/update/fancy/_toolbar.php | 2 ++ 6 files changed, 11 insertions(+) diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index 5608ec75f9..2e65cdf8bb 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -15,6 +15,7 @@ + + From bc7e4937110e2f386901021df330eaca66ec5909 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 15 Mar 2025 16:28:57 -0400 Subject: [PATCH 28/49] no need for two links with the same url --- modules/backend/layouts/_breadcrumb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/layouts/_breadcrumb.php b/modules/backend/layouts/_breadcrumb.php index c9f5755392..cc56ddfda8 100644 --- a/modules/backend/layouts/_breadcrumb.php +++ b/modules/backend/layouts/_breadcrumb.php @@ -12,7 +12,7 @@
  • label)) ?>
  • - + url !== $menu->url): ?>
  • label)) ?>
  • label)) ?>
  • From 077d4c4767caca053b11e1e19c22547445863534 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Tue, 6 May 2025 10:11:14 -0400 Subject: [PATCH 29/49] do not show "delete selected" button if the list does not show the records checkboxes --- .../backend/behaviors/listcontroller/views/_list_toolbar.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php index 5ba126ef63..8ee88e231d 100644 --- a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php +++ b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php @@ -10,6 +10,7 @@ class="btn btn-primary wn-icon-plus"> trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?> + showCheckboxes) && $listConfig->showCheckboxes != false) : ?> +
From acc69e8a2c4b9be0c966ab60460fb280fc752e6f Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Tue, 6 May 2025 11:22:59 -0400 Subject: [PATCH 30/49] add cancel button in default fancy toolbar --- .../behaviors/formcontroller/views/create/fancy/_toolbar.php | 2 ++ .../behaviors/formcontroller/views/update/fancy/_toolbar.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php index db806e41f0..d8c7fd3604 100644 --- a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php @@ -11,4 +11,6 @@ class="btn btn-primary wn-icon-check save" > + + diff --git a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php index fc628ea7d3..e30e433e44 100644 --- a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php @@ -37,6 +37,8 @@ class="btn btn-primary wn-icon-crosshairs" + + - + showCheckboxes) && $listConfig->showCheckboxes != false): ?> + + From a36b3e073c5e926c1836a1a0605aabfc6c8a79a7 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 10 May 2025 02:54:13 -0400 Subject: [PATCH 33/49] Extract create/update form buttons into their own partials (#1352) Co-authored-by: Luke Towers There is now a single partial for the formcontroller create/update buttons. This partial can be overridden in your controllers using the partial names below: create: _form_create_toolbar.php update: _form_update_toolbar.php both: _form_toolbar.php Also adds Create and new button/action to FormController. --- modules/backend/behaviors/FormController.php | 22 +++++ .../formcontroller/partials/_toolbar.php | 81 +++++++++++++++++++ .../behaviors/formcontroller/views/create.php | 9 +-- .../formcontroller/views/create/_sidebar.php | 27 +------ .../formcontroller/views/create/_standard.php | 27 +------ .../formcontroller/views/preview.php | 8 +- .../behaviors/formcontroller/views/update.php | 9 +-- .../formcontroller/views/update/_sidebar.php | 40 +-------- .../formcontroller/views/update/_standard.php | 38 +-------- modules/backend/lang/en/lang.php | 1 + modules/backend/lang/es/lang.php | 1 + modules/backend/lang/fr/lang.php | 1 + modules/backend/lang/nl/lang.php | 1 + modules/backend/lang/pl/lang.php | 1 + modules/backend/lang/ru/lang.php | 1 + 15 files changed, 116 insertions(+), 151 deletions(-) create mode 100644 modules/backend/behaviors/formcontroller/partials/_toolbar.php diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index ae58bb475f..1b6c125296 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -191,7 +191,9 @@ public function initForm($model, $context = null) protected function prepareVars($model) { $this->controller->vars['formModel'] = $model; + $this->controller->vars['formConfig'] = $this->getConfig(); $this->controller->vars['formContext'] = $this->formGetContext(); + $this->controller->vars['formController'] = $this; $this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name')); } @@ -473,6 +475,10 @@ public function makeRedirect($context = null, $model = null) return Redirect::refresh(); } + if (post('new', false)) { + return Redirect::to($this->controller->actionUrl('create')); + } + if (post('redirect', true)) { $redirectUrl = $this->controller->formGetRedirectUrl($context, $model); } @@ -882,4 +888,20 @@ public static function extendFormFields($callback) call_user_func_array($callback, [$widget, $widget->model, $widget->getContext()]); }); } + + /** + * Controller accessor for making partials within this behavior. + */ + public function formMakePartial(string $partial, array $params = []): string + { + $contents = $this->controller->makePartial('form_' . $this->context . '_' . $partial, $params + $this->vars, false); + if (!$contents) { + $contents = $this->controller->makePartial('form_' . $partial, $params + $this->vars, false); + } + if (!$contents) { + $contents = $this->makePartial($partial, $params); + } + + return $contents; + } } diff --git a/modules/backend/behaviors/formcontroller/partials/_toolbar.php b/modules/backend/behaviors/formcontroller/partials/_toolbar.php new file mode 100644 index 0000000000..d4929319fb --- /dev/null +++ b/modules/backend/behaviors/formcontroller/partials/_toolbar.php @@ -0,0 +1,81 @@ +name ?? ''; +?> + +
+ + + + + + +
+ +
+ + + + + + +
+ diff --git a/modules/backend/behaviors/formcontroller/views/create.php b/modules/backend/behaviors/formcontroller/views/create.php index 308d711d6b..12080a6fc8 100644 --- a/modules/backend/behaviors/formcontroller/views/create.php +++ b/modules/backend/behaviors/formcontroller/views/create.php @@ -1,9 +1,5 @@ getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController->getConfig(); - // Decide which layout we should be rendering $layout = $this->formLayout ?? $formConfig->formLayout ?? null; if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { @@ -21,7 +17,4 @@ $this->appendViewPath(sprintf('%s/create/%s', __DIR__, $layout)); // Render the form layout -echo $this->makePartial(sprintf('create/%s.php', $layout), [ - 'formController' => $formController, - 'formConfig' => $formConfig, -]); +echo $this->makePartial(sprintf('create/%s.php', $layout)); diff --git a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php index 2e65cdf8bb..f278789de0 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/create/_sidebar.php @@ -11,32 +11,7 @@
-
- - - - - -
+ formMakePartial('toolbar') ?>
diff --git a/modules/backend/behaviors/formcontroller/views/create/_standard.php b/modules/backend/behaviors/formcontroller/views/create/_standard.php index 45a39802f7..7b88ff8b33 100644 --- a/modules/backend/behaviors/formcontroller/views/create/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/create/_standard.php @@ -13,32 +13,7 @@
-
- - - - - -
+ formMakePartial('toolbar') ?>
diff --git a/modules/backend/behaviors/formcontroller/views/preview.php b/modules/backend/behaviors/formcontroller/views/preview.php index 29d64847e4..1429909ce1 100644 --- a/modules/backend/behaviors/formcontroller/views/preview.php +++ b/modules/backend/behaviors/formcontroller/views/preview.php @@ -1,8 +1,5 @@ getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController->getConfig(); // Decide which layout we should be rendering $layout = $this->formLayout ?? $formConfig->formLayout ?? null; @@ -21,7 +18,4 @@ $this->appendViewPath(sprintf('%s/preview/%s', __DIR__, $layout)); // Render the form layout -echo $this->makePartial(sprintf('preview/%s.php', $layout), [ - 'formController' => $formController, - 'formConfig' => $formConfig, -]); +echo $this->makePartial(sprintf('preview/%s.php', $layout)); diff --git a/modules/backend/behaviors/formcontroller/views/update.php b/modules/backend/behaviors/formcontroller/views/update.php index fe9fe58210..eb439c1f9a 100644 --- a/modules/backend/behaviors/formcontroller/views/update.php +++ b/modules/backend/behaviors/formcontroller/views/update.php @@ -1,9 +1,5 @@ getClassExtension(\Backend\Behaviors\FormController::class); -$formConfig = $formController->getConfig(); - // Decide which layout we should be rendering $layout = $this->formLayout ?? $formConfig->formLayout ?? null; if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { @@ -21,7 +17,4 @@ $this->appendViewPath(sprintf('%s/update/%s', __DIR__, $layout)); // Render the form layout -echo $this->makePartial(sprintf('update/%s.php', $layout), [ - 'formController' => $formController, - 'formConfig' => $formConfig, -]); +echo $this->makePartial(sprintf('update/%s.php', $layout)); diff --git a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php index 75ac048f69..f278789de0 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_sidebar.php +++ b/modules/backend/behaviors/formcontroller/views/update/_sidebar.php @@ -11,45 +11,7 @@
-
- - - - - - - -
+ formMakePartial('toolbar') ?>
diff --git a/modules/backend/behaviors/formcontroller/views/update/_standard.php b/modules/backend/behaviors/formcontroller/views/update/_standard.php index b9327585a2..7b88ff8b33 100644 --- a/modules/backend/behaviors/formcontroller/views/update/_standard.php +++ b/modules/backend/behaviors/formcontroller/views/update/_standard.php @@ -13,43 +13,7 @@
-
- - - - - - -
+ formMakePartial('toolbar') ?>
diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 92888d965d..2645960d33 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -265,6 +265,7 @@ 'not_found' => 'Form record with an ID of :id could not be found.', 'action_confirm' => 'Are you sure?', 'create' => 'Create', + 'create_and_new' => 'Create and new', 'create_and_close' => 'Create and close', 'creating' => 'Creating...', 'creating_name' => 'Creating :name...', diff --git a/modules/backend/lang/es/lang.php b/modules/backend/lang/es/lang.php index c10026cf7f..9a06c3719a 100644 --- a/modules/backend/lang/es/lang.php +++ b/modules/backend/lang/es/lang.php @@ -195,6 +195,7 @@ 'not_found' => 'El registro del formulario con un ID de :id no se pudo encontrar.', 'action_confirm' => '¿Está usted seguro?', 'create' => 'Crear', + 'create_and_new' => 'Crear y nuevo', 'create_and_close' => 'Crear y cerrar', 'creating' => 'Creando...', 'creating_name' => 'Creando :name...', diff --git a/modules/backend/lang/fr/lang.php b/modules/backend/lang/fr/lang.php index 251d800c18..ef499132bf 100644 --- a/modules/backend/lang/fr/lang.php +++ b/modules/backend/lang/fr/lang.php @@ -263,6 +263,7 @@ 'not_found' => 'Aucun enregistrement de formulaire ne correspond à l\'ID :id.', 'action_confirm' => 'Confirmer l\'action ?', 'create' => 'Créer', + 'create_and_new' => 'Créer et nouveau', 'create_and_close' => 'Créer et fermer', 'creating' => 'Création en cours…', 'creating_name' => 'Création d\'un(e) :name en cours…', diff --git a/modules/backend/lang/nl/lang.php b/modules/backend/lang/nl/lang.php index 425a3f4c10..52495bb734 100644 --- a/modules/backend/lang/nl/lang.php +++ b/modules/backend/lang/nl/lang.php @@ -259,6 +259,7 @@ 'not_found' => 'Het formulier met record ID :id is niet gevonden.', 'action_confirm' => 'Weet je het zeker?', 'create' => 'Maken', + 'create_and_new' => 'Maken en nieuw', 'create_and_close' => 'Maken en sluiten', 'creating' => 'Maken...', 'creating_name' => ':name maken...', diff --git a/modules/backend/lang/pl/lang.php b/modules/backend/lang/pl/lang.php index 1e9a18a5d0..8d47307cd1 100644 --- a/modules/backend/lang/pl/lang.php +++ b/modules/backend/lang/pl/lang.php @@ -253,6 +253,7 @@ 'not_found' => 'Rekord formularza o ID :id nie został znaleziony.', 'action_confirm' => 'Czy jesteś pewny?', 'create' => 'Stwórz', + 'create_and_new' => 'Utwórz i nowe', 'create_and_close' => 'Stwórz i zamknij', 'creating' => 'Tworzenie...', 'creating_name' => 'Tworzenie :name...', diff --git a/modules/backend/lang/ru/lang.php b/modules/backend/lang/ru/lang.php index 828f5e1b52..ec071a9590 100644 --- a/modules/backend/lang/ru/lang.php +++ b/modules/backend/lang/ru/lang.php @@ -264,6 +264,7 @@ 'not_found' => 'Форма записи с идентификатором :ID не найдена.', 'action_confirm' => 'Вы уверены, что хотите сделать это?', 'create' => 'Создать', + 'create_and_new' => 'Создать и новый', 'create_and_close' => 'Создать и закрыть', 'creating' => 'Создание...', 'creating_name' => 'Создание :name...', From 451f4f9f18dfe10b1abe88c6b51c8ab44b9b15f1 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sat, 10 May 2025 01:02:06 -0600 Subject: [PATCH 34/49] Use toolbar partial --- .../scaffold/controller/sidebar/create.stub | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/modules/backend/console/scaffold/controller/sidebar/create.stub b/modules/backend/console/scaffold/controller/sidebar/create.stub index 9e2bbd9cec..fcdcfafeca 100644 --- a/modules/backend/console/scaffold/controller/sidebar/create.stub +++ b/modules/backend/console/scaffold/controller/sidebar/create.stub @@ -3,40 +3,16 @@ fatalError): ?> -
-
formRenderOutsideFields() ?> formRenderPrimaryTabs() ?>
-
- - - - or - -
+ formMakePartial('toolbar') ?>
-
@@ -49,7 +25,6 @@ makeLayout('form-with-sidebar') ?> -
From 22ab21eab51550e75efffe82b05bf5049ce430e7 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sat, 10 May 2025 01:02:52 -0600 Subject: [PATCH 35/49] Update update.stub --- .../scaffold/controller/sidebar/update.stub | 36 +------------------ 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/modules/backend/console/scaffold/controller/sidebar/update.stub b/modules/backend/console/scaffold/controller/sidebar/update.stub index 232997fa41..5d1ef6f7bd 100644 --- a/modules/backend/console/scaffold/controller/sidebar/update.stub +++ b/modules/backend/console/scaffold/controller/sidebar/update.stub @@ -3,48 +3,15 @@ fatalError): ?> -
-
formRenderOutsideFields() ?> formRenderPrimaryTabs() ?>
-
-
- - - - - or - -
+ formMakePartial('toolbar') ?>
-
@@ -57,7 +24,6 @@ makeLayout('form-with-sidebar') ?> -
From 37322603a4d22c30f9b31716b4150e53d297505b Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sat, 10 May 2025 01:03:24 -0600 Subject: [PATCH 36/49] Update create.stub --- .../scaffold/controller/standard/create.stub | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/modules/backend/console/scaffold/controller/standard/create.stub b/modules/backend/console/scaffold/controller/standard/create.stub index 6a91048591..2a936e607a 100644 --- a/modules/backend/console/scaffold/controller/standard/create.stub +++ b/modules/backend/console/scaffold/controller/standard/create.stub @@ -3,43 +3,16 @@ fatalError): ?> - 'layout']) ?> -
formRender() ?>
-
- - - - or - -
+ formMakePartial('toolbar') ?>
- - -

fatalError) ?>

- From 76b833c36be2284e8f07c59afa35d729eaf5223b Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sat, 10 May 2025 01:03:53 -0600 Subject: [PATCH 37/49] Update update.stub --- .../scaffold/controller/standard/update.stub | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/modules/backend/console/scaffold/controller/standard/update.stub b/modules/backend/console/scaffold/controller/standard/update.stub index 67c5a51734..b4da197e06 100644 --- a/modules/backend/console/scaffold/controller/standard/update.stub +++ b/modules/backend/console/scaffold/controller/standard/update.stub @@ -3,51 +3,15 @@ fatalError): ?> - 'layout']) ?> -
formRender() ?>
-
-
- - - - - or - -
+ formMakePartial('toolbar') ?>
- - -

fatalError) ?>

- From 9bbdfa54673069a27af02752a38ebf05ac0c1817 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 10 May 2025 14:47:56 -0400 Subject: [PATCH 38/49] add reorder button on default list toolbar --- .../behaviors/listcontroller/views/_list_toolbar.php | 6 ++++++ modules/backend/lang/en/lang.php | 1 + 2 files changed, 7 insertions(+) diff --git a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php index 55b8fde06d..c059fc2e28 100644 --- a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php +++ b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php @@ -26,4 +26,10 @@ class="btn btn-danger wn-icon-trash-o" + + isClassExtendedWith(\Backend\Behaviors\ReorderController::class)): ?> + + trans($listConfig->title)])); ?> + +
diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 2645960d33..ee4e5bd019 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -360,6 +360,7 @@ ], 'reorder' => [ 'default_title' => 'Reorder records', + 'reorder_title' => 'Reorder :name', 'no_records' => 'There are no records available to sort.', ], 'model' => [ From 33e1d3bd33b569dfe999903ae840b6b9e9833212 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 10 May 2025 15:02:52 -0400 Subject: [PATCH 39/49] fix icon class --- .../backend/behaviors/listcontroller/views/_list_toolbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php index c059fc2e28..1881f25598 100644 --- a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php +++ b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php @@ -28,7 +28,7 @@ class="btn btn-danger wn-icon-trash-o" isClassExtendedWith(\Backend\Behaviors\ReorderController::class)): ?> - + trans($listConfig->title)])); ?> From 3cff2dc4f7c66df7c5eb4110ef85b452b28b646d Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sat, 10 May 2025 15:11:41 -0400 Subject: [PATCH 40/49] only add create button if FormController is used --- .../listcontroller/views/_list_toolbar.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php index 1881f25598..de27b60948 100644 --- a/modules/backend/behaviors/listcontroller/views/_list_toolbar.php +++ b/modules/backend/behaviors/listcontroller/views/_list_toolbar.php @@ -4,11 +4,13 @@ ?>
- - trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?> - + isClassExtendedWith(\Backend\Behaviors\FormController::class)): ?> + + trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?> + + showCheckboxes) && $listConfig->showCheckboxes != false): ?>
From 0d7e874815a236c4f7164146322bb70f4421b8c2 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 28 May 2025 15:21:51 -0600 Subject: [PATCH 44/49] Add support for abort(403) in the backend --- .../behaviors/ImportExportController.php | 5 +-- modules/backend/classes/BackendController.php | 42 +++++++++++++------ modules/backend/classes/Controller.php | 2 +- modules/backend/controllers/UserRoles.php | 10 ++--- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 3688e1b06e..d8a4a02360 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\MassAssignmentException; use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Response; -use Illuminate\Support\Facades\View; use League\Csv\EscapeFormula as CsvEscapeFormula; use League\Csv\Reader as CsvReader; use League\Csv\Statement as CsvStatement; @@ -149,7 +148,7 @@ public function __construct($controller) public function import() { if (!$this->userHasAccess('import')) { - return Response::make(View::make('backend::access_denied'), 403); + abort(403); } $this->addJs('js/winter.import.js', 'core'); @@ -164,7 +163,7 @@ public function import() public function export() { if (!$this->userHasAccess('export')) { - return Response::make(View::make('backend::access_denied'), 403); + abort(403); } if ($response = $this->checkUseListExportMode()) { diff --git a/modules/backend/classes/BackendController.php b/modules/backend/classes/BackendController.php index 1dfb370d4e..e816e8ee8b 100644 --- a/modules/backend/classes/BackendController.php +++ b/modules/backend/classes/BackendController.php @@ -1,17 +1,21 @@ -cmsHandling = true; - return App::make('Cms\Classes\Controller')->run($url); - } else { - return Response::make(View::make('backend::404'), 404); + $response = App::make('Cms\Classes\Controller')->run($url); + if ($response->getStatusCode() !== 404) { + return $response; + } } + + return Response::make(View::make('backend::404'), 404); } /** @@ -142,8 +149,17 @@ public function run($url = null) { // Handle NotFoundHttpExceptions in the backend (usually triggered by abort(404)) Event::listen('exception.beforeRender', function ($exception, $httpCode, $request) { - if (!$this->cmsHandling && $exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { + if ($this->cmsHandling) { + return; + } + + if ($exception instanceof NotFoundHttpException) { return View::make('backend::404'); + } elseif ( + $exception instanceof HttpException + && $exception->getStatusCode() === 403 + ) { + return View::make('backend::access_denied'); } }, 1); diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index 447adcbec0..a4d8a9b151 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -269,7 +269,7 @@ public function run($action = null, $params = []) * Check access groups against the page definition */ if ($this->requiredPermissions && !$this->user->hasAnyAccess($this->requiredPermissions)) { - return Response::make(View::make('backend::access_denied'), 403); + abort(403); } } diff --git a/modules/backend/controllers/UserRoles.php b/modules/backend/controllers/UserRoles.php index 7aa23d0458..765063a067 100644 --- a/modules/backend/controllers/UserRoles.php +++ b/modules/backend/controllers/UserRoles.php @@ -1,9 +1,9 @@ -bindEvent('page.beforeDisplay', function () { if (!$this->user->isSuperUser()) { - return Response::make(View::make('backend::access_denied'), 403); + abort(403); } }); } From e24f395aebd7946258114922c4e99c6d22caf43c Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 28 May 2025 15:39:51 -0600 Subject: [PATCH 45/49] Improve abort(404) handling in the backend --- modules/backend/classes/BackendController.php | 3 ++- modules/cms/ServiceProvider.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/backend/classes/BackendController.php b/modules/backend/classes/BackendController.php index e816e8ee8b..9f73346d24 100644 --- a/modules/backend/classes/BackendController.php +++ b/modules/backend/classes/BackendController.php @@ -2,6 +2,7 @@ namespace Backend\Classes; +use Backend\Facades\BackendAuth; use Closure; use Illuminate\Routing\Controller as ControllerBase; use Illuminate\Support\Facades\App; @@ -129,7 +130,7 @@ class_exists('\Cms\Classes\Controller') ) { $this->cmsHandling = true; $response = App::make('Cms\Classes\Controller')->run($url); - if ($response->getStatusCode() !== 404) { + if ($response->getStatusCode() !== 404 || !BackendAuth::check()) { return $response; } } diff --git a/modules/cms/ServiceProvider.php b/modules/cms/ServiceProvider.php index f114cb9238..6f3a03aeea 100644 --- a/modules/cms/ServiceProvider.php +++ b/modules/cms/ServiceProvider.php @@ -94,6 +94,10 @@ protected function registerConsole() protected function registerErrorHandler() { $this->app->error(function (HttpExceptionInterface $exception, $code, $fromConsole) { + if ($this->app->runningInBackend() && BackendAuth::check()) { + return; + } + $theme = Theme::getActiveTheme(); $controller = new CmsController($theme); if ($code === 404) { From 8eb44e9eb5797f7931b30b74a9d45986a5fdee01 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 18 Jun 2025 14:17:30 -0600 Subject: [PATCH 46/49] Add icons to the default form buttons --- .../behaviors/formcontroller/partials/_toolbar.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/partials/_toolbar.php b/modules/backend/behaviors/formcontroller/partials/_toolbar.php index d4929319fb..64e67a637e 100644 --- a/modules/backend/behaviors/formcontroller/partials/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/partials/_toolbar.php @@ -11,7 +11,7 @@ data-hotkey="ctrl+shift+s, cmd+shift+s" data-load-indicator=" trans($modelName)])); ?>" data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" - class="btn btn-primary"> + class="btn btn-primary wn-icon-plus"> @@ -49,7 +49,7 @@ class="btn btn-default"> data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" data-request-data="redirect:0" data-hotkey="ctrl+s, cmd+s" - class="btn btn-primary" + class="btn btn-primary wn-icon-save" > @@ -61,7 +61,7 @@ class="btn btn-primary" data-hotkey="ctrl+enter, cmd+enter" data-load-indicator="" data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" - class="btn btn-default" + class="btn btn-default wn-icon-check" > From fe10d4249814a310e046f3a2fb787fe45a2653f6 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 18 Jun 2025 15:32:54 -0600 Subject: [PATCH 47/49] Add missing buttons and icons to the form fancy toolbars --- .../views/create/fancy/_toolbar.php | 38 ++++++++++++++----- .../views/update/fancy/_toolbar.php | 4 +- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php index d8c7fd3604..df4540d560 100644 --- a/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php @@ -1,16 +1,36 @@
- - + + + + - +
diff --git a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php index e30e433e44..a7eaf55ec0 100644 --- a/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php +++ b/modules/backend/behaviors/formcontroller/views/update/fancy/_toolbar.php @@ -2,7 +2,7 @@ - + + + + + + + + + + + + + + + + + + + + + url): ?> + + + + + + + + + + + +
diff --git a/modules/backend/console/scaffold/controller/fancy/create.stub b/modules/backend/console/scaffold/controller/fancy/create.stub new file mode 100644 index 0000000000..2358dfc9d0 --- /dev/null +++ b/modules/backend/console/scaffold/controller/fancy/create.stub @@ -0,0 +1,20 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> +
+ 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?> +
+ +
+ +

fatalError) ?>

+

+ diff --git a/modules/backend/console/scaffold/controller/fancy/preview.stub b/modules/backend/console/scaffold/controller/fancy/preview.stub new file mode 100644 index 0000000000..e7f9176c01 --- /dev/null +++ b/modules/backend/console/scaffold/controller/fancy/preview.stub @@ -0,0 +1,14 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> + 'layout']) ?> +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+

+ diff --git a/modules/backend/console/scaffold/controller/fancy/update.stub b/modules/backend/console/scaffold/controller/fancy/update.stub new file mode 100644 index 0000000000..2358dfc9d0 --- /dev/null +++ b/modules/backend/console/scaffold/controller/fancy/update.stub @@ -0,0 +1,20 @@ + + makeLayoutPartial('breadcrumb') ?> + + +fatalError): ?> +
+ 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => 'true', + ]) ?> +
+ formRender() ?> +
+ +
+ +

fatalError) ?>

+

+ diff --git a/modules/system/console/BaseScaffoldCommand.php b/modules/system/console/BaseScaffoldCommand.php index 5f8187d6a8..514862039e 100644 --- a/modules/system/console/BaseScaffoldCommand.php +++ b/modules/system/console/BaseScaffoldCommand.php @@ -89,18 +89,19 @@ public function makeStubs(): void . DIRECTORY_SEPARATOR . 'lang.php' ); + if (!file_exists($langFilePath)) { $this->makeDirectory($langFilePath); - $comment = 'File generated: ' . str_replace(base_path(), '', $langFilePath); + $comment = 'File generated: ' . str_replace(base_path(), '', $langFilePath); } else { - $comment = 'File updated: ' . str_replace(base_path(), '', $langFilePath); + $comment = 'File updated: ' . str_replace(base_path(), '', $langFilePath); } // Store the localization messages to the determined file path ArrayFile::open($langFilePath)->set($langKeys)->write(); // Inform the user - $this->comment($comment); + $this->output->writeLn($comment); } /**