@ -21,6 +21,10 @@ 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,
@ -42,38 +46,6 @@ class theme extends common {
'scroll' => 'Standard',
'fixed' => 'Fixe'
];
public static $fonts = [
'Arial' => 'Arial',
'Bodoni MT' => 'Bodoni MT',
'Baskerville' => 'Baskerville',
'Calibri' => 'Calibri',
'Calisto MT' => 'Calisto MT',
'Cambria' => 'Cambria',
'Candara' => 'Candara',
'Century Gothic' => 'Century Gothic',
'Consolas' => 'Consolas',
'Copperplate Gothic' => 'Copperplate Gothic',
'Courrier New' => 'Courrier New',
'Dejavu Sans' => 'Dejavu Sans',
'Didot' => 'Didot',
'Franklin Gothic' => 'Franklin Gothic',
'Garamond' => 'Garamond',
'Georgia' => 'Georgia',
'Goudy Old Style' => 'Goudy Old Style',
'Helvetica' => 'Helvetica',
'Impact' => 'Impact',
'Lucida Bright' => 'Lucida Bright',
'Lucida Sans' => 'Lucida Sans',
'Microsoft Sans Serif' => 'Microsoft Sans Serif',
'Optima' => 'Optima',
'Palatino' => 'Palatino',
'Perpetua' => 'Perpetua',
'Rockwell' => 'Rockwell',
'Segoe UI' => 'Segoe UI',
'Tahoma' => 'Tahoma',
'Trebuchet MS' => 'Trebuchet MS',
'Verdana' => 'Verdana'
];
public static $containerWides = [
'container' => 'Limitée au site',
'none' => 'Etendue sur la page'
@ -267,6 +239,17 @@ class theme extends common {
'title' => 'Titre du site',
'logo' => 'Logo du site'
];
// 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'
];
// Variable pour construire la liste des pages du site
public static $pagesList = [];
@ -292,6 +275,7 @@ class theme extends common {
'fontTitle' => $this->getInput('adminFontTitle'),
'backgroundBlockColor' => $this->getInput('adminBackGroundBlockColor'),
'borderBlockColor' => $this->getInput('adminBorderBlockColor'),
'maj' => true
]]);
// Valeurs en sortie
$this->addOutput([
@ -300,6 +284,7 @@ class theme extends common {
'state' => true
]);
}
self::$fonts = $this->extract('./site/data/fonts.json');
// Valeurs en sortie
$this->addOutput([
'title' => 'Administration',
@ -334,7 +319,177 @@ class theme extends common {
'view' => 'advanced'
]);
}
/**
* Gestion des polices / affichage principal
*/
public function fonts() {
// 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:'.$fontsId.'" > '.$fontsId.'< / span > ',
'< span style = "font-family:'.$fontsId.'" > '.$this->getData(['fonts', $fontsId, 'name']).'< / span > ',
'< span style = "font-family:'.$fontsId.'" > '.$this->getData(['fonts', $fontsId, 'file']).'< / span > ',
'< span style = "font-family:'.$fontsId.'" > 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' => 'Gestion des polices',
'view' => 'fonts'
]);
}
/**
* Gestion des polices / édition
*/
public function editfonts() {
// Retour du formulaire
if($this->isPost()) {
if( $this->getInput('typeEditFont') === 'file' & & $this->getInput('fileEditFont') === 'Sélectionner le fichier...'){
// Valeurs en sortie
$this->addOutput([
'notification' => 'Vous devez sélectionner un fichier',
'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' => 'Modifications enregistrées',
'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] = 'Sélectionner le fichier...';
unset($values[array_search('..', $values)]);
if (count($values) < = 1){
self::$icsFiles = array(0 => 'Pas de fichier dans le dossier '.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 => 'Dossier '.self::FILE_DIR.'source/fonts inexistant');
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Édition d\'une police',
'view' => 'editFonts'
]);
}
/**
* Gestion des polices / suppression
*/
public function deleteFonts() {
//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' => 'Police supprimée',
'redirect' => helper::baseUrl() . 'theme/fonts',
'state' => true
]);
}
/**
* Gestion des polices / ajout
*/
public function addFonts() {
// Retour du formulaire
if($this->isPost()) {
if( $this->getInput('typeAddFont') === 'file' & & $this->getInput('fileAddFont') === 'Sélectionner le fichier...'){
// Valeurs en sortie
$this->addOutput([
'notification' => 'Vous devez sélectionner un fichier',
'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' => 'Modifications enregistrées',
'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] = 'Sélectionner le fichier...';
unset($values[array_search('..', $values)]);
if (count($values) < = 1){
self::$icsFiles = array(0 => 'Pas de fichier dans le dossier '.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 => 'Dossier '.self::FILE_DIR.'source/fonts inexistant');
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Ajout d\'une police',
'view' => 'addFonts'
]);
}
/**
* Options de l'arrière plan
*/
@ -416,7 +571,7 @@ class theme extends common {
// 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' => 'Modifications enregistrées',
@ -434,7 +589,7 @@ class theme extends common {
unset(self::$pagesList[$page]);
}
}
self::$fonts = $this->extract('./site/data/fonts.json');
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du pied de page',
@ -493,6 +648,7 @@ class theme extends common {
) {
$this->setData(['theme', 'menu', 'position','site']);
}
// Valeurs en sortie
$this->addOutput([
'notification' => 'Modifications enregistrées',
@ -500,6 +656,7 @@ class theme extends common {
'state' => true
]);
}
self::$fonts = $this->extract('./site/data/fonts.json');
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation de la bannière',
@ -552,6 +709,7 @@ class theme extends common {
'burgerLogo' => $this->getInput('themeMenuBurgerLogo'),
'burgerContent' => $this->getInput('themeMenuBurgerContent')
]]);
// Valeurs en sortie
$this->addOutput([
'notification' => 'Modifications enregistrées',
@ -559,6 +717,7 @@ class theme extends common {
'state' => true
]);
}
self::$fonts = $this->extract('./site/data/fonts.json');
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du menu',
@ -648,6 +807,7 @@ class theme extends common {
'blockBorderRadius' => $this->getInput('themeBlockBorderRadius'),
'blockBorderShadow' => $this->getInput('themeBlockBorderShadow')
]]);
// Valeurs en sortie
$this->addOutput([
'notification' => 'Modifications enregistrées',
@ -655,6 +815,7 @@ class theme extends common {
'state' => true
]);
}
self::$fonts = $this->extract('./site/data/fonts.json');
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du site',
@ -874,36 +1035,19 @@ class theme extends common {
}
/*
*
* Extraction des noms des polices de fonts.json vers self::$fonts
*/
/*
private function changeName($path = '.')
{
$ignore = array('cgi-bin', '.', '..');
if(is_dir($path)){
if($dir = opendir($path)){
while(false !== ($file = readdir($dir))) {
if(!in_array($file, $ignore)) {
if(is_dir("$path$file")) {
$this->changeName( "$path$file/");
}
else {
$oldName = $file;
$newName = date("YmdHi").$file;
rename("$path$oldName", "$path$newName");
// Modification du nom de fichier dans .../import/site/data/theme.json
$fileTheme = './site/file/import/site/data/theme.json';
if(file_exists($fileTheme)){
$json = file_get_contents($fileTheme);
$json = str_replace($oldName, $newName, $json);
file_put_contents($fileTheme,$json);
}
}
}
}
closedir($dir);
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;
}
}
*/
}