From 1a0f66cc9c914477141b71ce02e078e1f9579351 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 9 Sep 2013 16:05:52 -0400 Subject: [PATCH] Dot syntax URIs weren't erroring correctly Instead of routing to a 404 or home, was just returning [] (empty JSON array). Updated to redirect home for the time being. 404 handling needs to be addressed soon anyway, it's kinda junk right now --- classes/Controller.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/classes/Controller.php b/classes/Controller.php index 28a6115..495420c 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -98,7 +98,7 @@ class Controller extends Object } // Loads the module's information - list($module_class, $module_filename, $template_basename, $css_class, $js_basename) = $this->prepareVariables($request); + list($module_class, $module_filename, $template_basename, $css_class, $js_basename, $dot_syntax) = $this->prepareVariables($request); unset($request); @@ -116,7 +116,11 @@ class Controller extends Object } else { - if ($this->config->pickles['logging'] === true) + if ($dot_syntax) + { + Browser::goHome(); + } + elseif ($this->config->pickles['logging'] === true) { Log::warning('Class named ' . $module_class . ' was not found in ' . $module_filename); } @@ -326,7 +330,7 @@ class Controller extends Object $valid_request = false; $valid_security_hash = false; - $error_message = 'An unexpected error has occurred'; + $error_message = 'An unexpected error has occurred.'; // Determines if the request method is valid for this request if ($module->method !== false) @@ -477,7 +481,9 @@ class Controller extends Object */ public function prepareVariables($basename) { - if (strpos($basename, '.') !== false) + $dot_syntax = strpos($basename, '.') !== false; + + if ($dot_syntax) { list($basename, $action) = explode('.', $basename, 2); $action = str_replace('.', '_', $action); @@ -504,7 +510,7 @@ class Controller extends Object $module_class = preg_replace('/(-(.{1}))/e', 'strtoupper("$2")', $module_class); } - return array($module_class, $module_filename, $template_basename, $css_class, $js_basename); + return array($module_class, $module_filename, $template_basename, $css_class, $js_basename, $dot_syntax); } }