summaryrefslogtreecommitdiff
path: root/app.php
diff options
context:
space:
mode:
Diffstat (limited to 'app.php')
-rw-r--r--app.php19
1 files changed, 18 insertions, 1 deletions
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;
+}