Port entirely to a MVC-like pattern #37

Open
kazhnuz wants to merge 29 commits from refactor/use-bludit-boot-code into main
2 changed files with 12 additions and 5 deletions
Showing only changes of commit b7d7c4498e - Show all commits

View file

@ -50,11 +50,6 @@ class Renderer {
die();
}
public function redirect($redirection) {
header("Location: " . $redirection);
die();
}
public function simple($title, $content) {
$this->prepare("title", $title);
$this->prepare("content", $content);

View file

@ -11,6 +11,7 @@ class Router {
public $controller;
public $func;
public $characterId = -1;
public $uri;
private $namespaces = [];
@ -45,12 +46,23 @@ class Router {
}
}
public function redirect($redirection) {
if ($this->uri == null) {
$this->parseUrl();
}
if ($this->uri != $redirection) {
header("Location: " . $redirection);
die();
}
}
private function getFromUrl($requestParts, $index, $default) {
return (isset($requestParts[$index]) && $requestParts[$index] != null) ? $requestParts[$index] : $default;
}
private function parseUrl() {
global $renderer;
$this->uri = $_SERVER['REQUEST_URI'];
$requestUri = trim($_SERVER['REQUEST_URI'], '/');
$requestParts = explode('/', $requestUri);