routing tweaks

This commit is contained in:
Timothy Warren 2012-05-15 11:22:16 -04:00
parent c895797f48
commit 67fc68c904

View File

@ -263,7 +263,7 @@ function route()
unset($custom_routes['default_controller']); unset($custom_routes['default_controller']);
unset($custom_routes['404_handler']); unset($custom_routes['404_handler']);
foreach($custom_routes as $uri => $map) foreach($custom_routes as $uri => &$map)
{ {
if (preg_match("`{$uri}`i", $pi)) if (preg_match("`{$uri}`i", $pi))
{ {
@ -290,17 +290,25 @@ function route()
$num_segments = count($segments); $num_segments = count($segments);
} }
// Determine route based on uri segments
if ($num_segments === 1) if ($num_segments === 1)
{ {
$func = $pi; $func = $pi;
} }
elseif ($num_segments === 2)
if ($num_segments === 2)
{ {
list($controller, $func) = $segments; list($module, $controller) = $segments;
// If it's just controller/function
if ($controller == 'index')
{
$controller = $module;
$module = $routes['default_module'];
$func = 'index';
} }
if ($num_segments >= 3) }
elseif ($num_segments >= 3)
{ {
list($module, $controller, $func) = $segments; list($module, $controller, $func) = $segments;
} }