Import et suppression des fontes
This commit is contained in:
parent
05e0fad922
commit
5d3f06a527
|
@ -583,31 +583,47 @@ class theme extends common {
|
||||||
if ($this->isPost()) {
|
if ($this->isPost()) {
|
||||||
$fontId = $this->getInput('fontAddFontId', null, true);
|
$fontId = $this->getInput('fontAddFontId', null, true);
|
||||||
$fontName = $this->getInput('fontAddFontName', null, true);
|
$fontName = $this->getInput('fontAddFontName', null, true);
|
||||||
$filePath = $this->getInput('fontAddFile', null, true);
|
$filePath = $this->getInput('fontAddFile', null);
|
||||||
$e = explode ('/', $filePath);
|
$e = explode ('/', $filePath);
|
||||||
$file = $e[count($e) - 1 ];
|
$file = $e[count($e) - 1 ];
|
||||||
|
|
||||||
// Charger les données des fontes
|
// Vérifier la validité de fontId si téléchargée de cdnFonts
|
||||||
$files = $this->getData(['fonts', 'files']);
|
$data = helper::urlGetContents('https://www.cdnfonts.com/' . $fontId . '.font');
|
||||||
$imported = $this->getData(['fonts', 'imported']);
|
|
||||||
|
|
||||||
// Concaténation dans les tableaux existants
|
if ( strpos($data, $fontName) === false
|
||||||
$imported = array_merge([$fontId => $fontName], $imported);
|
&& empty($filePath)
|
||||||
$files = array_merge([$fontId => $file], $files);
|
) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => 'Cette fonte n\'existe pas sur le serveur https://cdnfonts.com<br>Il faut spécifier un fichier de fonte (format WOFFF) ',
|
||||||
|
'redirect' => helper::baseUrl() . 'theme/fontAdd',
|
||||||
|
'state' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Charger les données des fontes
|
||||||
|
$files = $this->getData(['fonts', 'files']);
|
||||||
|
$imported = $this->getData(['fonts', 'imported']);
|
||||||
|
|
||||||
// Copier la fonte
|
// Concaténation dans les tableaux existants
|
||||||
copy ( self::FILE_DIR . 'source/' . $filePath, self::DATA_DIR . 'fonts/' . $file );
|
$imported = array_merge([$fontId => $fontName], $imported);
|
||||||
|
$files = array_merge([$fontId => $file], $files);
|
||||||
|
|
||||||
// Mettre à jour le fichier des fontes
|
// Copier la fonte si le nom du fichier est fourni
|
||||||
$this->setData(['fonts', 'imported', $imported ]);
|
if (!empty($filePath)) {
|
||||||
$this->setData(['fonts', 'files', $files ]);
|
copy ( self::FILE_DIR . 'source/' . $filePath, self::DATA_DIR . 'fonts/' . $file );
|
||||||
// Valeurs en sortie
|
}
|
||||||
|
|
||||||
$this->addOutput([
|
// Mettre à jour le fichier des fontes
|
||||||
'notification' => 'La fonte a été importée',
|
$this->setData(['fonts', 'imported', $imported ]);
|
||||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
$this->setData(['fonts', 'files', $files ]);
|
||||||
'state' => true
|
|
||||||
]);
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => 'La fonte a été importée',
|
||||||
|
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
|
@ -641,7 +657,7 @@ class theme extends common {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supprimer les entrées
|
// Supprimer les entrées
|
||||||
unset($file[$this->getUrl(2)]);
|
unset($files[$this->getUrl(2)]);
|
||||||
unset($imported[$this->getUrl(2)]);
|
unset($imported[$this->getUrl(2)]);
|
||||||
|
|
||||||
// Mettre à jour le fichier des fontes
|
// Mettre à jour le fichier des fontes
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col12">
|
<div class="col12">
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h4>Identification</h4>
|
<h4>Identité de la fonte</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::text('fontAddFontId', [
|
<?php echo template::text('fontAddFontId', [
|
||||||
'autocomplete' => 'off',
|
'autocomplete' => 'off',
|
||||||
'label' => 'Identifiant',
|
'label' => 'Identifiant (sans espace ni majuscule)',
|
||||||
'placeholder' => 'perry-gothic'
|
'placeholder' => 'perry-gothic'
|
||||||
|
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
Loading…
Reference in New Issue