From f6c0270d40f6730fe1e1820f2866b08792df1db6 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 10 Dec 2016 18:22:34 +0100 Subject: rewrite data-model so that every configuration option is accessed through the conference --- lib/helper.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/helper.php') diff --git a/lib/helper.php b/lib/helper.php index 4fce91e..df7f329 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -18,14 +18,20 @@ function baseurl() if(startswith('//', $base)) $base = proto().':'.$base; - return forceslash(forceslash($base).@$GLOBALS['MANDATOR']); + return forceslash($base); } $base = ssl() ? 'https://' : 'http://'; $base .= $_SERVER['HTTP_HOST']; $base .= forceslash(dirname($_SERVER['SCRIPT_NAME'])); - return forceslash(forceslash($base).@$GLOBALS['MANDATOR']); + return forceslash($base); +} + +function joinpath($parts) +{ + $parts = array_map('forceslash', $parts); + return rtrim(implode('', $parts), '/'); } function forceslash($url) -- cgit v1.2.3 From 35e7a2b2adad42b077de60d1566c22da62edeb77 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 18 Dec 2016 13:31:34 +0100 Subject: move upcoming & current logic from javascript/ajax into php --- lib/helper.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/helper.php') diff --git a/lib/helper.php b/lib/helper.php index df7f329..1925382 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -114,3 +114,34 @@ function url_params() return ''; } + +/** + * returns the fielst element matching $predicate or null, if none matched. + * $predicate is a callable that receives one array value at a time and can + * return a bool'ish value + */ +function array_filter_first($array, $predicate) +{ + foreach ($array as $value) { + if( $predicate($value) ) { + return $value; + } + } + + return null; +} +/** + * returns the fielst element matching $predicate or null, if none matched. + * $predicate is a callable that receives one array value at a time and can + * return a bool'ish value + */ +function array_filter_last($array, $predicate) +{ + foreach (array_reverse($array) as $value) { + if( $predicate($value) ) { + return $value; + } + } + + return null; +} -- cgit v1.2.3