Skip to content

Commit

Permalink
routing fix, is never empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sb0y committed May 4, 2013
1 parent c988b42 commit cc2ae5c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
5 changes: 5 additions & 0 deletions adm/engine/controllers/ajax.php
Expand Up @@ -40,4 +40,9 @@ function requestModels (&$modelsNeeded)
{
$modelsNeeded = array();
}

function start()
{

}
}
5 changes: 5 additions & 0 deletions adm/engine/controllers/blog.php
Expand Up @@ -25,6 +25,11 @@ function index()
{
$this->posts();
}

function start()
{

}

function writePost()
{
Expand Down
6 changes: 5 additions & 1 deletion adm/engine/controllers/index.php
Expand Up @@ -31,5 +31,9 @@ function requestModels (&$modelsNeeded)
{
$modelsNeeded = array("blog");
}


function start()
{

}
}
5 changes: 5 additions & 0 deletions adm/engine/controllers/portfolio.php
Expand Up @@ -26,6 +26,11 @@ function index()
$this->items();
}

function start()
{

}

function requestModels (&$modelsNeeded)
{
$modelsNeeded = array("blog");
Expand Down
5 changes: 5 additions & 0 deletions adm/engine/controllers/users.php
Expand Up @@ -26,6 +26,11 @@ function index()
system::setParam ("page", "users");
blog::buildList ("users");
}

function start()
{

}

function edit()
{
Expand Down
4 changes: 1 addition & 3 deletions engine/controllers/blog.php
Expand Up @@ -25,7 +25,7 @@ function index()
{
system::setParam ("page", "post");

if (!empty ($this->args[0]))
if ($this->args[0] != "blog")
{
$cacheID = $this->args[0]."|POST";
$this->smarty->setCacheID ($cacheID);
Expand All @@ -52,8 +52,6 @@ function index()
}
}
} else system::redirect ("/");

//$this->smarty->clearCache ("post.tpl");
}

function start()
Expand Down
2 changes: 1 addition & 1 deletion engine/controllers/index.php
Expand Up @@ -23,7 +23,7 @@ class controller_index extends controller_base
{
function index()
{
if (!isset ($this->args[0]))
if ($this->args[0] == "index")
{
$this->smarty->setCacheID ("MAINPAGE|offset_0");
if (!$this->smarty->isCached ("main.tpl", "MAINPAGE|offset_0"))
Expand Down
11 changes: 6 additions & 5 deletions engine/core/class.router.php
Expand Up @@ -106,25 +106,28 @@ private function getController (&$file, &$controller, &$action, &$args)

$controller = array_shift ($parts);

if (empty($controller)) { $controller = "index"; }
if (empty($controller)) $controller = "index";

$action = array_shift ($parts);

if (empty($action)) { $action = "index"; }
if (empty($action)) $action = "index";

$file = $this->path."/$controller.php";

$this->args[] = $controller;

if (!is_readable ($file))
{

if (!is_readable (TPL_PATH."/static/$controller.tpl"))
{
throw new Exception ("404 Not Found (file $file is NOT readable)", 404);
} else {
$this->args[] = $controller;
$this->smarty->setCacheID ("STATIC|".$controller);
$controller = "index";
$file = $this->path."/index.php";
}

}

$args = $parts;
Expand Down Expand Up @@ -152,8 +155,6 @@ function delegate()
$controllerObject->start();
$modelsNeeded[] = "index";
$this->loadModels ($modelsNeeded, $controllerName);

$this->args[] = $controllerName;

$controllerObject->$controllerAction();

Expand Down

0 comments on commit cc2ae5c

Please sign in to comment.