Choix de la langue à l'intallation

This commit is contained in:
Fred Tempez 2022-09-21 15:09:25 +02:00
parent 55b4763cff
commit a62135c172
6 changed files with 175 additions and 118 deletions

View File

@ -18,6 +18,7 @@ class install extends common {
public static $actions = [
'index' => self::GROUP_VISITOR,
"postinstall" => self::GROUP_VISITOR,
'steps' => self::GROUP_ADMIN,
'update' => self::GROUP_ADMIN
];
@ -75,11 +76,55 @@ class install extends common {
// source: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
];
/**
* Installation
* Pré-installation - choix de la langue
*/
public function index() {
// Accès refusé
if($this->getData(['user']) !== []) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
}
// Accès autorisé
else {
// Soumission du formulaire
if($this->isPost()) {
$this->setData(['config', 'i18n', 'interface', $this->getInput('installLanguage')]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'install/postinstall'
]);
}
}
// Liste des langues UI disponibles
if (is_dir(self::I18N_DIR)) {
$dir = getcwd();
chdir(self::I18N_DIR);
$files = glob('*.json');
// Ajouter une clé au tableau avec le code de langue
foreach( $files as $file) {
// La langue est-elle référencée ?
if (array_key_exists(basename($file, '.json'), self::$languagesUI)) {
self::$i18nFiles[basename($file, '.json')] = self::$languagesUI[basename($file, '.json')];
}
}
chdir($dir);
}
$this->addOutput([
'display' => self::DISPLAY_LAYOUT_LIGHT,
'title' => 'Installation',
'view' => 'index'
]);
}
/**
* post Installation
*/
public function postInstall() {
// Accès refusé
if($this->getData(['user']) !== []) {
// Valeurs en sortie
@ -204,21 +249,6 @@ class install extends common {
$dataThemes = json_decode($dataThemes, true);
self::$themes = helper::arrayColumn($dataThemes, 'name');
// Liste des langues UI disponibles
if (is_dir(self::I18N_DIR)) {
$dir = getcwd();
chdir(self::I18N_DIR);
$files = glob('*.json');
// Ajouter une clé au tableau avec le code de langue
foreach( $files as $file) {
// La langue est-elle référencée ?
if (array_key_exists(basename($file, '.json'), self::$languagesUI)) {
self::$i18nFiles[basename($file, '.json')] = self::$languagesUI[basename($file, '.json')];
}
}
chdir($dir);
}
// Créer sitemap
$this->createSitemap();
// Mise à jour de la liste des pages pour TinyMCE
@ -228,7 +258,7 @@ class install extends common {
$this->addOutput([
'display' => self::DISPLAY_LAYOUT_LIGHT,
'title' => 'Installation',
'view' => 'index'
'view' => 'postinstall'
]);
}
}

View File

@ -1 +0,0 @@
/* Vide */

View File

@ -1,100 +1,20 @@
<p>
<?php echo template::topic('Renseignez les champs ci-dessous pour finaliser l\'installation.'); ?>
</p>
<?php echo template::formOpen('installForm'); ?>
<h3>
<?php echo template::topic('Compte administrateur'); ?>
</h3>
<div>
<div class="row">
<div class="col12">
<?php echo template::text('installId', [
'autocomplete' => 'off',
'label' => 'Identifiant'
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::password('installPassword', [
'autocomplete' => 'off',
'label' => 'Mot de passe'
]); ?>
</div>
<div class="col6">
<?php echo template::password('installConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
</div>
</div>
<?php echo template::mail('installMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail'
]); ?>
<div class="row">
<div class="col6">
<?php echo template::text('installFirstname', [
'autocomplete' => 'off',
'label' => 'Prénom'
]); ?>
</div>
<div class="col6">
<?php echo template::text('installLastname', [
'autocomplete' => 'off',
'label' => 'Nom'
]); ?>
</div>
</div>
</div>
<ul class="accordion" data-speed="150">
<li class="accordion-item">
<h3 class="accordion-title">
<?php echo template::topic('&#9655; Options avancées'); ?>
</h3>
<div class="accordion-content">
<div class="row">
<div class="col12">
<?php echo template::checkbox('installDefaultData',true , 'Ne pas charger l\'exemple de site (utilisateurs avancés)', [
'checked' => false
]);
?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::select('installProxyType', $module::$proxyType, [
'label' => 'Type de proxy'
]); ?>
</div>
<div class="col6">
<?php echo template::text('installProxyUrl', [
'label' => 'Adresse du proxy',
'placeholder' => 'cache.proxy.fr'
]); ?>
</div>
<div class="col3">
<?php echo template::text('installProxyPort', [
'label' => 'Port du proxy',
'placeholder' => '6060'
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('installTheme', $module::$themes, [
'label' => 'Thème'
]); ?>
</div>
</div>
</div>
</li>
</ul>
<div class="row">
<div class="col3 offset9">
<?php echo template::submit('installSubmit', [
'value' => 'Installer'
]); ?>
</div>
</div>
<?php echo template::formOpen('installForm'); ?>
<h3>
<?php echo template::topic('Dans quelle langue utiliserez-vous Zwii ?'); ?>
</h3>
<div class="row">
<div class="col6 offset3">
<?php echo template::select('installLanguage', $module::$i18nFiles, [
'label' => 'Langues installées',
'selected' => $this->getData(['config', 'i18n', 'interface'])
]); ?>
</div>
</div>
<div class="row">
<div class="col3 offset9">
<?php echo template::submit('installSubmit', [
'value' => 'Suivant'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -0,0 +1 @@
/* Vide */

View File

@ -0,0 +1,107 @@
<p>
<?php echo template::topic('Renseignez les champs ci-dessous pour finaliser l\'installation.'); ?>
</p>
<?php echo template::formOpen('installForm'); ?>
<h3>
<?php echo template::topic('Compte administrateur'); ?>
</h3>
<div>
<div class="row">
<div class="col12">
<?php echo template::text('installId', [
'autocomplete' => 'off',
'label' => 'Identifiant'
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::password('installPassword', [
'autocomplete' => 'off',
'label' => 'Mot de passe'
]); ?>
</div>
<div class="col6">
<?php echo template::password('installConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
</div>
</div>
<?php echo template::mail('installMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail'
]); ?>
<div class="row">
<div class="col6">
<?php echo template::text('installFirstname', [
'autocomplete' => 'off',
'label' => 'Prénom'
]); ?>
</div>
<div class="col6">
<?php echo template::text('installLastname', [
'autocomplete' => 'off',
'label' => 'Nom'
]); ?>
</div>
</div>
</div>
<ul class="accordion" data-speed="150">
<li class="accordion-item">
<h3 class="accordion-title">
<?php echo template::topic('&#9655; Options avancées'); ?>
</h3>
<div class="accordion-content">
<div class="row">
<div class="col12">
<?php echo template::checkbox('installDefaultData',true , 'Ne pas charger l\'exemple de site (utilisateurs avancés)', [
'checked' => false
]);
?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::select('installProxyType', $module::$proxyType, [
'label' => 'Type de proxy'
]); ?>
</div>
<div class="col6">
<?php echo template::text('installProxyUrl', [
'label' => 'Adresse du proxy',
'placeholder' => 'cache.proxy.fr'
]); ?>
</div>
<div class="col3">
<?php echo template::text('installProxyPort', [
'label' => 'Port du proxy',
'placeholder' => '6060'
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('installTheme', $module::$themes, [
'label' => 'Thème'
]); ?>
</div>
</div>
</div>
</li>
</ul>
<div class="row">
<div class="col2">
<?php echo template::button('installPrevious', [
'class' => 'buttonGrey',
'href' => helper::baseUrl(true) . '?install',
'value' => template::ico('left')
]); ?>
</div>
<div class="col3 offset7">
<?php echo template::submit('installSubmit', [
'value' => 'Installer'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>