Skip to content

Commit

Permalink
fix latte errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Mar 20, 2024
1 parent 01aae36 commit 6e695b6
Show file tree
Hide file tree
Showing 72 changed files with 212 additions and 182 deletions.
1 change: 1 addition & 0 deletions app/Components/ApiResults/ApiResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function render(): void

/**
* @throws JsonException
* @throws Throwable
*/
public function renderTeamsData(): void
{
Expand Down
2 changes: 1 addition & 1 deletion app/Components/ImageGallery/ImageGalleryControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

namespace App\Components\ImageGallery;
;

use Fykosak\Utils\Components\DIComponent;
use Nette\Caching\Cache;
use Nette\Caching\Storage;
Expand Down
5 changes: 3 additions & 2 deletions app/Components/TeamResults/TeamResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\NetteDownloader\ORM\Models\ModelTeam;
use App\Models\NetteDownloader\ORM\Services\DummyService;
use App\Modules\Core\Lang;
use Fykosak\FKSDBDownloaderCore\Requests\TeamsRequest;
use Fykosak\Utils\Components\DIComponent;
use Nette\Application\UI\Form;
Expand Down Expand Up @@ -148,7 +149,7 @@ protected function createComponentFilterForm(): Form
// one member teams
$form->addCheckbox(
'OneMemberTeams',
$this->translator->lang === 'cs' ? 'Pouze jednočlenné týmy' : 'One member teams only'
$this->translator->lang === Lang::CS ? 'Pouze jednočlenné týmy' : 'One member teams only'
);

// countries
Expand All @@ -163,7 +164,7 @@ protected function createComponentFilterForm(): Form
$countryISOContainer->addCheckbox(
$countryISO,
sprintf(
$this->translator->lang === 'cs' ? '%s:%s účastníků' : '%s:%s participants',
$this->translator->lang === Lang::CS ? '%s:%s účastníků' : '%s:%s participants',
$countryISO,
$count
)
Expand Down
1 change: 1 addition & 0 deletions app/Components/UpperHomePrague/upperHomePrague.latte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{varType App\Models\GamePhaseCalculator $gamePhaseCalculator}
{varType string $lang}

{block content}

Expand Down
22 changes: 16 additions & 6 deletions app/Modules/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Exceptions\UnderConstructionException;
use Fykosak\Utils\Localization\GettextTranslator;
use Fykosak\Utils\Localization\UnsupportedLanguageException;
use Fykosak\Utils\UI\Navigation\NavItem;
use Fykosak\Utils\UI\PageTitle;
use Nette\Application\UI\Presenter;
use Nette\Application\UI\Template;
Expand All @@ -18,6 +19,7 @@ abstract class BasePresenter extends Presenter
{
/** @persistent */
public ?string $lang = null; // = 'cs';
public Lang $language;

public GettextTranslator $translator;

Expand Down Expand Up @@ -45,6 +47,9 @@ protected function createComponentNavigation(): Navigation
return $navigation;
}

/**
* @return NavItem[]
*/
abstract protected function getNavItems(): array;

final public function setPageTitle(PageTitle $pageTitle): void
Expand All @@ -56,6 +61,7 @@ protected function createTemplate(): Template
{
$template = parent::createTemplate();
$template->lang = $this->lang;
$template->language = $this->language;
/** @var \Nette\Bridges\ApplicationLatte\Template $template */
$template->setTranslator($this->translator);

Expand All @@ -71,18 +77,22 @@ protected function createTemplate(): Template
protected function localize(): void
{
// Lang is null in error presenter because no rote rule was applied
if (!isset($this->lang) || $this->lang == null) {
if (!isset($this->lang) || !$this->lang) {
$this->lang = 'en'; // todo guess language by domain
}
$this->language = Lang::from($this->lang);

$this->translator->setLang($this->lang);
$this->translator->setLang($this->language);
}

/**
* @return string[]
*/
public function formatTemplateFiles(): array
{
[$file,] = parent::formatTemplateFiles();
return [
str_replace('.latte', '.' . $this->lang . '.latte', $file),
str_replace('.latte', '.' . $this->language->value . '.latte', $file),
$file,
];
}
Expand All @@ -92,7 +102,7 @@ public function formatTemplateFiles(): array
*/
protected function csen(string $cs, string $en): string
{
if ($this->lang === 'cs') {
if ($this->translator->lang === Lang::CS) {
return $cs;
} else {
return $en;
Expand All @@ -115,11 +125,11 @@ protected function throwUnderConstructionException(): void
*/
protected function createComponentGallery(): ImageGalleryControl
{
return new ImageGalleryControl($this->context);
return new ImageGalleryControl($this->getContext());
}

protected function createComponentPdfGallery(): PdfGalleryControl
{
return new PdfGalleryControl($this->context);
return new PdfGalleryControl($this->getContext());
}
}
12 changes: 8 additions & 4 deletions app/Modules/Dsef/ArchiveModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function formatTemplateFiles(): array
$key = parent::getEventKey($this->getEvent());

return [
str_replace('.latte', '.' . $key . '.' . $this->lang . '.latte', end($files)),
str_replace('.latte', '.' . $key . '.' . $this->language->value . '.latte', end($files)),
str_replace('.latte', '.' . $key . '.latte', end($files)),
...$files,
];
Expand All @@ -97,25 +97,29 @@ protected function createComponentScheduleParticipants(): AllScheduleListCompone
return new AllScheduleListComponent($this->event->eventId, $this->getContext());
}

/**
* @return NavItem[]
* @throws \Throwable
*/
protected function getNavItems(): array
{
$items = [];
if (RegistrationPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle( 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Registration:',
);
}

if (CurrentPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle( 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Current:',
);
}

$items[] = new NavItem(
new PageTitle( 'Archiv', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Archiv', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Archive:default',
);
return $items;
Expand Down
8 changes: 4 additions & 4 deletions app/Modules/Dsef/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ protected function localize(): void
}

/**
* @throws \Throwable
* @return NavItem[]
*/
protected function getNavItems(): array
{
$items = [];
$items[] = new NavItem(
new PageTitle( 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Registration:',
);
$items[] = new NavItem(
new PageTitle( 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Current:',
);
$items[] = new NavItem(
new PageTitle( 'Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Archive:',
);

Expand Down
1 change: 1 addition & 0 deletions app/Modules/Dsef/Core/templates/@layout.latte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{varType string $lang}
<!DOCTYPE html>
<html lang="cs">
<head>
Expand Down
7 changes: 4 additions & 3 deletions app/Modules/Dsef/DefaultModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@
abstract class BasePresenter extends \App\Modules\Dsef\Core\BasePresenter
{
/**
* @return NavItem[]
* @throws \Throwable
*/
protected function getNavItems(): array
{
$items = [];
if (RegistrationPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle( 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Registration:',
);
}

if (CurrentPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle( 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Current:',
);
}

$items[] = new NavItem(
new PageTitle( 'Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle('Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Archive:',
);
return $items;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{varType string $lang}
{varType App\Models\GamePhaseCalculator $gamePhaseCalculator}

{block title}
Expand Down
5 changes: 4 additions & 1 deletion app/Modules/Fof/ArchiveModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ protected function getEvent(): ModelEvent
return $this->event;
}

/**
* @return NavItem[]
*/
protected function getNavItems(): array
{
return [
Expand Down Expand Up @@ -100,7 +103,7 @@ public function formatTemplateFiles(): array
$key = parent::createEventKey($this->getEvent());

return [
str_replace('.latte', '.' . $key . '.' . $this->lang . '.latte', end($files)),
str_replace('.latte', '.' . $key . '.' . $this->language->value . '.latte', end($files)),
str_replace('.latte', '.' . $key . '.latte', end($files)),
...$files,
];
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/ArchiveModule/DetailedResultsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class DetailedResultsPresenter extends BasePresenter
{
public function renderDefault(): void
{
$this->setPageTitle(new PageTitle( $this->csen('Podrobné výsledky', 'Detailed results')));
$this->setPageTitle(new PageTitle($this->csen('Podrobné výsledky', 'Detailed results')));
}
}
2 changes: 1 addition & 1 deletion app/Modules/Fof/ArchiveModule/ReportsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function renderDefault(): void
/* $this->template->reports = $this->reportService->getTable()
->where('lang = ? AND event_id = ?', $this->lang, $this->getEvent()->eventId);*/
$this->template->year = $this->getEvent()->begin->format('Y');
$this->setPageTitle(new PageTitle( $this->csen('Ohlasy účastníků', 'Contestants\' reports')));
$this->setPageTitle(new PageTitle($this->csen('Ohlasy účastníků', 'Contestants\' reports')));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/ArchiveModule/ResultsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ResultsPresenter extends BasePresenter

public function renderDefault(): void
{
$this->setPageTitle(new PageTitle( $this->csen('Výsledky', 'Results')));
$this->setPageTitle(new PageTitle($this->csen('Výsledky', 'Results')));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/ArchiveModule/TeamsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TeamsPresenter extends BasePresenter
{
public function renderDefault(): void
{
$this->setPageTitle(new PageTitle( $this->csen('Týmy', 'Teams')));
$this->setPageTitle(new PageTitle($this->csen('Týmy', 'Teams')));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions app/Modules/Fof/Core/templates/@layout.latte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{varType App\Modules\Core\BasePresenter $presenter}
{varType string $lang}
{varType App\Modules\Core\Lang $language}
{varType App\Models\GamePhaseCalculator $gamePhaseCalculator}


<!DOCTYPE html>
<html lang="{$presenter->lang}">
<html lang="{$language->value}">
<head>
<title>
{ifset title}{include title} | {/ifset}
Expand All @@ -25,7 +25,7 @@
<meta property="og:image" content="{switch $lang}{case cs}https://fyziklani.cz/images/fof-og-image-cs.png{default}https://fyziklani.cz/images/fof-og-image-en.png{/switch}"/>
<meta property="og:description" content="{switch $lang}{case cs}Týmová soutěž v řešení fyzikálních problémů{default}Team competition in solving physics problems{/switch}"/>
<meta property="og:image:type" content="image/png"/>
<meta property="og:locale" content="{$presenter->translator->locales[$presenter->lang]}"/>
<meta property="og:locale" content="{$language->getLocale()}"/>
<meta property="og:url" content="{plink //this}"/>
<link href="{$basePath}/images/icon.png" rel="icon" type="image/png"/>
<link href="{asset 'assets/main.css'}" rel="stylesheet"/>
Expand Down Expand Up @@ -128,7 +128,7 @@
</a>*}
<a href="https://www.nfneuron.cz/" style="text-align: center">
<img src="{$basePath}/images/logos/neuron-logo.jpg" alt="Neuron logo" style="max-width: 10rem">
</a>
</a>
</div>
</div>
<div class="category">
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/DefaultModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getNavItems(): array
);
$items[] = new NavItem(
new PageTitle(
$this->csen('Ubytování', 'Accommodation'),
$this->csen('Ubytování', 'Accommodation'),
'visible-sm-inline glyphicon glyphicon-question-sign'
),
':Default:Accommodation:default',
Expand Down
3 changes: 2 additions & 1 deletion app/Modules/Fof/DefaultModule/SchedulePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\Downloader\FKSDBDownloader;
use App\Models\Downloader\ScheduleRequest;
use App\Modules\Core\Lang;

final class SchedulePresenter extends BasePresenter
{
Expand All @@ -18,7 +19,7 @@ public function inject(FKSDBDownloader $downloader): void

public function translateDay(string $day): string
{
if ($this->lang !== 'cs') {
if ($this->language !== Lang::CS) {
return $day;
}
return match ($day) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{varType string $lang}
{block main}
<div class="panel color-auto">
<section class="inner-container">
Expand Down Expand Up @@ -26,7 +27,7 @@
<p><a href="https://www.hotelduo.cz/">Hotel Duo</a> je čtyřhvězdičkový hotel kousek od metra Střížkov. Jeho polohu najdete na adrese <a href="https://www.google.com/maps/place/Hotel+Duo/@50.12811,14.4721567,14.5z/data=!4m8!3m7!1s0x470bec9f3e172603:0x19ad14d3ab594bd!5m2!4m1!1i2!8m2!3d50.1268927!4d14.4859316">Teplická 492, 190 00 Praha, Česká republika</a>.</p>

<p>V ceně ubytování je zahrnuta snídaně formou bufetu.</p>

<p>Pokoje v hotelu jsou dvojlůžkové a trojlůžkové. Soutěžící a doprovod bude do pokojů přiřazen podle délky pobytu a až poté podle vlastních preferencí (tedy ubytovaní na více nocí zřejmě nebudou s těmi na jednu noc).
</p>
{default}
Expand Down
3 changes: 2 additions & 1 deletion app/Modules/Fof/DefaultModule/templates/Merch/default.latte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{varType string $lang}
{block main}
<div class="panel color-auto">
<section class="inner-container">
Expand Down Expand Up @@ -195,4 +196,4 @@
</div>
</section>
</div>
{/block}
{/block}
3 changes: 2 additions & 1 deletion app/Modules/Fof/DefaultModule/templates/Rules/default.latte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{varType string $lang}
{block subtitle}
{switch $lang}
{case cs}Pravidla
Expand Down Expand Up @@ -144,4 +145,4 @@
</div>
</div>

{/block}
{/block}
Loading

0 comments on commit 6e695b6

Please sign in to comment.