38 protected function fragment(
string $page): string
40 if (
'.html' != \substr($page, -5)) {
45 return $view->parseFile(APPPATH . DIRECTORY_SEPARATOR .
'Views' . DIRECTORY_SEPARATOR . $page, $this->data, $this->rawData);
53 $caller = debug_backtrace(0, 2)[1];
54 $classParts = explode(
'\\', $caller[
'class']);
55 $page = strtolower(end($classParts)) . DIRECTORY_SEPARATOR . $caller[
'function'];
59 $this->rawData[
'template_content'] = $fragment;
60 $siteName =
DotEnv::getEnv(
'SITE_NAME') ??
'change SITE_NAME in .env';
61 $this->data[
'template_title'] = array_key_exists(
'page_title', $this->data) ? $this->data[
'page_title'] .
' — ' . $siteName : $siteName;
63 $template = $this->
fragment(
'template.html');
75 return strtolower($_SERVER[
'REQUEST_METHOD']);
93 protected function isGet(): bool
105 return 'xmlhttprequest' == strtolower($_SERVER[
'HTTP_X_REQUESTED_WITH'] ??
'');
119 protected function getPost(?
string $element =
null)
121 if (
null === $element) {
125 return $_POST[$element] ??
null;
139 protected function getGet(?
string $element =
null)
141 if (
null === $element) {
145 return $_GET[$element] ??
null;
155 protected function redirect(
string $location): void
165 protected function show404(?
string $message =
null): void
167 header(
'HTTP/1.1 404 Not Found');
Handles I/O and HTTP methods.
show404(?string $message=null)
redirect(string $location)
getPost(?string $element=null)
getGet(?string $element=null)
static getEnv(string $key)
Detects deliberate 404 errors.
Parses files to insert data.