Skip to content

Commit

Permalink
Erneutes Setup: Sprache vorauswählen (#5237)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Jul 18, 2022
1 parent 593b28e commit bf61215
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 9 deletions.
Binary file modified .github/tests-visual/setup--dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/tests-visual/setup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .tools/bin/setup
Expand Up @@ -31,6 +31,7 @@ if (rex::isSetup()) {
rex::setConfig('utf8mb4', $utf8mb4);

$config['setup'] = false;
$config['lang'] = 'de_de';
if (rex_file::putConfig($configFile, $config)) {
rex_delete_cache();
echo 'instance setup successfull', PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/backend.php
Expand Up @@ -62,7 +62,7 @@
// ----------------- SETUP
if (rex::isSetup()) {
// ----------------- SET SETUP LANG
$requestLang = rex_request('lang', 'string');
$requestLang = rex_request('lang', 'string', rex::getProperty('lang'));
if (in_array($requestLang, rex_i18n::getLocales())) {
rex::setProperty('lang', $requestLang);
} else {
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/default.config.yml
Expand Up @@ -45,7 +45,7 @@ password_policy:
# no_reuse_within: P6W
# force_renew_after: P6W
# block_account_after: P3M
lang: de_de
lang: en_gb
lang_fallback: [en_gb, de_de]
use_https: false
use_hsts: false
Expand Down
3 changes: 2 additions & 1 deletion redaxo/src/core/lang/de_de.lang
Expand Up @@ -174,7 +174,8 @@ setup_error2 = Leider konnte die config.yml nicht beschrieben werden. Bitte trag


setup_100 = Setup: Schritt 1 von 6 / Sprache
setup_101 = bitte wähle eine Sprache
setup_101 = Sprache wählen
setup_110 = Weiter zu Schritt 2
setup_199 = 1 / Sprache

setup_200 = Setup: Schritt 2 von 6 / Systemcheck
Expand Down
3 changes: 2 additions & 1 deletion redaxo/src/core/lang/en_gb.lang
Expand Up @@ -174,7 +174,8 @@ setup_error2 = Unfortunately, the configuration file could not be written to. Pl


setup_100 = Setup: step 1 of 6 / Language
setup_101 = Please select a language
setup_101 = Select a language
setup_110 = Continue with step 2
setup_199 = 1 / Language

setup_200 = Setup: step 2 of 6 / System check
Expand Down
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/console/setup/run.php
Expand Up @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
ksort($langs);

$config['lang'] = $this->getOptionOrAsk(
new ChoiceQuestion('Please select a language', $langs),
new ChoiceQuestion('Please select a language', $langs, $config['lang'] ?? null),
'lang',
null,
'Language "%s" selected.',
Expand Down
13 changes: 10 additions & 3 deletions redaxo/src/core/lib/setup/setup.php
Expand Up @@ -248,17 +248,24 @@ public static function checkDbSecurity()
*/
public static function isInitialSetup(): bool
{
/** @var bool|null $initial */
static $initial;

if (null !== $initial) {
return $initial;
}

try {
$userSql = rex_sql::factory();
$userSql->setQuery('select * from ' . rex::getTable('user') . ' LIMIT 1');

return 0 == $userSql->getRows();
return $initial = 0 == $userSql->getRows();
} catch (rex_sql_could_not_connect_exception $e) {
return true;
return $initial = true;
} catch (rex_sql_exception $e) {
$sql = $e->getSql();
if ($sql && rex_sql::ERRNO_TABLE_OR_VIEW_DOESNT_EXIST === $sql->getErrno()) {
return true;
return $initial = true;
}
throw $e;
}
Expand Down
13 changes: 12 additions & 1 deletion redaxo/src/core/pages/setup.step1.php
Expand Up @@ -5,10 +5,14 @@

rex_setup::init();

$initial = rex_setup::isInitialSetup();
$current = rex_i18n::getLocale();

$langs = [];
foreach (rex_i18n::getLocales() as $locale) {
$label = rex_i18n::msgInLocale('lang', $locale);
$langs[$label] = '<a class="list-group-item" href="' . $context->getUrl(['lang' => $locale, 'step' => 2]) . '">' . $label . '</a>';
$active = !$initial && $current === $locale ? ' active' : '';
$langs[$label] = '<a class="list-group-item'.$active.'" href="' . $context->getUrl(['lang' => $locale, 'step' => 2]) . '">' . $label . '</a>';
}
ksort($langs);
echo rex_view::title(rex_i18n::msg('setup_100').$cancelSetupBtn);
Expand All @@ -17,4 +21,11 @@
$fragment = new rex_fragment();
$fragment->setVar('heading', rex_i18n::msg('setup_101'), false);
$fragment->setVar('content', $content, false);

if (!$initial) {
$buttons = '<a class="btn btn-setup" href="' . $context->getUrl(['step' => 2]) . '">' . rex_i18n::msg('setup_110') . '</a>';

$fragment->setVar('buttons', $buttons, false);
}

echo $fragment->parse('core/page/section.php');

0 comments on commit bf61215

Please sign in to comment.