Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1288 → Rev 1289

/trunk/client/bottin/bibliotheque/inscription.fonct.php
19,8 → 19,8
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: inscription.fonct.php,v 1.24 2007-01-04 16:37:27 alexandre_tb Exp $
// CVS : $Id: inscription.fonct.php,v 1.24 2007-01-04 16:37:27 alexandre_tb Exp $
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
/**
* Fonctions du module inscription
*
32,8 → 32,8
//Autres auteurs :
*@author Florian Schmitt <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.24 $ $Date: 2007-01-04 16:37:27 $
*@version $Revision: 1.24 $ $Date: 2007-01-04 16:37:27 $
*@version $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
*@version $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
// +------------------------------------------------------------------------------------------------------+
*/
 
604,26 → 604,44
* Génère un nom wiki valide à partir des données saisies par l'utilisateur
* fait une requete dans la base
*
* UPDATE: modification de la fonction pour propretée du titre / nom --julien
* @return string un nom wiki valide
*/
 
function genere_nom_wiki($prenom, $nom) {
// 1. suppression des espaces
$nom = trim ($nom) ;
$prenom = trim ($prenom) ;
function genere_nom_wiki($nom, $spaces = TRUE)
{
// traitement des accents
$nom = str_replace(array('é','è','ë','ê','É','È','Ë','Ê','&','£'), 'e', $nom);
$nom = str_replace(array('à','ä','â','Â','Ä','À','@'), 'a', $nom);
$nom = str_replace(array('ç','Ç'), 'c', $nom);
$nom = str_replace(array('ÿ','¾'), 'y', $nom);
$nom = str_replace(array('ô','ö','ò','Ô','Ò','Ö'), 'o', $nom);
$nom = str_replace(array('ï','î','ì','Î','Ï','Ì'), 'i', $nom);
$nom = str_replace('$', 's', $nom);
// 2. suppression des caractères non ascii et ajout de la première lettre en majuscule
$nom = trim_non_ascii ($nom) ;
$prenom = trim_non_ascii ($prenom) ;
// Vérification
$nom_wiki = $prenom.$nom ;
if (!preg_match('/^[A-Z][a-z]+[A-Z,0-9][A-Z,a-z,0-9]*$/', $nom_wiki)) {
$nom_wiki = chr(rand(65, 90)).$nom_wiki.chr(rand(65, 90)) ;
}
return $nom_wiki ;
$temp = str_split($nom);
$count = 0;
$final = NULL;
foreach($temp as $letter)
{
if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
{
$final .= ($spaces ? '_' : '');
} elseif(preg_match ('/[a-zA-Z0-9]/', $letter)) {
$final .= (($count == 0 || $count == (strlen($nom) - 1)) ? strtoupper($letter) : strtolower($letter));
}
$count++;
}
// vérifions que le retour n'est pas uniquement un underscore
if(preg_match('/^[[:punct:]]+$/', $final)) return FALSE;
 
// sinon retour du nom formaté
return($final);
}
 
 
/**
* Cette fonction supprime les caractères autres que asccii et les chiffres
*
659,7 → 677,7
}
 
//==============================================================================
/** function create_new_random($n,$type) permet de générer un nombre de caractères aléatoires.
/** function create_new_random($n,$type) permet de générer un nombre de caractères alçatoires.
*
*
*
718,6 → 736,9
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.24 2007/01/04 16:37:27 alexandre_tb
* ajout d'un test pour savoir si la fonction inscription_validee existe déjà (peut être inutile à vérifier)
*
* Revision 1.23 2006/12/01 13:23:15 florian
* integration annuaire backoffice
*