コード例 #1
0
 function __construct()
 {
     $this->prepareUrl();
     // load controller with /setup/Loader::loadController()
     $controller = Loader::loadController($this->_controller);
     // runAction($action, Array $arg)
     // method from main Controler /lib/Controller.php
     $controller->runAction($this->_action, $this->_args);
 }
コード例 #2
0
ファイル: router.php プロジェクト: prafiny/wolf_framework
 /**
  * Each time a page will be load, this method will be called each time
  *
  * TODO : How are we supposed to provide the request string like so if it is a singleton? 
  *			Maxime Martineau
  *
  * @method parseRequest
  * @access public
  * @param string $request URL of the requested page
  * @return void
  * @author Quentin LOZACH 
  * @version 0.1
  */
 public function parseRequest($request = FALSE)
 {
     // Load the Loader class
     include BASE_PATH . '/core/loader/loader.php';
     // Instanciation of the loader which will load every file on the project
     $loader = new Loader();
     // Are we on the index page or note ?
     switch ($request) {
         // We are on the index page
         case FALSE:
             // Load the mainController, the index method, mainView
             $this->controller = "mainController";
             $this->method = "index";
             $this->params = NULL;
             $loader->loadController($this->controller);
             break;
             // We are on another page so load the Controller and the model with the same name
         // We are on another page so load the Controller and the model with the same name
         default:
             // Load the mainController, mainView and mainModel
             $requestExploded = explode("/", $request);
             // If the user is trying to load a file directly in the URL such as : .php, .html, .css, .js, .sql ...
             $requestSecured = explode(".", $request);
             // If there is only a controller with no method, raise an error with error() method
             if (empty($requestExploded[1]) && !empty($requestExploded[0])) {
                 $this->error("empty-method");
             } else {
                 // If requestSecured[1] is not empty the user tried to load a file in the URL
                 if (isset($requestSecured[1])) {
                     // The controller is the name of the 1st param but cleaned with the explode
                     $this->controller = $requestSecured[0];
                 } else {
                     // The controller is the first parameter of the URL
                     $this->controller = $requestExploded[0];
                 }
                 // The method is the second parameter of the URL
                 $this->method = $requestExploded[1];
             }
             // Getting parameters, so let's keep only useful informations
             unset($requestExploded[0]);
             unset($requestExploded[1]);
             // Getting the rest of the parameters in the $_GET['request'] in the URL
             if (!empty($requestExploded[2])) {
                 $this->params = $requestExploded;
             } else {
                 $this->params = NULL;
             }
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: redspade-/monkimvc
if($_SERVER['SERVER_ADDR']=='127.0.0.1')
{
	/*PHP error settings*/
	error_reporting(E_ALL ^ E_NOTICE);
	ini_set('display_errors','On'); 
	
	$sConfig = 'development';
}
else
{
	
}

//load config
$aConfig = parse_ini_file("applications/{$sConfig}.ini", true);

//constants
$oLoader->loadClass('Constants');

//call Bootstrap
include('applications/Bootstrap.php');


$oController = $oLoader->loadController($controller);

//call action
$oController->$action();

$oLoader->renderView($oController, $action);
コード例 #4
0
<?php

require_once "Loader.php";
require_once 'Router.php';
include_once realpath("controllers/baseController.php");
include_once realpath("models/baseModel.php");
Loader::loadClass('Session');
Loader::loadClass('Cookie');
Session::start();
//Loader::loadClass('Cookie');
//Cookie::set('interval', "100", "1", "/", false, false);
//Cookie::set('intervalDrugi', "100", "1", "/", false, false);
//$cookie = Cookie::get("interval");
//var_dump($cookie);
//$del = Cookie::delete("intervalDrugi");
//var_dump($del);
/**
 * $_GET['rt'] automatski setova u .htaccess fajlu regularnim izrazom
 */
$route = new Router($_GET['rt']);
$controller = $route->getController();
$method = $route->getMethod();
$params = $route->getParams();
Loader::loadController($controller, $method, $params);