diff --git a/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php b/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php index 59614b4d748..9849ee3e8d2 100644 --- a/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php +++ b/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php @@ -184,8 +184,14 @@ protected function compile() continue; } - // Skip occurrences in the past but show running events (see #8497) - if (($this->cal_hideRunning || $event['repeatEnd']) && $event['end'] < $intStart) + // Hide running events + if ($this->cal_hideRunning && $event['begin'] < $intStart) + { + continue; + } + + // Skip occurrences in the past + if ($event['repeatEnd'] && $event['end'] < $intStart) { continue; } diff --git a/core-bundle/src/Resources/contao/classes/Backend.php b/core-bundle/src/Resources/contao/classes/Backend.php index 2c55bea88b7..a2b3dc5faae 100644 --- a/core-bundle/src/Resources/contao/classes/Backend.php +++ b/core-bundle/src/Resources/contao/classes/Backend.php @@ -1128,6 +1128,23 @@ public static function getDcaPickerWizard($extras, $table, $field, $inputName) '; } + /** + * Return the decoded host name + * + * @return string + */ + public static function getDecodedHostname() + { + $host = Environment::get('host'); + + if (strncmp($host, 'xn--', 4) === 0) + { + $host = Idna::decode($host); + } + + return $host; + } + /** * Add the custom layout section references */ diff --git a/core-bundle/src/Resources/contao/classes/Frontend.php b/core-bundle/src/Resources/contao/classes/Frontend.php index aa02c98ffae..bee541486a1 100644 --- a/core-bundle/src/Resources/contao/classes/Frontend.php +++ b/core-bundle/src/Resources/contao/classes/Frontend.php @@ -308,6 +308,20 @@ public static function getRootPageFromUrl() $logger = System::getContainer()->get('monolog.logger.contao'); $accept_language = Environment::get('httpAcceptLanguage'); + // Get the language from the URL if it is not set (see #456) + if (!isset($_GET['language']) && Config::get('addLanguageToUrl')) + { + $arrMatches = array(); + + // Get the request without the query string + list($strRequest) = explode('?', Environment::get('relativeRequest'), 2); + + if (preg_match('@^([a-z]{2}(-[A-Z]{2})?)/@', $strRequest, $arrMatches)) + { + Input::setGet('language', $arrMatches[1]); + } + } + // The language is set in the URL if (!empty($_GET['language']) && Config::get('addLanguageToUrl')) { diff --git a/core-bundle/src/Resources/contao/controllers/BackendAlerts.php b/core-bundle/src/Resources/contao/controllers/BackendAlerts.php index 437c5cc2ab1..9093aa85027 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendAlerts.php +++ b/core-bundle/src/Resources/contao/controllers/BackendAlerts.php @@ -55,7 +55,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['systemMessages']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->messages = Message::generateUnwrapped() . Backend::getSystemMessages(); $objTemplate->noMessages = $GLOBALS['TL_LANG']['MSC']['noSystemMessages']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendConfirm.php b/core-bundle/src/Resources/contao/controllers/BackendConfirm.php index 001d52df88b..cc5c3e7fc75 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendConfirm.php +++ b/core-bundle/src/Resources/contao/controllers/BackendConfirm.php @@ -153,7 +153,7 @@ public function run() $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->h1 = $GLOBALS['TL_LANG']['MSC']['invalidToken']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['invalidToken']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); return $objTemplate->getResponse(); diff --git a/core-bundle/src/Resources/contao/controllers/BackendFile.php b/core-bundle/src/Resources/contao/controllers/BackendFile.php index 481b4962adb..c4d0e8c5c6d 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendFile.php +++ b/core-bundle/src/Resources/contao/controllers/BackendFile.php @@ -149,7 +149,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->addSearch = true; $objTemplate->search = $GLOBALS['TL_LANG']['MSC']['search']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendHelp.php b/core-bundle/src/Resources/contao/controllers/BackendHelp.php index 7ab165f6d5d..60d53606d74 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendHelp.php +++ b/core-bundle/src/Resources/contao/controllers/BackendHelp.php @@ -149,7 +149,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizardTitle']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->headline = $arrData['label'][0] ?: $field; $objTemplate->helpWizard = $GLOBALS['TL_LANG']['MSC']['helpWizard']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendIndex.php b/core-bundle/src/Resources/contao/controllers/BackendIndex.php index d76f02a7f09..f470ed5854e 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendIndex.php +++ b/core-bundle/src/Resources/contao/controllers/BackendIndex.php @@ -100,7 +100,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->languages = System::getLanguages(true); // backwards compatibility - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0]; $objTemplate->curLanguage = Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']); diff --git a/core-bundle/src/Resources/contao/controllers/BackendMain.php b/core-bundle/src/Resources/contao/controllers/BackendMain.php index d7d42939922..847232594cc 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendMain.php +++ b/core-bundle/src/Resources/contao/controllers/BackendMain.php @@ -288,7 +288,7 @@ protected function output() $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = StringUtil::specialchars(strip_tags($this->Template->title)); - $this->Template->host = Environment::get('host'); + $this->Template->host = Backend::getDecodedHostname(); $this->Template->charset = Config::get('characterSet'); $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1]; $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendPage.php b/core-bundle/src/Resources/contao/controllers/BackendPage.php index b850b219113..d54563510ec 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendPage.php +++ b/core-bundle/src/Resources/contao/controllers/BackendPage.php @@ -139,7 +139,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->addSearch = true; $objTemplate->search = $GLOBALS['TL_LANG']['MSC']['search']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendPassword.php b/core-bundle/src/Resources/contao/controllers/BackendPassword.php index 99f4684986d..64d38c4ae55 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendPassword.php +++ b/core-bundle/src/Resources/contao/controllers/BackendPassword.php @@ -130,7 +130,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->action = ampersand(Environment::get('request')); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_new']; diff --git a/core-bundle/src/Resources/contao/controllers/BackendPopup.php b/core-bundle/src/Resources/contao/controllers/BackendPopup.php index b5c216f402b..3a572440ee5 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendPopup.php +++ b/core-bundle/src/Resources/contao/controllers/BackendPopup.php @@ -164,7 +164,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($this->strFile); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->labels = (object) $GLOBALS['TL_LANG']['MSC']; $objTemplate->download = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fileDownload']); diff --git a/core-bundle/src/Resources/contao/controllers/BackendPreview.php b/core-bundle/src/Resources/contao/controllers/BackendPreview.php index 376a8cef988..667aad9c805 100644 --- a/core-bundle/src/Resources/contao/controllers/BackendPreview.php +++ b/core-bundle/src/Resources/contao/controllers/BackendPreview.php @@ -85,7 +85,7 @@ public function run() $objTemplate->base = Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']); - $objTemplate->host = Environment::get('host'); + $objTemplate->host = Backend::getDecodedHostname(); $objTemplate->charset = Config::get('characterSet'); $objTemplate->site = Input::get('site', true); $objTemplate->switchHref = $objRouter->generate('contao_backend_switch'); diff --git a/core-bundle/src/Resources/contao/dca/tl_form.php b/core-bundle/src/Resources/contao/dca/tl_form.php index d35d1cf79d8..92306c2a523 100644 --- a/core-bundle/src/Resources/contao/dca/tl_form.php +++ b/core-bundle/src/Resources/contao/dca/tl_form.php @@ -473,7 +473,7 @@ public function generateAlias($varValue, Contao\DataContainer $dc) // Generate an alias if there is none if ($varValue == '') { - $varValue = Contao\System::getContainer()->get('contao.slug')->generate($dc->activeRecord->title, $dc->activeRecord->jumpTo, $aliasExists); + $varValue = Contao\System::getContainer()->get('contao.slug')->generate($dc->activeRecord->title, Contao\Input::post('jumpTo') ?: $dc->activeRecord->jumpTo, $aliasExists); } elseif ($aliasExists($varValue)) { diff --git a/core-bundle/tests/Functional/RoutingTest.php b/core-bundle/tests/Functional/RoutingTest.php index a9e7379c94b..59153937c4f 100644 --- a/core-bundle/tests/Functional/RoutingTest.php +++ b/core-bundle/tests/Functional/RoutingTest.php @@ -385,7 +385,7 @@ public function getAliasesWithLocale(): \Generator '/en/home.xml', 404, '(404 Not Found)', - [], + ['language' => 'en'], 'root-with-home.local', false, false, @@ -395,7 +395,7 @@ public function getAliasesWithLocale(): \Generator '/en/home/auto_item/foo.html', 404, '(404 Not Found)', - [], + ['language' => 'en'], 'root-with-home.local', false, false, @@ -445,7 +445,7 @@ public function getAliasesWithLocale(): \Generator '/en/.html', 404, '(404 Not Found)', - [], + ['language' => 'en'], 'root-with-home.local', false, false, @@ -495,7 +495,7 @@ public function getAliasesWithLocale(): \Generator '/en/home/auto_item/foo.html', 404, '(404 Not Found)', - [], + ['language' => 'en'], 'root-with-home.local', true, false, @@ -545,7 +545,7 @@ public function getAliasesWithLocale(): \Generator '/en/folder/url/home/auto_item/foo.html', 404, '(404 Not Found)', - [], + ['language' => 'en'], 'root-with-folder-urls.local', true, true,