1
0

downgrade to kirby v3

This commit is contained in:
Philip Wagner
2024-09-01 10:47:15 +02:00
parent a4b2aece7b
commit af86acb7a1
1085 changed files with 54743 additions and 65042 deletions

View File

@@ -8,6 +8,9 @@ class LanguageRoutes
{
/**
* Creates all multi-language routes
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function create(App $kirby): array
{
@@ -30,11 +33,7 @@ class LanguageRoutes
'method' => 'ALL',
'env' => 'site',
'action' => function ($path = null) use ($language) {
$result = $language->router()->call($path);
// explicitly test for null as $result can
// contain falsy values that should still be returned
if ($result !== null) {
if ($result = $language->router()->call($path)) {
return $result;
}
@@ -55,6 +54,9 @@ class LanguageRoutes
/**
* Create the fallback route
* for unprefixed default language URLs.
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function fallback(App $kirby): array
{
@@ -67,10 +69,7 @@ class LanguageRoutes
$extension = F::extension($path);
// try to redirect prefixed pages
if (
empty($extension) === true &&
$page = $kirby->page($path)
) {
if (empty($extension) === true && $page = $kirby->page($path)) {
$url = $kirby->request()->url([
'query' => null,
'params' => null,
@@ -78,17 +77,15 @@ class LanguageRoutes
]);
if ($url->toString() !== $page->url()) {
// redirect to translated page directly if translation
// is exists and languages detect is enabled
$lang = $kirby->detectedLanguage()->code();
// redirect to translated page directly
// if translation is exists and languages detect is enabled
if (
$kirby->option('languages.detect') === true &&
$page->translation($lang)->exists() === true
$page->translation($kirby->detectedLanguage()->code())->exists() === true
) {
return $kirby
->response()
->redirect($page->url($lang));
->redirect($page->url($kirby->detectedLanguage()->code()));
}
return $kirby
@@ -104,6 +101,9 @@ class LanguageRoutes
/**
* Create the multi-language home page route
*
* @param \Kirby\Cms\App $kirby
* @return array
*/
public static function home(App $kirby): array
{
@@ -114,10 +114,7 @@ class LanguageRoutes
'env' => 'site',
'action' => function () use ($kirby) {
// find all languages with the same base url as the current installation
$languages = $kirby->languages()->filter(
'baseurl',
$kirby->url()
);
$languages = $kirby->languages()->filter('baseurl', $kirby->url());
// if there's no language with a matching base url,
// redirect to the default language
@@ -127,8 +124,7 @@ class LanguageRoutes
->redirect($kirby->defaultLanguage()->url());
}
// if there's just one language,
// we take that to render the home page
// if there's just one language, we take that to render the home page
if ($languages->count() === 1) {
$currentLanguage = $languages->first();
} else {