Exemple #1
0
 /**
  * run
  * the main() to this whole darned thing.
  *
  * @param array $configuration
  */
 public static function run(array $configuration)
 {
     define('DS', DIRECTORY_SEPARATOR);
     define('ROOT', __DIR__);
     // having short_open_tag enabled is a dirp
     // requirement.
     if (!ini_get('short_open_tag')) {
         throw new \Exception("The 'short_open_tag' setting MUST be enabled in your php.ini to use dirp, sorry!");
     }
     // setup the autoloader and the exception handler:
     set_exception_handler(array('\\dirp\\app', 'exception_handler'));
     static::_autoloader_init();
     static::$_cfg = new helper\params($configuration);
     static::$_http_request = http\request::factory($_GET, $_POST, $_SERVER);
     static::$_http_response = new http\response();
     // prepare addons:
     if ($addons = static::cfg()->addons) {
         addon\manager::load_addons((array) $addons);
     }
     // the master view is the frame/template around
     // the main content area. addons have access to
     // it directly through the \dirp\addon\base::master
     // method.
     static::$_master = view::factory('master/template', array('title' => 'dirp framework', 'body' => '', 'icon' => 'folder_heart.png', 'panels' => addon\event::fire('renderpanels', array('panels' => array()))->panels, 'css' => array(), 'js' => array(), 'head' => array()));
     addon\base::set_master_view(static::$_master);
     // dispatch the request and figure out what to do with
     // the controller's response:
     // TO-DO: HEY THE WAY CONTROLLER RETURNS ARE HANDLED IS KINDA FLAKY.
     if ($ret = router::dispatch(static::get_request(), static::get_response())) {
         if (is_string($ret)) {
             if (static::get_request()->is_ajax()) {
                 static::get_response()->header('content-type', 'text/plain');
                 static::get_response()->write($ret);
                 static::get_response()->send();
             } else {
                 static::get_master()->body = $ret;
             }
         }
     }
     static::get_response()->write(static::get_master()->render());
     addon\event::fire('shutdown', array());
     static::get_response()->send();
 }
Exemple #2
0
    $path = substr(Path, strlen(Path) - strlen("/")) == "/" ? Path : Path . "/";
    $registry->path = $path;
    if (!defined('requiresBD')) {
        $db = new dbFactory(strtolower(DB_Engine));
    } else {
        if (requiresBD) {
            $db = new dbFactory(strtolower(DB_Engine));
        } else {
            $db = null;
        }
    }
    $registry->db = $db;
    $views = new appviews();
    $registry->views = $views;
    $themes = new themes();
    $registry->themes = $themes;
    $session = session::getInstance();
    $registry->session = $session;
    $cookie = cookie::getInstance();
    $registry->cookie = $cookie;
    $router = new router();
    $registry->router = $router;
    $debug = debug::getInstance();
    $registry->debug = $debug;
    $registry->validateErrors = array();
    $router->dispatch();
    // Here starts the party
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}
Exemple #3
0
		}
	}
	$registry->db = $db;

	$views = new appviews();
	$registry->views = $views;

	$themes = new themes();
	$registry->themes = $themes;

	$session = session::getInstance();
	$registry->session = $session;

	$cookie = cookie::getInstance();
	$registry->cookie = $cookie;

	$router = new router();
	$registry->router = $router;
	
	$debug = debug::getInstance();
	$registry->debug = $debug;
	
	$registry->validateErrors = array();

	$router->dispatch(); // Here starts the party

} catch(Exception $e) {
	echo $e->getMessage();
	exit();
}
?>