Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev martin routing #75

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions app/Modules/Fykos/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ protected function getNavItems(): array
[],
[
new NavItem(new PageTitle($this->csen('Co je FYKOS?', 'What Is FYKOS?')), ':Default:About:default'),
new NavItem(new PageTitle($this->csen('Organizátoři', 'Organizers')), ':Default:About:Organizers'),
new NavItem(new PageTitle($this->csen('Historie', 'History')), ':Default:About:History'),
new NavItem(new PageTitle($this->csen('Kontakt', 'Contact')), ':Default:About:Contact'),
new NavItem(new PageTitle($this->csen('Organizátoři', 'Organizers')), ':Default:About:organizers'),
new NavItem(new PageTitle($this->csen('Historie', 'History')), ':Default:About:history'),
new NavItem(new PageTitle($this->csen('Kontakt', 'Contact')), ':Default:About:contact'),
],
);

Expand All @@ -44,7 +44,7 @@ protected function getNavItems(): array
[],
[
new NavItem(new PageTitle($this->csen('Základní informace', 'Basic Information')), ':Events:Fykos:'),
new NavItem(new PageTitle($this->csen('Pravidla', 'Rules')), ':Events:Fykos:Rules'),
new NavItem(new PageTitle($this->csen('Pravidla', 'Rules')), ':Events:Fykos:rules'),
new NavItem(
new PageTitle($this->csen('Jak psát řešení', 'How to Write Solutions')),
':Events:Fykos:TexTutorial'
Expand Down
37 changes: 32 additions & 5 deletions app/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ private static function useTranslateFilter(?array $domainList, array $routerMapp
$params['presenter'] = $routerMapping[$params['lang']][$params['presenter']];
}

// Translate action
if (
isset($routerMapping['actions'][$params['lang']]) &&
isset($routerMapping['actions'][$params['lang']][$params['action']])
) {
$params['action'] = $routerMapping['actions'][$params['lang']][$params['action']];
}

return $params;
},

Expand All @@ -97,6 +105,14 @@ private static function useTranslateFilter(?array $domainList, array $routerMapp
}
}

// Translate action
if (isset($routerMapping['actions'][$params['lang']])) {
$key = array_search($params['action'], $routerMapping['actions'][$params['lang']]);
if ($key !== false) {
$params['action'] = $key;
}
}

// Either set the language in the domain, or in lang parameter
if (isset($domainList) && count($domainList)) {
$params['domain'] = array_search($params['lang'], $domainList);
Expand Down Expand Up @@ -187,6 +203,16 @@ public static function createFykosRouter(?array $domainList, array $routerMappin
{
$router = new RouteList();

$router->addRoute('//<domain>/<lang events|akce>/[<presenter>[/<action>]]', [
'module' => 'Events',
'presenter' => 'Default',
'action' => 'default',
'lang' => ['filterTable' => [
'akce' => "cs",
'events' => "en",
]],
null => self::useTranslateFilter($domainList, $routerMapping['events']),
]);

$router->addRoute('//<domain>/<lang results|poradi>[/<year ([0-9]{1,2})>]', [
'module' => 'Default',
Expand All @@ -207,11 +233,12 @@ public static function createFykosRouter(?array $domainList, array $routerMappin
null => self::useTranslateFilter($domainList, $routerMapping['default']),
]);

$router->addRoute('//<domain>/<module events>/[<presenter>[/<action>]]', [
'presenter' => 'Default',
'action' => 'default',
null => self::useTranslateFilter($domainList, $routerMapping['events']),
]);

// $router->addRoute('//<domain>/<module events>/[<presenter>[/<action>]]', [
// 'presenter' => 'Default',
// 'action' => 'default',
// null => self::useTranslateFilter($domainList, $routerMapping['events']),
// ]);

$router->withModule('Default')
->addRoute('//<domain>/<presenter>[/<action>]', [
Expand Down
7 changes: 7 additions & 0 deletions app/config/fof-router-mapping.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ parameters:
Spoluprace: Cooperation
en:
About: AboutTheCompetition
actions:
cs:
organizatori: organizers
uplna: complete
organizacniRad: organizationalRegulations
rozhodnutiKomise: resolutions

archive:
cs:
Default: Default
Expand Down
9 changes: 9 additions & 0 deletions app/config/fol-router-mapping.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ parameters:
Spoluprace: Cooperation
en:
About: AboutTheCompetition
actions:
cs:
uplna: complete
organizacniRad: organizationalRegulations
organisationalRegulations: organizationalRegulations # historical
rozhodnutiKomise: resolutions
en:
organisationalRegulations: organizationalRegulations # historical

archive:
cs:
Default: Default
Expand Down
21 changes: 12 additions & 9 deletions app/config/fykos-router-mapping.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ parameters:
Default: Default
ONas: About
Pravidla: Rules
Organizatori: Organizers
Historie: History
Kontakt: Contact
Zadani: Problems
ArchivUloh: ProblemsArchive
actions:
cs:
historie: history
organizatori: organizers
kontakt: contact
events:
cs:
Default: Default
Akce: Events
Experimenty: Experiments
Pravidla: Rules
jakPsat: TexTutorial

Soustredeni: Camps
actions:
cs:
pravidla: rules
jakPsat: texTutorial
experimenty: experiments
cena: price
Loading