Exemplo n.º 1
0
function route($controller, $query)
{
    $controllers = array("News", "Contact", "Admin");
    if (in_array(@$controller, $controllers)) {
        switch ($controller) {
            case "News":
                $myController = new NewsController($query);
                break;
            case "Contact":
                $myController = new ContactController($query);
                break;
            case "Admin":
                $myController = new AdminController($query);
                break;
        }
        $myController->render($query);
    } else {
        $myController = new NewsController('News');
        $myController->render($query);
        if (@$controller != null) {
            $message = "Site which you want to connect does not exists";
            echo "<script type='text/javascript'>alert('{$message}');</script>";
        }
    }
}