public static function find($filename) { if (($resource = Plugins::find(self::WWW_DIR . DIRECTORY_SEPARATOR . $filename)) !== null) { return $resource; } if (($resource = Plugins::find(self::VENDOR_DIR . DIRECTORY_SEPARATOR . $filename)) !== null) { return $resource; } return; }
public static function findTemplate($filename) { if ($filename[0] != DIRECTORY_SEPARATOR) { $template_file = Plugins::find(self::TEMPLATES_DIR . DIRECTORY_SEPARATOR . $filename); if ($template_file !== null) { return $template_file; } return false; } return file_exists($filename); }
protected function autoload($class_name) { if (parent::autoload($class_name)) { return true; } $class_name = $this->removeNamespace($class_name); $plugin = Plugins::find(self::MODEL_DIR . DIRECTORY_SEPARATOR . $class_name . '.class.php'); if ($plugin !== null) { require_once $plugin; return true; } $plugin = Plugins::find(self::BASE_MODEL_DIR . DIRECTORY_SEPARATOR . $class_name . '.class.php'); if ($plugin !== null) { require_once $plugin; return true; } return false; }
public static function handle($method = null, $path = null) { if ($path == null) { $path = @$_SERVER["PATH_INFO"]; } if ($method == null) { $method = $_SERVER["REQUEST_METHOD"]; } while (strlen($path) > 0 && $path[0] == "/") { $path = substr($path, 1); } if ($path == "") { $path = "index"; } $pos = strpos($path, "/"); if ($pos === false) { $request = $path; $next_path = ""; } else { $request = substr($path, 0, $pos); $next_path = substr($path, $pos); } $request = str_replace(".", "_", $request); $request = str_replace("-", " ", $request); $request = ucwords($request); $request = str_replace(" ", "", $request) . "Rest"; $request_file = Plugins::find(self::REQUEST_DIR . DIRECTORY_SEPARATOR . $request . ".class.php"); if ($request_file === null) { ErrorHandler::error(404, null, $request . ".class.php"); } require_once $request_file; $class_name = __NAMESPACE__ . "\\" . $request; $instance = new $class_name(); $instance->handleRequest($method, $next_path); ErrorHandler::error(204); }