Méthode number

This commit is contained in:
Fred Tempez 2025-01-21 19:45:31 +01:00
parent 0c975d8f42
commit 83943c6b52
7 changed files with 123 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# ZwiiCampus 1.18.00
# ZwiiCampus 1.19.00
ZwiiCampus (Learning Management System) est logiciel auteur destiné à mettre en ligne des tutoriels. Il dispose de plusieurs modalités d'ouverture et d'accès des contenus. Basé sur la version 13 du CMS Zwii, la structure logicielle est solide, le framework de Zwii est éprouvé.

View File

@ -140,7 +140,7 @@ class core extends common
$css .= 'span.mce-text{background-color: unset !important;}';
$css .= 'body,.row > div{font-size:' . $this->getData(['theme', 'text', 'fontSize']) . '}';
$css .= 'body{color:' . $this->getData(['theme', 'text', 'textColor']) . '}';
$css .= 'select,input[type=password],input[type=email],input[type=text],input[type=date],input[type=time],input[type=week],input[type=month],input[type=datetime-local],.inputFile,select,textarea{color:' . $this->getData(['theme', 'text', 'textColor']) . ';background-color:' . $this->getData(['theme', 'site', 'backgroundColor']) . ';}';
$css .= 'select,input[type=password],input[type=email],input[type=text],input[type=date],input[type=time],input[type=week],input[type=month],input[type=datetime-local],input[type=number],.inputFile,select,textarea{color:' . $this->getData(['theme', 'text', 'textColor']) . ';background-color:' . $this->getData(['theme', 'site', 'backgroundColor']) . ';}';
// spécifiques au module de blog
$css .= '.blogDate {color:' . $this->getData(['theme', 'text', 'textColor']) . ';}.blogPicture img{border:1px solid ' . $this->getData(['theme', 'text', 'textColor']) . '; box-shadow: 1px 1px 5px ' . $this->getData(['theme', 'text', 'textColor']) . ';}';
// Couleur fixée dans admin.css
@ -168,7 +168,7 @@ class core extends common
$colors = helper::colorVariants($this->getData(['theme', 'button', 'backgroundColor']));
$css .= '.speechBubble,.button,.button:hover,button[type=submit],.pagination a,.pagination a:hover,input[type=checkbox]:checked + label:before,input[type=radio]:checked + label:before,.helpContent{background-color:' . $colors['normal'] . ';color:' . $colors['text'] . '}';
$css .= '.helpButton span{color:' . $colors['normal'] . '}';
$css .= 'input[type=text]:hover,input[type=date]:hover,input[type=time]:hover,input[type=week]:hover,input[type=month]:hover,input[type=datetime-local]:hover,input[type=password]:hover,.inputFile:hover,select:hover,textarea:hover{border-color:' . $colors['normal'] . '}';
$css .= 'input[type=text]:hover,input[type=date]:hover,input[type=time]:hover,input[type=week]:hover,input[type=month]:hover,input[type=datetime-local]:hover,input[type=number]:hover,input[type=password]:hover,.inputFile:hover,select:hover,textarea:hover{border-color:' . $colors['normal'] . '}';
$css .= '.speechBubble:before{border-color:' . $colors['normal'] . ' transparent transparent transparent}';
$css .= '.button:hover,button[type=submit]:hover,.pagination a:hover,input[type=checkbox]:not(:active):checked:hover + label:before,input[type=checkbox]:active + label:before,input[type=radio]:checked:hover + label:before,input[type=radio]:not(:checked):active + label:before{background-color:' . $colors['darken'] . '}';
$css .= '.helpButton span:hover{color:' . $colors['darken'] . '}';
@ -381,7 +381,7 @@ class core extends common
$css .= '.button.buttonGreen, button[type=submit] {background-color: ' . $colors['normal'] . ';color: ' . $colors['text'] . ';}.button.buttonGreen:hover, button[type=submit]:hover {background-color: ' . $colors['darken'] . ';color: ' . $colors['text'] . ';}.button.buttonGreen:active, button[type=submit]:active {background-color: ' . $colors['darken'] . ';color: ' . $colors['text'] . ';}';
$colors = helper::colorVariants($this->getData(['admin', 'backgroundBlockColor']));
$css .= '.buttonTab, .block {border: 1px solid ' . $this->getData(['admin', 'borderBlockColor']) . ';}.buttonTab, .block h4 {background-color: ' . $colors['normal'] . ';color:' . $colors['text'] . ';}';
$css .= 'table tr,input[type=email],input[type=date],input[type=time],input[type=month],input[type=week],input[type=datetime-local],input[type=text],input[type=password],select:not(#barSelectCourse),select:not(#menuSelectCourse),select:not(#barSelectPage),textarea:not(.editorWysiwyg), textarea:not(.editorWysiwygComment),.inputFile{background-color: ' . $colors['normal'] . ';color:' . $colors['text'] . ';border: 1px solid ' . $this->getData(['admin', 'borderBlockColor']) . ';}';
$css .= 'table tr,input[type=email],input[type=date],input[type=time],input[type=month],input[type=week],input[type=datetime-local],input[type=text],input[type=number],input[type=password],select:not(#barSelectLanguage),select:not(#barSelectPage),textarea:not(.editorWysiwyg), textarea:not(.editorWysiwygComment),.inputFile{background-color: ' . $colors['normal'] . ';color:' . $colors['text'] . ';border: 1px solid ' . $this->getData(['admin', 'borderBlockColor']) . ';}';
// Bordure du contour TinyMCE
$css .= '.mce-tinymce{border: 1px solid ' . $this->getData(['admin', 'borderBlockColor']) . '!important;}';
// Enregistre la personnalisation

View File

@ -992,6 +992,117 @@ class template
return $html;
}
/**
* Génère un champ de saisie de type number (input[type="number"])
*
* Cette méthode crée un champ numérique HTML complet avec son wrapper,
* son label et ses messages d'aide/erreur. Elle gère automatiquement
* la conversion des valeurs en nombres et les contraintes de validation.
*
* @param string $nameId Identifiant unique du champ, utilisé pour name et id
* @param array $attributes Tableau des attributs du champ avec les clés suivantes :
* @type boolean $before Active la récupération des données précédentes en cas d'erreur (défaut: true)
* @type string $class Classes CSS additionnelles pour l'input (défaut: '')
* @type string $classWrapper Classes CSS additionnelles pour le wrapper (défaut: '')
* @type boolean $noDirty Désactive le marquage dirty du champ (défaut: false)
* @type boolean $disabled Désactive le champ (défaut: false)
* @type string $help Texte d'aide affiché sous le label (défaut: '')
* @type string $label Texte du label (défaut: '')
* @type string $placeholder Texte de placeholder (défaut: '')
* @type boolean $readonly Rend le champ en lecture seule (défaut: false)
* @type mixed $value Valeur initiale du champ (défaut: '')
* @type number $min Valeur minimum autorisée (défaut: null)
* @type number $max Valeur maximum autorisée (défaut: null)
* @type number $step Pas d'incrémentation (ex: 1 pour entiers, 0.01 pour prix) (défaut: null)
* @type string $pattern Expression régulière de validation (défaut: null)
*
* @return string Code HTML du champ number complet
*/
public static function number($nameId, array $attributes = [])
{
// Attributs par défaut spécifiques aux champs numériques
$attributes = array_merge([
'type' => 'number',
'before' => true,
'class' => '',
'classWrapper' => '',
'noDirty' => false,
'disabled' => false,
'help' => '',
'id' => $nameId,
'label' => '',
'name' => $nameId,
'placeholder' => '',
'readonly' => false,
'required' => false,
'value' => '',
'min' => null,
'max' => null,
'step' => null,
'pattern' => null
], $attributes);
// Conversion de la valeur en nombre si elle n'est pas vide
if ($attributes['value'] !== '') {
$attributes['value'] = floatval($attributes['value']);
}
// Nettoyage des attributs null pour ne pas les afficher dans le HTML
foreach (['min', 'max', 'step', 'pattern'] as $attr) {
if ($attributes[$attr] === null) {
unset($attributes[$attr]);
}
}
// Traduction de l'aide et de l'étiquette
$attributes['label'] = helper::translate($attributes['label']);
$attributes['help'] = helper::translate($attributes['help']);
// Sauvegarde des données en cas d'erreur
if ($attributes['before'] && array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']];
}
// Gestion du champ obligatoire
if (isset($attributes['required']) && $attributes['required']) {
// Affiche l'astérisque dans le label
$required = ' required-field';
// Ajoute l'attribut required au champ input
$attributes['required'] = 'required';
}
// Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label
if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'],
// Ajoute la classe required-field si le champ est obligatoire
'class' => isset($required) ? $required : ''
]);
}
// Notice
$notice = '';
if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice';
}
$html .= self::notice($attributes['id'], $notice);
// Input number
$html .= sprintf(
'<input type="number" %s>',
helper::sprintAttributes($attributes)
);
// Fin du wrapper
$html .= '</div>';
return $html;
}
/**
* Crée un champ texte long
* @param string $nameId Nom et id du champ

View File

@ -51,7 +51,7 @@ class common
const ACCESS_TIMER = 1800;
// Numéro de version
const ZWII_VERSION = '1.18.00';
const ZWII_VERSION = '1.19.00';
// URL autoupdate
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/';

View File

@ -1200,6 +1200,7 @@ input[type='datetime-local'],
input[type='time'],
input[type='month'],
input[type='week'],
input[type='number'],
.inputFile,
select,
textarea {
@ -1225,6 +1226,7 @@ input[type='datetime-local']:hover,
input[type='time']:hover,
input[type='month']:hover,
input[type='week']:hover,
input[type='number']:hover,
.inputFile:hover,
select:hover,
textarea:hover {
@ -1239,6 +1241,7 @@ input[type='datetime-local'].notice,
input[type='time'].notice,
input[type='month'].notice,
input[type='week'].notice,
input[type='number'].notice,
.inputFile.notice,
select.notice,
textarea.notice {
@ -1254,6 +1257,7 @@ input[type='datetime-local'].notice:hover,
input[type='time'].notice:hover,
input[type='month'].notice:hover,
input[type='week'].notice:hover,
input[type='number'].notice:hover,
.inputFile.notice:hover,
select.notice:hover,
textarea.notice:hover {

View File

@ -20,7 +20,7 @@
]); ?>
</div>
<div class="col2">
<?php echo template::text('configProxyPort', [
<?php echo template::number('configProxyPort', [
'label' => 'Port du proxy',
'placeholder' => '6060',
'value' => $this->getData(['config', 'proxyPort'])

View File

@ -893,11 +893,11 @@ class theme extends common
$redirect = '';
switch ($this->getUrl(2)) {
case 'admin':
$this->initData('admin', self::$i18nUI);
$this->initData('admin', self::$siteContent);
$redirect = helper::baseUrl() . 'theme/admin';
break;
case 'manage':
$this->initData('theme', self::$i18nUI);
$this->initData('theme', self::$siteContent);
$redirect = helper::baseUrl() . 'theme/manage';
break;
case 'custom':