diff --git a/App/Controllers/DialniceController.php b/App/Controllers/DialniceController.php index 41c1463..af86ff5 100644 --- a/App/Controllers/DialniceController.php +++ b/App/Controllers/DialniceController.php @@ -14,7 +14,7 @@ public function index(): Response } public function add() : Response { - if ($this->request()->getValue('trasa')) { + if ($this->request()->getValue('id')) { $newKategoria = new Dialnice(); $newKategoria->setNazov($this->request()->getValue('nazov')); @@ -28,12 +28,7 @@ public function add() : Response $newKategoria->save(); return $this->redirect("?"); - } - - return $this->html(); } - - } \ No newline at end of file diff --git a/App/Controllers/HomeController.php b/App/Controllers/HomeController.php index 41b43d5..09483c3 100644 --- a/App/Controllers/HomeController.php +++ b/App/Controllers/HomeController.php @@ -5,6 +5,7 @@ use App\Core\AControllerBase; use App\Core\Responses\Response; use App\Models\Dialnice; +use App\Models\Post; /** * Class HomeController @@ -56,8 +57,8 @@ public function zeleznice(): Response */ public function dialnice(): Response { - $kategorie = Dialnice::getAll(); - return $this->html($kategorie); + $dialnice = Dialnice::getAll(); + return $this->html($dialnice); } /** @@ -75,6 +76,7 @@ public function rychlostnecesty(): Response */ public function ostatne(): Response { - return $this->html(); + $posty = Post::getAll(); + return $this->html($posty); } } diff --git a/App/Controllers/PostController.php b/App/Controllers/PostController.php index cbe012b..15f6e2f 100644 --- a/App/Controllers/PostController.php +++ b/App/Controllers/PostController.php @@ -17,16 +17,15 @@ public function add() : Response if ($this->request()->getValue('text')) { $newPost = new Post(); - $newPost->setPicture($this->request()->getValue('picture')); - $newPost->setText($this->request()->getValue('text')); + $newPost->setNazov($this->request()->getValue('nazov')); + $newPost->setPopis($this->request()->getValue('popis')); + $newPost->setDatumPublikovania($this->request()->getValue('datumPublikovania')); + $newPost->setZdroj($this->request()->getValue('zdroj')); $newPost->save(); return $this->redirect("?"); - } - - return $this->html(); } diff --git a/App/Models/Dialnice.php b/App/Models/Dialnice.php index 65e9339..87e683b 100644 --- a/App/Models/Dialnice.php +++ b/App/Models/Dialnice.php @@ -25,7 +25,7 @@ public function getZaciatokVystavby(): int return $this->zaciatokVystavby; } - public function getKoniedVystavby(): int + public function getKoniecVystavby(): int { return $this->koniecVystavby; } diff --git a/App/Models/Post.php b/App/Models/Post.php index 523d716..09c33fd 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -1,62 +1,77 @@ id; } - /** - * @param int $id - */ public function setId(int $id): void { $this->id = $id; } - /** - * @return string - */ - public function getText(): string + public function getNazov(): string { - return $this->text; + return $this->nazov; } - /** - * @param string $text - */ - public function setText(string $text): void + public function setNazov(string $nazov): void { - $this->text = $text; + $this->nazov = $nazov; } - /** - * @return string - */ - public function getPicture(): string + public function getPopis(): string { - return $this->picture; + return $this->popis; } - /** - * @param string $picture - */ - public function setPicture(string $picture): void + public function setPopis(string $popis): void { - $this->picture = $picture; + $this->popis = $popis; } + public function getDatumPublikovania(): string + { + $inputString = $this->datumPublikovania; + $dateTime = new DateTime($inputString); + $outputString = $dateTime->format('d.m.Y'); + return $outputString; + } + public function setDatumPublikovania(string $datumPublikovania): void + { + $this->datumPublikovania = $datumPublikovania; + } + + public function getZdroj(): string + { + return $this->zdroj; + } + + public function getZdrojSkrateny(): string + { + $parsedUrl = parse_url($this->zdroj); + $hostParts = explode('.', $parsedUrl['host']); + $substring = $hostParts[count($hostParts) - 2]; + return $substring; + } + + public function setZdroj(string $zdroj): void + { + $this->zdroj = $zdroj; + } } \ No newline at end of file diff --git a/App/Views/Home/dialnice.view.php b/App/Views/Home/dialnice.view.php index 2e46168..3bd7314 100644 --- a/App/Views/Home/dialnice.view.php +++ b/App/Views/Home/dialnice.view.php @@ -16,10 +16,10 @@
= $dialnica->getTrasa() ?>
Rekonštrukcie ciest I. triedy
-Opravy mostov
-Mestská hromadná doprava.
-Cyklochodníky
+Opravy mostov
+Mestská hromadná doprava.
+Cyklochodníky
- -Aj napriek komplikáciám, ktoré sa počas výstavby vyskytli, sa harmonogram - prác na predmetnej stavbe darí dodržiavať.
+= $post->getPopis() ?>