[aur-dev] [PATCH 1/3] confparser: Split loading of config into own function
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- web/lib/confparser.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php index 3977911..ae862d3 100644 --- a/web/lib/confparser.inc.php +++ b/web/lib/confparser.inc.php @@ -1,11 +1,16 @@ <?php -function config_get($section, $key) { +function config_load() { global $AUR_CONFIG; if (!isset($AUR_CONFIG)) { $AUR_CONFIG = parse_ini_file("../../conf/config", true, INI_SCANNER_RAW); } +} + +function config_get($section, $key) { + global $AUR_CONFIG; + config_load() return $AUR_CONFIG[$section][$key]; } -- 2.4.2
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- web/lib/confparser.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php index ae862d3..09fee5a 100644 --- a/web/lib/confparser.inc.php +++ b/web/lib/confparser.inc.php @@ -23,3 +23,10 @@ function config_get_bool($section, $key) { $val = strtolower(config_get($section, $key)); return ($val == 'yes' || $val == 'true' || $val == '1'); } + +function config_key_exists($key) { + global $AUR_CONFIG; + config_load(); + + return array_key_exists($key, $AUR_CONFIG); +} -- 2.4.2
On Sun, 14 Jun 2015 at 13:32:38, Johannes Löthberg wrote:
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- web/lib/confparser.inc.php | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php index ae862d3..09fee5a 100644 --- a/web/lib/confparser.inc.php +++ b/web/lib/confparser.inc.php @@ -23,3 +23,10 @@ function config_get_bool($section, $key) { $val = strtolower(config_get($section, $key)); return ($val == 'yes' || $val == 'true' || $val == '1'); } + +function config_key_exists($key) {
I'd rather call this config_section_exists() to make it clear that it checks for a section.
+ global $AUR_CONFIG; + config_load(); + + return array_key_exists($key, $AUR_CONFIG); +} -- 2.4.2
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- web/lib/confparser.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php index 09fee5a..2c49413 100644 --- a/web/lib/confparser.inc.php +++ b/web/lib/confparser.inc.php @@ -24,6 +24,13 @@ function config_get_bool($section, $key) { return ($val == 'yes' || $val == 'true' || $val == '1'); } +function config_items($section) { + global $AUR_CONFIG; + config_load(); + + return $AUR_CONFIG[$section]; +} + function config_exists($key) { global $AUR_CONFIG; config_load(); -- 2.4.2
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- web/lib/confparser.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php index b494058..c2459eb 100644 --- a/web/lib/confparser.inc.php +++ b/web/lib/confparser.inc.php @@ -24,6 +24,13 @@ function config_get_bool($section, $key) { return ($val == 'yes' || $val == 'true' || $val == '1'); } +function config_items($section) { + global $AUR_CONFIG; + config_load(); + + return $AUR_CONFIG[$section]; +} + function config_key_exists($key) { global $AUR_CONFIG; config_load(); -- 2.4.2
participants (2)
-
Johannes Löthberg
-
Lukas Fleischer