From c4f65aaa0a142761e5a538d3325bed24b63f903d Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 2 Sep 2016 11:18:56 +0200 Subject: [PATCH] Dispatcher: check actions before tags. --- models/Dispatcher.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/models/Dispatcher.php b/models/Dispatcher.php index 3647905..627c9c7 100644 --- a/models/Dispatcher.php +++ b/models/Dispatcher.php @@ -36,23 +36,24 @@ class Dispatcher $_SERVER['PATH_INFO'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); } - // Nothing in particular? Just show the root of the album list. + // Just showing the album index? if (empty($_SERVER['PATH_INFO']) || $_SERVER['PATH_INFO'] == '/') { return new ViewPhotoAlbum(); } + // Look for particular actions... + elseif (preg_match('~^/(?[a-z]+)/?~', $_SERVER['PATH_INFO'], $path) && isset($possibleActions[$path['action']])) + { + $_GET = array_merge($_GET, $path); + return new $possibleActions[$path['action']](); + } // An album, person, or any other tag? elseif (preg_match('~^/(?.+?)(?:/page/(?\d+))?/?$~', $_SERVER['PATH_INFO'], $path) && Tag::matchSlug($path['tag'])) { $_GET = array_merge($_GET, $path); return new ViewPhotoAlbum(); } - // Look for an action... - elseif (preg_match('~^/(?[a-z]+)(?:/page/(?\d+))?/?~', $_SERVER['PATH_INFO'], $path) && isset($possibleActions[$path['action']])) - { - $_GET = array_merge($_GET, $path); - return new $possibleActions[$path['action']](); - } + // No idea, then? else throw new NotFoundException(); }