mirror of
https://gitlab.com/mojo42/Jirafeau.git
synced 2025-01-18 05:18:38 +01:00
[FEATURE] Install script: Simplify config generation
Simplify the generation of the local configuration file by replacing various loops with shorter PHP standard methods. This will cause the local configuration to have a slightly different style, but it is still an array therefore is readable and changeable by PHP developers.
This commit is contained in:
parent
af7e43a4a3
commit
e1c30044b1
35
install.php
35
install.php
@ -20,7 +20,7 @@
|
||||
define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
|
||||
define ('NL', "\n");
|
||||
define ('QUOTE', "'");
|
||||
define ('JIRAFEAU_CFG', JIRAFEAU_ROOT.'lib/config.local.php');
|
||||
define ('JIRAFEAU_CFG', JIRAFEAU_ROOT . 'lib/config.local.php');
|
||||
define ('JIRAFEAU_VAR_RAND_LENGTH', 15);
|
||||
|
||||
require (JIRAFEAU_ROOT . 'lib/settings.php');
|
||||
@ -40,32 +40,17 @@ jirafeau_quoted ($str)
|
||||
function
|
||||
jirafeau_export_cfg ($cfg)
|
||||
{
|
||||
$handle = fopen (JIRAFEAU_CFG, 'w');
|
||||
fwrite ($handle, '<?php' . NL);
|
||||
fwrite ($handle,
|
||||
'/* ' .
|
||||
t ('This file was generated by the install process. ' .
|
||||
$content = '<?php' . NL;
|
||||
$content .= '/* ' . t ('This file was generated by the install process. ' .
|
||||
'You can edit it. Please see config.original.php to understand the ' .
|
||||
'configuration items.') . ' */' . NL);
|
||||
foreach ($cfg as $key => $item)
|
||||
{
|
||||
fwrite ($handle, '$cfg[' . jirafeau_quoted ($key) . '] = ');
|
||||
if (is_bool ($item))
|
||||
fwrite ($handle, ($item ? 'true' : 'false'));
|
||||
else if (is_string ($item))
|
||||
fwrite ($handle, jirafeau_quoted ($item));
|
||||
else if (is_int ($item))
|
||||
fwrite ($handle, $item);
|
||||
else if (is_array ($item))
|
||||
fwrite ($handle, str_replace(array("\n", "\r"), "",
|
||||
var_export ($item, true)));
|
||||
else
|
||||
fwrite ($handle, 'null');
|
||||
fwrite ($handle, ';'.NL);
|
||||
'configuration items.') . ' */' . NL;
|
||||
$content .= '$cfg = ' . var_export($cfg, true) . ';';
|
||||
|
||||
$fileWrite = file_put_contents(JIRAFEAU_CFG, $content);
|
||||
|
||||
if (false === $fileWrite) {
|
||||
jirafeau_fatal_error(t('Can not write local configuration file'));
|
||||
}
|
||||
/* No newline at the end of the file to be able to send headers. */
|
||||
fwrite ($handle, '?>');
|
||||
fclose ($handle);
|
||||
}
|
||||
|
||||
function
|
||||
|
@ -21,10 +21,13 @@ global $cfg;
|
||||
|
||||
// Read config files
|
||||
require (JIRAFEAU_ROOT . 'lib/config.original.php');
|
||||
|
||||
if (file_exists(JIRAFEAU_ROOT . 'lib/config.local.php'))
|
||||
{
|
||||
// read local copy and merge with original values
|
||||
$cfgOriginal = $cfg;
|
||||
require (JIRAFEAU_ROOT . 'lib/config.local.php');
|
||||
$cfg = array_merge($cfgOriginal, $cfg);
|
||||
unset($cfgOriginal);
|
||||
}
|
||||
|
||||
/* Jirafeau constants */
|
||||
|
Loading…
x
Reference in New Issue
Block a user