From f8763afe982257727126b37aae58a3437bb082b1 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 15 Jul 2023 23:12:18 -0700 Subject: [PATCH] Setup UI - Use separate "Database" section (on standalone) --- setup/plugins/blocks/advanced.tpl.php | 2 ++ setup/plugins/blocks/database.civi-setup.php | 38 ++++++++++++++++++++ setup/plugins/blocks/database.tpl.php | 24 +++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 setup/plugins/blocks/database.civi-setup.php create mode 100644 setup/plugins/blocks/database.tpl.php diff --git a/setup/plugins/blocks/advanced.tpl.php b/setup/plugins/blocks/advanced.tpl.php index 12531bed4b..e130a6a8b4 100644 --- a/setup/plugins/blocks/advanced.tpl.php +++ b/setup/plugins/blocks/advanced.tpl.php @@ -9,6 +9,7 @@ endif; ?>
+ cms !== 'Standalone'): ?> + diff --git a/setup/plugins/blocks/database.civi-setup.php b/setup/plugins/blocks/database.civi-setup.php new file mode 100644 index 0000000000..c642416dc8 --- /dev/null +++ b/setup/plugins/blocks/database.civi-setup.php @@ -0,0 +1,38 @@ +addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) { + \Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__))); + + /** + * @var \Civi\Setup\UI\SetupController $ctrl + */ + $ctrl = $e->getCtrl(); + + $ctrl->blocks['database'] = [ + 'is_active' => ($e->getModel()->cms === 'Standalone'), + 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'database.tpl.php', + 'class' => '', + 'weight' => 15, + ]; + if (empty($ctrl->blocks['database']['is_active'])) { + return; + } + + $webDefault = ['server' => '127.0.0.1:3306', 'database' => 'civicrm', 'username' => '', 'password' => '']; + + if ($e->getMethod() === 'GET') { + $e->getModel()->db = $webDefault; + } + elseif ($e->getMethod() === 'POST') { + $db = $e->getField('db', $webDefault); + + foreach (['server', 'database', 'username', 'password'] as $field) { + $e->getModel()->db[$field] = $db[$field]; + } + } + + }, \Civi\Setup::PRIORITY_PREPARE); diff --git a/setup/plugins/blocks/database.tpl.php b/setup/plugins/blocks/database.tpl.php new file mode 100644 index 0000000000..b6f75b84ab --- /dev/null +++ b/setup/plugins/blocks/database.tpl.php @@ -0,0 +1,24 @@ + + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

-- 2.25.1
@@ -44,6 +45,7 @@ endif; ?>
settingsPath); ?>