[10.0.036.dev] Aperçu des polices dans les sélecteurs

This commit is contained in:
Fred Tempez 2020-02-18 15:07:57 +01:00
parent 61e22d4831
commit 7b67951714
5 changed files with 30 additions and 12 deletions

View File

@ -507,12 +507,19 @@ class template {
'id' => $nameId,
'label' => '',
'name' => $nameId,
'selected' => ''
'selected' => '',
'fonts' => false
], $attributes);
// Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['selected'] = common::$inputBefore[$attributes['id']];
}
// Liste des polices à intégrer
if ($attributes['fonts'] === true) {
foreach ($options as $fontId) {
echo "<link href='http://fonts.googleapis.com/css?family=".str_replace(" ", "+", $fontId)."' rel='stylesheet' type='text/css'>\n";
}
}
// Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label
@ -533,7 +540,13 @@ class template {
helper::sprintAttributes($attributes)
);
foreach($options as $value => $text) {
$html .= sprintf(
$html .= $attributes['fonts'] === true ? sprintf(
'<option value="%s"%s style="font-family: %s;">%s</option>',
$value,
$attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string
str_replace('+',' ',$value),
$text
) : sprintf(
'<option value="%s"%s>%s</option>',
$value,
$attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string

View File

@ -103,7 +103,8 @@
<div class="col3">
<?php echo template::select('themeFooterFont', $module::$fonts, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'footer', 'font'])
'selected' => $this->getData(['theme', 'footer', 'font']),
'fonts' => true
]); ?>
</div>
<div class="col3">

View File

@ -143,7 +143,8 @@
<div class="col3">
<?php echo template::select('themeHeaderFont', $module::$fonts, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'header', 'font'])
'selected' => $this->getData(['theme', 'header', 'font']),
'fonts' => true
]); ?>
</div>
<div class="col3">

View File

@ -82,7 +82,8 @@
<div class="col6">
<?php echo template::select('themeMenuFont', $module::$fonts, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'menu', 'font'])
'selected' => $this->getData(['theme', 'menu', 'font']),
'fonts' => true
]); ?>
</div>
<div class="col6">

View File

@ -71,7 +71,8 @@
<div class="col6">
<?php echo template::select('themeTextFont', $module::$fonts, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'text', 'font'])
'selected' => $this->getData(['theme', 'text', 'font']),
'fonts' => true
]); ?>
</div>
<div class="col6">
@ -91,7 +92,8 @@
<div class="col4">
<?php echo template::select('themeTitleFont', $module::$fonts, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'title', 'font'])
'selected' => $this->getData(['theme', 'title', 'font']),
'fonts' => true
]); ?>
</div>
<div class="col4">