/** * @return mixed|null */ public static function get_manifest() { if (!self::$config_manifest) { self::$config_manifest = unserialize(file_get_contents(TEMP_PATH . '/config_manifest')); } return self::$config_manifest; }
/** * */ public static function route() { $url = $_GET['url']; $base = ConfigManifest::get_config('BasePath'); if ($base && $base != '/' && strpos($url, $base) === 0) { $url = substr($url, strlen($base)); } if (empty($url)) { $url = '/'; } $parts = explode('/', $url); array_shift($parts); $response = new View(); $action = "index"; if (count($parts) == 1 && $parts[0] == "") { $parts[0] = 'home'; } if (count($parts) > 1 && $parts[1] != "") { $action = trim($parts[1]); } $processed = false; if ($parts[0] && ClassManifest::has_class($parts[0]) && ClassManifest::is_a($parts[0], 'Controller')) { $page = new Page(); $page->ID = -1; $page->URLSegment = $parts[0]; $page->Title = 'Default Controller'; $controller = new $parts[0](); if (method_exists($controller, 'getDefaultRecord')) { $page = $controller->getDefaultRecord(); } $controller->setRecord($page); $response->setController($controller); if (method_exists($controller, $action)) { $response->setContents($controller->{$action}()); $processed = true; } } else { if ($page = Page::find_one("URLSegment = '" . DB::raw2sql($parts[0]) . "'")) { $controller = $page->getController(); $response->setController($controller); if (method_exists($controller, $action)) { $response->setContents($controller->{$action}()); $processed = true; } } } if (!$processed) { $controller = new NotFoundController(); $page = $controller->getDefaultRecord(); $controller->setRecord($page); $response->setController($controller); $response->setContents($controller->index()); } if (!headers_sent()) { http_response_code($controller->getHTTPCode()); } echo $response->render(); }
public static function init() { $host = ConfigManifest::get_config('Database.host'); $user = ConfigManifest::get_config('Database.user'); $pass = ConfigManifest::get_config('Database.password'); $database = ConfigManifest::get_config('Database.db'); if ($host && $user && $pass && $database) { self::$conn = new mysqli($host, $user, $pass, $database); } else { user_error('I can\'t find any database records', E_USER_WARNING); } }
public function getBase() { return ConfigManifest::get_config('BasePath'); }
public static function reload_manifest() { self::build_file_manifest(BASE_PATH); ClassManifest::make_manifest(); ConfigManifest::make_manifest(); }