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,
@ -71,13 +72,13 @@ class init extends common {
],
'fonts' => [
'files' => [],
'imported'=> [
'arimo'=> [
'imported' => [
'arimo' => [
'name' => 'Arimo',
'font-family' => 'Arimo, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/arimo'
],
'arvo'=> [
'arvo' => [
'name' => 'Arvo',
'font-family' => 'Arvo, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/arvo'
@ -87,47 +88,47 @@ class init extends common {
'font-family' => '\'Dancing Script\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/dancing-script'
],
'droid-sans-2'=> [
'droid-sans-2' => [
'name' => 'Droid Sans',
'font-family' => '\'Droid Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2'
],
'droid-serif-2'=> [
'droid-serif-2' => [
'name' => 'Droid Serif',
'font-family' => '\'Droid Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2'
],
'indie-flower'=> [
'indie-flower' => [
'name' => 'Indie Flower',
'font-family' => '\'Indie Flower\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/indie-flower'
],
'liberation-sans'=> [
'liberation-sans' => [
'name' => 'Liberation Sans',
'font-family' => '\'Liberation Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/liberation-sans'
],
'liberation-serif'=> [
'liberation-serif' => [
'name' => 'Liberation Serif',
'font-family' => '\'Liberation Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif'
],
'lobster-2'=> [
'lobster-2' => [
'name' => 'Lobster',
'font-family' => 'Lobster, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/lobster-2'
],
'lato'=> [
'lato' => [
'name' => 'lato',
'font-family' => 'Lato, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/lato'
],
'lora'=> [
'lora' => [
'name' => 'Lora',
'font-family' => 'Lora, serif',
'resource' => 'https://fonts.cdnfonts.com/css/lora'
],
'old-standard-tt-3'=> [
'old-standard-tt-3' => [
'name' => 'Old Standard TT',
'font-family' => '\'Old Standard TT\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/old-standard-tt-3'
@ -137,37 +138,37 @@ class init extends common {
'font-family' => '\'Open Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/open-sans'
],
'oswald-4'=> [
'oswald-4' => [
'name' => 'Oswald',
'font-family' => 'Oswald, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/oswald-4'
],
'pt-mono'=> [
'pt-mono' => [
'name' => 'PT Mono',
'font-family' => '\'PT Mono\', monospace',
'resource' => 'https://fonts.cdnfonts.com/css/pt-mono'
],
'pt-serif'=> [
'pt-serif' => [
'name' => 'PR Serif',
'font-family' => '\'PT Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/pt-serif'
],
'rancho'=> [
'rancho' => [
'name' => 'Rancho',
'font-family' => 'Rancho, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/rancho'
],
'roboto'=> [
'roboto' => [
'name' => 'Roboto',
'font-family' => 'Roboto, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/roboto'
],
'ubuntu'=> [
'ubuntu' => [
'name' => 'Ubuntu',
'font-family' => 'Ubuntu, sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/ubuntu'
],
'vollkorn'=> [
'vollkorn' => [
'name' => 'Vollkorn',
'font-family' => 'Vollkorn, serif',
'resource' => 'https://fonts.cdnfonts.com/css/vollkorn'
@ -198,7 +199,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -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 = [
@ -360,7 +416,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -387,7 +443,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -414,7 +470,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -441,7 +497,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -468,7 +524,7 @@ class init extends common {
'barRight' => 'barrelateraleavecmenu',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -495,7 +551,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -522,7 +578,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -550,7 +606,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -577,7 +633,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -594,7 +650,7 @@ class init extends common {
'moduleId' => '',
'modulePosition' => 'bottom',
'parentPageId' => '',
'position' => 0 ,
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => 'Barre latérale',
@ -604,7 +660,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -621,7 +677,7 @@ class init extends common {
'moduleId' => '',
'modulePosition' => 'bottom',
'parentPageId' => '',
'position' => 0 ,
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => 'Barre latérale avec menu',
@ -631,7 +687,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'parents',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -741,7 +797,7 @@ class init extends common {
'barRight' => '',
'displayMenu' => 'none',
'hideMenuSide' => false,
'hideMenuChildren' =>false,
'hideMenuChildren' => false,
'extraPosition' => false,
'css' => '',
'js' => ''
@ -857,7 +913,7 @@ class init extends common {
'beaux-paysages' => [
'config' => [
'name' => 'Beaux paysages',
'directory' => self::FILE_DIR.'source/galerie/landscape',
'directory' => self::FILE_DIR . 'source/galerie/landscape',
'homePicture' => 'iceberg.jpg',
'sort' => 'SORT_ASC',
'position' => 1
@ -876,7 +932,7 @@ class init extends common {
'espace' => [
'config' => [
'name' => 'Espace',
'directory' => self::FILE_DIR.'source/galerie/space',
'directory' => self::FILE_DIR . 'source/galerie/space',
'homePicture' => 'nebula.jpg',
'sort' => 'SORT_ASC',
'position' => 2
@ -903,7 +959,7 @@ class init extends common {
'thumbBorderColor' => 'rgba(221, 221, 221, 1)',
'thumbRadius' => '.3em',
'thumbShadows' => '1px 1px 10px',
'thumbShadowsColor'=> 'rgba(125, 125, 125, 1)',
'thumbShadowsColor' => 'rgba(125, 125, 125, 1)',
'legendHeight' => '.375em',
'legendAlign' => 'center',
'legendTextColor' => 'rgba(255, 255, 255, 1)',
@ -979,7 +1035,7 @@ class init extends common {
<div class="col4"><p>Principium autem unde latius se funditabat, emersit ex negotio tali. Chilo ex vicario et coniux eius Maxima nomine, questi apud Olybrium ea tempestate urbi praefectum, vitamque suam venenis petitam adseverantes inpetrarunt ut hi, quos suspectati sunt, ilico rapti conpingerentur in vincula, organarius Sericus et Asbolius palaestrita et aruspex Campensis.</p></div>
</div>'
],
'privee'=> [
'privee' => [
'content' => '<p>Cette page n\'est visible que des membres de votre site !</p>
<div class="row">
<div class="col6"><p>Eius populus ab incunabulis primis ad usque pueritiae tempus extremum, quod annis circumcluditur fere trecentis, circummurana pertulit bella, deinde aetatem ingressus adultam post multiplices bellorum aerumnas Alpes transcendit et fretum, in iuvenem erectus et virum ex omni plaga quam orbis ambit inmensus, reportavit laureas et triumphos, iamque vergens in senium et nomine solo aliquotiens vincens ad tranquilliora vitae discessit.</p></div>
@ -1067,7 +1123,7 @@ class init extends common {
<p justify="">Pour toute question relative &agrave; l&rsquo;application des pr&eacute;sentes CGU, vous pouvez joindre l&rsquo;&eacute;diteur aux coordonn&eacute;es inscrites &agrave; l&rsquo;ARTICLE 1.</p>'
],
'erreur302' => [
'content' =>'<p>Notre site est actuellement en maintenance. Nous sommes d&eacute;sol&eacute;s pour la g&ecirc;ne occasionn&eacute;e et faisons notre possible pour &ecirc;tre rapidement de retour.</p>
'content' => '<p>Notre site est actuellement en maintenance. Nous sommes d&eacute;sol&eacute;s pour la g&ecirc;ne occasionn&eacute;e et faisons notre possible pour &ecirc;tre rapidement de retour.</p>
<div class="row"><div class="col4 offset8 textAlignCenter"><a href="./?user/login" id="maintenanceLogin" name="maintenanceLogin" class="button"><span class="zwiico-lock zwiico-margin-right"></span>Administration</a></div></div>'
],
'erreur403' => [

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,6 +17,15 @@
]);*/ ?>
</div>
<div class="col1 offset8">
<?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'),
@ -24,18 +33,10 @@
'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>
<div class="tab">
<?php echo template::button('translateContentButton', [
<?php echo template::button('translateContentButton', [
'value' => 'Site',
'class' => 'buttonTab'
]); ?>