From f19dc454eefa4f67a185da41e5a7bb60da9ba887 Mon Sep 17 00:00:00 2001 From: Benjy Date: Sat, 5 Nov 2016 19:10:28 +0100 Subject: [PATCH] Add base URL configuration field in installer and in sample configuration file --- config.php.sample | 2 +- .../Install/Controller/InstallController.php | 27 ++++++++++--------- .../module/install/config_new.tpl.html | 19 ++++++++----- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/config.php.sample b/config.php.sample index 667afe2e..42f6f9ec 100755 --- a/config.php.sample +++ b/config.php.sample @@ -4,4 +4,4 @@ define('PSM_DB_USER', 'db_user'); define('PSM_DB_PASS', 'db_pass'); define('PSM_DB_NAME', 'db_name'); define('PSM_DB_HOST', 'localhost'); - +define('PSM_BASE_URL', ''); diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index dad31b14..582f64aa 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -120,11 +120,12 @@ class InstallController extends AbstractController { } $config = array( - 'host' => 'localhost', - 'name' => '', - 'user' => '', - 'pass' => '', - 'prefix' => 'psm_', + 'db_host' => 'localhost', + 'db_name' => '', + 'db_user' => '', + 'db_pass' => '', + 'db_prefix' => 'psm_', + 'base_url' => '', ); $changed = false; @@ -140,10 +141,10 @@ class InstallController extends AbstractController { if($changed) { // test db connection $this->db = new \psm\Service\Database( - $config['host'], - $config['user'], - $config['pass'], - $config['name'] + $config['db_host'], + $config['db_user'], + $config['db_pass'], + $config['db_name'] ); if($this->db->status()) { @@ -275,11 +276,11 @@ class InstallController extends AbstractController { * @param array $db_vars prefix,user,pass,name,host * @return boolean|string TRUE on success, string with config otherwise */ - protected function writeConfigFile($db_vars) { + protected function writeConfigFile($array_config) { $config = " $value) { - $line = "define('PSM_DB_{key}', '{value}');".PHP_EOL; + foreach($array_config as $key => $value) { + $line = "define('PSM_{key}', '{value}');".PHP_EOL; $line = str_replace( array('{key}', '{value}'), array(strtoupper($key), $value), @@ -308,7 +309,7 @@ class InstallController extends AbstractController { 'name' => '', 'host' => '', ); - $pattern = "/define\('SM_DB_{key}', '(.*?)'/u"; + $pattern = "/define\('SM_{key}', '(.*?)'/u"; foreach($vars as $key => $value) { $pattern_key = str_replace('{key}', strtoupper($key), $pattern); diff --git a/src/templates/default/module/install/config_new.tpl.html b/src/templates/default/module/install/config_new.tpl.html index 64fe07ab..84be15c8 100644 --- a/src/templates/default/module/install/config_new.tpl.html +++ b/src/templates/default/module/install/config_new.tpl.html @@ -10,35 +10,42 @@
{{ macro.csrf_input() }} +

Please enter the application url:

+
+ +
+ +
+

Please enter your database info:

- +
- +
- +
- +
- +
@@ -60,4 +67,4 @@
{% endif %}
-{% endblock %} \ No newline at end of file +{% endblock %}