[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / verifier / inc / normaliser.php
1 <?php
2
3 // Sécurité
4 if (!defined("_ECRIRE_INC_VERSION")) return;
5
6 /**
7 * Fonction de base de l'API de normalisation.
8 * (En cours de dev... sera peut etre a revoir)
9 *
10 */
11 function inc_normaliser_dist($valeur, $type, $options=null){
12
13 // On vérifie que les options sont bien un tableau
14 if (!is_array($options))
15 $options = array();
16
17 $erreur = '';
18
19 // On cherche si une fonction correspond au type existant
20 if ($normaliser = charger_fonction($type, 'normaliser', true)) {
21 $valeur_normalisee = $normaliser($valeur, $options, $erreur);
22 }
23
24 return array(
25 'erreur' => $erreur,
26 'valeur' => $valeur_normalisee,
27 'changement' => !$erreur and ($valeur_normalisee != $valeur)
28 );
29 }
30
31
32 ?>