function callRoute($request = null) { if (!isset($request)) { $request = $this->getRequest(); } //D::log($this->loadController(), 'controller funcj'); f_call($this->loadController()); }
function __call($var, $args=array()) { if(array_key_exists($var, $this->__model->rowMethods)) { //D::show(array_merge(array($this), $args), 'rowmethod'); return f_call($this->__model->rowMethods[$var], array_merge(array($this), $args)); } }
function loadController($fileName, $part=0) { D::log($fileName, 'Loading Controller…'); //$fileName = Events::callEvent('loadController', $fileName); require(LOC . 'Controllers/' . $fileName); //print_r($this); static $partCount = 0; $class = substr(strrchr('/' . $fileName, '/'), 1, -4); $page = $this->lib->Uri->loadUrl($class::$urlPattern, $part); if(is_array(f_last($page))) { if(is_array( f_first(f_last($page)) )) { $this->loadController(f_first(f_first(f_last($page))), $part+1); return true; } $page[$part] = f_first(f_last($page)); //D::log($page[$part], 'page o parts'); } D::log($page, 'Loading Controller…'); $this->controller = new $class(); $this->controller->getLibrary('Databases/Query.php'); /*@todo make "shortcuts" more dynamic */ $this->controller->template =& $this->controller->lib->Template; if(empty($page[$part])) { echo $this->controller->index(); } else { if(method_exists($class, $page[$part])) { echo f_call(array( $this->controller, $page[$part] )); return true; } else { return f_function(function() { header("HTTP/1.0 404 Not Found"); echo '<h1>404 error</h1>'; //todo check for some sort of custom 404… }); } } D::log($page, 'controller method array'); }
function callRoute($request=null, $controller=null) { if(isset($request)) { $this->request = $request; } echo f_call($this->loadController()); }