1525 lines
45 KiB
PHP
1525 lines
45 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This file is part of DeltaCMS.
|
|
* For full copyright and license information, please see the LICENSE
|
|
* file that was distributed with this source code.
|
|
* @author Sylvain Lelièvre <lelievresylvain@free.fr>
|
|
* @copyright Copyright (C) 2021-2022, Sylvain Lelièvre
|
|
* @license GNU General Public License, version 3
|
|
* @link https://deltacms.fr/
|
|
*
|
|
* Delta was created from version 11.2.00.24 of ZwiiCMS
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
|
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
|
|
*/
|
|
|
|
class theme extends common {
|
|
|
|
public static $actions = [
|
|
'advanced' => self::GROUP_ADMIN,
|
|
'body' => self::GROUP_ADMIN,
|
|
'fonts' => self::GROUP_ADMIN,
|
|
'editFonts' => self::GROUP_ADMIN,
|
|
'deleteFonts' => self::GROUP_ADMIN,
|
|
'addFonts' => self::GROUP_ADMIN,
|
|
'footer' => self::GROUP_ADMIN,
|
|
'header' => self::GROUP_ADMIN,
|
|
'index' => self::GROUP_ADMIN,
|
|
'menu' => self::GROUP_ADMIN,
|
|
'reset' => self::GROUP_ADMIN,
|
|
'site' => self::GROUP_ADMIN,
|
|
'admin' => self::GROUP_ADMIN,
|
|
'manage' => self::GROUP_ADMIN,
|
|
'export' => self::GROUP_ADMIN,
|
|
'import' => self::GROUP_ADMIN,
|
|
'save' => self::GROUP_ADMIN
|
|
];
|
|
public static $aligns = [
|
|
'left' => 'À gauche',
|
|
'center' => 'Au centre',
|
|
'right' => 'À droite'
|
|
];
|
|
public static $aligns_en = [
|
|
'left' => 'Left',
|
|
'center' => 'Center',
|
|
'right' => 'Right'
|
|
];
|
|
public static $attachments = [
|
|
'scroll' => 'Standard',
|
|
'fixed' => 'Fixe'
|
|
];
|
|
public static $attachments_en = [
|
|
'scroll' => 'Standard',
|
|
'fixed' => 'Fixed'
|
|
];
|
|
public static $containerWides = [
|
|
'container' => 'Limitée au site',
|
|
'none' => 'Etendue sur la page'
|
|
];
|
|
public static $containerWides_en = [
|
|
'container' => 'Limited to the site',
|
|
'none' => 'Extended to the page'
|
|
];
|
|
public static $footerblocks = [
|
|
1 => [
|
|
'hide' => 'Masqué',
|
|
'center' => 'Affiché' ],
|
|
2 => [
|
|
'hide' => 'Masqué',
|
|
'left' => 'À gauche',
|
|
'right' => 'À droite' ],
|
|
3 => [
|
|
'hide' => 'Masqué',
|
|
'left' => 'À gauche',
|
|
'center' => 'Au centre',
|
|
'right' => 'À droite' ],
|
|
4 => [
|
|
'hide' => 'Masqué',
|
|
'left' => 'En haut',
|
|
'center' => 'Au milieu',
|
|
'right' => 'En bas' ]
|
|
];
|
|
public static $footerblocks_en = [
|
|
1 => [
|
|
'hide' => 'Hidden',
|
|
'center' => 'Affiché' ],
|
|
2 => [
|
|
'hide' => 'Hidden',
|
|
'left' => 'Left',
|
|
'right' => 'Right' ],
|
|
3 => [
|
|
'hide' => 'Hidden',
|
|
'left' => 'Left',
|
|
'center' => 'Center',
|
|
'right' => 'Right' ],
|
|
4 => [
|
|
'hide' => 'Hidden',
|
|
'left' => 'Top',
|
|
'center' => 'Middle',
|
|
'right' => 'Bottom' ]
|
|
];
|
|
|
|
public static $fontWeights = [
|
|
'normal' => 'Maigre',
|
|
'bold' => 'Gras'
|
|
];
|
|
public static $fontWeights_en = [
|
|
'normal' => 'Thin',
|
|
'bold' => 'Bold'
|
|
];
|
|
public static $footerHeights = [
|
|
'0px' => 'Nulles (0px)',
|
|
'5px' => 'Très petites (5px)',
|
|
'10px' => 'Petites (10px)',
|
|
'15px' => 'Moyennes (15px)',
|
|
'20px' => 'Grandes (20px)'
|
|
];
|
|
public static $footerHeights_en = [
|
|
'0px' => 'Nome (0px)',
|
|
'5px' => 'Very small (5px)',
|
|
'10px' => 'small (10px)',
|
|
'15px' => 'Medium (15px)',
|
|
'20px' => 'Large (20px)'
|
|
];
|
|
public static $footerPositions = [
|
|
'hide' => 'Caché',
|
|
'site' => 'Dans le site',
|
|
'body' => 'En dessous du site'
|
|
];
|
|
public static $footerPositions_en = [
|
|
'hide' => 'Hidden',
|
|
'site' => 'In the site',
|
|
'body' => 'Below the site'
|
|
];
|
|
public static $footerFontSizes = [
|
|
'.8em' => 'Très petite (80%)',
|
|
'.9em' => 'Petite (90%)',
|
|
'1em' => 'Standard (100%)',
|
|
'1.1em' => 'Moyenne (110%)',
|
|
'1.2em' => 'Grande (120%)',
|
|
'1.3em' => 'Très grande (130%)'
|
|
];
|
|
public static $footerFontSizes_en = [
|
|
'.8em' => 'Very small (80%)',
|
|
'.9em' => 'Small (90%)',
|
|
'1em' => 'Standard (100%)',
|
|
'1.1em' => 'Medium (110%)',
|
|
'1.2em' => 'Large (120%)',
|
|
'1.3em' => 'Very large (130%)'
|
|
];
|
|
public static $headerFontSizes = [
|
|
'1.6em' => 'Très petite (160%)',
|
|
'1.8em' => 'Petite (180%)',
|
|
'2em' => 'Moyenne (200%)',
|
|
'2.2em' => 'Grande (220%)',
|
|
'2.4vmax' => 'Très grande (240%)'
|
|
];
|
|
public static $headerFontSizes_en = [
|
|
'1.6em' => 'Very small (160%)',
|
|
'1.8em' => 'Small (180%)',
|
|
'2em' => 'Medium (200%)',
|
|
'2.2em' => 'Large (220%)',
|
|
'2.4vmax' => 'Very large (240%)'
|
|
];
|
|
public static $headerHeights = [
|
|
'unset' => 'Libre', // texte dynamique cf header.js.php
|
|
'100px' => 'Très petite (100px) ',
|
|
'150px' => 'Petite (150px)',
|
|
'200px' => 'Moyenne (200px)',
|
|
'300px' => 'Grande (300px)',
|
|
'400px' => 'Très grande (400px)',
|
|
];
|
|
public static $headerHeights_en = [
|
|
'unset' => 'Free', // texte dynamique cf header.js.php
|
|
'100px' => 'Very small (100px) ',
|
|
'150px' => 'Small (150px)',
|
|
'200px' => 'Medium (200px)',
|
|
'300px' => 'Large (300px)',
|
|
'400px' => 'Very large (400px)',
|
|
];
|
|
public static $headerPositions = [
|
|
'body' => 'Au dessus du site',
|
|
'site' => 'Dans le site',
|
|
'hide' => 'Cachée'
|
|
];
|
|
public static $headerPositions_en = [
|
|
'body' => 'Above the site',
|
|
'site' => 'In the site',
|
|
'hide' => 'Hidden'
|
|
];
|
|
public static $headerFeatures = [
|
|
'wallpaper' => 'Couleur unie ou papier-peint',
|
|
'feature' => 'Contenu personnalisé'
|
|
];
|
|
public static $headerFeatures_en = [
|
|
'wallpaper' => 'Solid colour or wallpaper',
|
|
'feature' => 'Custom content'
|
|
];
|
|
public static $imagePositions = [
|
|
'top left' => 'En haut à gauche',
|
|
'top center' => 'En haut au centre',
|
|
'top right' => 'En haut à droite',
|
|
'center left' => 'Au milieu à gauche',
|
|
'center center' => 'Au milieu au centre',
|
|
'center right' => 'Au milieu à droite',
|
|
'bottom left' => 'En bas à gauche',
|
|
'bottom center' => 'En bas au centre',
|
|
'bottom right' => 'En bas à droite'
|
|
];
|
|
public static $imagePositions_en = [
|
|
'top left' => 'Top left',
|
|
'top center' => 'Top center',
|
|
'top right' => 'Top right',
|
|
'center left' => 'Middle left',
|
|
'center center' => 'Middle center',
|
|
'center right' => 'Middle right',
|
|
'bottom left' => 'Bottom left',
|
|
'bottom center' => 'Bottom center',
|
|
'bottom right' => 'Bottom right'
|
|
];
|
|
public static $menuFontSizes = [
|
|
'.8em' => 'Très petite (80%)',
|
|
'.9em' => 'Petite (90%)',
|
|
'1em' => 'Standard (100%)',
|
|
'1.1em' => 'Moyenne (110%)',
|
|
'1.2em' => 'Grande (120%)',
|
|
'1.3em' => 'Très grande (130%)'
|
|
];
|
|
public static $menuFontSizes_en = [
|
|
'.8em' => 'Very small (80%)',
|
|
'.9em' => 'Small (90%)',
|
|
'1em' => 'Standard (100%)',
|
|
'1.1em' => 'Medium (110%)',
|
|
'1.2em' => 'Large (120%)',
|
|
'1.3em' => 'Very large (130%)'
|
|
];
|
|
public static $menuBurgerFontSizes = [
|
|
'1em' => 'Très petite (100%)',
|
|
'1.2em' => 'Petite (120%)',
|
|
'1.5em' => 'Standard (150%)',
|
|
'1.8em' => 'Moyenne (180%)',
|
|
'2em' => 'Grande (200%)',
|
|
'2.5em' => 'Très grande (250%)'
|
|
];
|
|
public static $menuBurgerFontSizes_en = [
|
|
'1em' => 'Very small (100%)',
|
|
'1.2em' => 'Small (120%)',
|
|
'1.5em' => 'Standard (150%)',
|
|
'1.8em' => 'Medium (180%)',
|
|
'2em' => 'Large (200%)',
|
|
'2.5em' => 'Very large (250%)'
|
|
];
|
|
public static $menuHeights = [
|
|
'5px 10px' => 'Très petite',
|
|
'10px' => 'Petite',
|
|
'15px 10px' => 'Moyenne',
|
|
'20px 15px' => 'Grande',
|
|
'25px 15px' => 'Très grande'
|
|
];
|
|
public static $menuHeights_en = [
|
|
'5px 10px' => 'Very small',
|
|
'10px' => 'Small',
|
|
'15px 10px' => 'Medium',
|
|
'20px 15px' => 'Large',
|
|
'25px 15px' => 'Very large'
|
|
];
|
|
public static $menuPositionsSite = [
|
|
'top' => 'En-dehors du site',
|
|
'site-first' => 'Avant la bannière',
|
|
'site-second' => 'Après la bannière',
|
|
'hide' => 'Caché'
|
|
];
|
|
public static $menuPositionsSite_en = [
|
|
'top' => 'Outside the site',
|
|
'site-first' => 'Before the banner',
|
|
'site-second' => 'After the banner',
|
|
'hide' => 'Hidden'
|
|
];
|
|
public static $menuPositionsBody = [
|
|
'top' => 'En-dehors du site',
|
|
'body-first' => 'Avant la bannière',
|
|
'body-second' => 'Après la bannière',
|
|
'site' => 'Dans le site',
|
|
'hide' => 'Caché'
|
|
];
|
|
public static $menuPositionsBody_en = [
|
|
'top' => 'Outside the site',
|
|
'body-first' => 'Before the banner',
|
|
'body-second' => 'After the banner',
|
|
'site' => 'In the site',
|
|
'hide' => 'Hidden'
|
|
];
|
|
public static $menuRadius = [
|
|
'0px' => 'Aucun',
|
|
'3px 3px 0px 0px' => 'Très léger',
|
|
'6px 6px 0px 0px' => 'Léger',
|
|
'9px 9px 0px 0px' => 'Moyen',
|
|
'12px 12px 0px 0px' => 'Important',
|
|
'15px 15px 0px 0px' => 'Très important'
|
|
];
|
|
public static $menuRadius_en = [
|
|
'0px' => 'None',
|
|
'3px 3px 0px 0px' => 'Very light',
|
|
'6px 6px 0px 0px' => 'Light',
|
|
'9px 9px 0px 0px' => 'Medium',
|
|
'12px 12px 0px 0px' => 'Important',
|
|
'15px 15px 0px 0px' => 'Very important'
|
|
];
|
|
public static $radius = [
|
|
'0px' => 'Aucun',
|
|
'5px' => 'Très léger',
|
|
'10px' => 'Léger',
|
|
'15px' => 'Moyen',
|
|
'25px' => 'Important',
|
|
'50px' => 'Très important'
|
|
];
|
|
public static $radius_en = [
|
|
'0px' => 'None',
|
|
'5px' => 'Very light',
|
|
'10px' => 'Light',
|
|
'15px' => 'Medium',
|
|
'25px' => 'Important',
|
|
'50px' => 'Very important'
|
|
];
|
|
public static $repeats = [
|
|
'no-repeat' => 'Ne pas répéter',
|
|
'repeat-x' => 'Sur l\'axe horizontal',
|
|
'repeat-y' => 'Sur l\'axe vertical',
|
|
'repeat' => 'Sur les deux axes'
|
|
];
|
|
public static $repeats_en = [
|
|
'no-repeat' => 'Do not repeat',
|
|
'repeat-x' => 'On the horizontal axis',
|
|
'repeat-y' => 'On the vertical axis',
|
|
'repeat' => 'On both axes'
|
|
];
|
|
public static $shadows = [
|
|
'0px 0px 0px' => 'Aucune',
|
|
'1px 1px 5px' => 'Très légère',
|
|
'1px 1px 10px' => 'Légère',
|
|
'1px 1px 15px' => 'Moyenne',
|
|
'1px 1px 25px' => 'Importante',
|
|
'1px 1px 50px' => 'Très importante'
|
|
];
|
|
public static $shadows_en = [
|
|
'0px 0px 0px' => 'None',
|
|
'1px 1px 5px' => 'Very light',
|
|
'1px 1px 10px' => 'Light',
|
|
'1px 1px 15px' => 'Medium',
|
|
'1px 1px 25px' => 'Importante',
|
|
'1px 1px 50px' => 'Very importante'
|
|
];
|
|
public static $blockShadows = [
|
|
'0px 0px 0px' => 'Aucune',
|
|
'1px 1px 2px' => 'Très légère',
|
|
'2px 2px 4px' => 'Légère',
|
|
'3px 3px 6px' => 'Moyenne',
|
|
'5px 5px 10px' => 'Important',
|
|
'10px 10px 20px' => 'Très important'
|
|
];
|
|
public static $blockShadows_en = [
|
|
'0px 0px 0px' => 'None',
|
|
'1px 1px 2px' => 'Very light',
|
|
'2px 2px 4px' => 'Light',
|
|
'3px 3px 6px' => 'Medium',
|
|
'5px 5px 10px' => 'Important',
|
|
'10px 10px 20px' => 'Very important'
|
|
];
|
|
public static $siteFontSizes = [
|
|
'12px' => '12 pixels',
|
|
'13px' => '13 pixels',
|
|
'14px' => '14 pixels',
|
|
'15px' => '15 pixels',
|
|
'16px' => '16 pixels',
|
|
'18px' => '18 pixels',
|
|
'20px' => '20 pixels'
|
|
];
|
|
public static $bodySizes = [
|
|
'auto' => 'Automatique',
|
|
'100% 100%' => 'Image étirée (100% 100%)',
|
|
'cover' => 'Responsive (cover)',
|
|
'contain' => 'Responsive (contain)'
|
|
];
|
|
public static $bodySizes_en = [
|
|
'auto' => 'Automatic',
|
|
'100% 100%' => 'Stretched image (100% 100%)',
|
|
'cover' => 'Responsive (cover)',
|
|
'contain' => 'Responsive (contain)'
|
|
];
|
|
public static $textTransforms = [
|
|
'none' => 'Standard',
|
|
'lowercase' => 'Minuscules',
|
|
'uppercase' => 'Majuscules',
|
|
'capitalize' => 'Majuscule à chaque mot'
|
|
];
|
|
public static $textTransforms_en = [
|
|
'none' => 'Standard',
|
|
'lowercase' => 'Lowercase',
|
|
'uppercase' => 'Upper case',
|
|
'capitalize' => 'Capitalize every word'
|
|
];
|
|
public static $siteWidths = [
|
|
'750px' => 'Petite (750 pixels)',
|
|
'960px' => 'Moyenne (960 pixels)',
|
|
'1170px' => 'Grande (1170 pixels)',
|
|
'100%' => 'Fluide (100%)'
|
|
];
|
|
public static $siteWidths_en = [
|
|
'750px' => 'Small (750 pixels)',
|
|
'960px' => 'Medium (960 pixels)',
|
|
'1170px' => 'Large (1170 pixels)',
|
|
'100%' => 'Fluide (100%)'
|
|
];
|
|
public static $headerWide = [
|
|
'auto auto' => 'Automatique',
|
|
'100% 100%' => 'Image étirée (100% 100%)',
|
|
'cover' => 'Responsive (cover)',
|
|
'contain' => 'Responsive (contain)'
|
|
];
|
|
public static $headerWide_en = [
|
|
'auto auto' => 'Automatic',
|
|
'100% 100%' => 'Stretched image (100% 100%)',
|
|
'cover' => 'Responsive (cover)',
|
|
'contain' => 'Responsive (contain)'
|
|
];
|
|
public static $footerTemplate = [
|
|
'1' => 'Une seule colonne',
|
|
'2' => 'Deux colonnes : 1/2 - 1/2',
|
|
'3' => 'Trois colonnes : 1/3 - 1/3 - 1/3',
|
|
'4' => 'Trois lignes superposées'
|
|
];
|
|
public static $footerTemplate_en = [
|
|
'1' => 'One column',
|
|
'2' => 'Two columns : 1/2 - 1/2',
|
|
'3' => 'Three columns : 1/3 - 1/3 - 1/3',
|
|
'4' => 'Three rows on top of each'
|
|
];
|
|
public static $burgerContent = [
|
|
'none' => 'Aucun',
|
|
'title' => 'Titre du site',
|
|
'logo' => 'Logo du site'
|
|
];
|
|
public static $burgerContent_en = [
|
|
'none' => 'None',
|
|
'title' => 'Site title',
|
|
'logo' => 'Site logo'
|
|
];
|
|
// Fonts
|
|
public static $fonts = [];
|
|
|
|
public static $fontFiles =[];
|
|
|
|
public static $typeAddFont = [
|
|
'none' => 'Aucune',
|
|
'file' => 'Fichier local'
|
|
//'link' => 'Fichier externe avec link',
|
|
//'import' => 'Fichier externe avec import'
|
|
];
|
|
public static $typeAddFont_en = [
|
|
'none' => 'None',
|
|
'file' => 'Local file'
|
|
//'link' => 'Fichier externe avec link',
|
|
//'import' => 'Fichier externe avec import'
|
|
];
|
|
// Variable pour construire la liste des pages du site
|
|
public static $pagesList = [];
|
|
|
|
/**
|
|
* Thème des écrans d'administration
|
|
*/
|
|
public function admin() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Administration';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Saved changes';
|
|
$text[1] = 'Administration';
|
|
break;
|
|
}
|
|
// Soumission du formulaire
|
|
if($this->isPost()) {
|
|
$this->setData(['admin', [
|
|
'backgroundColor' => $this->getInput('adminBackgroundColor'),
|
|
'colorTitle' => $this->getInput('adminColorTitle'),
|
|
'colorText' => $this->getInput('adminColorText'),
|
|
'colorButtonText' => $this->getInput('adminColorButtonText'),
|
|
'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'),
|
|
'maj' => true
|
|
]]);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme/admin',
|
|
'state' => true
|
|
]);
|
|
}
|
|
self::$fonts = $this->extract('./site/data/fonts.json');
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'view' => 'admin',
|
|
'vendor' => [
|
|
'tinycolorpicker'
|
|
],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Mode avancé
|
|
*/
|
|
public function advanced() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Éditeur CSS';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Saved changes';
|
|
$text[1] = 'CSS Editor';
|
|
break;
|
|
}
|
|
// Soumission du formulaire
|
|
if($this->isPost()) {
|
|
// Enregistre le CSS
|
|
file_put_contents(self::DATA_DIR.'custom.css', $this->getInput('themeAdvancedCss', null));
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme/advanced',
|
|
'state' => true
|
|
]);
|
|
}
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'vendor' => [
|
|
'codemirror'
|
|
],
|
|
'view' => 'advanced'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Gestion des polices / affichage principal
|
|
*/
|
|
public function fonts() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Gestion des polices';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Font management';
|
|
break;
|
|
}
|
|
// Préparation du tableau d'affichage des polices
|
|
$fontsName = helper::arrayCollumn($this->getData(['fonts']), 'name');
|
|
ksort($fontsName);
|
|
foreach($fontsName as $fontsId => $value) {
|
|
|
|
self::$fonts[] = [
|
|
'<span style="font-family:'.$this->getData(['fonts', $fontsId, 'name']).'">'.$fontsId.'</span>',
|
|
'<span style="font-family:'.$this->getData(['fonts', $fontsId, 'name']).'">'.$this->getData(['fonts', $fontsId, 'name']).'</span>',
|
|
'<span style="font-family:'.$this->getData(['fonts', $fontsId, 'name']).'">'.$this->getData(['fonts', $fontsId, 'file']).'</span>',
|
|
'<span style="font-family:'.$this->getData(['fonts', $fontsId, 'name']).'">TPQtpq741àéèôüç</span>',
|
|
template::button('fontsEdit' . $fontsId, [
|
|
'href' => helper::baseUrl() . 'theme/editFonts/' . $fontsId,
|
|
'value' => template::ico('pencil')
|
|
]),
|
|
template::button('fontsDelete' . $fontsId, [
|
|
'class' => 'fontDelete buttonRed',
|
|
'href' => helper::baseUrl() . 'theme/deleteFonts/' . $fontsId,
|
|
'value' => template::ico('cancel')
|
|
])
|
|
];
|
|
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[0],
|
|
'view' => 'fonts'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Gestion des polices / édition
|
|
*/
|
|
public function editfonts() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Sélectionner le fichier...';
|
|
$text[1] = 'Vous devez sélectionner un fichier';
|
|
$text[2] = 'Modifications enregistrées';
|
|
$text[3] = 'Pas de fichier dans le dossier ';
|
|
$text[4] = 'Dossier ';
|
|
$text[5] = 'inexistant';
|
|
$text[6] = 'Édition d\'une police';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Select file...';
|
|
$text[1] = 'You need to select a file';
|
|
$text[2] = 'Changes saved';
|
|
$text[3] = 'No file in folder';
|
|
$text[4] = 'File';
|
|
$text[5] = 'Non-existent';
|
|
$text[6] = 'Editing a font';
|
|
break;
|
|
}
|
|
// Retour du formulaire
|
|
if($this->isPost()) {
|
|
if( $this->getInput('typeEditFont') === 'file' && $this->getInput('fileEditFont') === $text[0]){
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[1],
|
|
'redirect' => helper::baseUrl() . 'theme/fonts',
|
|
'state' => false
|
|
]);
|
|
}
|
|
else{
|
|
$file = $this->getInput('typeEditFont') === 'none' ? '' : $this->getInput('fileEditFont');
|
|
$key = strtolower(str_replace(' ','-',$this->getInput('nameEditFont')));
|
|
$this->setData(['fonts', $key, [
|
|
'name' => $this->getInput('nameEditFont'),
|
|
'type' => $this->getInput('typeEditFont'),
|
|
'file' => $file,
|
|
'link' => '',
|
|
'license' => $this->getInput('licenseEditFont')
|
|
]]);
|
|
// Force une maj de admin.css
|
|
$this-> setData(['admin', 'maj', true]);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[2],
|
|
'redirect' => helper::baseUrl() . 'theme/fonts',
|
|
'state' => true
|
|
]);
|
|
}
|
|
}
|
|
|
|
// Fichiers site/file/fonts/
|
|
if(is_dir(self::FILE_DIR.'source/fonts')) {
|
|
$dir=self::FILE_DIR.'source/fonts';
|
|
$values = scandir($dir);
|
|
$values[0] = $text[0];
|
|
unset($values[array_search('..', $values)]);
|
|
if (count($values) <= 1){
|
|
self::$icsFiles = array(0 => $text[3].self::FILE_DIR.'source/fonts');
|
|
}
|
|
else{
|
|
//Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur
|
|
self::$fontFiles = array_combine($values,$values);
|
|
}
|
|
}
|
|
else {
|
|
self::$fontFiles = array(0 => $text[4].self::FILE_DIR.'source/fonts '.$text[5]);
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[6],
|
|
'view' => 'editFonts'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Gestion des polices / suppression
|
|
*/
|
|
public function deleteFonts() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Police supprimée';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Deleted font';
|
|
break;
|
|
}
|
|
//Suppression de la police passée en paramètre
|
|
$this->deleteData(['fonts', $this->getUrl(2)]);
|
|
// Force une maj de admin.css
|
|
$this-> setData(['admin', 'maj', true]);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme/fonts',
|
|
'state' => true
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Gestion des polices / ajout
|
|
*/
|
|
public function addFonts() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Sélectionner le fichier...';
|
|
$text[1] = 'Vous devez sélectionner un fichier';
|
|
$text[2] = 'Modifications enregistrées';
|
|
$text[3] = 'Pas de fichier dans le dossier ';
|
|
$text[4] = 'Dossier ';
|
|
$text[5] = 'inexistant';
|
|
$text[6] = 'Ajout d\'une police';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Select file...';
|
|
$text[1] = 'You need to select a file';
|
|
$text[2] = 'Changes saved';
|
|
$text[3] = 'No file in folder';
|
|
$text[4] = 'File';
|
|
$text[5] = 'Non-existent';
|
|
$text[6] = 'Adding a font';
|
|
break;
|
|
}
|
|
// Retour du formulaire
|
|
if($this->isPost()) {
|
|
if( $this->getInput('typeAddFont') === 'file' && $this->getInput('fileAddFont') === $text[0]){
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[1],
|
|
'redirect' => helper::baseUrl() . 'theme/addFonts',
|
|
'state' => false
|
|
]);
|
|
}
|
|
else{
|
|
$file = $this->getInput('typeAddFont') === 'none' ? '' : $this->getInput('fileAddFont');
|
|
$key = strtolower(str_replace(' ','-',$this->getInput('nameAddFont')));
|
|
$this->setData(['fonts', $key, [
|
|
'name' => $this->getInput('nameAddFont'),
|
|
'type' => $this->getInput('typeAddFont'),
|
|
'file' => $file,
|
|
'link' => '',
|
|
'license' => $this->getInput('licenseAddFont')
|
|
]]);
|
|
// Force une maj de admin.css
|
|
$this-> setData(['admin', 'maj', true]);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[2],
|
|
'redirect' => helper::baseUrl() . 'theme/fonts',
|
|
'state' => true
|
|
]);
|
|
}
|
|
}
|
|
// Fichiers site/file/fonts/
|
|
if(is_dir(self::FILE_DIR.'source/fonts')) {
|
|
$dir=self::FILE_DIR.'source/fonts';
|
|
$values = scandir($dir);
|
|
$values[0] = $text[0];
|
|
unset($values[array_search('..', $values)]);
|
|
if (count($values) <= 1){
|
|
self::$icsFiles = array(0 => $text[3].self::FILE_DIR.'source/fonts');
|
|
}
|
|
else{
|
|
//Modifier les clefs (qui sont les valeurs de retour du formulaire avec clef = valeur
|
|
self::$fontFiles = array_combine($values,$values);
|
|
}
|
|
}
|
|
else {
|
|
self::$fontFiles = array(0 => $text[4].self::FILE_DIR.'source/fonts '.$text[5]);
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[6],
|
|
'view' => 'addFonts'
|
|
]);
|
|
}
|
|
|
|
|
|
/**
|
|
* Options de l'arrière plan
|
|
*/
|
|
public function body() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Personnalisation de l\'arrière plan';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Changes saved';
|
|
$text[1] = 'Customise background';
|
|
break;
|
|
}
|
|
// 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')
|
|
]]);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme',
|
|
'state' => true
|
|
]);
|
|
}
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'vendor' => [
|
|
'tinycolorpicker'
|
|
],
|
|
'view' => 'body'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Options du pied de page
|
|
*/
|
|
public function footer() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Sélectionnez au moins un contenu à afficher';
|
|
$text[1] = 'Modifications enregistrées';
|
|
$text[2] = 'Personnalisation du pied de page';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Select at least one content to display';
|
|
$text[1] = 'Saved changes';
|
|
$text[2] = 'Customise footer';
|
|
break;
|
|
}
|
|
// Soumission du formulaire
|
|
if($this->isPost()) {
|
|
if ( $this->getInput('themeFooterCopyrightPosition') === 'hide' &&
|
|
$this->getInput('themeFooterSocialsPosition') === 'hide' &&
|
|
$this->getInput('themeFooterTextPosition') === 'hide' ) {
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme/footer',
|
|
'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),
|
|
'displayMemberBar'=> $this->getInput('themeFooterDisplayMemberBar', helper::FILTER_BOOLEAN),
|
|
'template' => $this->getInput('themeFooterTemplate')
|
|
]]);
|
|
|
|
// Sauvegarder la configuration localisée
|
|
$this->setData(['locale','legalPageId', $this->getInput('configLegalPageId')]);
|
|
$this->setData(['locale','searchPageId', $this->getInput('configSearchPageId')]);
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[1],
|
|
'redirect' => helper::baseUrl() . 'theme',
|
|
'state' => true
|
|
]);
|
|
}
|
|
}
|
|
|
|
// Liste des pages
|
|
self::$pagesList = $this->getData(['page']);
|
|
foreach(self::$pagesList as $page => $pageId) {
|
|
if ($this->getData(['page',$page,'block']) === 'bar' ||
|
|
$this->getData(['page',$page,'disable']) === true) {
|
|
unset(self::$pagesList[$page]);
|
|
}
|
|
}
|
|
self::$fonts = $this->extract('./site/data/fonts.json');
|
|
// Passage de la langue d'administration à Tinymce
|
|
$lang_admin = 'fr_FR';
|
|
if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en') $lang_admin = 'en_GB';
|
|
?>
|
|
<script>
|
|
var lang_admin = "<?php echo $lang_admin ?>";
|
|
</script>
|
|
<?php
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[2],
|
|
'vendor' => [
|
|
'tinycolorpicker',
|
|
'tinymce'
|
|
],
|
|
'view' => 'footer'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Options de la bannière
|
|
*/
|
|
public function header() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Personnalisation de la bannière';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Changes saved';
|
|
$text[1] = 'Customise banner';
|
|
break;
|
|
}
|
|
// Soumission du formulaire
|
|
if($this->isPost()) {
|
|
// Modification des URL des images dans la bannière perso
|
|
$featureContent = $this->getInput('themeHeaderText', null);
|
|
// $featureContent = str_replace(helper::baseUrl(false,false), './', $featureContent);
|
|
// Si une image est positionnée, l'arrière en transparent.
|
|
$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
|
|
]]);
|
|
// 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']))]);
|
|
}
|
|
if ( $this->getData(['theme','header','position']) == 'body')
|
|
{
|
|
$this->setData(['theme', 'menu', 'position',str_replace ('site-','body-',$this->getData(['theme','menu','position']))]);
|
|
}
|
|
// Menu accroché à la bannière qui devient cachée
|
|
if ( $this->getData(['theme','header','position']) == 'hide' &&
|
|
in_array( $this->getData(['theme','menu','position']) , ['body-first', 'site-first', 'body-first' , 'site-second'])
|
|
) {
|
|
$this->setData(['theme', 'menu', 'position','site']);
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme',
|
|
'state' => true
|
|
]);
|
|
}
|
|
self::$fonts = $this->extract('./site/data/fonts.json');
|
|
// Passage de la langue d'administration à Tinymce
|
|
$lang_admin = 'fr_FR';
|
|
if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en') $lang_admin = 'en_GB';
|
|
?>
|
|
<script>
|
|
var lang_admin = "<?php echo $lang_admin ?>";
|
|
</script>
|
|
<?php
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'vendor' => [
|
|
'tinycolorpicker',
|
|
'tinymce'
|
|
],
|
|
'view' => 'header'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Accueil de la personnalisation
|
|
*/
|
|
public function index() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Personnalisation des thèmes';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Theme customisation';
|
|
break;
|
|
}
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[0],
|
|
'view' => 'index'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Options du menu
|
|
*/
|
|
public function menu() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Personnalisation du menu';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Saved changes';
|
|
$text[1] = 'Customise menu';
|
|
break;
|
|
}
|
|
// 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'),
|
|
'burgerTextColor' => $this->getInput('themeMenuBurgerTextColor'),
|
|
'burgerFontSize' => $this->getInput('themeMenuBurgerFontSize')
|
|
]]);
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme',
|
|
'state' => true
|
|
]);
|
|
}
|
|
self::$fonts = $this->extract('./site/data/fonts.json');
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'vendor' => [
|
|
'tinycolorpicker'
|
|
],
|
|
'view' => 'menu'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Réinitialisation de la personnalisation avancée
|
|
*/
|
|
public function reset() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Réinitialisation effectuée';
|
|
$text[1] = 'Jeton incorrect';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Reset performed';
|
|
$text[1] = 'Incorrect token';
|
|
break;
|
|
}
|
|
// $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');
|
|
$redirect = helper::baseUrl() . 'theme/admin';
|
|
break;
|
|
case 'manage':
|
|
$this->initData('theme');
|
|
$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' => $text[0],
|
|
'redirect' => $redirect,
|
|
'state' => true
|
|
]);
|
|
} else {
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[1]
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Options du site
|
|
*/
|
|
public function site() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Modifications enregistrées';
|
|
$text[1] = 'Personnalisation du site';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Changes saved';
|
|
$text[1] = 'Site customisation';
|
|
break;
|
|
}
|
|
// 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'),
|
|
'backgroundTitleColor' => $this->getInput('themeBlockBackgroundTitleColor'),
|
|
'blockBorderRadius' => $this->getInput('themeBlockBorderRadius'),
|
|
'blockBorderShadow' => $this->getInput('themeBlockBorderShadow')
|
|
]]);
|
|
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0],
|
|
'redirect' => helper::baseUrl() . 'theme',
|
|
'state' => true
|
|
]);
|
|
}
|
|
self::$fonts = $this->extract('./site/data/fonts.json');
|
|
// Passage de la langue d'administration à Tinymce
|
|
$lang_admin = 'fr_FR';
|
|
if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en') $lang_admin = 'en_GB';
|
|
?>
|
|
<script>
|
|
var lang_admin = "<?php echo $lang_admin ?>";
|
|
</script>
|
|
<?php
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[1],
|
|
'vendor' => [
|
|
'tinycolorpicker',
|
|
'tinymce'
|
|
],
|
|
'view' => 'site'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Import du thème
|
|
*/
|
|
public function manage() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Gestion des thèmes';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Theme management';
|
|
break;
|
|
}
|
|
if($this->isPost() ) {
|
|
|
|
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
|
|
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename);
|
|
if ($data['success']) {
|
|
header("Refresh:0");
|
|
// Régénérer theme.css
|
|
if (file_exists(self::DATA_DIR . 'theme.css')) {
|
|
unlink(self::DATA_DIR . 'theme.css');
|
|
}
|
|
} else {
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $data['notification'],
|
|
'state' => $data['success'],
|
|
'title' => $text[0],
|
|
'view' => 'manage'
|
|
]);;
|
|
}
|
|
}
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'title' => $text[0],
|
|
'view' => 'manage'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Importe un thème
|
|
* @param string Url du thème à télécharger
|
|
* @param @return array contenant $success = true ou false ; $ notification string message à afficher
|
|
*/
|
|
|
|
public function import($zipName = '') {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Le thème a été importé';
|
|
$text[1] = 'Erreur lors de l\'extraction, vérifiez les permissions.';
|
|
$text[2] = 'Ce n\'est pas l\'archive d\'un thème !';
|
|
$text[3] = 'Impossible d\'ouvrir l\'archive';
|
|
$text[4] = 'Archive non spécifiée ou introuvable';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'The theme has been imported';
|
|
$text[1] = 'Error while extracting, check permissions';
|
|
$text[2] = 'This is not a theme archive!';
|
|
$text[3] = 'Unable to open the archive';
|
|
$text[4] = 'Archive not specified or not found';
|
|
break;
|
|
}
|
|
|
|
if ($zipName !== '' &&
|
|
file_exists($zipName)) {
|
|
// Init variables de retour
|
|
$success = false;
|
|
$notification = '';
|
|
// Dossier temporaire
|
|
$tempFolder = uniqid();
|
|
// Ouvrir le zip
|
|
$zip = new ZipArchive();
|
|
if ($zip->open($zipName) === TRUE) {
|
|
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
|
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
|
$modele = '';
|
|
// Archive de thème ?
|
|
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.json')
|
|
) {
|
|
$modele = 'theme';
|
|
$this->sauve( $modele );
|
|
}
|
|
if(
|
|
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
|
|
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
|
|
) {
|
|
$modele = 'admin';
|
|
$this->sauve( $modele );
|
|
}
|
|
if (!empty($modele)
|
|
) {
|
|
// traiter l'archive
|
|
$importFolder = './site/file/import';
|
|
mkdir ($importFolder, 0755);
|
|
$success = $zip->extractTo($importFolder);
|
|
// $path = $importFolder.'/site/file/source/';
|
|
// Modifie le nom de tous les fichiers de $path et leur nom dans theme.json
|
|
// $this->changeName($path);
|
|
$this->copyDir( $importFolder, './');
|
|
$this->removeDir($importFolder);
|
|
// traitement de l'erreur
|
|
$notification = $success ? $text[0] : $text[1];
|
|
|
|
|
|
} else {
|
|
// pas une archive de thème
|
|
$success = false;
|
|
$notification = $text[2];
|
|
}
|
|
// Supprimer le dossier temporaire même si le thème est invalide
|
|
$this->removeDir(self::TEMP_DIR . $tempFolder);
|
|
$zip->close();
|
|
} else {
|
|
// erreur à l'ouverture
|
|
$success = false;
|
|
$notification = $text[3];
|
|
}
|
|
return (['success' => $success, 'notification' => $notification]);
|
|
}
|
|
|
|
return (['success' => false, 'notification' => $text[4]]);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Export du thème
|
|
*/
|
|
public function export() {
|
|
// Make zip
|
|
$zipFilename = $this->zipTheme($this->getUrl(2));
|
|
// Téléchargement du ZIP
|
|
header('Content-Description: File Transfer');
|
|
header('Content-Type: application/octet-stream');
|
|
header('Content-Transfer-Encoding: binary');
|
|
header('Content-Disposition: attachment; filename="' . $zipFilename . '"');
|
|
header('Content-Length: ' . filesize(self::TEMP_DIR . $zipFilename));
|
|
readfile(self::TEMP_DIR . $zipFilename);
|
|
// Nettoyage du dossier
|
|
unlink (self::TEMP_DIR . $zipFilename);
|
|
exit();
|
|
}
|
|
|
|
/**
|
|
* Export du thème
|
|
*/
|
|
public function save() {
|
|
// Lexique
|
|
$text = [];
|
|
$val = $this->getData(['config', 'i18n', 'langAdmin']);
|
|
switch ($val) {
|
|
case 'fr' :
|
|
$text[0] = 'Archive ';
|
|
$text[1] = ' sauvegardée avec succès';
|
|
break;
|
|
case 'en' :
|
|
$text[0] = 'Archive ';
|
|
$text[1] = ' successfully saved';
|
|
break;
|
|
}
|
|
// Make zip
|
|
$zipFilename = $this->zipTheme($this->getUrl(2));
|
|
// Téléchargement du ZIP
|
|
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
|
mkdir(self::FILE_DIR.'source/theme', 0755);
|
|
}
|
|
copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename);
|
|
// Nettoyage du dossier
|
|
unlink (self::TEMP_DIR . $zipFilename);
|
|
// Valeurs en sortie
|
|
$this->addOutput([
|
|
'notification' => $text[0].'<b>'.$zipFilename.'</b>'. $text[1],
|
|
'redirect' => helper::baseUrl() . 'theme/manage',
|
|
'state' => true
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Sauvegarde du thème du site ou de l'administration avant application d'un nouveau thème
|
|
*/
|
|
public function sauve( $type ) {
|
|
// Make zip
|
|
$zipFilename = $this->zipTheme( $type );
|
|
// Téléchargement du ZIP
|
|
if (!is_dir(self::FILE_DIR.'source/theme')) {
|
|
mkdir(self::FILE_DIR.'source/theme', 0755);
|
|
}
|
|
copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename);
|
|
// Nettoyage du dossier
|
|
unlink (self::TEMP_DIR . $zipFilename);
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* construction du zip
|
|
* @param string $modele theme ou admin
|
|
*/
|
|
private function zipTheme($modele) {
|
|
// Creation du dossier
|
|
$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) {
|
|
case 'admin':
|
|
$zip->addFile(self::DATA_DIR.'admin.json',self::DATA_DIR.'admin.json');
|
|
$zip->addFile(self::DATA_DIR.'admin.css',self::DATA_DIR.'admin.css');
|
|
break;
|
|
case 'theme':
|
|
$zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json');
|
|
$zip->addFile(self::DATA_DIR.'theme.css',self::DATA_DIR.'theme.css');
|
|
$zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css');
|
|
if ($this->getData(['theme','body','image']) !== '' ) {
|
|
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']),
|
|
self::FILE_DIR.'source/'.$this->getData(['theme','body','image'])
|
|
);
|
|
}
|
|
if ($this->getData(['theme','header','image']) !== '' ) {
|
|
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']),
|
|
self::FILE_DIR.'source/'.$this->getData(['theme','header','image'])
|
|
);
|
|
}
|
|
// Extraction des images de la bannière personnalisée
|
|
$images=[];
|
|
$ii=0;
|
|
if( $this->getData(['theme','header','feature'])=== 'feature') {
|
|
$tab = str_word_count($this->getData(['theme','header','featureContent']), 1, './' );
|
|
foreach( $tab as $key=>$value ){
|
|
if( $value ==='src'){
|
|
$images[$ii] = $tab [$key + 1];
|
|
$ii++;
|
|
}
|
|
}
|
|
// ajout des images dans le zip
|
|
foreach( $images as $key=>$value){
|
|
$value = str_replace( './site', 'site' , $value);
|
|
$zip->addFile( $value, $value );
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
$ret = $zip->close();
|
|
}
|
|
return ($zipFilename);
|
|
}
|
|
|
|
/*
|
|
* Extraction des noms des polices de fonts.json vers self::$fonts
|
|
*/
|
|
private function extract( $file) {
|
|
$fonts = [];
|
|
if (file_exists($file)){
|
|
$json = file_get_contents($file);
|
|
$fonts1 = json_decode($json, true);
|
|
$fonts2 = $fonts1['fonts'];
|
|
foreach ($fonts2 as $key=>$value){
|
|
$fonts[$key] = $value['name'];
|
|
}
|
|
return $fonts;
|
|
}
|
|
}
|
|
|
|
}
|