font edit à terminer
This commit is contained in:
parent
c6e1ef2aeb
commit
dbf1f18e34
@ -185,16 +185,16 @@ class common {
|
||||
|
||||
public static $fontsWebSafe = [
|
||||
'arial' => 'Arial, Helvetica, sans-serif;',
|
||||
'arial-black' => 'Arial Black, Gadget, sans-serif;',
|
||||
'courrier' => 'Courier, Liberation Mono, monospace;',
|
||||
'courrier-new' => 'Courier New, Courier, monospace',
|
||||
'arial-black' => '"Arial Black", Gadget, sans-serif;',
|
||||
'courrier' => 'Courier, "Liberation Mono", monospace;',
|
||||
'courrier-new' => '"Courier New", Courier, monospace',
|
||||
'garamond' => 'Garamond, serif',
|
||||
'georgia' => 'Georgia, serif;',
|
||||
'impact' => 'Impact, Charcoal, sans-serif;',
|
||||
'lucida' => 'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
||||
'lucida' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif',
|
||||
'tahoma' => 'Tahoma, Geneva, sans-serif;',
|
||||
'times-new-roman' => 'Times New Roman, Liberation Serif, serif;',
|
||||
'trebuchet' => 'Trebuchet MS, Arial, Helvetica, sans-serif;',
|
||||
'times-new-roman' => '"Times New Roman", "Liberation Serif", serif;',
|
||||
'trebuchet' => '"Trebuchet MS", Arial, Helvetica, sans-serif;',
|
||||
'tahoma' => 'Tahoma, Geneva, sans-serif;',
|
||||
'verdana' => 'Verdana, Geneva, sans-serif;',
|
||||
];
|
||||
|
@ -32,6 +32,7 @@ class theme extends common {
|
||||
'save' => self::GROUP_ADMIN,
|
||||
'fonts' => self::GROUP_ADMIN,
|
||||
'fontAdd' => self::GROUP_ADMIN,
|
||||
'fontEdit' => self::GROUP_ADMIN,
|
||||
'fontDelete' => self::GROUP_ADMIN
|
||||
];
|
||||
public static $aligns = [
|
||||
@ -586,12 +587,14 @@ class theme extends common {
|
||||
'<span style="font-family:' . $f[$type][$fontId]['font-family'] . '">' . $f[$type][$fontId]['name'] . '</span>' ,
|
||||
$f[$type][$fontId]['font-family'],
|
||||
$fontUsed[$fontId],
|
||||
//array_key_exists($fontId, $fonts['imported']) ? 'Importée' : '',
|
||||
/*array_key_exists($fontId, $fonts['files']) ?
|
||||
$fonts['files'][$fontId] :
|
||||
(array_key_exists($fontId, self::$fontsWebSafe) ? 'WebSafe' : 'CDN Fonts'),
|
||||
*/
|
||||
$type,
|
||||
$type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [
|
||||
'class' => 'themeFontEdit',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $fontId . '/' . $_SESSION['csrf'],
|
||||
'value' => template::ico('pencil'),
|
||||
'disabled' => !empty($fontUsed[$fontId])
|
||||
])
|
||||
: '',
|
||||
$type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [
|
||||
'class' => 'themeFontDelete buttonRed',
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontDelete/' . $fontId . '/' . $_SESSION['csrf'],
|
||||
@ -665,6 +668,62 @@ class theme extends common {
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajouter une fonte
|
||||
*/
|
||||
public function fontEdit() {
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
// Type d'import en ligne ou local
|
||||
$type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
|
||||
$ressource = $type === 'imported' ? $this->getInput('fontAddUrl', helper::FILTER_STRING_SHORT) : $this->getInput('fontAddFile', helper::FILTER__SHORT_STRING);
|
||||
$fontId = $this->getInput('fontAddFontId', helper::FILTER_STRING_SHORT, true);
|
||||
$fontName = $this->getInput('fontAddFontName', helper::FILTER_STRING_SHORT, true);
|
||||
$fontFamilyName = $this->getInput('fontAddFontFamilyName', helper::FILTER_STRING_SHORT, true);
|
||||
|
||||
// Vérifier l'existence de fontId et validité de family name si usage en ligne de cdnFonts
|
||||
|
||||
// Charger les données des fontes
|
||||
$fonts = $this->getData(['fonts']);
|
||||
|
||||
// Concaténation dans les tableaux existants
|
||||
$t = [ $fontId => [
|
||||
'name' => $fontName,
|
||||
'font-family' => $fontFamilyName,
|
||||
'ressource' => $ressource
|
||||
]];
|
||||
|
||||
// Stocker les fontes
|
||||
$this->setData(['fonts', $type, [ $fontId =>
|
||||
[
|
||||
'name' => $fontName,
|
||||
'font-family' => $fontFamilyName,
|
||||
'ressource' => $ressource
|
||||
]]
|
||||
]);
|
||||
|
||||
// Copier la fonte si le nom du fichier est fourni
|
||||
if ( $type === 'files' &&
|
||||
is_file(self::FILE_DIR . 'source/' . $ressource)
|
||||
) {
|
||||
copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource );
|
||||
}
|
||||
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'notification' => 'La fonte a été importée',
|
||||
'redirect' => helper::baseUrl() . 'theme/fonts',
|
||||
'state' => true
|
||||
]);
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => 'Ajouter une fonte',
|
||||
'view' => 'fontAdd'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Effacer une fonte
|
||||
*/
|
||||
|
18
core/module/theme/view/fontEdit/fontEdit.css
Normal file
18
core/module/theme/view/fontEdit/fontEdit.css
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* This file is part of Zwii.
|
||||
*
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @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-2022, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
|
||||
/** NE PAS EFFACER
|
||||
* admin.css
|
||||
*/
|
44
core/module/theme/view/fontEdit/fontEdit.js.php
Normal file
44
core/module/theme/view/fontEdit/fontEdit.js.php
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* This file is part of Zwii.
|
||||
* For full copyright and license information, please see the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
||||
* @copyright Copyright (C) 2018-2022, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Option par défaut du sélecteur de mode
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
$('input[name=fontAddFontImported]').prop('checked', true);
|
||||
$('input[name=fontAddFontUrl]').prop('checked', false);
|
||||
$('#containerFontAddFile').hide();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Mode téléchargement en ligne de la fonte ou installation locale
|
||||
*/
|
||||
$("input[name=fontAddFontImported]").on("click", function() {
|
||||
if( $('input[name=fontAddFontImported]').is(':checked') ){
|
||||
$('input[name=fontAddFontFile]').prop('checked', false);
|
||||
} else {
|
||||
$('input[name=fontAddFontFile]').prop('checked', true);
|
||||
}
|
||||
$('#containerFontAddFile').hide();
|
||||
$('#containerFontAddUrl').show();
|
||||
});
|
||||
|
||||
$("input[name=fontAddFontFile]").on("click", function() {
|
||||
if( $('input[name=fontAddFontFile]').is(':checked') ){
|
||||
$('input[name=fontAddFontImported]').prop('checked', false);
|
||||
} else {
|
||||
$('input[name=fontAddFontImported]').prop('checked', true);
|
||||
}
|
||||
$('#containerFontAddFile').show();
|
||||
$('#containerFontAddUrl').hide();
|
||||
});
|
83
core/module/theme/view/fontEdit/fontEdit.php
Normal file
83
core/module/theme/view/fontEdit/fontEdit.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php echo template::formOpen('fontAddForm'); ?>
|
||||
<div class="row">
|
||||
<div class="col2">
|
||||
<?php echo template::button('fontAddBack', [
|
||||
'class' => 'buttonGrey',
|
||||
'href' => helper::baseUrl() . 'theme/fonts',
|
||||
'ico' => 'left',
|
||||
'value' => 'Retour'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2">
|
||||
<?php echo template::button('pageEditHelp', [
|
||||
'href' => 'https://doc.zwiicms.fr/fontes#add',
|
||||
'target' => '_blank',
|
||||
'ico' => 'help',
|
||||
'value' => 'Aide',
|
||||
'class' => 'buttonHelp'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2 offset6">
|
||||
<?php echo template::submit('fontAddPublish', [
|
||||
'value' => 'Valider',
|
||||
'uniqueSubmission' => true
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Identité de la fonte</h4>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::checkbox('fontAddFontImported', true, 'Fonte en ligne', []); ?>
|
||||
</div>
|
||||
<div class="col6">
|
||||
<?php echo template::checkbox('fontAddFontFile', true,'Fonte installée', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::text('fontAddFontId', [
|
||||
'autocomplete' => 'off',
|
||||
'label' => 'Identifiant (sans espace ni majuscule)',
|
||||
'placeholder' => 'big-marker-extrude'
|
||||
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col6">
|
||||
<?php echo template::text('fontAddFontName', [
|
||||
'autocomplete' => 'off',
|
||||
'label' => 'Nom',
|
||||
'placeholder' => 'Big Marker Extrude'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::text('fontAddFontFamilyName', [
|
||||
'autocomplete' => 'off',
|
||||
'label' => 'Famille',
|
||||
'placeholder' => "'Big Marker Extrude', sans-serif"
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="containerFontAddFile">
|
||||
<div class="col12">
|
||||
<?php echo template::file('fontAddFile', [
|
||||
'label' => 'Fichier de fonte (Format WOFF)'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="containerFontAddUrl">
|
||||
<div class="col12">
|
||||
<?php echo template::text('fontAddUrl', [
|
||||
'label' => 'Url du fichier de fonte',
|
||||
'placeholder' => 'https://fonts.cdnfonts.com/css/big-marker-extrude'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php if($module::$fontsDetail): ?>
|
||||
<?php echo template::table([2, 2, 3, 3, 1, 1], $module::$fontsDetail, ['FontId', 'Nom', 'Famille', 'Affectation', 'Origine', '']); ?>
|
||||
<?php echo template::table([2, 2, 3, 2, 1, 1, 1], $module::$fontsDetail, ['FontId', 'Nom', 'Famille', 'Affectation', 'Origine', '', '']); ?>
|
||||
<?php else: ?>
|
||||
<?php echo template::speech('Aucune fonte !'); ?>
|
||||
<?php endif; ?>
|
Loading…
Reference in New Issue
Block a user