mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-27 16:26:32 +01:00
Fixed issue saving page with non-standard language #1667
This commit is contained in:
@@ -631,7 +631,7 @@ class AdminBaseController
|
||||
// now the first 4 chars of base contain the lang code.
|
||||
// if redirect path already contains the lang code, and is != than the base lang code, then use redirect path as-is
|
||||
if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect)
|
||||
&& 0 !== strpos($this->redirect, substr($base, 0, 4))
|
||||
&& !Utils::startsWith($this->redirect, $base)
|
||||
) {
|
||||
$redirect = $this->redirect;
|
||||
} else {
|
||||
|
||||
@@ -2375,18 +2375,19 @@ class AdminController extends AdminBaseController
|
||||
*/
|
||||
public function determineFilenameIncludingLanguage($current_filename, $language)
|
||||
{
|
||||
$filename = substr($current_filename, 0, -strlen('.md'));
|
||||
$ext = '.md';
|
||||
$filename = substr($current_filename, 0, -strlen($ext));
|
||||
$languages_enabled = $this->grav['config']->get('system.languages.supported', []);
|
||||
|
||||
if (substr($filename, -3, 1) === '.') {
|
||||
$filename = str_replace(substr($filename, -2), $language, $filename);
|
||||
} elseif (substr($filename, -6, 1) === '.') {
|
||||
$filename = str_replace(substr($filename, -5), $language, $filename);
|
||||
} else {
|
||||
$filename .= '.' . $language;
|
||||
$parts = explode('.', trim($filename, '.'));
|
||||
$lang = array_pop($parts);
|
||||
|
||||
if ($lang === $language) {
|
||||
return $filename . $ext;
|
||||
} elseif (in_array($lang, $languages_enabled)) {
|
||||
$filename = implode('.', $parts);
|
||||
}
|
||||
|
||||
return $filename . '.md';
|
||||
return $filename . '.' . $language . $ext;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user