Skip to content

Commit

Permalink
prepracovanie všeobecných postov
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip10 committed Nov 29, 2023
1 parent 2387b21 commit c9ea4e1
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 64 deletions.
7 changes: 1 addition & 6 deletions App/Controllers/DialniceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -28,12 +28,7 @@ public function add() : Response
$newKategoria->save();

return $this->redirect("?");

}


return $this->html();
}


}
8 changes: 5 additions & 3 deletions App/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Core\AControllerBase;
use App\Core\Responses\Response;
use App\Models\Dialnice;
use App\Models\Post;

/**
* Class HomeController
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -75,6 +76,7 @@ public function rychlostnecesty(): Response
*/
public function ostatne(): Response
{
return $this->html();
$posty = Post::getAll();
return $this->html($posty);
}
}
9 changes: 4 additions & 5 deletions App/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion App/Models/Dialnice.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getZaciatokVystavby(): int
return $this->zaciatokVystavby;
}

public function getKoniedVystavby(): int
public function getKoniecVystavby(): int
{
return $this->koniecVystavby;
}
Expand Down
71 changes: 43 additions & 28 deletions App/Models/Post.php
Original file line number Diff line number Diff line change
@@ -1,62 +1,77 @@
<?php

namespace App\Models;

use App\Core\Model;
use DateTime;

class Post extends Model
{
protected int $id;
protected string $text;
protected string $picture;
protected string $nazov;
protected string $popis;
protected string $datumPublikovania;
protected string $zdroj;

/**
* @return int
*/
public function getId(): int
{
return $this->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;
}
}
4 changes: 2 additions & 2 deletions App/Views/Home/dialnice.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<div class="col p-4 d-flex flex-column position-static">
<h3 class="mb-0"><?= $dialnica->getNazov() ?></h3>
<div class="mb-1 text-body-secondary"><?= $dialnica->getZaciatokVystavby() ?>
- <?php if ($dialnica->getKoniedVystavby() == 0) {
- <?php if ($dialnica->getKoniecVystavby() == 0) {
echo "súčastnosť";
} else {
echo $dialnica->getKoniedVystavby();
echo $dialnica->getKoniecVystavby();
} ?></div>
<p class="card-text mb-2"><?= $dialnica->getTrasa() ?></p>
<div class="progress mb-auto" role="progressbar" aria-valuenow="0" aria-valuemin="0"
Expand Down
47 changes: 28 additions & 19 deletions App/Views/Home/ostatne.view.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
<?php

/** @var Array $data */
/** @var Post[] $data */

/** @var \App\Core\LinkGenerator $link */

use App\Models\Post;

?>

<p>Rekonštrukcie ciest I. triedy</p>
<p>Opravy mostov</p>
<p>Mestská hromadná doprava.</p>
<p>Cyklochodníky</p>
<p>Opravy mostov</p>
<p>Mestská hromadná doprava.</p>
<p>Cyklochodníky</p>


<div class="row mb-3 p-3">
<div class="row mb-3 p-3">
<?php
foreach ($data as $post) {
?>
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<h3 class="mb-2">Vyskytli sa aj komplikácie: Takto prebieha rekonštrukcia horského priechodu
Vernár</h3>
<div class="mb-1 text-body-secondary">24.10.2023</div>
<p class="card-text mb-3">Aj napriek komplikáciám, ktoré sa počas výstavby vyskytli, sa harmonogram
prác na predmetnej stavbe darí dodržiavať.</p>
<h3 class="mb-2"><?= $post->getNazov() ?></h3>
<div class="mb-1 text-body-secondary"><?= $post->getDatumPublikovania() ?></div>
<p class="card-text mb-3"><?= $post->getPopis() ?></p>
<div class="row mb-2">
<div class="col">
<button type="button" class="btn btn-outline-warning">I/66</button>
</div>
</div>
<a href="https://poprad.dnes24.sk/vyskytli-sa-aj-komplikacie-takto-prebieha-rekonstrukcia-horskeho-priechodu-vernar-foto-440664?ref=dopravanaslovensku.sk"
<a href="<?= $post->getZdroj() ?>?ref=dopravanaslovensku.sk"
class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8em">
Čítať viac
<svg class="bi">
Čítať viac
<svg class="bi">
<use xlink:href="#chevron-right"></use>
</svg>
</a>
Expand All @@ -39,11 +42,17 @@ class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8
focusable="false"><title>Placeholder</title>
<rect width="100%" height="100%" fill="#55595c"></rect>
<text x="50%" y="50%" fill="#eceeef" dy=".3em">Dnes 24</text>
<image href="obrazky/logo_dnes24.png" x="0" y="0" width="100%" height="100%"/>
<image href="obrazky/logo_<?= $post->getZdrojSkrateny() ?>.png" x="0" y="0" width="100%" height="100%"/>
</svg>
</div>
</div>
</div>
<?php
}
?>


<div class="row mb-3 p-3">
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative">
<div class="col p-4 d-flex flex-column position-static">
Expand All @@ -59,8 +68,8 @@ class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8
</div>
<a href="https://spis.korzar.sme.sk/c/23235295/priprava-obchvatu-velkej-lomnice-pokracuje-kraj-ide-vykupovat-pozemky.html?ref=dopravanaslovensku.sk"
class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8em">
Čítať viac
<svg class="bi">
Čítať viac
<svg class="bi">
<use xlink:href="#chevron-right"></use>
</svg>
</a>
Expand Down Expand Up @@ -94,8 +103,8 @@ class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8
</div>
<a href="https://www.rimava.sk/spravy-z-regionu/prace-na-vystavbe-kruhoveho-objazdu-na-sobotke-zacnu-uz-buduci-tyzden-dovodom-ich-zdrzania-bolo-dopravne-znacenie/?ref=dopravanaslovensku.sk"
class="icon-link gap-1 icon-link-hover stretched-link" style="margin-bottom: 0.8em">
Čítať viac
<svg class="bi">
Čítať viac
<svg class="bi">
<use xlink:href="#chevron-right"></use>
</svg>
</a>
Expand Down
Binary file removed obrazky/logo_SME.webp
Binary file not shown.
File renamed without changes

0 comments on commit c9ea4e1

Please sign in to comment.