From 1730e54d3423a8d0ab3a2bd9791575b59ab399cc Mon Sep 17 00:00:00 2001 From: horus Date: Fri, 12 Mar 2021 23:33:11 +0100 Subject: Add faces as submodule --- app.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app.php') diff --git a/app.php b/app.php index e436e42..53ca7eb 100644 --- a/app.php +++ b/app.php @@ -7,7 +7,7 @@ $twig = new \Twig\Environment($loader); # no cache $function = new \Twig\TwigFunction('is_active', function($route) { $url = strtok($_SERVER["REQUEST_URI"], '?'); - if ( $url == $route ) { + if ( str_starts_with($url, $route) ) { echo " active "; } }); @@ -18,3 +18,20 @@ $function = new \Twig\TwigFunction('maincss', function() { }); $twig->addFunction($function); + +/** + * Debug + */ +$function = new \Twig\TwigFunction('dump', function($data) { + var_dump($data); +}); +$twig->addFunction($function); + +function get_faces(){ + return json_decode( file_get_contents( __DIR__ . '/views/tools/faces/faces.json' ), true ); +} + +function str_starts_with( $haystack, $needle ) { + $length = strlen( $needle ); + return substr( $haystack, 0, $length ) === $needle; +} -- cgit v1.2.3