diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-05-27 15:12:38 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-05-27 15:12:38 +0300 |
commit | 4b4c5271adf657331c867e79f88044d3317901ef (patch) | |
tree | 28a9699bd850b28e9c9cf9e2a508046d176cc6a0 /MainApp.php | |
parent | d462d86f086c812599f226861539829d427915e7 (diff) | |
download | main-4b4c5271adf657331c867e79f88044d3317901ef.tar.gz main-4b4c5271adf657331c867e79f88044d3317901ef.tar.bz2 main-4b4c5271adf657331c867e79f88044d3317901ef.zip |
fixes
Diffstat (limited to 'MainApp.php')
-rw-r--r-- | MainApp.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/MainApp.php b/MainApp.php index 759a522..a74c6d4 100644 --- a/MainApp.php +++ b/MainApp.php @@ -11,7 +11,6 @@ * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ - class MainApp { //// @@ -30,15 +29,15 @@ class MainApp if (strlen($param) < 1) { $action = self::conf('defaults.action'); } - + // fire up the output buffer ob_start(); - // dispatch correct controller + // dispatch requested controller $controller = self::classname($controller); - $c = new $controller; + $c = new $controller(); - // assume no method name was given, try $param, then default to defaultAction + // assume no method name was given, try $param // URL format is always controller/param/action if (method_exists($c, $action)) { return $c->$action($_POST); @@ -49,15 +48,16 @@ class MainApp return $c->$param($_POST); } - // controller/param + // ...then fall back to defaultAction if (method_exists($c, $c->defaultAction)) { $action = $c->defaultAction; return $c->$action($_POST); } - self::error("{$controller}/{$action}: no such method"); + // don't know what to do, giving up... + self::error("no such method: {$controller}/{$action}"); - // release the output buffer + // release the output buffer, normally this is done in render() ob_end_flush(); } @@ -65,13 +65,15 @@ class MainApp //// // requests should always be in the form: controller/action/parameters.type // Strip type info since it's not needed at this point - static function url($part = false) + static function url($part = FALSE) { $url = parse_url($_SERVER['REQUEST_URI']); - if ($part == 'query') { - return $url['query']; - } + if ($part == 'query') { + if (isset($url['query'])) { + return $url['query']; + } + } $req = ltrim($url['path'], '/'); $array = explode('/', preg_replace('/\.\w+$/', '', $req)); |