<?php /** * This file starts x4xphp framework's main program, * load config, execute filter, find Controller and execute it, etc * @author yangrl <*****@*****.**> */ namespace CORE; include_once COREPATH . 'common.php'; // x4xphp run process: // read config // find required class and method //var_dump($_SERVER); $parsed = parseUri($_SERVER['REQUEST_URI']); if (is_array($parsed)) { list($path, $class, $method) = $parsed; $c = findController($class, $path); $c->_execute($method); } else { show404(); } // execute controller
requireOnly("bin", array("init.php")); //=============================================== // Config //=============================================== $config = new Config(); $GLOBALS['config'] = $config->getConfig(); // load config and other initiators (dependent on helpers) requireAll("bin", array("init.php")); //=============================================== // Session //=============================================== session_start(); //=============================================== // Start the controller //===============================================s $controller = findController($url['path']); $output = new $controller('controllers/', WEB_FOLDER, DEFAULT_ROUTE, DEFAULT_ACTION); //=============================================== // Helpers //=============================================== // Lookup available dirs in our environment function lookUpDirs() { if (defined("APP")) { // check if there is a directory in that location if (is_dir(APP)) { // do nothing atm, this condition will evaluate just true in MOST cases } else { // create it if not mkdir(APP, 0775); }
function __construct($view = false, $vars = false, $data = false) { parent::__construct($view, $vars); // find the requested controller from the path $class = findController($this->data["vars"]["path"]); // get the data for the specific URI $this->data['items'] = $class::getBody($this->data["vars"]["path"]); // currently override the view set by the parent section class //$this->view = ( $view ) ? getPath('views/'.$class.'/body-'.$view.'.php') : getPath('views/'.$class.'/body.php'); $this->view = getPath('views/' . strtolower($class) . '/body.php'); // render the section $this->render(); }