Commit a2e5b7df authored by Tino Goratsch's avatar Tino Goratsch

fixed and reworked the language changing logic of the installer/updater

parent f150a34c
......@@ -31,6 +31,21 @@ class Bootstrap extends Core\Application\AbstractBootstrap
$this->outputPage();
}
/**
* @inheritdoc
*/
public function startupChecks()
{
// Standardzeitzone festlegen
date_default_timezone_set('UTC');
if ($this->appMode === Core\Environment\ApplicationMode::UPDATER) {
return $this->databaseConfigExists();
}
return true;
}
/**
* @param string $appMode
*/
......@@ -71,19 +86,4 @@ class Bootstrap extends Core\Application\AbstractBootstrap
$redirect->temporary('errors/index/server_error')->send();
}
}
/**
* @inheritdoc
*/
public function startupChecks()
{
// Standardzeitzone festlegen
date_default_timezone_set('UTC');
if ($this->appMode === Core\Environment\ApplicationMode::UPDATER) {
return $this->databaseConfigExists();
}
return true;
}
}
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Installer\Core\Application\Event\Listener;
use ACP3\Core\Http\RequestInterface;
use ACP3\Core\Redirect;
class OnFrontControllerBeforeDispatchListener
{
/**
* @var RequestInterface
*/
private $request;
/**
* @var Redirect
*/
private $redirect;
/**
* OnFrontControllerBeforeDispatchListener constructor.
* @param RequestInterface $request
* @param Redirect $redirect
*/
public function __construct(
RequestInterface $request,
Redirect $redirect)
{
$this->request = $request;
$this->redirect = $redirect;
}
/**
* If the language has been changed, set a cookie with the new default language and force a page reload
*/
public function onLanguageChange()
{
if ($this->request->getPost()->has('lang')) {
setcookie('ACP3_INSTALLER_LANG', $this->request->getPost()->get('lang', ''), time() + 3600, '/');
$this->redirect->temporary($this->request->getFullPath())->send();
exit;
}
}
}
......@@ -66,11 +66,6 @@ abstract class AbstractInstallerAction implements ActionInterface
*/
public function preDispatch()
{
if ($this->request->getPost()->has('lang')) {
setcookie('ACP3_INSTALLER_LANG', $this->request->getPost()->get('lang', ''), time() + 3600, '/');
$this->redirect()->temporary($this->request->getFullPath());
}
$this->setLanguage();
// Einige Template Variablen setzen
......@@ -83,9 +78,13 @@ abstract class AbstractInstallerAction implements ActionInterface
$this->view->assign('UA_IS_MOBILE', $this->request->getUserAgent()->isMobileBrowser());
$this->view->assign('IS_AJAX', $this->request->isAjax());
$languageInfo = simplexml_load_file($this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/' . $this->translator->getLocale() . '.xml');
$this->view->assign('LANG_DIRECTION',
isset($languageInfo->info->direction) ? $languageInfo->info->direction : 'ltr');
$languageInfo = simplexml_load_file(
$this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/' . $this->translator->getLocale() . '.xml'
);
$this->view->assign(
'LANG_DIRECTION',
isset($languageInfo->info->direction) ? $languageInfo->info->direction : 'ltr'
);
$this->view->assign('LANG', $this->translator->getShortIsoCode());
}
......@@ -130,7 +129,6 @@ abstract class AbstractInstallerAction implements ActionInterface
*/
private function languagesDropdown($selectedLanguage)
{
// Dropdown-Menü für die Sprachen
$languages = [];
$path = $this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/';
......@@ -172,7 +170,7 @@ abstract class AbstractInstallerAction implements ActionInterface
) {
$language = $cookieLocale;
} else {
$language = 'en_US'; // Fallback default language
$language = 'en_US'; // Fallback language
foreach ($this->request->getUserAgent()->parseAcceptLanguage() as $locale => $val) {
$locale = str_replace('-', '_', $locale);
......
......@@ -19,6 +19,14 @@ services:
- '@core.request'
- '@service_container'
core.application.event.listener.on_front_controller_before_dispatch_listener:
class: ACP3\Installer\Core\Application\Event\Listener\OnFrontControllerBeforeDispatchListener
arguments:
- '@core.request'
- '@core.redirect'
tags:
- { name: core.eventListener, event: core.application.front_controller.before_dispatch, method: onLanguageChange }
core.date:
class: ACP3\Installer\Core\Date
arguments:
......
......@@ -51,7 +51,7 @@ class Index extends Core\Controller\AbstractInstallerAction
public function execute()
{
if ($this->request->getPost()->isEmpty() === false) {
if ($this->request->getPost()->get('action') === 'confirmed') {
$this->executePost();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment