Merge branch '10400' into editeur

This commit is contained in:
Fred Tempez 2020-11-03 17:10:49 +01:00
commit bcaf62d736
4 changed files with 76 additions and 25 deletions

View File

@ -144,7 +144,6 @@ class init extends common {
'fontWeight' => 'normal', 'fontWeight' => 'normal',
'height' => '15px 10px', 'height' => '15px 10px',
'loginLink' => false, 'loginLink' => false,
'burgerTitle' => true,
'margin' => false, 'margin' => false,
'position' => 'site-second', 'position' => 'site-second',
'textAlign' => 'left', 'textAlign' => 'left',
@ -155,6 +154,7 @@ class init extends common {
'activeColor' => 'rgba(255, 255, 255, 1)', 'activeColor' => 'rgba(255, 255, 255, 1)',
'activeTextColor' => 'rgba(255, 255, 255, 1)', 'activeTextColor' => 'rgba(255, 255, 255, 1)',
'radius' => '0px', 'radius' => '0px',
'burgerTitle' => true,
'memberBar' => true 'memberBar' => true
], ],
'site' => [ 'site' => [

View File

@ -29,7 +29,8 @@ class theme extends common {
'admin' => self::GROUP_ADMIN, 'admin' => self::GROUP_ADMIN,
'manage' => self::GROUP_ADMIN, 'manage' => self::GROUP_ADMIN,
'export' => self::GROUP_ADMIN, 'export' => self::GROUP_ADMIN,
'save' => self::GROUP_ADMIN 'save' => self::GROUP_ADMIN,
'checkImport' => self::GROUP_ADMIN
]; ];
public static $aligns = [ public static $aligns = [
'left' => 'À gauche', 'left' => 'À gauche',
@ -407,7 +408,6 @@ class theme extends common {
// Si une image est positionnée, l'arrière en transparent. // Si une image est positionnée, l'arrière en transparent.
$this->setData(['theme', 'header', [ $this->setData(['theme', 'header', [
'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'), 'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'),
'textTransform' => $this->getInput('themeHeaderTextTransform'),
'font' => $this->getInput('themeHeaderFont'), 'font' => $this->getInput('themeHeaderFont'),
'fontSize' => $this->getInput('themeHeaderFontSize'), 'fontSize' => $this->getInput('themeHeaderFontSize'),
'fontWeight' => $this->getInput('themeHeaderFontWeight'), 'fontWeight' => $this->getInput('themeHeaderFontWeight'),
@ -420,6 +420,7 @@ class theme extends common {
'textAlign' => $this->getInput('themeHeaderTextAlign'), 'textAlign' => $this->getInput('themeHeaderTextAlign'),
'textColor' => $this->getInput('themeHeaderTextColor'), 'textColor' => $this->getInput('themeHeaderTextColor'),
'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN), 'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN),
'textTransform' => $this->getInput('themeHeaderTextTransform'),
'linkHomePage' => $this->getInput('themeHeaderlinkHomePage',helper::FILTER_BOOLEAN), 'linkHomePage' => $this->getInput('themeHeaderlinkHomePage',helper::FILTER_BOOLEAN),
'imageContainer' => $this->getInput('themeHeaderImageContainer') 'imageContainer' => $this->getInput('themeHeaderImageContainer')
]]); ]]);
@ -436,8 +437,10 @@ class theme extends common {
default: default:
$position = $this->getData(['theme','menu','position']); $position = $this->getData(['theme','menu','position']);
} }
$this->setData(['theme', 'menu', [ $this->setData(['theme', 'menu', [
'backgroundColor' => $this->getData(['theme', 'menu', 'backgroundColor']), 'backgroundColor' => $this->getData(['theme', 'menu', 'backgroundColor']),
'backgroundColorSub' => $this->getData(['theme', 'menu', 'backgroundColorSub']),
'font' => $this->getData(['theme', 'menu', 'font']), 'font' => $this->getData(['theme', 'menu', 'font']),
'fontSize' => $this->getData(['theme', 'menu', 'fontSize']), 'fontSize' => $this->getData(['theme', 'menu', 'fontSize']),
'fontWeight' => $this->getData(['theme', 'menu', 'fontWeight']), 'fontWeight' => $this->getData(['theme', 'menu', 'fontWeight']),
@ -451,8 +454,9 @@ class theme extends common {
'fixed' => $this->getData(['theme','menu','fixed']), 'fixed' => $this->getData(['theme','menu','fixed']),
'activeColorAuto' => $this->getData(['theme','menu','activeColorAuto']), 'activeColorAuto' => $this->getData(['theme','menu','activeColorAuto']),
'activeColor' => $this->getData(['theme','menu','activeColor']), 'activeColor' => $this->getData(['theme','menu','activeColor']),
'activeTextColor' => $this->getData(['theme','menu','activeTextColor']),
'radius' => $this->getData(['theme','menu','radius']), 'radius' => $this->getData(['theme','menu','radius']),
'burgerTitle' => $this->getData(['theme','menu','burgerTitle']) 'memberBar' => $this->getData(['theme','menu','memberBar'])
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -616,20 +620,31 @@ class theme extends common {
if ($zip->open(self::FILE_DIR.'source/'.$zipFilename) === TRUE) { if ($zip->open(self::FILE_DIR.'source/'.$zipFilename) === TRUE) {
mkdir (self::TEMP_DIR . $tempFolder); mkdir (self::TEMP_DIR . $tempFolder);
$zip->extractTo(self::TEMP_DIR . $tempFolder ); $zip->extractTo(self::TEMP_DIR . $tempFolder );
$modele = '';
// Archive de thème ? // Archive de thème ?
if (( file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css') if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css') AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json') AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
) OR ( ) {
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json') $modele = 'theme';
) }
if(
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
) {
$mode = 'admin';
}
if (!empty($modele)
) { ) {
// traiter l'archive // traiter l'archive
$success = $zip->extractTo('.'); $success = $zip->extractTo('.');
// traitement de l'erreur // traitement de l'erreur
$notification = $success ? 'Le thème a été importé' : 'Erreur lors de l\'extraction, vérifiez les permissions.'; $notification = $success ? 'Le thème a été importé' : 'Erreur lors de l\'extraction, vérifiez les permissions.';
// Supprimmer le dossier temporaire // Supprimmer le dossier temporaire
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
// Check le thème
$this->checkImport($modele);
} else { } else {
// pas une archive de thème // pas une archive de thème
$success = false; $success = false;
@ -697,6 +712,50 @@ class theme extends common {
]); ]);
} }
/**
* Contrôle du thème
* Vérifie la présence de toutes les clés par rapport au thème par défaut
* les créer si elles n'existent pas.
*/
private function checkImport ($modele = 'theme') {
require_once('core/module/install/ressource/defaultdata.php');
switch ($modele) {
case 'theme':
$default['theme'] = init::$defaultData['theme'];
// Check le thème
$dataKeys = ['body','footer','header','menu','site','block','text','title','button'];
// Parcourir les clés principales et stocker les contenus
foreach($dataKeys as $key1) {
$itemKeys = $default['theme'][$key1];
// Parcourir les clés secondaires
foreach ($itemKeys as $key2 => $value) {
// Données nulles ou vides instaurer la donnée par défaut
if ($this->getData(['theme',$key1,$key2]) === NULL
OR empty($this->getData(['theme',$key1,$key2]) )
) {
$this->setData(['theme',$key1,$key2,$value]);
}
}
}
break;
case 'admin':
// Check Admin
$default['admin'] = init::$defaultData['admin'];
// Pas de clé secondaire
$itemKeys = $default['admin'];
foreach ($itemKeys as $key1 => $value) {
// Données nulles ou vides instaurer la donnée par défaut
if ($this->getData(['admin',$key1]) === NULL
OR empty($this->getData(['admin',$key1]) )
) {
$this->setData(['admin',$key1,$value]);
}
}
break;
}
}
/** /**
* construction du zip * construction du zip
* @param string $modele theme ou admin * @param string $modele theme ou admin

View File

@ -22,20 +22,20 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col3 offset3"> <div class="col3 offset3">
<?php echo template::button('themeAdvanced', [
'ico' => 'code',
'href' => helper::baseUrl() . $this->getUrl(0) . '/advanced',
'value' => 'Éditeur CSS'
]); ?>
</div>
<div class="col3">
<?php echo template::button('themeManage', [ <?php echo template::button('themeManage', [
'ico' => 'upload', 'ico' => 'upload',
'href' => helper::baseUrl() . $this->getUrl(0) . '/manage', 'href' => helper::baseUrl() . $this->getUrl(0) . '/manage',
'value' => 'Gestion' 'value' => 'Gestion'
]); ?> ]); ?>
</div> </div>
<div class="col3">
<?php echo template::button('themeAdvanced', [
'ico' => 'code',
'href' => helper::baseUrl() . $this->getUrl(0) . '/advanced',
'value' => 'Éditeur CSS'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col4 offset4"> <div class="col4 offset4">

View File

@ -11,11 +11,3 @@
* @license GNU General Public License, version 3 * @license GNU General Public License, version 3
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
/*
/** @import url("site/data/admin.css"); */
/** NE PAS EFFACER
* admin.css
*/
*/