aboutsummaryrefslogtreecommitdiff
path: root/lib/helper.php
diff options
context:
space:
mode:
authorMaZderMind2015-02-26 17:57:42 +0100
committerMaZderMind2015-02-26 17:57:42 +0100
commit6db2f0f4b9816ccd271332b89a05a9d0d753216b (patch)
treefd7ecf7cf16b33bdb75c45e747d12f9ecca43358 /lib/helper.php
parent9fb5b19bb0652b9c187c9b552c0a7ec4d6778222 (diff)
shuffle things around on the way to a bootstrap-based configurable website
Diffstat (limited to '')
-rw-r--r--lib/helper.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 2127c14..98397e4 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -96,3 +96,41 @@ function strtoduration($str)
$parts = explode(':', $str);
return ((int)$parts[0] * 60 + (int)$parts[1]) * 60;
}
+
+function has($keychain)
+{
+ return _has($GLOBALS['CONFIG'], $keychain);
+}
+function _has($array, $keychain)
+{
+ if(!is_array($keychain))
+ $keychain = explode('.', $keychain);
+
+ $key = $keychain[0];
+ if(!isset($array[$key]))
+ return false;
+
+ if(count($keychain) == 1)
+ return true;
+
+ return _has($array[$key], array_slice($keychain, 1));
+}
+
+function get($keychain, $default = null)
+{
+ return _get($GLOBALS['CONFIG'], $keychain, $default);
+}
+function _get($array, $keychain, $default)
+{
+ if(!is_array($keychain))
+ $keychain = explode('.', $keychain);
+
+ $key = $keychain[0];
+ if(!isset($array[$key]))
+ return $default;
+
+ if(count($keychain) == 1)
+ return $array[$key];
+
+ return _get($array[$key], array_slice($keychain, 1), $default);
+}