beta07 Génère un content vide localisé selon la langue sélectionnée

This commit is contained in:
Fred Tempez 2022-12-18 11:34:06 +01:00
parent 5f2f9ee820
commit 0dca0487ec
5 changed files with 245 additions and 184 deletions

View File

@ -49,7 +49,7 @@ class common
// Numéro de version
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
const ZWII_VERSION = '12.0.00-beta06';
const ZWII_VERSION = '12.0.00-beta07';
const ZWII_UPDATE_CHANNEL = "test";
public static $actions = [];
@ -326,8 +326,10 @@ class common
];
// Convertit les dossiers vers la nouvelle structure
foreach ($languages as $key => $value) {
if (is_dir(self::DATA_DIR . $key) &&
!is_dir(self::DATA_DIR . $value)) {
if (
is_dir(self::DATA_DIR . $key) &&
!is_dir(self::DATA_DIR . $value)
) {
rename(self::DATA_DIR . $key, self::DATA_DIR . $value);
}
}
@ -689,31 +691,46 @@ class common
}
$db = $this->dataFiles[$module];
if ($sampleSite === true) {
if ($sampleSite === true && $lang === 'fr_FR') {
$db->set($module, init::$siteData[$module]);
} else {
$db->set($module, init::$defaultData[$module]);
}
$db->save;
// Dossier des pages
if (!is_dir(self::DATA_DIR . $lang . '/content')) {
mkdir(self::DATA_DIR . $lang . '/content', 0755);
}
// Créer le jeu de pages du site de test
if ($module === 'page') {
$langFolder = $lang . '/content/';
// Dossier des pages
if (!is_dir(self::DATA_DIR . $langFolder)) {
mkdir(self::DATA_DIR . $langFolder, 0755);
}
// Site de test ou page simple
if ($lang === 'fr_FR') {
if ($sampleSite === true) {
foreach (init::$siteContent as $key => $value) {
// Creation du contenu de la page
if (!empty($this->getData(['page', $key, 'content']))) {
file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $key, 'content']), $value);
file_put_contents(self::DATA_DIR . $langFolder . $this->getData(['page', $key, 'content']), $value);
}
}
} else {
// Créer la page d'accueil
file_put_contents(self::DATA_DIR . $lang . '/content/' . 'accueil.html', '<p>Contenu de votre nouvelle page.</p>');
file_put_contents(self::DATA_DIR .$langFolder . 'accueil.html', '<p>Contenu de votre nouvelle page.</p>');
}
} else {
// En_EN si le contenu localisé n'est pas traduit
if (!isset(init::$defaultDataI18n[$lang])) {
$lang = 'en_EN';
}
// Messages localisés
$this->setData(['locale', init::$defaultDataI18n[$lang]['locale']]);
// Page dans une autre langue, page d'accueil
$this->setData(['page', init::$defaultDataI18n[$lang]['page']]);
// Créer la page d'accueil
$pageId = init::$defaultDataI18n[$lang]['locale']['homePageId'];
$content = init::$defaultDataI18n[$lang]['html'];
file_put_contents(self::DATA_DIR . $langFolder . init::$defaultDataI18n[$lang]['page'][$pageId]['content'], $content);
}
}
}

View File

@ -173,6 +173,12 @@ class install extends common
$this->setData(['module', 'blog', 'posts', 'mon-troisieme-article', 'userId', $userId]);
}
// Jeu réduit pour les pages étrangères
if ( $lang !== 'fr_FR') {
$this->initData('page', self::$i18nContent, false);
$this->initData('module', self::$i18nContent, false);
}
// Sauvegarder la configuration du Proxy
$this->setData(['config', 'proxyType', $this->getInput('installProxyType')]);
$this->setData(['config', 'proxyUrl', $this->getInput('installProxyUrl')]);

View File

@ -1,5 +1,6 @@
<?php
class init extends common {
class init extends common
{
public static $defaultData = [
'config' => [
'autoBackup' => true,
@ -333,6 +334,61 @@ class init extends common {
],
'blacklist' => []
];
public static $defaultDataI18n = [
'en_EN' => [
'locale' => [
'homePageId' => 'home',
'page302' => 'none',
'page403' => 'none',
'page404' => 'none',
'legalPageId' => 'none',
'searchPageId' => 'none',
'searchPageLabel' => 'none',
'sitemapPageLabel' => 'none',
'legalPageLabel' => 'legals',
'metaDescription' => 'Zwii is a database-free CMS that makes it easy to create and manage a website without any programming knowledge.',
'title' => 'Your site in a few clicks!',
'cookies' => [
'mainLabel' => 'This site uses cookies necessary for its operation, they make it possible to streamline its operation for example by memorizing the connection data, the language you have chosen or the validation of this message.',
'titleLabel' => 'Essential cookies',
'linkLegalLabel' => 'Consult the legal notice',
'cookiesFooterText' => 'Cookies',
'buttonValidLabel' => 'Ok'
]
],
'page' => [
'home' => [
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => false,
'content' => 'home.html',
'hideTitle' => false,
'homePageId' => true,
'breadCrumb' => false,
'metaDescription' => '',
'metaTitle' => '',
'moduleId' => '',
'modulePosition' => 'bottom',
'parentPageId' => '',
'position' => 1,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => 'HomePage',
'shortTitle' => 'Home',
'block' => '12',
'barLeft' => '',
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
]
],
'html' => 'Welcome in this ZiiCMS, this is you first page !'
]
];
public static $siteData = [

View File

@ -207,30 +207,11 @@ class translate extends common
// 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é
// Stockage dans un sous-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;
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'translate',

View File

@ -17,20 +17,21 @@
]);*/ ?>
</div>
<div class="col1 offset8">
<?php echo template::button('translateButtonAddContent', [
'href' => helper::baseUrl() . 'translate/add',
'value' => template::ico('plus'),
'class' => 'buttonGreen',
'help' => 'Nouveau contenu localisé'
]); ?>
</div>
<div class="col1">
<?php echo template::button('translateButtonCopyContent', [
'href' => helper::baseUrl() . 'translate/copy',
'value' => template::ico('docs'),
'disabled' => $module::$siteCopy,
'help' => 'Copie de contenus localisés'
]); ?>
</div>
<div class="col1">
<?php echo template::button('translateButtonAddContent', [
'href' => helper::baseUrl() . 'translate/add',
'value' => template::ico('plus'),
'class' => 'buttonGreen',
'help' => 'Nouveau contenu localisé'
]); ?>
</div>
</div>