Código PHP:
   class FrontController{    
 
    var $controller;
    var $dbObject;
    var $phpvars;
    var $contentsVars;
    
    function __construct(){
                
        include "controllers/BaseController.php"; 
        $baseController = new BaseController(); 
        $baseController->defineConstants();
        
        include "models/Model.php"; 
        $this->dbObject = new dbConsults();
        
        
        /* Translations for the UI */
        $this->phpvars = $baseController->varsConsult($this->dbObject); 
                
        // utf-8 fixer
        include (APP_LIB."fixEncoding.php"); 
        
        $this->includeControllers();
        
        /*** init View ****/
        include "views/View.php";            
        $whichView = $this->chooseView(); //$whichView = $this->chooseView(); // template name    
        $View = new View($whichView); // display view
        $View->prepareContents($this->phpvars, $this->contentsVars);
        $View->render();
    }    
    
    private function chooseView(){
        
        if ( isset($_GET['login']) )        
            $response = TEMPLATES."login.tpl.php";
        
        elseif ( isset($_GET['register']) )        
            $response = TEMPLATES."registration.tpl.php";
        
        elseif ( isset($_GET['lostpassword']) )        
            $response = TEMPLATES."lostpassword.tpl.php";
            
        elseif(isset($download))            
            $response = TEMPLATES."contents.download.tpl.php";
        
        elseif(!isset($_SESSION['name']))        
            $response = TEMPLATES."contents.NoLogued.tpl.php";
        
        elseif(isset($_SESSION['name']))        
            $response = TEMPLATES."contents.Logued.tpl.php";    
            
        return $response;    
    }
 
    private function includeControllers()
    {
        
        if (isset($_GET['login']))
        {    
        
            include "controllers/LoginController.php"; 
            $LoginController = new LoginController($this->dbObject);
            $this->contentsVars['usersData'] = $LoginController->checkUser();                    
        }    
        elseif (isset($_GET['register']))
        {    
        
            include "controllers/RegistrationController.php"; 
            $RegistrationController = new RegistrationController($this->dbObject);
            $this->contentsVars['usersData'] = $RegistrationController->registerUser();    
        }
        elseif (isset($_GET['logout']))
        {    
        
            include "controllers/LoginController.php"; 
            $LoginController = new LoginController($this->dbObject);
            $LoginController->logout();
        }    
        elseif (isset($_GET['lostpassword']))
        {    
        
            include "controllers/RememberPassController.php"; 
            $RememberPassController = new RememberPassController($this->dbObject);
            $this->contentsVars['usersData'] = $RememberPassController->rememberPassword();
        }
        elseif (!isset($_GET['load']) and (FILENAME == "index"))
        {
            
            include "controllers/MainPageController.php"; 
            $MainPageController = new MainPageController();
            $this->contentsVars['tutorialsList'] = $MainPageController->listTutorials($this->phpvars, $this->dbObject);                        
        }
        else{
        
            include "controllers/PageController.php"; 
            $PageController = new PageController($this->dbObject);
            $this->contentsVars['theContents'] = $PageController->printPageContents();    
        }
        
        include "controllers/MenusController.php"; 
        $MenusController = new MenusController($this->dbObject);
        $this->contentsVars['mainLinks'] = $MenusController->printMainMenu( $this->phpvars );
        @$this->contentsVars['relPages']  = $MenusController->printSecondaryMenu( $contentsVars['theContents']['relatedPages'] );
        
        include "controllers/TagsController.php"; 
        $TagsController = new TagsController($this->dbObject);
        $this->contentsVars['theTags'] = $TagsController->tag_cloud();
    }    
    
} 
    
 



