Nom de la constante langue du contenu

This commit is contained in:
Fred Tempez 2022-09-02 18:45:55 +02:00
parent 20521c57da
commit 914ea0dc79
12 changed files with 54 additions and 46 deletions

View File

@ -158,6 +158,7 @@ class common {
'pt' => 'Portugais (pt)',
];
// Langue du contenu courante
public static $i18nContent;
public static $i18n;
// Langue de l'interface, tableau des dialogues
public static $dialog;
@ -267,14 +268,14 @@ class common {
$this->input['_COOKIE'] = $_COOKIE;
}
// Déterminer la langue sélectionnée pour le chargement des fichiers de données
// Déterminer la langue du contenu du site
if (isset($this->input['_COOKIE']['ZWII_I18N_SITE'])
) {
self::$i18n = $this->input['_COOKIE']['ZWII_I18N_SITE'];
setlocale (LC_TIME, self::$i18n . '_' . strtoupper (self::$i18n) );
self::$i18nContent = $this->input['_COOKIE']['ZWII_I18N_SITE'];
setlocale (LC_TIME, self::$i18nContent . '_' . strtoupper (self::$i18nContent) );
} else {
self::$i18n = 'fr';
self::$i18nContent = '';
}
// Instanciation de la classe des entrées / sorties
@ -283,19 +284,26 @@ class common {
// Constructeur JsonDB
$this->dataFiles[$keys] = new \Prowebcraft\JsonDb([
'name' => $keys . '.json',
'dir' => $this->dataPath ($keys, self::$i18n),
'dir' => $this->dataPath ($keys, self::$i18nContent),
'backup' => file_exists('site/data/.backup')
]);;
}
// Langue de l'administration
self::$i18n = $this->getData(['config', 'i18n', 'default']);
// La langue par défaut du contenu est celle du site si le cookie est absent.
if (self::$i18nContent === '') {
self::$i18nContent = self::$i18n;
}
// Installation fraîche, initialisation des modules manquants
// La langue d'installation par défaut est fr
foreach ($this->dataFiles as $stageId => $item) {
$folder = $this->dataPath ($stageId, self::$i18n);
$folder = $this->dataPath ($stageId, self::$i18nContent);
if ( file_exists($folder . $stageId .'.json') === false ||
$this->getData([$stageId]) === NULL
) {
$this->initData($stageId, self::$i18n);
$this->initData($stageId, self::$i18nContent);
common::$coreNotices [] = $stageId ;
}
}
@ -1576,7 +1584,7 @@ class common {
) {
if (
$this->getData(['user', $this->getUser('id') , 'files']) === true
) {
) {
$itemsRight .= '<li>' . template::ico('folder', [
'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json'),
'attr' => 'data-lity',
@ -2737,7 +2745,7 @@ class core extends common {
) {
$this->addOutput([
'title' => $title,
'content' => $this->getPage($this->getUrl(0), self::$i18n) .
'content' => $this->getPage($this->getUrl(0), self::$i18nContent) .
// Concatène avec les paramètres avancés.
$this->getData(['page', $this->getUrl(0), 'css']) .
$this->getData(['page', $this->getUrl(0), 'js']),
@ -2747,10 +2755,10 @@ class core extends common {
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page',$this->getUrl(0),'barRight'])
? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18n)
? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18nContent)
: '',
'contentLeft' => $this->getData(['page',$this->getUrl(0),'barLeft'])
? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18n)
? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18nContent)
: ''
]);
}
@ -2771,13 +2779,13 @@ class core extends common {
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page',$this->getUrl(0),'barRight'])
? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18n)
? $this->getPage($this->getData(['page',$this->getUrl(0),'barRight']), self::$i18nContent)
: '',
'contentLeft' => $this->getData(['page',$this->getUrl(0),'barLeft'])
? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18n)
? $this->getPage($this->getData(['page',$this->getUrl(0),'barLeft']), self::$i18nContent)
: ''
]);
$pageContent = $this->getPage($this->getUrl(0), self::$i18n);
$pageContent = $this->getPage($this->getUrl(0), self::$i18nContent);
}
else {
$moduleId = $this->getUrl(0);

View File

@ -438,8 +438,8 @@ if ($this->getData(['core', 'dataVersion']) < 11000) {
// Liste des pages dans pageList
$pageList = array();
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
}
foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) {
$pageList [] = $parentKey;
@ -449,7 +449,7 @@ if ($this->getData(['core', 'dataVersion']) < 11000) {
}
foreach ($pageList as $parentKey => $parent) {
$content = $this->getData(['page', $parent, 'content']);
//file_put_contents(self::DATA_DIR . self::$i18n . '/content/' . $parent . '.html', $content);
//file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $parent . '.html', $content);
$this->setPage($parent, $content, 'fr');
$this->setData(['page', $parent, 'content', $parent . '.html']);
}
@ -564,7 +564,7 @@ if ($this->getData(['core', 'dataVersion']) < 11203) {
$success = false ;
// Boucler sur les pages
foreach($this->getHierarchy(null,null,null) as $parentId => $childIds) {
$content = $this->getPage($parentId, self::$i18n);
$content = $this->getPage($parentId, self::$i18nContent);
$titre = $this->getData(['page', $parentId, 'title']);
$content = $titre . ' ' . $content ;
$replace = str_replace( 'href="' . $old , 'href="'. $new , stripslashes($content),$c1) ;
@ -572,17 +572,17 @@ if ($this->getData(['core', 'dataVersion']) < 11203) {
if ($c1 > 0 || $c2 > 0) {
$success = true;
$this->setPage($parentId, $replace, self::$i18n);
$this->setPage($parentId, $replace, self::$i18nContent);
$c3 += $c1 + $c2;
}
foreach($childIds as $childId) {
$content = $this->getPage($childId, self::$i18n);
$content = $this->getPage($childId, self::$i18nContent);
$content = $titre . ' ' . $content ;
$replace = str_replace( 'href="' . $old , 'href="'. $new , stripslashes($content),$c1) ;
$replace = str_replace( 'src="' . $old , 'src="'. $new , stripslashes($replace),$c2) ;
if ($c1 > 0 || $c2 > 0) {
$success = true;
$this->setPage($childId, $replace, self::$i18n);
$this->setPage($childId, $replace, self::$i18nContent);
$c3 += $c1 + $c2;
}
}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18n;?>">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18nContent;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18n;?>">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18nContent;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18n;?>">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo self::$i18nContent;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -434,8 +434,8 @@ class addon extends common {
// Export des pages hébergeant le module
$pageParam[$pageId] = $this->getData(['page',$pageId]);
// Export du contenu de la page
//$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content']));
$pageContent[$pageId] = $this->getPage($pageId, self::$i18n);
//$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getData(['page', $pageId, 'content']));
$pageContent[$pageId] = $this->getPage($pageId, self::$i18nContent);
// Export de fr/module.json
$moduleId = 'fr/module.json';
$moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);

View File

@ -37,7 +37,7 @@ class maintenance extends common {
? ''
: $this->getData(['page',$this->getData(['locale','page302']),'title']),
//'content' => $this->getdata(['page',$this->getData(['locale','page302']),'content']),
'content' => $this->getPage($this->getData(['locale','page302']), self::$i18n),
'content' => $this->getPage($this->getData(['locale','page302']), self::$i18nContent),
'view' => 'index'
]);
} else {

View File

@ -161,11 +161,11 @@ class page extends common {
]
]);
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
}
//file_put_contents(self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html', '<p>Contenu de votre nouvelle page.</p>');
$this->setPage($pageId, '<p>Contenu de votre nouvelle page.</p>', self::$i18n);
//file_put_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $pageId . '.html', '<p>Contenu de votre nouvelle page.</p>');
$this->setPage($pageId, '<p>Contenu de votre nouvelle page.</p>', self::$i18nContent);
// Met à jour le site map
$this->createSitemap('all');
// Mise à jour de la liste des pages pour TinyMCE
@ -289,8 +289,8 @@ class page extends common {
}
// Effacer la page
$this->deleteData(['page', $url[0]]);
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {
unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html');
if (file_exists(self::DATA_DIR . self::$i18nContent . '/content/' . $url[0] . '.html')) {
unlink(self::DATA_DIR . self::$i18nContent . '/content/' . $url[0] . '.html');
}
$this->deleteData(['module', $url[0]]);
// Met à jour le site map
@ -372,8 +372,8 @@ class page extends common {
// Supprime l'ancienne page si l'id a changée
if($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]);
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html')) {
unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html');
if (file_exists(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html')) {
unlink (self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html');
}
}
// Traitement des pages spéciales affectées dans la config :
@ -496,11 +496,11 @@ class page extends common {
]);
// Creation du contenu de la page
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
if (!is_dir(self::DATA_DIR . self::$i18nContent . '/content')) {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
}
$content = empty($this->getInput('pageEditContent', null)) ? '<p></p>' : str_replace('<p></p>', '<p>&nbsp;</p>', $this->getInput('pageEditContent', null));
$this->setPage($pageId , $content, self::$i18n);
$this->setPage($pageId , $content, self::$i18nContent);
// Met à jour le site map
$this->createSitemap('all');

View File

@ -109,7 +109,7 @@
<div class="col12">
<?php echo template::textarea('pageEditContent', [
'class' => 'editorWysiwyg',
'value' => $this->getPage($this->getUrl(2), self::$i18n)
'value' => $this->getPage($this->getUrl(2), self::$i18nContent)
]); ?>
</div>
</div>

View File

@ -502,8 +502,8 @@ class plugin extends common {
// Mise en forme du tableau des modules employés dans les pages
// Avec les commandes de sauvegarde et de restauration
$keyi18n = self::$i18n;
$valueI18n = $pagesInfos[self::$i18n];
$keyi18n = self::$i18nContent;
$valueI18n = $pagesInfos[self::$i18nContent];
foreach ($valueI18n as $keyPage=>$value) {
if (isset($infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']])) {
// Co[nstruire le tableau de sortie

View File

@ -69,7 +69,7 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Modules configurés <?php echo template::flag( self::$i18n, '20px'); ?> </h4>
<h4>Modules configurés <?php echo template::flag( self::$i18nContent, '20px'); ?> </h4>
<div class="row">
<div class="col1 offset11">
<?php echo template::button('configModuledataImport', [

View File

@ -189,8 +189,8 @@ class search extends common {
$this->getData(['page', $parentId, 'block']) !== 'bar') {
$url = $parentId;
$titre = $this->getData(['page', $parentId, 'title']);
//$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $parentId, 'content']));
$content = $this->getPage($parentId, self::$i18n);
//$content = file_get_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getData(['page', $parentId, 'content']));
$content = $this->getPage($parentId, self::$i18nContent);
$content = $titre . ' ' . $content ;
// Pages sauf pages filles et articles de blog
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);
@ -206,8 +206,8 @@ class search extends common {
$this->getData(['page', $parentId, 'block']) !== 'bar') {
$url = $childId;
$titre = $this->getData(['page', $childId, 'title']);
//$content = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $childId, 'content']));
$content = $this->getPage($childId, self::$i18n);
//$content = file_get_contents(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getData(['page', $childId, 'content']));
$content = $this->getPage($childId, self::$i18nContent);
$content = $titre . ' ' . $content ;
//Pages filles
$tempData = $this->occurrence($url, $titre, $content, $motclef, self::$motentier);