Added comments to config.php to clarify use

Signed-off-by: Diederik de Groot <ddegroot@talon.nl>
This commit is contained in:
Diederik de Groot
2020-02-18 18:31:41 +01:00
parent 3a4286628e
commit 6dae0556b2

View File

@@ -65,7 +65,7 @@ class ConfigParser {
'; ';
function __construct($base_path, $config_file) { function __construct($base_path, $config_file) {
# Merge config # Merge defaults with ini file
$default_config = $this->parse_multi_ini_string($this->defaults,true,INI_SCANNER_TYPED); $default_config = $this->parse_multi_ini_string($this->defaults,true,INI_SCANNER_TYPED);
$ini_config = $this->parse_multi_ini_file("$base_path/$config_file", true, INI_SCANNER_TYPED); $ini_config = $this->parse_multi_ini_file("$base_path/$config_file", true, INI_SCANNER_TYPED);
if (!empty($ini_config)) { if (!empty($ini_config)) {
@@ -77,7 +77,13 @@ class ConfigParser {
$this->config = $config; $this->config = $config;
} }
private $tree_structure = Array( /*!
* replace config['subdirs'] paths using tree_structure
* method imported from old version (and rewritten)
* Note: Still not sure if we actually need to do all this
*/
private function replaceSubdirTreeStructure($tmpSubdirs) {
$tree_structure = Array(
'etc' => array('parent' => NULL, "strip" => true), 'etc' => array('parent' => NULL, "strip" => true),
'tftproot' => array('parent' => NULL, "strip" => true), 'tftproot' => array('parent' => NULL, "strip" => true),
'settings' => array('parent' => 'tftproot', "strip" => true), 'settings' => array('parent' => 'tftproot', "strip" => true),
@@ -88,10 +94,9 @@ class ConfigParser {
'languages' => array('parent' => 'locales', "strip" => false), 'languages' => array('parent' => 'locales', "strip" => false),
'countries' => array('parent' => 'locales', "strip" => false), 'countries' => array('parent' => 'locales', "strip" => false),
); );
function replaceSubdirTreeStructure($tmpSubdirs) {
# replace config['subdirs'] paths using tree_structure
$subdirs = Array(); $subdirs = Array();
foreach ($this->tree_structure as $key => $value) { foreach ($tree_structure as $key => $value) {
if (!empty($tmpSubdirs[$key])) { if (!empty($tmpSubdirs[$key])) {
if (substr($tmpSubdirs[$key], 0, 1) !== "/") { if (substr($tmpSubdirs[$key], 0, 1) !== "/") {
if (!$value['parent']) { if (!$value['parent']) {
@@ -110,6 +115,11 @@ class ConfigParser {
return $subdirs; return $subdirs;
} }
/*!
* config parser that understands multidimensional ini entries
* using "." as the dimension separator
* standin replacement for parse_ini_string
*/
private function parse_multi_ini_string($string, $process_sections = false, $scanner_mode = INI_SCANNER_NORMAL) { private function parse_multi_ini_string($string, $process_sections = false, $scanner_mode = INI_SCANNER_NORMAL) {
$explode_str = '.'; $explode_str = '.';
$escape_char = "'"; $escape_char = "'";
@@ -154,8 +164,12 @@ class ConfigParser {
return $data; return $data;
} }
/*!
* config file parser that understands multidimensional ini entries
* using "." as the dimension separator
* standin replacement for parse_ini_file
*/
private function parse_multi_ini_file($file, $process_sections = false, $scanner_mode = INI_SCANNER_NORMAL) { private function parse_multi_ini_file($file, $process_sections = false, $scanner_mode = INI_SCANNER_NORMAL) {
// load ini file the normal way
$string = file_get_contents($file); $string = file_get_contents($file);
return $this->parse_multi_ini_string($string, $process_sections, $scanner_mode); return $this->parse_multi_ini_string($string, $process_sections, $scanner_mode);
return $data; return $data;