Upgrade to 4.4.1

This commit is contained in:
Bastian Allgeier
2024-09-23 11:46:43 +02:00
parent 8bc7250b68
commit 49287c7a5e
8 changed files with 30 additions and 42 deletions

View File

@@ -3,7 +3,6 @@
namespace Kirby\Cms;
use Kirby\Filesystem\F;
use Kirby\Toolkit\Str;
class LanguageRoutes
{
@@ -30,26 +29,9 @@ class LanguageRoutes
'pattern' => $language->pattern(),
'method' => 'ALL',
'env' => 'site',
'action' => function ($path = null) use ($kirby, $language) {
'action' => function ($path = null) use ($language) {
$result = $language->router()->call($path);
// redirect secondary-language pages that have
// been accessed with non-translated slugs in their path
// to their fully translated URL
if ($path !== null && $result instanceof Page) {
if (Str::endsWith($result->url(), $path) === false) {
$url = $result->url();
$query = $kirby->request()->query()->toString();
// preserve query across redirect
if (empty($query) === false) {
$url .= '?' . $query;
}
return $kirby->response()->redirect($url);
}
}
// explicitly test for null as $result can
// contain falsy values that should still be returned
if ($result !== null) {

View File

@@ -2,7 +2,6 @@
namespace Kirby\Filesystem;
use Kirby\Cms\App;
use Kirby\Cms\Language;
use Kirby\Toolkit\Str;
@@ -49,7 +48,8 @@ class Filename
public function __construct(
protected string $filename,
protected string $template,
protected array $attributes = []
protected array $attributes = [],
protected string|null $language = null
) {
$this->name = $this->sanitizeName($filename);
$this->extension = $this->sanitizeExtension(
@@ -234,13 +234,12 @@ class Filename
{
// temporarily store language rules
$rules = Str::$language;
$kirby = App::instance(null, true);
// if current user, add rules for their language to `Str` class
if ($user = $kirby?->user()) {
// add rules for a particular language to `Str` class
if ($this->language !== null) {
Str::$language = [
...Str::$language,
...Language::loadRules($user->language())];
...Language::loadRules($this->language)];
}
// sanitize name