Suppression du cookie configLayout

This commit is contained in:
Fred Tempez 2024-09-18 19:33:59 +02:00
parent 5ab8efe72e
commit cd509dfcb1
4 changed files with 43 additions and 56 deletions

View File

@ -30,7 +30,8 @@ class config extends common
'logReset' => self::GROUP_ADMIN, 'logReset' => self::GROUP_ADMIN,
'logDownload' => self::GROUP_ADMIN, 'logDownload' => self::GROUP_ADMIN,
'blacklistReset' => self::GROUP_ADMIN, 'blacklistReset' => self::GROUP_ADMIN,
'blacklistDownload' => self::GROUP_ADMIN 'blacklistDownload' => self::GROUP_ADMIN,
'register' => self::GROUP_ADMIN,
]; ];
public static $timezones = [ public static $timezones = [
@ -972,4 +973,25 @@ class config extends common
return getenv('HTTP_MOD_REWRITE') == 'On' || getenv('REDIRECT_STATUS') == '200'; return getenv('HTTP_MOD_REWRITE') == 'On' || getenv('REDIRECT_STATUS') == '200';
} }
} }
/**
* Stocke la variable dans les paramètres de l'utilisateur pour activer la tab à sa prochaine visite
* @return never
*/
public function register(): void
{
$this->setData([
'user',
$this->getUser('id'),
'view',
[
'config' => $this->getUrl(2),
'page' => $this->getData(['user', $this->getUser('id'), 'view', 'page']),
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config/' . $this->getUrl(2),
]);
}
} }

View File

@ -66,11 +66,12 @@ $(document).ready(function () {
$("#connectCaptchaStrong").prop("checked", false); $("#connectCaptchaStrong").prop("checked", false);
} }
var configLayout = getCookie("configLayout"); var configLayout = "<?php echo $this->getData(['user', $this->getUser('id'), 'view', 'config']);?>";
// Non défini, valeur par défaut
if (configLayout == null) { if (configLayout == null) {
configLayout = "locale"; configLayout = "setup";
setCookie("configLayout", "locale");
} }
$("#localeContainer").hide(); $("#localeContainer").hide();
$("#socialContainer").hide(); $("#socialContainer").hide();
$("#connectContainer").hide(); $("#connectContainer").hide();
@ -168,7 +169,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "locale");
}); });
$("#configSetupButton").on("click", function () { $("#configSetupButton").on("click", function () {
$("#localeContainer").hide(); $("#localeContainer").hide();
@ -181,7 +181,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "setup");
}); });
$("#configSocialButton").on("click", function () { $("#configSocialButton").on("click", function () {
@ -195,7 +194,6 @@ $(document).ready(function () {
$("#configSocialButton").addClass("activeButton"); $("#configSocialButton").addClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "social");
}); });
$("#configConnectButton").on("click", function () { $("#configConnectButton").on("click", function () {
$("#setupContainer").hide(); $("#setupContainer").hide();
@ -208,7 +206,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").addClass("activeButton"); $("#configConnectButton").addClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "connect");
}); });
$("#configNetworkButton").on("click", function () { $("#configNetworkButton").on("click", function () {
$("#setupContainer").hide(); $("#setupContainer").hide();
@ -221,7 +218,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").addClass("activeButton"); $("#configNetworkButton").addClass("activeButton");
setCookie("configLayout", "network");
}); });
@ -308,27 +304,6 @@ $(document).ready(function () {
}); });
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
// Define function to capitalize the first letter of a string // Define function to capitalize the first letter of a string
function capitalizeFirstLetter(string) { function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);

View File

@ -7,45 +7,34 @@
'value' => template::ico('home') 'value' => template::ico('home')
]); ?> ]); ?>
</div> </div>
<div class="col1">
<?php /**echo template::button('configHelp', [
'class' => 'buttonHelp',
'href' => 'https://doc.zwiicms.fr/configuration-du-site',
'target' => '_blank',
'value' => template::ico('help'),
'help' => 'Consulter l\'aide en ligne'
]); */?>
</div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('Submit'); ?> <?php echo template::submit('Submit'); ?>
</div> </div>
</div> </div>
<div class="tab"> <div class="tab">
<?php echo template::button('configLocaleButton', [
'value' => 'Identité - Étiquettes',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('configSetupButton', [ <?php echo template::button('configSetupButton', [
'value' => 'Configuration - Outils', 'value' => 'Configuration',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/setup'
]); ?> ]); ?>
<?php echo template::button('configSocialButton', [ <?php echo template::button('configSocialButton', [
'value' => 'Réseaux sociaux', 'value' => 'Référencement',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/social'
]); ?> ]); ?>
<?php echo template::button('configConnectButton', [ <?php echo template::button('configConnectButton', [
'value' => 'Sécurité', 'value' => 'Connexion',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/connect'
]); ?> ]); ?>
<?php echo template::button('configNetworkButton', [ <?php echo template::button('configNetworkButton', [
'value' => 'Réseau', 'value' => 'Réseau',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/network'
]); ?> ]); ?>
</div> </div>
<?php include('core/module/config/view/locale/locale.php') ?> <?php include('core/module/config/view/locale/locale.php') ?>
<?php include('core/module/config/view/setup/setup.php') ?> <?php include('core/module/config/view/setup/setup.php') ?>
<?php include('core/module/config/view/social/social.php') ?> <?php include('core/module/config/view/social/social.php') ?>

View File

@ -758,7 +758,8 @@ class page extends common
$this->getUser('id'), $this->getUser('id'),
'view', 'view',
[ [
'page' => $this->getUrl(2) 'page' => $this->getUrl(2),
'config' => $this->getData(['user', $this->getUser('id'), 'view', 'config']),
] ]
]); ]);
// Valeurs en sortie // Valeurs en sortie