Skip to content

Commit

Permalink
controllers to template parts
Browse files Browse the repository at this point in the history
  • Loading branch information
dakur committed Dec 19, 2024
1 parent cd2ff34 commit 53d3bdb
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 216 deletions.
38 changes: 0 additions & 38 deletions UI/Contacts/ContactDC.php

This file was deleted.

50 changes: 0 additions & 50 deletions UI/Contacts/ContactsController.php

This file was deleted.

8 changes: 0 additions & 8 deletions UI/ControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
use HnutiBrontosaurus\Theme\UI\AboutSuccesses\AboutSuccessesController;
use HnutiBrontosaurus\Theme\UI\Base\BaseFactory;
use HnutiBrontosaurus\Theme\UI\BaseUnitsAndClubsList\BaseUnitsAndClubsListController;
use HnutiBrontosaurus\Theme\UI\Contacts\ContactsController;
use HnutiBrontosaurus\Theme\UI\Courses\CoursesController;
use HnutiBrontosaurus\Theme\UI\English\EnglishController;
use HnutiBrontosaurus\Theme\UI\Error\ErrorController;
use HnutiBrontosaurus\Theme\UI\Event\EventController;
use HnutiBrontosaurus\Theme\UI\FirstTime\FirstTimeController;
use HnutiBrontosaurus\Theme\UI\ForChildren\ForChildrenController;
use HnutiBrontosaurus\Theme\UI\Future\FutureController;
use HnutiBrontosaurus\Theme\UI\HighSchools\HighSchoolsController;
use HnutiBrontosaurus\Theme\UI\Homepage\HomepageController;
use HnutiBrontosaurus\Theme\UI\Meetups\MeetupsController;
use HnutiBrontosaurus\Theme\UI\Preview\PreviewController;
Expand Down Expand Up @@ -61,7 +57,6 @@ public function create(?\WP_Post $post, bool $isPreview): Controller
}

return match ($post->post_name) {
'kontakty' => new ContactsController($base, $this->latte),
'pronajmy' => new RentalsController($base, $this->latte),
AboutCrossroadController::PAGE_SLUG => new AboutCrossroadController($base, $this->latte),
VoluntaryController::PAGE_SLUG => new VoluntaryController($this->dateFormatHuman, $this->dateFormatRobot, $this->bisApiClient, $base, $this->latte),
Expand All @@ -71,10 +66,7 @@ public function create(?\WP_Post $post, bool $isPreview): Controller
'podpor-nas' => new SupportOverviewController($base, $this->latte),
AboutHighlightsController::PAGE_SLUG => new AboutHighlightsController($base, $this->latte),
AboutSuccessesController::PAGE_SLUG => new AboutSuccessesController($base, $this->latte),
'english' => new EnglishController($base, $this->latte),
'hlavni-stranka' => new HomepageController($this->dateFormatHuman, $this->dateFormatRobot, $this->bisApiClient, $base, $this->latte),
'jedu-poprve' => new FirstTimeController($base, $this->latte),
'programy-pro-stredni-skoly' => new HighSchoolsController($base, $this->latte),
FutureController::PAGE_SLUG => new FutureController($this->dateFormatHuman, $this->dateFormatRobot, $this->bisApiClient, $base, $this->latte),
AboutStructureController::PAGE_SLUG => new AboutStructureController($this->bisApiClient, $base, $this->latte, $this->coordinatesResolver),
EventController::PAGE_SLUG => new EventController($this->dateFormatHuman, $this->dateFormatRobot, $this->applicationUrlTemplate, $this->bisApiClient, $base, $this->latte),
Expand Down
27 changes: 0 additions & 27 deletions UI/English/EnglishController.php

This file was deleted.

32 changes: 0 additions & 32 deletions UI/FirstTime/FirstTimeController.php

This file was deleted.

31 changes: 0 additions & 31 deletions UI/HighSchools/HighSchoolsController.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{layout $layoutPath}
<?php declare(strict_types = 1);

/** @var Container $hb_container defined in functions.php */

?>

{block content}
<main role="main">
<article class="english">
<h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{layout $layoutPath}

{block content}
<main role="main">
<article>
<h1>
Expand Down Expand Up @@ -48,7 +45,7 @@
co vzít s sebou a jak se na místo dopravit.
</p>
<a class="hero button--secondary-wrapper hb-mb-4 hb-lg-mbe-6" href="{$voluntaryPageLink}?{$filtersKey}=jedu-poprve#obsah" style="--hero-background-image-url: url('{$themePathRelative|noescape}/frontend/dist/images/box-firstTime.jpg')">
<a class="hero button--secondary-wrapper hb-mb-4 hb-lg-mbe-6" href="/dobrovolnicke-akce?jen=jedu-poprve#obsah" style="--hero-background-image-url: url('https://brontosaurus.cz/wp-content/uploads/2024/12/box-firstTime-scaled.jpg')">
<div class="button button--secondary">Vybrat si dobrovolnickou akci</div>
</a>
Expand Down Expand Up @@ -82,7 +79,7 @@
</ul>
<div class="hb-ta-c">
<a class="button button--primary" href="{$voluntaryPageLink}?{$filtersKey}=jedu-poprve#obsah">
<a class="button button--primary" href="/dobrovolnicke-akce?jen=jedu-poprve#obsah">
Vybrat si akci
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
{layout $layoutPath}
<?php declare(strict_types = 1);

$posts = get_posts(['post_type' => 'contacts', 'numberposts' => -1]);

/** @var array<stdClass{name: string, hasPhoto: bool, photo: ?string, role: string, about: string, emailAddresses: string[]}> $contacts */
$contacts = array_map(function (WP_Post $post) {
$thumbnail = get_the_post_thumbnail_url($post);
$thumbnail = $thumbnail === false ? null : $thumbnail; // convert false to null which makes more sense

$emailAddresses = explode("\n", get_post_meta($post->ID, 'contacts_email', single: true));
if ($emailAddresses === false || $emailAddresses[0] === '') {
$emailAddresses = [];
}

return (object) [
'name' => $post->post_title,
'hasPhoto' => $thumbnail !== null,
'photo' => $thumbnail,
'role' => get_post_meta($post->ID, 'contacts_role', single: true),
'about' => get_post_meta($post->ID, 'contacts_about', single: true),
'emailAddresses' => $emailAddresses,
];
}, $posts);

?>

{block content}
<main role="main">
<h1>
Kontakty na&nbsp;Hnutí Brontosaurus
Expand All @@ -14,7 +37,7 @@
</p>

<p>
V&nbsp;různých městech také působí: <a href="{$aboutStructurePageLink}#mapa-zakladni-clanky">články</a>, <a href="{$aboutStructurePageLink}#mapa-kluby">kluby</a> a&nbsp;<a href="{$aboutStructurePageLink}#mapa-regionalni-centra">regionální centra</a>.
V&nbsp;různých městech také působí: <a href="/o-brontosaurovi/hnuti-brontosaurus#mapa-zakladni-clanky">články</a>, <a href="/o-brontosaurovi/hnuti-brontosaurus#mapa-kluby">kluby</a> a&nbsp;<a href="/o-brontosaurovi/hnuti-brontosaurus#mapa-regionalni-centra">regionální centra</a>.
</p>
</div>

Expand Down Expand Up @@ -103,30 +126,36 @@
Naši lidé
</h2>

<div class="[ hb-lg-d-f hb-lg-fd-r hb-lg-jc-sb ] [ hb-sm-c-r ] hb-mw-40 hb-mi-auto hb-mbe-5" n:foreach="$contacts as $contact">
<?php foreach ($contacts as $contact): ?>
<div class="[ hb-lg-d-f hb-lg-fd-r hb-lg-jc-sb ] [ hb-sm-c-r ] hb-mw-40 hb-mi-auto hb-mbe-5">
<div class="contacts__imageWrapper hb-sm-f-r">
<img class="contacts__image hb-mw-full hb-mbe-3 hb-lg-mbe-0" src="{$contact->photo}" alt="" n:if="$contact->hasPhoto">
<?php if ($contact->hasPhoto): ?>
<img class="contacts__image hb-mw-full hb-mbe-3 hb-lg-mbe-0" src="<?php echo $contact->photo ?>" alt="">
<?php endif; ?>
</div>

<div class="contacts__description hb-lg-d-f hb-lg-fd-c hb-lg-jc-c">
<div class="hb-mbe-3">
<span class="hb-fw-b">{$contact->name}</span>
<span class="hb-fw-b"><?php echo $contact->name ?></span>
<br>
{$contact->role}
<?php echo $contact->role ?>
</div>

<div class="contacts__about hb-mbe-3">
{$contact->about}
<?php echo $contact->about ?>
</div>

{if count($contact->emailAddresses) > 0}
<div class="contacts__mail hb-pis-4" n:inner-foreach="$contact->emailAddresses as $emailAddress">
<a href="mailto:{$emailAddress}" target="_blank">{$emailAddress}</a>
{sep}<br>{/sep}
<?php if (count($contact->emailAddresses) > 0): ?>
<div class="contacts__mail hb-pis-4">
<?php foreach ($contact->emailAddresses as $index => $emailAddress): ?>
<?php if ($index > 0): ?><br><?php endif; ?>
<a href="mailto:<?php echo $emailAddress ?>" target="_blank"><?php echo $emailAddress ?></a>
<?php endforeach; ?>
</div>
{/if}
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</main>
Loading

0 comments on commit 53d3bdb

Please sign in to comment.