translate ajout d'une langue OK

This commit is contained in:
Fred Tempez 2022-09-28 14:15:06 +02:00
parent 9a44401cf7
commit d242199446
3 changed files with 64 additions and 44 deletions

View File

@ -613,6 +613,7 @@ class common {
mkdir (self::DATA_DIR .$lang, 0755);
}
$db = $this->dataFiles[$module];
if ($sampleSite === true) {
$db->set($module,init::$siteData[$module]);
} else {
@ -620,6 +621,7 @@ class common {
}
$db->save;
// Dossier des pages
if (!is_dir(self::DATA_DIR . $lang . '/content')) {
mkdir(self::DATA_DIR . $lang . '/content', 0755);

View File

@ -162,7 +162,6 @@ class translate extends common {
chdir($dir);
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Multilangues',
@ -180,32 +179,33 @@ class translate extends common {
// Soumission du formulaire
if($this->isPost()) {
// Création du contenu
$lang = $this->getInput('translateAddContent');
// Tableau avec les données vierges
require_once('core/module/install/ressource/defaultdata.php');
// Créer la structure
foreach (['page', 'module', 'locale'] as $key) {
// Sus-dossier localisé
if (!file_exists(self::DATA_DIR . $lang)) {
mkdir (self::DATA_DIR . $lang, 0755);
}
// Initialiser la classe
$db = new \Prowebcraft\JsonDb([
'name' => $key . '.json',
'dir' => self::DATA_DIR . $lang,
'backup' => file_exists('site/data/.backup')
]);;
// Capturer et sauver
$db->set($key,init::$defaultData[$key]);
$db->save;
}
// Sauvegarder les locales
$this->setData([
'locale',
[
'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true),
'page404' => $this->getInput('localePage404'),
'page403' => $this->getInput('localePage403'),
'page302' => $this->getInput('localePage302'),
'legalPageId' => $this->getInput('localeLegalPageId'),
'searchPageId' => $this->getInput('localeSearchPageId'),
'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT),
'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT),
'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT),
'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true),
'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true),
'cookies' => [
// Les champs sont obligatoires si l'option consentement des cookies est active
'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN))
]
]
]);
// Valeurs en sortie
$this->addOutput([
@ -219,22 +219,10 @@ class translate extends common {
// Préparation de l'affichage du formulaire
//-----------------------------------------
// Générer la liste des pages disponibles
self::$pagesList = $this->getData(['page']);
foreach(self::$pagesList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' ||
$this->getData(['page',$page,'disable']) === true) {
unset(self::$pagesList[$page]);
}
}
self::$orphansList = $this->getData(['page']);
foreach(self::$orphansList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' ||
$this->getData(['page',$page,'disable']) === true ||
$this->getdata(['page',$page, 'position']) !== 0) {
unset(self::$orphansList[$page]);
}
// Tableau des langues non installées
foreach (self::$languages as $key => $value) {
if (!is_dir( self::DATA_DIR . $key))
self::$i18nFiles [$key] = $value;
}
// Valeurs en sortie
@ -285,8 +273,7 @@ class translate extends common {
]
]
];
echo "<pre>";
var_dump($data);
// Sauvegarde hors méthodes si la langue n'est pas celle de l'UI
if ( $this->getUrl(2) === self::$i18nUI ) {
// Enregistrer les données par lecture directe du formulaire

View File

@ -0,0 +1,31 @@
<?php echo template::formOpen('translateAddForm'); ?>
<div class="row">
<div class="col1">
<?php echo template::button('translateFormBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'translate',
'value' => template::ico('left')
]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('translateFormSubmit'); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo template::topic('Ajout d\'une longue de contenu'); ?>
</h4>
<div class="row">
<div class="col4 offset4">
<?php echo template::select('translateAddContent', $module::$i18nFiles, [
'label' => 'Langues disponibles'
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>