From 258135cd81900a2a88751f7e5390f6f1a0f29870 Mon Sep 17 00:00:00 2001 From: William Date: Wed, 11 May 2022 15:36:20 +0000 Subject: [PATCH] Commit --- app/lib/App/Core/App.php | 15 ++--- app/view/pages/race/results.php | 99 ++++++++++++++++++++++----------- public/race/results.php | 72 +++++++++++++++++++----- 3 files changed, 133 insertions(+), 53 deletions(-) diff --git a/app/lib/App/Core/App.php b/app/lib/App/Core/App.php index 1b41c9e..97b75ec 100644 --- a/app/lib/App/Core/App.php +++ b/app/lib/App/Core/App.php @@ -55,18 +55,19 @@ class App /** * Render given view + * + * Reason for the funky names is to avoid name conflicts */ - public function view(string $view, array $data = []): void + public function view(string $__VIEW, array $__DATA = []): void { - // import variables into the current symbol table from an array - extract($data); - // require view file - $path = $this->dir . '/view/' . $view . '.php'; - if (!file_exists($path)) + $__PATH = $this->dir . '/view/' . $__VIEW . '.php'; + if (!file_exists($__PATH)) { throw new Exception("View does not exist"); } - require $path; + // import variables into the current symbol table from an array + extract($__DATA); + require $__PATH; } /** diff --git a/app/view/pages/race/results.php b/app/view/pages/race/results.php index 55728ea..01a5bf8 100644 --- a/app/view/pages/race/results.php +++ b/app/view/pages/race/results.php @@ -1,41 +1,76 @@ - - -

Resultater

-Fokusert visning ] -
+ + + + + +

Resultater

+

Denne siden oppdateres automagisk.

+ Fokusert visning ] + Sammendrag ]  +
+ + + + +
+ Laster inn... +
+ + + + + + - + -
-Laster inn... -
+

Sammendrag

+ Tilbake til resultater ]  +
- - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/race/results.php b/public/race/results.php index 135aa7a..c483f59 100644 --- a/public/race/results.php +++ b/public/race/results.php @@ -1,17 +1,61 @@ view('template/header', [ - "title" => "Resultater", - "hide_nav" => TRUE, - "hide_menu" => TRUE - ]); - $app->view('pages/race/results', ["focused" => TRUE]); - $app->view('template/footer'); -} else { - $app->view('template/header', ["title" => "Resultater"]); - $app->view('pages/race/results'); - $app->view('template/footer'); -} +$view = filter_input(INPUT_GET, 'view'); + +switch ($view) { + + case 'focused': + + $app->view('template/header', + [ + "title" => "Resultater", + "hide_nav" => TRUE, + "hide_menu" => TRUE + ] + ); + $app->view('pages/race/results', + [ + "view" => "focused" + ] + ); + $app->view('template/footer'); + + break; + + case 'summary': + + $team_mapper = new TeamMapper($app->database->conn); + + $teams = $team_mapper->getAll(); + $filtered_teams = []; + + // filter out any teams that have no rounds + foreach ($teams as $team) + { + if ($team->rounds !== 0) + { + $filtered_teams[] = $team; + } + } + + $app->view('template/header', ["title" => "Sammendrag"]); + $app->view('pages/race/results', + [ + "view" => "summary", + "teams" => $filtered_teams + ] + ); + $app->view('template/footer'); + + break; + + default: + + $app->view('template/header', ["title" => "Resultater"]); + $app->view('pages/race/results'); + $app->view('template/footer'); + + break; +} \ No newline at end of file