Skip to content

Commit

Permalink
Mejorado el diseño de las páginas no encontradas.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoRazorX committed May 20, 2023
1 parent 37b2830 commit 00debec
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
21 changes: 20 additions & 1 deletion Core/Error/PageNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ public function run(): void
{
http_response_code(404);

echo '<h1>' . Tools::lang()->trans('page-not-found') . '</h1>';
$title = Tools::lang()->trans('page-not-found');
$bodyCss = 'bg-info';
$bodyHtml = '<div class="container">'
. '<div class="row justify-content-center">'
. '<div class="col-sm-6">'
. '<div class="card shadow mt-5 mb-5">'
. '<div class="card-body text-center">'
. '<div class="display-1 text-info">404</div>'
. '<h1 class="card-title">' . $title . '</h1>'
. '<p class="mb-0">' . Tools::lang()->trans('page-not-found-p') . '</p>'
. '</div>'
. '<div class="card-footer">'
. '<a href="/" class="btn btn-secondary">' . Tools::lang()->trans('homepage') . '</a>'
. '</div>'
. '</div>'
. '</div>'
. '</div>'
. '</div>';

echo $this->html($title, $bodyHtml, $bodyCss);
}
}
2 changes: 1 addition & 1 deletion Core/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static function shutdown(): void
. '<body class="bg-danger">' . PHP_EOL
. '<div class="container mt-5 mb-5">' . PHP_EOL
. '<div class="row justify-content-center">' . PHP_EOL
. '<div class="col-6">' . PHP_EOL
. '<div class="col-sm-6">' . PHP_EOL
. '<div class="card shadow">' . PHP_EOL
. '<div class="card-body">' . PHP_EOL
. '<img src="' . $info['report_qr'] . '" alt="' . $info['hash'] . '" class="float-end">' . PHP_EOL
Expand Down
16 changes: 16 additions & 0 deletions Core/Template/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,20 @@ public function __construct(Exception $exception, string $url = '')
$this->exception = $exception;
$this->url = $url;
}

protected function html(string $title, string $bodyHtml, string $bodyCss): string
{
return '<!doctype html>' . PHP_EOL
. '<html lang="en">' . PHP_EOL
. '<head>' . PHP_EOL
. '<meta charset="utf-8">' . PHP_EOL
. '<meta name="viewport" content="width=device-width, initial-scale=1">' . PHP_EOL
. '<title>' . $title . '</title>' . PHP_EOL
. '<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">' . PHP_EOL
. '</head>' . PHP_EOL
. '<body class="' . $bodyCss . '">' . PHP_EOL
. $bodyHtml
. '</body>' . PHP_EOL
. '</html>';
}
}

0 comments on commit 00debec

Please sign in to comment.