Gestion des paramètres de site (accueil, titre, méta) par langue WIP

This commit is contained in:
fredtempez 2019-09-19 09:41:00 +02:00
parent a5d72705e0
commit bb867dbe63
4 changed files with 44 additions and 43 deletions

View File

@ -176,11 +176,11 @@ class common {
foreach (self::$dataStage as $stageId) {
$folder = $this->dirData ($stageId, 'fr');
if (file_exists($folder . $stageId .'.json') === false) {
$this->iniData($stageId,'fr');
$this->initData($stageId,'fr');
common::$coreNotices [] = $stageId ;
}
}
// Déterminer la langue du visiteur
// --------------------------------
// 1 Langue sélectionnée par l'utilisateur prioritaire
@ -200,11 +200,10 @@ class common {
// Sauvegarder la sélection
$this->seti18N($i18nFrontEnd);
// Mise à jour des données core
$this->update();
// Utilisateur connecté
if($this->user === []) {
$this->user = $this->getData(['user', $this->getInput('ZWII_USER_ID')]);
@ -270,7 +269,7 @@ class common {
$this->url = $url;
}
else {
$this->url = $this->getData(['config', 'homePageId']);
$this->url = $this->getData(['page', 'homePageId']);
}
}
}
@ -686,10 +685,10 @@ class common {
* @param $lang langue des pages
* @return string du dossier à créer
*/
public function dirData ($stageId, $lang) {
public function dirData($id, $lang) {
// Sauf pour les pages et les modules
if ($stageId === 'page' ||
$stageId === 'module') {
if ($id === 'page' ||
$id === 'module') {
$folder = self::DATA_DIR . $lang . '/' ;
} else {
$folder = self::DATA_DIR;
@ -854,8 +853,8 @@ class common {
$mail = new PHPMailer\PHPMailer\PHPMailer;
$mail->CharSet = 'UTF-8';
$host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$mail->setFrom('no-reply@' . $host, $this->getData(['config', 'title']));
$mail->addReplyTo('no-reply@' . $host, $this->getData(['config', 'title']));
$mail->setFrom('no-reply@' . $host, $this->getData(['page', 'title']));
$mail->addReplyTo('no-reply@' . $host, $this->getData(['page', 'title']));
if(is_array($to)) {
foreach($to as $userMail) {
$mail->addAddress($userMail);
@ -928,7 +927,7 @@ class common {
* @param array $module : nom du module à générer
* choix valides : core config user theme page module
*/
public function iniData($module, $lang = 'fr') {
public function initData($module, $lang = 'fr') {
// Tableau avec les données vierges
require_once('core/module/install/ressource/defaultdata.php');
@ -945,7 +944,7 @@ class common {
'dir' => $folder,
'template' => self::TEMP_DIR . 'data.template.json'
]);
$db->set($module,initdata::$defaultData[$module]);
$db->set($module,init::$defaultData[$module]);
$db->save;
}
@ -1001,26 +1000,22 @@ class common {
// Version 8.4.4
if($this->getData(['core', 'dataVersion']) < 844) {
$this->setData(['core', 'dataVersion', 844]);
//$this->SaveData();
}
// Version 8.4.6
if($this->getData(['core', 'dataVersion']) < 846) {
$this->setData(['config','itemsperPage',10]);
$this->setData(['core', 'dataVersion', 846]);
//$this->saveData();
}
// Version 8.5.0
if($this->getData(['core', 'dataVersion']) < 850) {
$this->setData(['theme','menu','font','Open+Sans']);
$this->setData(['core', 'dataVersion', 850]);
//$this->saveData();
}
// Version 8.5.1
if($this->getData(['core', 'dataVersion']) < 851) {
$this->setData(['config','itemsperPage',10]);
$this->deleteData(['config','ItemsperPage']);
$this->setData(['core', 'dataVersion', 851]);
//$this->saveData();
}
// Version 9.0.0
if($this->getData(['core', 'dataVersion']) < 9000) {
@ -1030,13 +1025,11 @@ class common {
}
$this->setData(['theme', 'menu','fixed',false]);
$this->setData(['core', 'dataVersion', 9000]);
//$this->saveData();
}
// Version 9.0.01
if($this->getData(['core', 'dataVersion']) < 9001) {
$this->deleteData(['config', 'social', 'googleplusId']);
$this->setData(['core', 'dataVersion', 9001]);
//$this->saveData();
}
// Version 9.0.08
if($this->getData(['core', 'dataVersion']) < 9008) {
@ -1045,31 +1038,26 @@ class common {
$this->setData(['theme', 'footer', 'fontSize','.8em']);
$this->setData(['theme', 'footer', 'font','Open+Sans']);
$this->setData(['core', 'dataVersion', 9008]);
//$this->saveData();
}
// Version 9.0.09
if($this->getData(['core', 'dataVersion']) < 9009) {
$this->setData(['core', 'dataVersion', 9009]);
//$this->saveData();
}
// Version 9.0.10
if($this->getData(['core', 'dataVersion']) < 9010) {
$this->deleteData(['config', 'social', 'googleplusId']);
$this->setData(['core', 'dataVersion', 9010]);
//$this->saveData();
}
// Version 9.0.11
if($this->getData(['core', 'dataVersion']) < 9011) {
if ($this->getData(['theme','menu','position']) === 'body')
$this->setData(['theme','menu','position','site']);
$this->setData(['core', 'dataVersion', 9011]);
//$this->saveData();
}
// Version 9.0.17
if($this->getData(['core', 'dataVersion']) < 9017) {
$this->setData(['theme','footer','displayVersion', true ]);
$this->setData(['core', 'dataVersion', 9017]);
//$this->saveData();
}
// Version 9.1.0
if($this->getData(['core', 'dataVersion']) < 9100) {
@ -1077,7 +1065,6 @@ class common {
$this->setData(['theme','footer','displaySiteMap', true ]);
$this->setData(['theme','footer','displayCopyright', true ]);
$this->setData(['core', 'dataVersion', 9100]);
//$this->saveData();
}
// Version 9.2.00
if($this->getData(['core', 'dataVersion']) < 9200) {
@ -1087,7 +1074,6 @@ class common {
$this->setData(['theme','footer','displaySearch', false ]);
$this->setData(['config','social','githubId', '' ]);
$this->setData(['core', 'dataVersion', 9200]);
//$this->saveData();
}
// Version 9.2.05
if($this->getData(['core', 'dataVersion']) < 9205) {
@ -1104,13 +1090,19 @@ class common {
rmdir ('core/vendor/swiper/');
}
$this->setData(['core', 'dataVersion', 9205]);
//$this->saveData();
}
// Version 10.0.00
if($this->getData(['core', 'dataVersion']) < 10000) {
$this->setData(['config','i18n','fr']);
$this->setData(['core', 'dataVersion', 10000]);
//$this->saveData();
if ($this->getData(['config','homePageId']) !== NULL) {
$this->setData(['page','homePageId',$this->getData(['config','homePageId'])]);
$this->setData(['page','title',$this->getData(['config','title'])]);
$this->setData(['page','metaDescription',$this->getData(['config','metaDescription'])]);
$this->deleteData(['config','homePageId']);
$this->deleteData(['config','title']);
$this->deleteData(['config','metaDescription']);
}
$this->setData(['core', 'dataVersion', 10000]);
}
}
@ -1714,6 +1706,9 @@ class helper {
*/
public static function arrayCollumn($array, $column, $sort = null) {
$newArray = [];
unset($array['homePageId']);
unset($array['metaDescription']);
unset($array['title']);
if(empty($array) === false) {
$newArray = array_map(function($element) use($column) {
return $element[$column];

View File

@ -276,8 +276,6 @@ class config extends common {
'maintenance' => $this->getInput('configMaintenance', helper::FILTER_BOOLEAN),
'cookieConsent' => $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN),
'favicon' => $this->getInput('configFavicon'),
'homePageId' => $this->getInput('configHomePageId', helper::FILTER_ID, true),
'metaDescription' => $this->getInput('configMetaDescription', helper::FILTER_STRING_LONG, true),
'social' => [
'facebookId' => $this->getInput('configSocialFacebookId'),
'linkedinId' => $this->getInput('configSocialLinkedinId'),
@ -288,11 +286,19 @@ class config extends common {
'githubId' => $this->getInput('configSocialGithubId')
],
'timezone' => $this->getInput('configTimezone', helper::FILTER_STRING_SHORT, true),
'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true),
'itemsperPage' => $this->getInput('itemsperPage', helper::FILTER_INT,true),
'legalPageId' => $this->getInput('configLegalPageId')
]
]);
$this->setData([
'page',
[
'homePageId' => $this->getInput('configHomePageId', helper::FILTER_ID, true),
'metaDescription' => $this->getInput('configMetaDescription', helper::FILTER_STRING_LONG, true),
'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true)
]
]);
if(self::$inputNotices === []) {
// Ecrire les fichiers de script
file_put_contents(self::DATA_DIR . 'head.inc.html',$this->getInput('configScriptHead',null));

View File

@ -18,22 +18,22 @@
<h4>Informations générales</h4>
<div class="row">
<div class="col4">
<?php echo template::select('configHomePageId', helper::arrayCollumn($this->getData(['page']), 'title', 'SORT_ASC'), [
<?php echo template::select('pageHomePageId', helper::arrayCollumn($this->getData(['page']), 'title', 'SORT_ASC'), [
'label' => 'Page d\'accueil',
'selected' => $this->getData(['config', 'homePageId'])
'selected' => $this->getData(['page', 'homePageId'])
]); ?>
</div>
<div class="col8">
<?php echo template::text('configTitle', [
<?php echo template::text('pageTitle', [
'label' => 'Titre du site',
'value' => $this->getData(['config', 'title']),
'value' => $this->getData(['page', 'title']),
'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.'
]); ?>
</div>
</div>
<?php echo template::textarea('configMetaDescription', [
<?php echo template::textarea('pageMetaDescription', [
'label' => 'Description du site',
'value' => $this->getData(['config', 'metaDescription']),
'value' => $this->getData(['page', 'metaDescription']),
'help' => 'Elle apparaît dans les partages sur les réseaux sociaux.'
]); ?>
</div>

View File

@ -1,5 +1,5 @@
<?php
class initdata extends common {
class init extends common {
public static $defaultData = [
'config' => [
@ -7,9 +7,7 @@ class initdata extends common {
'autoBackup' => true,
'cookieConsent' => true,
'favicon' => 'favicon.ico',
'homePageId' => 'accueil',
'maintenance' => false,
'metaDescription' => 'Zwii est un CMS sans base de données qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation.',
'maintenance' => false,
'social' => [
'facebookId' => 'facebook',
'instagramId' => '',
@ -19,17 +17,19 @@ class initdata extends common {
'githubId' => ''
],
'timezone' => 'Europe/Paris',
'title' => 'Zwii, votre site en quelques clics !',
'itemsperPage' => 10,
'legalPageId' => '',
'i18n' => 'fr'
],
'core' => [
'dataVersion' => 0,
'dataVersion' => 1000,
'lastBackup' => 0,
'lastClearTmp' => 0
],
'page' => [
'homePageId' => 'accueil',
'metaDescription' => 'Zwii est un CMS sans base de données qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation.',
'title' => 'Zwii, votre site en quelques clics !',
'accueil' => [
'typeMenu' => 'text',
'iconUrl' => '',