Theme reset csrf
This commit is contained in:
parent
a68e30b52f
commit
f4dfbbe8e0
@ -105,7 +105,8 @@ class theme extends common
|
||||
'2.4vmax' => '240%'
|
||||
];
|
||||
public static $headerHeights = [
|
||||
'unset' => 'Libre', // texte dynamique cf header.js.php
|
||||
'unset' => 'Libre',
|
||||
// texte dynamique cf header.js.php
|
||||
'100px' => '100px',
|
||||
'150px' => '150px',
|
||||
'200px' => '200px',
|
||||
@ -119,7 +120,7 @@ class theme extends common
|
||||
];
|
||||
public static $headerFeatures = [
|
||||
'wallpaper' => 'Couleur unie ou papier-peint',
|
||||
'feature' => 'Contenu HTML'
|
||||
'feature' => 'Contenu HTML'
|
||||
];
|
||||
public static $imagePositions = [
|
||||
'top left' => 'En haut à gauche',
|
||||
@ -249,21 +250,24 @@ class theme extends common
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
$this->setData(['admin', [
|
||||
'backgroundColor' => $this->getInput('adminBackgroundColor'),
|
||||
'colorTitle' => $this->getInput('adminColorTitle'),
|
||||
'colorText' => $this->getInput('adminColorText'),
|
||||
'backgroundColorButton' => $this->getInput('adminColorButton'),
|
||||
'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'),
|
||||
'backgroundColorButtonRed' => $this->getInput('adminColorRed'),
|
||||
'backgroundColorButtonGreen' => $this->getInput('adminColorGreen'),
|
||||
'backgroundColorButtonHelp' => $this->getInput('adminColorHelp'),
|
||||
'fontText' => $this->getInput('adminFontText'),
|
||||
'fontSize' => $this->getInput('adminFontTextSize'),
|
||||
'fontTitle' => $this->getInput('adminFontTitle'),
|
||||
'backgroundBlockColor' => $this->getInput('adminBackGroundBlockColor'),
|
||||
'borderBlockColor' => $this->getInput('adminBorderBlockColor'),
|
||||
]]);
|
||||
$this->setData([
|
||||
'admin',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('adminBackgroundColor'),
|
||||
'colorTitle' => $this->getInput('adminColorTitle'),
|
||||
'colorText' => $this->getInput('adminColorText'),
|
||||
'backgroundColorButton' => $this->getInput('adminColorButton'),
|
||||
'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'),
|
||||
'backgroundColorButtonRed' => $this->getInput('adminColorRed'),
|
||||
'backgroundColorButtonGreen' => $this->getInput('adminColorGreen'),
|
||||
'backgroundColorButtonHelp' => $this->getInput('adminColorHelp'),
|
||||
'fontText' => $this->getInput('adminFontText'),
|
||||
'fontSize' => $this->getInput('adminFontTextSize'),
|
||||
'fontTitle' => $this->getInput('adminFontTitle'),
|
||||
'backgroundBlockColor' => $this->getInput('adminBackGroundBlockColor'),
|
||||
'borderBlockColor' => $this->getInput('adminBorderBlockColor'),
|
||||
]
|
||||
]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
@ -318,16 +322,20 @@ class theme extends common
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
$this->setData(['theme', 'body', [
|
||||
'backgroundColor' => $this->getInput('themeBodyBackgroundColor'),
|
||||
'image' => $this->getInput('themeBodyImage'),
|
||||
'imageAttachment' => $this->getInput('themeBodyImageAttachment'),
|
||||
'imagePosition' => $this->getInput('themeBodyImagePosition'),
|
||||
'imageRepeat' => $this->getInput('themeBodyImageRepeat'),
|
||||
'imageSize' => $this->getInput('themeBodyImageSize'),
|
||||
'toTopbackgroundColor' => $this->getInput('themeBodyToTopBackground'),
|
||||
'toTopColor' => $this->getInput('themeBodyToTopColor')
|
||||
]]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'body',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeBodyBackgroundColor'),
|
||||
'image' => $this->getInput('themeBodyImage'),
|
||||
'imageAttachment' => $this->getInput('themeBodyImageAttachment'),
|
||||
'imagePosition' => $this->getInput('themeBodyImagePosition'),
|
||||
'imageRepeat' => $this->getInput('themeBodyImageRepeat'),
|
||||
'imageSize' => $this->getInput('themeBodyImageSize'),
|
||||
'toTopbackgroundColor' => $this->getInput('themeBodyToTopBackground'),
|
||||
'toTopColor' => $this->getInput('themeBodyToTopColor')
|
||||
]
|
||||
]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
@ -364,34 +372,38 @@ class theme extends common
|
||||
'state' => false
|
||||
]);
|
||||
} else {
|
||||
$this->setData(['theme', 'footer', [
|
||||
'backgroundColor' => $this->getInput('themeFooterBackgroundColor'),
|
||||
'copyrightAlign' => $this->getInput('themeFooterCopyrightAlign'),
|
||||
'height' => $this->getInput('themeFooterHeight'),
|
||||
'loginLink' => $this->getInput('themeFooterLoginLink'),
|
||||
'margin' => $this->getInput('themeFooterMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeFooterPosition'),
|
||||
'fixed' => $this->getInput('themeFooterFixed', helper::FILTER_BOOLEAN),
|
||||
'socialsAlign' => $this->getInput('themeFooterSocialsAlign'),
|
||||
'text' => $this->getInput('themeFooterText', null),
|
||||
'textAlign' => $this->getInput('themeFooterTextAlign'),
|
||||
'textColor' => $this->getInput('themeFooterTextColor'),
|
||||
'copyrightPosition' => $this->getInput('themeFooterCopyrightPosition'),
|
||||
'textPosition' => $this->getInput('themeFooterTextPosition'),
|
||||
'socialsPosition' => $this->getInput('themeFooterSocialsPosition'),
|
||||
'textTransform' => $this->getInput('themeFooterTextTransform'),
|
||||
'font' => $this->getInput('themeFooterFont'),
|
||||
'fontSize' => $this->getInput('themeFooterFontSize'),
|
||||
'fontWeight' => $this->getInput('themeFooterFontWeight'),
|
||||
'displayVersion' => $this->getInput('themefooterDisplayVersion', helper::FILTER_BOOLEAN),
|
||||
'displaySiteMap' => $this->getInput('themefooterDisplaySiteMap', helper::FILTER_BOOLEAN),
|
||||
'displayCopyright' => $this->getInput('themefooterDisplayCopyright', helper::FILTER_BOOLEAN),
|
||||
'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN),
|
||||
'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN),
|
||||
'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN),
|
||||
'memberBar' => $this->getInput('themeFooterMemberBar', helper::FILTER_BOOLEAN),
|
||||
'template' => $this->getInput('themeFooterTemplate')
|
||||
]]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'footer',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeFooterBackgroundColor'),
|
||||
'copyrightAlign' => $this->getInput('themeFooterCopyrightAlign'),
|
||||
'height' => $this->getInput('themeFooterHeight'),
|
||||
'loginLink' => $this->getInput('themeFooterLoginLink'),
|
||||
'margin' => $this->getInput('themeFooterMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeFooterPosition'),
|
||||
'fixed' => $this->getInput('themeFooterFixed', helper::FILTER_BOOLEAN),
|
||||
'socialsAlign' => $this->getInput('themeFooterSocialsAlign'),
|
||||
'text' => $this->getInput('themeFooterText', null),
|
||||
'textAlign' => $this->getInput('themeFooterTextAlign'),
|
||||
'textColor' => $this->getInput('themeFooterTextColor'),
|
||||
'copyrightPosition' => $this->getInput('themeFooterCopyrightPosition'),
|
||||
'textPosition' => $this->getInput('themeFooterTextPosition'),
|
||||
'socialsPosition' => $this->getInput('themeFooterSocialsPosition'),
|
||||
'textTransform' => $this->getInput('themeFooterTextTransform'),
|
||||
'font' => $this->getInput('themeFooterFont'),
|
||||
'fontSize' => $this->getInput('themeFooterFontSize'),
|
||||
'fontWeight' => $this->getInput('themeFooterFontWeight'),
|
||||
'displayVersion' => $this->getInput('themefooterDisplayVersion', helper::FILTER_BOOLEAN),
|
||||
'displaySiteMap' => $this->getInput('themefooterDisplaySiteMap', helper::FILTER_BOOLEAN),
|
||||
'displayCopyright' => $this->getInput('themefooterDisplayCopyright', helper::FILTER_BOOLEAN),
|
||||
'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN),
|
||||
'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN),
|
||||
'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN),
|
||||
'memberBar' => $this->getInput('themeFooterMemberBar', helper::FILTER_BOOLEAN),
|
||||
'template' => $this->getInput('themeFooterTemplate')
|
||||
]
|
||||
]);
|
||||
|
||||
// Sauvegarder la configuration localisée
|
||||
$this->setData(['locale', 'legalPageId', $this->getInput('configLegalPageId')]);
|
||||
@ -453,29 +465,33 @@ class theme extends common
|
||||
}
|
||||
|
||||
// Sauvegarder
|
||||
$this->setData(['theme', 'header', [
|
||||
'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'),
|
||||
'font' => $this->getInput('themeHeaderFont'),
|
||||
'fontSize' => $this->getInput('themeHeaderFontSize'),
|
||||
'fontWeight' => $this->getInput('themeHeaderFontWeight'),
|
||||
'height' => $this->getInput('themeHeaderHeight'),
|
||||
'wide' => $this->getInput('themeHeaderWide'),
|
||||
'image' => $this->getInput('themeHeaderImage'),
|
||||
'imagePosition' => $this->getInput('themeHeaderImagePosition'),
|
||||
'imageRepeat' => $this->getInput('themeHeaderImageRepeat'),
|
||||
'margin' => $this->getInput('themeHeaderMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeHeaderPosition'),
|
||||
'textAlign' => $this->getInput('themeHeaderTextAlign'),
|
||||
'textColor' => $this->getInput('themeHeaderTextColor'),
|
||||
'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN),
|
||||
'textTransform' => $this->getInput('themeHeaderTextTransform'),
|
||||
'linkHomePage' => $this->getInput('themeHeaderlinkHomePage', helper::FILTER_BOOLEAN),
|
||||
'imageContainer' => $this->getInput('themeHeaderImageContainer'),
|
||||
'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN),
|
||||
'feature' => $this->getInput('themeHeaderFeature'),
|
||||
'featureContent' => $featureContent,
|
||||
'featureFiles' => $files
|
||||
]]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'header',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeHeaderBackgroundColor'),
|
||||
'font' => $this->getInput('themeHeaderFont'),
|
||||
'fontSize' => $this->getInput('themeHeaderFontSize'),
|
||||
'fontWeight' => $this->getInput('themeHeaderFontWeight'),
|
||||
'height' => $this->getInput('themeHeaderHeight'),
|
||||
'wide' => $this->getInput('themeHeaderWide'),
|
||||
'image' => $this->getInput('themeHeaderImage'),
|
||||
'imagePosition' => $this->getInput('themeHeaderImagePosition'),
|
||||
'imageRepeat' => $this->getInput('themeHeaderImageRepeat'),
|
||||
'margin' => $this->getInput('themeHeaderMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeHeaderPosition'),
|
||||
'textAlign' => $this->getInput('themeHeaderTextAlign'),
|
||||
'textColor' => $this->getInput('themeHeaderTextColor'),
|
||||
'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN),
|
||||
'textTransform' => $this->getInput('themeHeaderTextTransform'),
|
||||
'linkHomePage' => $this->getInput('themeHeaderlinkHomePage', helper::FILTER_BOOLEAN),
|
||||
'imageContainer' => $this->getInput('themeHeaderImageContainer'),
|
||||
'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN),
|
||||
'feature' => $this->getInput('themeHeaderFeature'),
|
||||
'featureContent' => $featureContent,
|
||||
'featureFiles' => $files
|
||||
]
|
||||
]);
|
||||
// Modification de la position du menu selon la position de la bannière
|
||||
if ($this->getData(['theme', 'header', 'position']) == 'site') {
|
||||
$this->setData(['theme', 'menu', 'position', str_replace('body-', 'site-', $this->getData(['theme', 'menu', 'position']))]);
|
||||
@ -535,30 +551,34 @@ class theme extends common
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
$this->setData(['theme', 'menu', [
|
||||
'backgroundColor' => $this->getInput('themeMenuBackgroundColor'),
|
||||
'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'),
|
||||
'font' => $this->getInput('themeMenuFont'),
|
||||
'fontSize' => $this->getInput('themeMenuFontSize'),
|
||||
'fontWeight' => $this->getInput('themeMenuFontWeight'),
|
||||
'height' => $this->getInput('themeMenuHeight'),
|
||||
'wide' => $this->getInput('themeMenuWide'),
|
||||
'loginLink' => $this->getInput('themeMenuLoginLink', helper::FILTER_BOOLEAN),
|
||||
'margin' => $this->getInput('themeMenuMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeMenuPosition'),
|
||||
'textAlign' => $this->getInput('themeMenuTextAlign'),
|
||||
'textColor' => $this->getInput('themeMenuTextColor'),
|
||||
'textTransform' => $this->getInput('themeMenuTextTransform'),
|
||||
'fixed' => $this->getInput('themeMenuFixed', helper::FILTER_BOOLEAN),
|
||||
'activeColorAuto' => $this->getInput('themeMenuActiveColorAuto', helper::FILTER_BOOLEAN),
|
||||
'activeColor' => $this->getInput('themeMenuActiveColor'),
|
||||
'activeTextColor' => $this->getInput('themeMenuActiveTextColor'),
|
||||
'radius' => $this->getInput('themeMenuRadius'),
|
||||
'burgerTitle' => $this->getInput('themeMenuBurgerTitle', helper::FILTER_BOOLEAN),
|
||||
'memberBar' => $this->getInput('themeMenuMemberBar', helper::FILTER_BOOLEAN),
|
||||
'burgerLogo' => $this->getInput('themeMenuBurgerLogo'),
|
||||
'burgerContent' => $this->getInput('themeMenuBurgerContent')
|
||||
]]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'menu',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeMenuBackgroundColor'),
|
||||
'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'),
|
||||
'font' => $this->getInput('themeMenuFont'),
|
||||
'fontSize' => $this->getInput('themeMenuFontSize'),
|
||||
'fontWeight' => $this->getInput('themeMenuFontWeight'),
|
||||
'height' => $this->getInput('themeMenuHeight'),
|
||||
'wide' => $this->getInput('themeMenuWide'),
|
||||
'loginLink' => $this->getInput('themeMenuLoginLink', helper::FILTER_BOOLEAN),
|
||||
'margin' => $this->getInput('themeMenuMargin', helper::FILTER_BOOLEAN),
|
||||
'position' => $this->getInput('themeMenuPosition'),
|
||||
'textAlign' => $this->getInput('themeMenuTextAlign'),
|
||||
'textColor' => $this->getInput('themeMenuTextColor'),
|
||||
'textTransform' => $this->getInput('themeMenuTextTransform'),
|
||||
'fixed' => $this->getInput('themeMenuFixed', helper::FILTER_BOOLEAN),
|
||||
'activeColorAuto' => $this->getInput('themeMenuActiveColorAuto', helper::FILTER_BOOLEAN),
|
||||
'activeColor' => $this->getInput('themeMenuActiveColor'),
|
||||
'activeTextColor' => $this->getInput('themeMenuActiveTextColor'),
|
||||
'radius' => $this->getInput('themeMenuRadius'),
|
||||
'burgerTitle' => $this->getInput('themeMenuBurgerTitle', helper::FILTER_BOOLEAN),
|
||||
'memberBar' => $this->getInput('themeMenuMemberBar', helper::FILTER_BOOLEAN),
|
||||
'burgerLogo' => $this->getInput('themeMenuBurgerLogo'),
|
||||
'burgerContent' => $this->getInput('themeMenuBurgerContent')
|
||||
]
|
||||
]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
@ -591,19 +611,19 @@ class theme extends common
|
||||
|
||||
// Polices liées au thème
|
||||
$used = [
|
||||
'Bannière' => $this->getData(['theme', 'header', 'font']),
|
||||
'Menu' => $this->getData(['theme', 'menu', 'font']),
|
||||
'Titre ' => $this->getData(['theme', 'title', 'font']),
|
||||
'Texte' => $this->getData(['theme', 'text', 'font']),
|
||||
'Pied de page' => $this->getData(['theme', 'footer', 'font']),
|
||||
'Bannière' => $this->getData(['theme', 'header', 'font']),
|
||||
'Menu' => $this->getData(['theme', 'menu', 'font']),
|
||||
'Titre ' => $this->getData(['theme', 'title', 'font']),
|
||||
'Texte' => $this->getData(['theme', 'text', 'font']),
|
||||
'Pied de page' => $this->getData(['theme', 'footer', 'font']),
|
||||
'Titre (admin)' => $this->getData(['admin', 'fontTitle']),
|
||||
'Admin (texte)' => $this->getData(['admin', 'fontText'])
|
||||
];
|
||||
|
||||
// Récupérer le détail des fontes installées
|
||||
//$f = $this->getFonts();
|
||||
$f['files'] = $this->getData(['fonts', 'files']);
|
||||
$f['imported'] = $this->getData(['fonts', 'imported']);
|
||||
$f['files'] = $this->getData(['fonts', 'files']);
|
||||
$f['imported'] = $this->getData(['fonts', 'imported']);
|
||||
$f['websafe'] = self::$fontsWebSafe;
|
||||
|
||||
// Parcourir les fontes disponibles et construire le tableau pour le formulaire
|
||||
@ -614,7 +634,7 @@ class theme extends common
|
||||
$fontUsed[$fontId] = '';
|
||||
foreach ($used as $key => $value) {
|
||||
if ($value === $fontId) {
|
||||
$fontUsed[$fontId] .= $key . '<br/>';
|
||||
$fontUsed[$fontId] .= $key . '<br/>';
|
||||
}
|
||||
}
|
||||
self::$fontsDetail[] = [
|
||||
@ -623,20 +643,20 @@ class theme extends common
|
||||
$f[$type][$fontId]['font-family'],
|
||||
$fontUsed[$fontId],
|
||||
$type,
|
||||
$type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [
|
||||
$type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [
|
||||
'class' => 'themeFontEdit',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $type . '/' . $fontId ,
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $type . '/' . $fontId,
|
||||
'value' => template::ico('pencil'),
|
||||
'disabled' => !empty($fontUsed[$fontId])
|
||||
])
|
||||
: '',
|
||||
$type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [
|
||||
: '',
|
||||
$type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [
|
||||
'class' => 'themeFontDelete buttonRed',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontDelete/' . $type . '/' . $fontId ,
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontDelete/' . $type . '/' . $fontId,
|
||||
'value' => template::ico('cancel'),
|
||||
'disabled' => !empty($fontUsed[$fontId])
|
||||
])
|
||||
: ''
|
||||
: ''
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -663,7 +683,7 @@ class theme extends common
|
||||
if (!empty($ressource)) {
|
||||
$fontId = $this->getInput('fontAddFontId', null, true);
|
||||
$fontName = $this->getInput('fontAddFontName', null, true);
|
||||
$fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true);
|
||||
$fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true);
|
||||
|
||||
// Remplace les doubles quotes par des simples quotes
|
||||
$fontFamilyName = str_replace('"', '\'', $fontFamilyName);
|
||||
@ -676,7 +696,8 @@ class theme extends common
|
||||
$this->setData([
|
||||
'fonts',
|
||||
$type,
|
||||
$fontId, [
|
||||
$fontId,
|
||||
[
|
||||
'name' => $fontName,
|
||||
'font-family' => $fontFamilyName,
|
||||
'resource' => $ressource
|
||||
@ -724,10 +745,10 @@ class theme extends common
|
||||
if ($this->isPost()) {
|
||||
// Type d'import en ligne ou local
|
||||
$type = $this->getInput('fontEditUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
|
||||
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null);
|
||||
$fontId = $this->getInput('fontEditFontId', null, true);
|
||||
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null);
|
||||
$fontId = $this->getInput('fontEditFontId', null, true);
|
||||
$fontName = $this->getInput('fontEditFontName', null, true);
|
||||
$fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true);
|
||||
$fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true);
|
||||
|
||||
// Remplace les doubles quotes par des simples quotes
|
||||
$fontFamilyName = str_replace('"', '\'', $fontFamilyName);
|
||||
@ -741,7 +762,8 @@ class theme extends common
|
||||
$this->setData([
|
||||
'fonts',
|
||||
$type,
|
||||
$fontId, [
|
||||
$fontId,
|
||||
[
|
||||
'name' => $fontName,
|
||||
'font-family' => $fontFamilyName,
|
||||
'resource' => $ressource
|
||||
@ -775,11 +797,11 @@ class theme extends common
|
||||
public function fontDelete()
|
||||
{
|
||||
// Jeton incorrect
|
||||
if ($this->getUrl(4) !== $_SESSION['csrf']) {
|
||||
if ($this->checkCSRF()) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||
'notification' => helper::translate('Action interdite')
|
||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||
'notification' => helper::translate('Jeton invalide')
|
||||
]);
|
||||
}
|
||||
// Suppression
|
||||
@ -798,7 +820,7 @@ class theme extends common
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||
'notification' => helper::translate('Fonte supprimée'),
|
||||
'state' => true
|
||||
]);
|
||||
@ -811,44 +833,32 @@ class theme extends common
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
// $url prend l'adresse sans le token
|
||||
$url = explode('&', $this->getUrl(2));
|
||||
|
||||
if (
|
||||
isset($_GET['csrf'])
|
||||
and $_GET['csrf'] === $_SESSION['csrf']
|
||||
) {
|
||||
// Réinitialisation
|
||||
$redirect = '';
|
||||
switch ($url[0]) {
|
||||
case 'admin':
|
||||
$this->initData('admin', self::$i18nUI);
|
||||
$redirect = helper::baseUrl() . 'theme/admin';
|
||||
break;
|
||||
case 'manage':
|
||||
$this->initData('theme', self::$i18nUI);
|
||||
$redirect = helper::baseUrl() . 'theme/manage';
|
||||
break;
|
||||
case 'custom':
|
||||
unlink(self::DATA_DIR . 'custom.css');
|
||||
$redirect = helper::baseUrl() . 'theme/advanced';
|
||||
break;
|
||||
default:
|
||||
$redirect = helper::baseUrl() . 'theme';
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Thème réinitialisé'),
|
||||
'redirect' => $redirect,
|
||||
'state' => true
|
||||
]);
|
||||
} else {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Jeton incorrect')
|
||||
]);
|
||||
// Réinitialisation
|
||||
$redirect = '';
|
||||
switch ($this->getUrl(2)) {
|
||||
case 'admin':
|
||||
$this->initData('admin', self::$i18nUI);
|
||||
$redirect = helper::baseUrl() . 'theme/admin';
|
||||
break;
|
||||
case 'manage':
|
||||
$this->initData('theme', self::$i18nUI);
|
||||
$redirect = helper::baseUrl() . 'theme/manage';
|
||||
break;
|
||||
case 'custom':
|
||||
unlink(self::DATA_DIR . 'custom.css');
|
||||
$redirect = helper::baseUrl() . 'theme/advanced';
|
||||
break;
|
||||
default:
|
||||
$redirect = helper::baseUrl() . 'theme';
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Thème réinitialisé'),
|
||||
'redirect' => $redirect,
|
||||
'state' => true
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -859,32 +869,52 @@ class theme extends common
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
$this->setData(['theme', 'title', [
|
||||
'font' => $this->getInput('themeTitleFont'),
|
||||
'textColor' => $this->getInput('themeTitleTextColor'),
|
||||
'fontWeight' => $this->getInput('themeTitleFontWeight'),
|
||||
'textTransform' => $this->getInput('themeTitleTextTransform')
|
||||
]]);
|
||||
$this->setData(['theme', 'text', [
|
||||
'font' => $this->getInput('themeTextFont'),
|
||||
'fontSize' => $this->getInput('themeTextFontSize'),
|
||||
'textColor' => $this->getInput('themeTextTextColor'),
|
||||
'linkColor' => $this->getInput('themeTextLinkColor')
|
||||
]]);
|
||||
$this->setData(['theme', 'site', [
|
||||
'backgroundColor' => $this->getInput('themeSiteBackgroundColor'),
|
||||
'radius' => $this->getInput('themeSiteRadius'),
|
||||
'shadow' => $this->getInput('themeSiteShadow'),
|
||||
'width' => $this->getInput('themeSiteWidth'),
|
||||
'margin' => $this->getInput('themeSiteMargin', helper::FILTER_BOOLEAN)
|
||||
]]);
|
||||
$this->setData(['theme', 'button', [
|
||||
'backgroundColor' => $this->getInput('themeButtonBackgroundColor')
|
||||
]]);
|
||||
$this->setData(['theme', 'block', [
|
||||
'backgroundColor' => $this->getInput('themeBlockBackgroundColor'),
|
||||
'borderColor' => $this->getInput('themeBlockBorderColor')
|
||||
]]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'title',
|
||||
[
|
||||
'font' => $this->getInput('themeTitleFont'),
|
||||
'textColor' => $this->getInput('themeTitleTextColor'),
|
||||
'fontWeight' => $this->getInput('themeTitleFontWeight'),
|
||||
'textTransform' => $this->getInput('themeTitleTextTransform')
|
||||
]
|
||||
]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'text',
|
||||
[
|
||||
'font' => $this->getInput('themeTextFont'),
|
||||
'fontSize' => $this->getInput('themeTextFontSize'),
|
||||
'textColor' => $this->getInput('themeTextTextColor'),
|
||||
'linkColor' => $this->getInput('themeTextLinkColor')
|
||||
]
|
||||
]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'site',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeSiteBackgroundColor'),
|
||||
'radius' => $this->getInput('themeSiteRadius'),
|
||||
'shadow' => $this->getInput('themeSiteShadow'),
|
||||
'width' => $this->getInput('themeSiteWidth'),
|
||||
'margin' => $this->getInput('themeSiteMargin', helper::FILTER_BOOLEAN)
|
||||
]
|
||||
]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'button',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeButtonBackgroundColor')
|
||||
]
|
||||
]);
|
||||
$this->setData([
|
||||
'theme',
|
||||
'block',
|
||||
[
|
||||
'backgroundColor' => $this->getInput('themeBlockBackgroundColor'),
|
||||
'borderColor' => $this->getInput('themeBlockBorderColor')
|
||||
]
|
||||
]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => helper::translate('Modifications enregistrées'),
|
||||
@ -914,7 +944,7 @@ class theme extends common
|
||||
{
|
||||
if ($this->isPost()) {
|
||||
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
||||
$data = $this->import(self::FILE_DIR . 'source/' . $zipFilename);
|
||||
if ($data['success']) {
|
||||
header("Refresh:0");
|
||||
@ -925,7 +955,8 @@ class theme extends common
|
||||
'notification' => $data['notification'],
|
||||
'state' => $data['success'],
|
||||
'view' => 'manage'
|
||||
]);;
|
||||
]);
|
||||
;
|
||||
}
|
||||
}
|
||||
// Valeurs en sortie
|
||||
@ -1057,7 +1088,7 @@ class theme extends common
|
||||
unlink(self::TEMP_DIR . $zipFilename);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => '<b>' . $zipFilename . '</b>'. helper::translate('sauvegardé avec succès'),
|
||||
'notification' => '<b>' . $zipFilename . '</b>' . helper::translate('sauvegardé avec succès'),
|
||||
'redirect' => helper::baseUrl() . 'theme/manage',
|
||||
'state' => true
|
||||
]);
|
||||
@ -1070,7 +1101,7 @@ class theme extends common
|
||||
private function zipTheme($modele)
|
||||
{
|
||||
// Creation du dossier
|
||||
$zipFilename = $modele . date('Y-m-d-H-i-s', time()) . '.zip';
|
||||
$zipFilename = $modele . date('Y-m-d-H-i-s', time()) . '.zip';
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
|
||||
switch ($modele) {
|
||||
@ -1197,8 +1228,8 @@ class theme extends common
|
||||
* id - nom
|
||||
* id - font-family - resource
|
||||
*/
|
||||
$f['files'] = $this->getData(['fonts', 'files']);
|
||||
$f['imported'] = $this->getData(['fonts', 'imported']);
|
||||
$f['files'] = $this->getData(['fonts', 'files']);
|
||||
$f['imported'] = $this->getData(['fonts', 'imported']);
|
||||
$f['websafe'] = self::$fontsWebSafe;
|
||||
// Construit un tableau avec leur ID et leur famille
|
||||
foreach (['websafe', 'imported', 'files'] as $type) {
|
||||
@ -1223,7 +1254,7 @@ class theme extends common
|
||||
|
||||
// Filtrage par fontes installées
|
||||
$fontsInstalled = [
|
||||
$this->getData(['theme', 'text', 'font']),
|
||||
$this->getData(['theme', 'text', 'font']),
|
||||
$this->getData(['theme', 'title', 'font']),
|
||||
$this->getData(['theme', 'header', 'font']),
|
||||
$this->getData(['theme', 'menu', 'font']),
|
||||
@ -1244,13 +1275,13 @@ class theme extends common
|
||||
foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) {
|
||||
if (
|
||||
($scope === 'user' && in_array($fontId, $fontsInstalled))
|
||||
|| $scope === 'all'
|
||||
|| $scope === 'all'
|
||||
) {
|
||||
//Pré chargement à revoir
|
||||
//$fileContent .= '<link rel="preload" href="' . $fontValue['resource'] . '" crossorigin="anonymous" as="style">';
|
||||
$fileContent .= '<link href="' . $fontValue['resource'] . '" rel="stylesheet">';
|
||||
// Pré connect pour api.google
|
||||
$gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true;
|
||||
$gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1269,16 +1300,16 @@ class theme extends common
|
||||
foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) {
|
||||
if (
|
||||
($scope === 'user' && in_array($fontId, $fontsInstalled))
|
||||
|| $scope === 'all'
|
||||
|| $scope === 'all'
|
||||
) {
|
||||
if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource'])) {
|
||||
// Extension
|
||||
$path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']);
|
||||
$path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']);
|
||||
// Chargement de la police
|
||||
$fileContentCss .= '@font-face {';
|
||||
$fileContentCss .= '@font-face {';
|
||||
$fileContentCss .= 'font-family:"' . $fontValue['name'] . '";';
|
||||
$fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");';
|
||||
$fileContentCss .= '}';
|
||||
$fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");';
|
||||
$fileContentCss .= '}';
|
||||
// Préchargement
|
||||
//$fileContent = '<link rel="preload" href="' . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '" type="font/woff" crossorigin="anonymous" as="font">' . $fileContent;
|
||||
}
|
||||
@ -1289,6 +1320,6 @@ class theme extends common
|
||||
// Enregistre la personnalisation
|
||||
file_put_contents(self::DATA_DIR . 'fonts/fonts.html', $fileContent);
|
||||
// Enregistre la personnalisation
|
||||
file_put_contents(self::DATA_DIR . 'fonts/fonts.css', $fileContentCss);
|
||||
file_put_contents(self::DATA_DIR . 'fonts/fonts.css', $fileContentCss);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user