public function start() { header('Content-Type: text/html; charset=UTF-8'); Router::route_controller($this->name); if (Router::$dir) { require_once Router::$dir . Router::$controller . '.php'; } $controller_classname = ucfirst(Router::$controller) . '_Controller'; $controller = new $controller_classname(); $controller->__initialize_controller(); $controller->db =& $this->db; $controller->application =& $this; $controller->__loadView(); $this->currentController = $controller; if (!is_callable(array($controller, Router::$action))) { Fm::error(ACTION_NOT_FOUND); } else { call_user_func_array(array($controller, Router::$action), Router::$params); } // check CSS files $dir = opendir(Fm::relativePath() . '/' . $this->name . '/public/css'); if ($dir) { while ($file = readdir($dir)) { if ($file != '.' and $file != '..') { $this->stylesFiles[] = substr($file, 0, strpos($file, '.')); } } } }
/** * Autoloader function * * @param string $class class name */ public static function autoLoader($class) { $type = substr($class, strpos($class, '_'), strlen($class)); $lower_name = strtolower(str_replace('_' . $type, '', $class)); $type = str_replace(ucfirst($lower_name), '', $type); if (empty($type)) { foreach (self::$system_dirs as $dir) { if (file_exists($f = Fm::relativePath() . 'system/' . $dir . '/' . $lower_name . '.php')) { require_once $f; break; } } } }
private function initialize_file() { if ($this->controller) { if (!file_exists($f = Fm::relativePath() . '/' . $this->controller->application->name . '/views/' . $this->view_file . '.php')) { $f = $this->systemTemplate($this->view_file); } } else { $f = $this->systemTemplate($this->view_file); } if (!file_exists($f)) { Fm::error(INVALID_VIEW_FILE . ' (' . $this->view_file . ')'); } else { $this->full_view_file = $f; } }