mirror of
				https://github.com/getgrav/grav-plugin-admin.git
				synced 2025-10-30 09:56:11 +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. |             // 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 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) |             if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect) | ||||||
|                 && 0 !== strpos($this->redirect, substr($base, 0, 4)) |                 && !Utils::startsWith($this->redirect, $base) | ||||||
|             ) { |             ) { | ||||||
|                 $redirect = $this->redirect; |                 $redirect = $this->redirect; | ||||||
|             } else { |             } else { | ||||||
|   | |||||||
| @@ -2375,18 +2375,19 @@ class AdminController extends AdminBaseController | |||||||
|      */ |      */ | ||||||
|     public function determineFilenameIncludingLanguage($current_filename, $language) |     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) === '.') { |         $parts = explode('.', trim($filename, '.')); | ||||||
|             $filename = str_replace(substr($filename, -2), $language, $filename); |         $lang = array_pop($parts); | ||||||
|         } elseif (substr($filename, -6, 1) === '.') { |  | ||||||
|             $filename = str_replace(substr($filename, -5), $language, $filename); |         if ($lang === $language) { | ||||||
|         } else { |             return $filename . $ext; | ||||||
|             $filename .= '.' . $language; |         } elseif (in_array($lang, $languages_enabled)) { | ||||||
|  |             $filename = implode('.', $parts); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $filename . '.md'; |         return $filename . '.' . $language . $ext; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user