Amélioration des liens dans le footer + gestion des drapeaux + masque de traduction

This commit is contained in:
Fred Tempez 2021-10-03 17:26:05 +02:00
parent ca067121f9
commit 3cabadc501
6 changed files with 130 additions and 91 deletions

View File

@ -425,19 +425,31 @@ class template {
/**
* Crée un drapeau du site courante
* @param string $langId Id de la langue à affiche ou site pour la langue traduite courante
* @param string $margin Ajoute un margin autour de l'icône (choix : left, right, all)
* @param string $size Taille en pixels (default = auto)
* @return string
*/
public static function flag( $size = 'auto') {
if ( isset($_COOKIE['ZWII_I18N_SITE'])
) {
$lang = $_COOKIE['ZWII_I18N_SITE'];
return '<img class="flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $lang . '.png"
width="' . $size .'"
height="' . $size .'"
alt="(' . $lang . ')"/>';
public static function flag($langId, $size = 'auto') {
switch ($langId) {
case '':
$lang = 'fr';
break;
case in_array($langId,['fr', 'de', 'en', 'es', 'it', 'nl', 'pt']):
$lang = $langId;
break;
case 'site':
if ( isset($_COOKIE['ZWII_I18N_SITE'])
) {
$lang = $_COOKIE['ZWII_I18N_SITE'];
} else {
$lang = 'fr';
}
}
return '<img class="flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $lang . '.png"
width="' . $size .'"
height="' . $size .'"
title="' . $lang .'"
alt="(' . $lang . ')"/>';
}
/**

View File

@ -48,11 +48,11 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Identité du site</h4>
<h4>Identité du site <?php echo template::flag('site', '20px');?></h4>
<div class="row">
<div class="col9">
<?php echo template::text('configTitle', [
'label' => 'Titre du site '. template::flag('20px') ,
'label' => 'Titre du site' ,
'value' => $this->getData(['locale', 'title']),
'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.'
]); ?>
@ -68,7 +68,7 @@
<div class="row">
<div class="col12">
<?php echo template::textarea('configMetaDescription', [
'label' => 'Description du site ' . template::flag('20px'),
'label' => 'Description du site',
'value' => $this->getData(['locale', 'metaDescription']),
'help' => 'La description d\'une page participe à son référencement, chaque page doit disposer d\'une description différente.'
]); ?>
@ -154,25 +154,25 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Etiquettes des pages spéciales dans le pied de page</h4>
<h4>Etiquettes des pages spéciales dans le pied de page <?php echo template::flag('site', '20px');?></h4>
<div class="row">
<div class="col4">
<?php echo template::text('configLegalPageLabel', [
'label' => 'Mentions légales ' . template::flag('20px'),
'label' => 'Mentions légales',
'placeholder' => 'Mentions légales',
'value' => $this->getData(['locale', 'legalPageLabel']),
'value' => $this->getData(['locale', 'legalPageLabel'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('configSearchPageLabel', [
'label' => 'Rechercher ' . template::flag('20px'),
'label' => 'Rechercher',
'placeholder' => 'Rechercher',
'value' => $this->getData(['locale', 'searchPageLabel']),
'value' => $this->getData(['locale', 'searchPageLabel'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('configSitemapPageLabel', [
'label' => 'Plan du site ' . template::flag('20px'),
'label' => 'Plan du site',
'placeholder' => 'Plan du site',
'value' => $this->getData(['locale', 'sitemapPageLabel']),
]); ?>

View File

@ -240,6 +240,10 @@ class theme extends common {
'4' => 'Trois lignes superposées'
];
// Variables pour construire la liste des pages du site
public static $pages = [];
public static $orphans = [];
/**
* Thème des écrans d'administration
*/

View File

@ -18,18 +18,18 @@
$("input, select").on("change", function() {
// Import des polices de caractères
var footerFont = $("#themeFooterFont").val();
var css = "@import url('https://fonts.googleapis.com/css?family=" + footerFont + "');";
var css = "@import url('https://fonts.googleapis.com/css?family=" + footerFont + "');";
// Couleurs du pied de page
var colors = core.colorVariants($("#themeFooterBackgroundColor").val());
var textColor = $("#themeFooterTextColor").val();
var css = "footer {background-color:" + colors.normal + ";color:" + textColor + "}";
var css = "footer {background-color:" + colors.normal + ";color:" + textColor + "}";
css += "footer a{color:" + textColor + "}";
// Couleur de l'éditeur
css += ".editorWysiwyg{background-color:" + colors.normal + " !important; color:" + textColor + " !important;}";
// Hauteur du pied de page
//css += "#footersiteLeft, #footersiteCenter, #footersiteRight, #footerbodyLeft, #footerbodyCenter, #footerbodyRight {margin:" + $("#themeFooterHeight").val() + " 0}";
css += "footer #footersite > div{margin:" + $("#themeFooterHeight").val() + " 0}";
css += "footer #footerbody > div{margin:" + $("#themeFooterHeight").val() + " 0}";
css += "footer #footersite > div{margin:" + $("#themeFooterHeight").val() + " 0}";
css += "footer #footerbody > div{margin:" + $("#themeFooterHeight").val() + " 0}";
// Alignement du contenu
css += "#footerSocials{text-align:" + $("#themeFooterSocialsAlign").val() + "}";
css += "#footerText > p {text-align:" + $("#themeFooterTextAlign").val() + "}";
@ -77,7 +77,7 @@ $("input, select").on("change", function() {
// Bloc texte personnalisé
$(".themeFooterContent").on("change",function() {
// Position site ou body
var footerPosition = $("#themeFooterPosition").val();
var footerPosition = $("#themeFooterPosition").val();
switch($("#themeFooterTextPosition").val()) {
case "hide":
$("#footerText").hide();
@ -89,12 +89,12 @@ $(".themeFooterContent").on("change",function() {
$("#footerText").show().appendTo("#footer" + footerPosition + textPosition);
//console.log("text");
//console.log("#footer" + footerPosition + textPosition);
break;
break;
}
switch($("#themeFooterSocialsPosition").val()) {
case 'hide':
$("#footerSocials").hide();
break;
break;
default:
// Choix de la position du bloc
socialsPosition = $("#themeFooterSocialsPosition").val();
@ -107,7 +107,7 @@ $(".themeFooterContent").on("change",function() {
switch($("#themeFooterCopyrightPosition").val()) {
case 'hide':
$("#footerCopyright").hide();
break;
break;
default:
// Choix de la position du bloc
copyrightPosition = $("#themeFooterCopyrightPosition").val();
@ -115,32 +115,32 @@ $(".themeFooterContent").on("change",function() {
$("#footerCopyright").show().appendTo("#footer" + footerPosition + copyrightPosition);
//console.log("copyright");
//console.log("#footer" + footerPosition + copyrightPosition);
break;
break;
}
}).trigger("change");
// Fin Position dans les blocs
// Modification dynamique de la mise en page
// Modification dynamique de la mise en page
$("#themeFooterTemplate").on("change",function() {
// Nettoyage des sélecteurs des contenus
var newOptions = {
4: {'hide' : 'Masqué', 'left' : 'En haut', 'center' : 'Au milieu', 'right' : 'En bas'} ,
4: {'hide' : 'Masqué', 'left' : 'En haut', 'center' : 'Au milieu', 'right' : 'En bas'} ,
3: {'hide': 'Masqué', 'left': 'A gauche', 'center': 'Au centre', 'right': 'A droite'} ,
2: {'hide': 'Masqué', 'left': 'A gauche', 'right': 'A droite'} ,
1: {'hide': 'Masqué', 'center': 'Affiché'}
};
1: {'hide': 'Masqué', 'center': 'Affiché'}
};
var $el = $(".themeFooterContent");
$el.empty();
$el.empty();
// Eléments des position de contenus
$.each(newOptions[$("#themeFooterTemplate").val()], function(key,value) {
$el.append($("<option></option>")
.attr("value", key).text(value));
});
var position = $("#themeFooterPosition").val();
// Masquer les contenus
// Masquer les contenus
$("#footerCopyright").hide();
$("#footerText").hide();
$("#footerSocials").hide();
@ -150,13 +150,13 @@ $("#themeFooterTemplate").on("change",function() {
$("#footer" + position + "Left").css("display","none");
$("#footer" + position + "Center").removeAttr('class').addClass("col12").css("display","");
$("#footer" + position + "Right").css("display","none");
break;
case "2":
break;
case "2":
$("#footer" + position + "Left").removeAttr('class').addClass('col6').css("display","");
$("#footer" + position + "Center").css("display","none").removeAttr('class');
$("#footer" + position + "Right").removeAttr('class').addClass('col6').css("display","");
break;
case "3":
case "3":
$("#footer" + position + "Left").removeAttr('class').addClass('col4').css("display","");
$("#footer" + position + "Center").removeAttr('class').addClass('col4').css("display","");
$("#footer" + position + "Right").removeAttr('class').addClass('col4').css("display","");
@ -167,18 +167,18 @@ $("#themeFooterTemplate").on("change",function() {
$("#footer" + position + "Right").removeAttr('class').addClass('col12').css("display","");
break;
}
}
});
// Désactivation des sélections multiples
$("#themeFooterSocialsPosition").on("change", function() {
if ($(this).prop('selectedIndex') >= 1 ) {
if ($(this).prop('selectedIndex') >= 1 ) {
if ( $("#themeFooterTextPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
$("#themeFooterTextPosition").prop('selectedIndex',0);
$("#footerText").hide();
$("#footerText").hide();
}
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
$("#themeFooterCopyrightPosition").prop('selectedIndex',0);
$("#footerCopyright").hide();
}
@ -190,7 +190,7 @@ $("#themeFooterTextPosition").on("change", function() {
$("#themeFooterSocialsPosition").prop('selectedIndex',0);
$("#footerSocials").hide();
}
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
$("#themeFooterCopyrightPosition").prop('selectedIndex',0);
$("#footerCopyright").hide();
}
@ -203,16 +203,16 @@ $("#themeFooterCopyrightPosition").on("change", function() {
$("#themeFooterTextPosition").prop('selectedIndex',0);
$("#footerText").hide();
}
if ( $("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
if ( $("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
$("#themeFooterSocialsPosition").prop('selectedIndex',0);
$("#footerSocials").hide();
$("#footerSocials").hide();
}
}
}).trigger("change");
// Affiche / Cache les options du footer fixe
$("#themeFooterPosition").on("change", function() {
if($(this).val() === 'body') {
$("#themeFooterPositionFixed").slideDown();
$("#themeFooterPositionFixed").slideDown();
}
else {
$("#themeFooterPositionFixed").slideUp(function() {
@ -230,7 +230,7 @@ $("#themeFooterLoginLink").on("change", function() {
$("#footerLoginLink").hide();
}
}).trigger("change");
// Numéro de version
$("#themefooterDisplayVersion").on("change", function() {
if($(this).is(":checked")) {
@ -271,6 +271,40 @@ $("#themeFooterDisplaySearch").on("change", function() {
}
}).trigger("change");
// Mentions légales
$("#themeFooterDisplayLegal").on("change", function() {
if($(this).is(":checked")) {
$("#footerDisplayLegal").show();
}
else {
$("#footerDisplayLegal").hide();
}
}).trigger("change");
// Pages spéciales : activation si une page est sélectionnée
$("#configLegalPageId").on("change", function() {
console.log($("#configLegalPageId option:selected").text());
if ( $("#configLegalPageId option:selected").text() === 'Aucune') {
$("#themeFooterDisplayLegal").prop('checked', false);
$("#themeFooterDisplayLegal").prop( "disabled", true );
$("#footerDisplayLegal").hide();
} else {
$("#themeFooterDisplayLegal").prop( "disabled", false );
}
}).trigger("change");
$("#configSearchPageId").on("change", function() {
console.log($("#configSearchPageId option:selected").text());
if ( $("#configSearchPageId option:selected").text() === 'Aucune') {
$("#themeFooterDisplaySearch").prop('checked', false);
$("#themeFooterDisplaySearch").prop( "disabled", true );
$("#footerDisplaySearch").hide();
} else {
$("#themeFooterDisplaySearch").prop( "disabled", false );
}
}).trigger("change");
/*
// Affiche / Cache les options de la position
$("#themeFooterPosition").on("change", function() {

View File

@ -37,7 +37,7 @@
</div>
</div>
<div class="row">
<div class="col7">
<div class="col12">
<div class="block">
<h4>Informations</h4>
<div class="row">
@ -76,7 +76,8 @@
</div>
</div>
</div>
<div class="col5">
<div class="row">
<div class="col12">
<div class="block">
<h4>Pages spéciales</h4>
<?php
@ -87,46 +88,34 @@
unset($pages[$page]);
}
}
$orphans = $this->getData(['page']);
foreach($orphans as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' ||
$this->getData(['page',$page,'disable']) === true ||
$this->getdata(['page',$page, 'position']) !== 0) {
unset($orphans[$page]);
}
}
?>
<div class="row">
<div class="col6">
<div class="col3 textAlignRight">
<?php echo template::checkbox('themeFooterDisplayLegal', true, 'Mentions légales', [
'checked' => $this->getData(['locale', 'legalPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displayLegal']),
'disabled' => $this->getData(['locale', 'legalPageId']) === 'none' ? true : false,
'help' => $this->getData(['locale', 'legalPageId']) === 'none' ? 'Une page contenant les mentions légales n\'est pas définie dans la configuration du site / pages spéciales.' : ''
]); ?>
</div>
<div class="col6">
<div class="col3">
<?php echo template::select('configLegalPageId', array_merge(['none' => 'Aucune'] , helper::arrayCollumn($pages, 'title', 'SORT_ASC') ) , [
'label' => 'Page Mentions légales ' . template::flag('site', '20px'),
'selected' => $this->getData(['locale', 'legalPageId'])
]); ?>
</div>
<div class="col3 textAlignRight">
<?php echo template::checkbox('themeFooterDisplaySearch', true, 'Rechercher', [
'checked' => $this->getData(['locale', 'searchPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displaySearch']),
'disabled' => $this->getData(['locale', 'searchPageId']) === 'none' ? true : false,
'help' => $this->getData(['locale', 'searchPageId']) === 'none' ? 'Une page contenant un module de recherche n\'est pas définie dans la configuration du site / pages spéciales.' : ''
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::select('configLegalPageId', array_merge(['none' => 'Aucune'] , helper::arrayCollumn($pages, 'title', 'SORT_ASC') ) , [
'label' => 'Page Mentions légales ' . template::flag('20px'),
'selected' => $this->getData(['locale', 'legalPageId']),
'help' => 'Options identique à la configuration du site',
'disabled' => true
]); ?>
</div>
<div class="col6">
<div class="col3">
<?php echo template::select('configSearchPageId', array_merge(['none' => 'Aucune'] , helper::arrayCollumn($pages, 'title', 'SORT_ASC') ) , [
'label' => 'Page Rechercher ' . template::flag('20px'),
'label' => 'Page Rechercher ' . template::flag('site', '20px'),
'selected' => $this->getData(['locale', 'searchPageId']),
'help' => 'Options identique à la configuration du site',
'disabled' => true
]); ?>
</div>
</div>

View File

@ -78,55 +78,55 @@
<div class="block" id="flagsWrapper">
<h4>Mode de traduction et affichage des drapeaux</h4>
<div class="row">
<div class="col4 offset4">
<div class="col3">
<?php echo template::select('translateFR', ['none'=>'Drapeau masqué','site'=>'Drapeau affiché'], [
'label' => 'Français',
'selected' => $this->getData(['config', 'i18n' , 'fr'])
'label' => template::flag('', '30px'),
'selected' => $this->getData(['config', 'i18n' , 'fr']),
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<div class="col8 offset2">
<div class="col3">
<div class="col12">
<?php echo template::select('translateDE', $module::$translateOptions['de'], [
'label' => 'Allemand',
'label' => template::flag('de', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'de'])
]); ?>
</div>
<div class="col8 offset2">
<div class="col12">
<?php echo template::select('translateEN', $module::$translateOptions['en'], [
'label' => 'Anglais',
'label' => template::flag('en', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'en'])
]); ?>
</div>
<div class="col8 offset2">
</div>
<div class="col3">
<div class="col12">
<?php echo template::select('translateES', $module::$translateOptions['es'], [
'label' => 'Espagnol',
'label' => template::flag('es', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'es'])
]); ?>
</div>
</div>
<div class="col6">
<div class="col8 offset2">
<div class="col12">
<?php echo template::select('translateIT', $module::$translateOptions['it'], [
'label' => 'Italien',
'label' => template::flag('it', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'it'])
]); ?>
</div>
<div class="col8 offset2">
</div>
<div class="col3">
<div class="col12">
<?php echo template::select('translateNL', $module::$translateOptions['nl'], [
'label' => 'Néerlandais',
'label' => template::flag('nl', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'nl'])
]); ?>
</div>
<div class="col8 offset2">
<div class="col12">
<?php echo template::select('translatePT', $module::$translateOptions['pt'], [
'label' => 'Portugais',
'label' => template::flag('pt', '30px'),
'class' => 'translateFlagSelect',
'selected' => $this->getData(['config', 'i18n' , 'pt'])
]); ?>