Subversion Repositories Applications.papyrus

Rev

Rev 1187 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1187 Rev 1289
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: inscription.fonct.php,v 1.24 2007-01-04 16:37:27 alexandre_tb Exp $
22
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
23
// CVS : $Id: inscription.fonct.php,v 1.24 2007-01-04 16:37:27 alexandre_tb Exp $
23
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
24
/**
24
/**
25
* Fonctions du module inscription
25
* Fonctions du module inscription
26
*
26
*
27
* Fonctions du module inscription
27
* Fonctions du module inscription
28
*
28
*
Line 30... Line 30...
30
//Auteur original :
30
//Auteur original :
31
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
*@author        Alexandre Granier <alexandre@tela-botanica.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@author        Florian Schmitt <florian@ecole-et-nature.org>
33
*@author        Florian Schmitt <florian@ecole-et-nature.org>
34
*@copyright     Tela-Botanica 2000-2004
34
*@copyright     Tela-Botanica 2000-2004
35
*@version       $Revision: 1.24 $ $Date: 2007-01-04 16:37:27 $
35
*@version       $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
36
*@version       $Revision: 1.24 $ $Date: 2007-01-04 16:37:27 $
36
*@version       $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
*/
38
*/
Line 39... Line 39...
39
 
39
 
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
Line 602... Line 602...
602
 
602
 
603
/**
603
/**
604
 *  Génère un nom wiki valide à partir des données saisies par l'utilisateur
604
 *  Génère un nom wiki valide à partir des données saisies par l'utilisateur
605
 *  fait une requete dans la base
605
 *  fait une requete dans la base
-
 
606
 *
606
 *
607
 * UPDATE: modification de la fonction pour propretée du titre / nom --julien
607
 * @return  string un nom wiki valide
608
 * @return  string un nom wiki valide
Line 608... Line 609...
608
 */
609
 */
-
 
610
 
609
 
611
function genere_nom_wiki($nom, $spaces = TRUE)
-
 
612
{
-
 
613
	// traitement des accents
610
function genere_nom_wiki($prenom, $nom) {
614
	$nom = str_replace(array('é','è','ë','ê','É','È','Ë','Ê','&','£'), 'e', $nom);
-
 
615
	$nom = str_replace(array('à','ä','â','Â','Ä','À','@'), 'a', $nom);
-
 
616
	$nom = str_replace(array('ç','Ç'), 'c', $nom);
-
 
617
	$nom = str_replace(array('ÿ','¾'), 'y', $nom);
611
    // 1. suppression des espaces
618
	$nom = str_replace(array('ô','ö','ò','Ô','Ò','Ö'), 'o', $nom);
612
    $nom = trim ($nom) ;
619
	$nom = str_replace(array('ï','î','ì','Î','Ï','Ì'), 'i', $nom);
613
    $prenom = trim ($prenom) ;
-
 
614
    
620
	$nom = str_replace('$', 's', $nom);
615
    // 2. suppression des caractères non ascii et ajout de la première lettre en majuscule
-
 
616
    $nom = trim_non_ascii ($nom) ;
621
    
-
 
622
	$temp = str_split($nom);
-
 
623
	
617
    $prenom = trim_non_ascii ($prenom) ;
624
	$count = 0;
-
 
625
	$final = NULL;
-
 
626
	foreach($temp as $letter)
-
 
627
	{
618
    
628
		if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
619
    // Vérification
629
		{
620
    $nom_wiki = $prenom.$nom ;
630
			$final .= ($spaces ? '_' : '');
621
    if (!preg_match('/^[A-Z][a-z]+[A-Z,0-9][A-Z,a-z,0-9]*$/', $nom_wiki)) {
631
		} elseif(preg_match ('/[a-zA-Z0-9]/', $letter)) {
622
        $nom_wiki = chr(rand(65, 90)).$nom_wiki.chr(rand(65, 90)) ;
632
            $final .= (($count == 0 || $count == (strlen($nom) - 1)) ? strtoupper($letter) : strtolower($letter));
-
 
633
        }
-
 
634
        $count++;
-
 
635
	}
-
 
636
	
-
 
637
	// vérifions que le retour n'est pas uniquement un underscore
-
 
638
	if(preg_match('/^[[:punct:]]+$/', $final)) return FALSE;
-
 
639
 
623
    }
640
 	// sinon retour du nom formaté
Line -... Line 641...
-
 
641
	return($final);
624
    return $nom_wiki ;
642
}
625
}
643
 
626
 
644
 
627
/**
645
/**
628
 *	Cette fonction supprime les caractères autres que asccii et les chiffres
646
 *	Cette fonction supprime les caractères autres que asccii et les chiffres
Line 657... Line 675...
657
    $trans_tbl = array_flip ($trans_tbl);
675
    $trans_tbl = array_flip ($trans_tbl);
658
    return strtr ($string, $trans_tbl);
676
    return strtr ($string, $trans_tbl);
659
}
677
}
Line 660... Line 678...
660
 
678
 
661
//==============================================================================
679
//==============================================================================
662
/** function create_new_random($n,$type) permet de générer un nombre de caractères aléatoires.
680
/** function create_new_random($n,$type) permet de générer un nombre de caractères alçatoires.
663
*
681
*
664
*  
682
*  
665
*
683
*
666
*  ENTREE :
684
*  ENTREE :
Line 716... Line 734...
716
}
734
}
Line 717... Line 735...
717
 
735
 
718
/* +--Fin du code ----------------------------------------------------------------------------------------+
736
/* +--Fin du code ----------------------------------------------------------------------------------------+
719
*
737
*
-
 
738
* $Log: not supported by cvs2svn $
-
 
739
* Revision 1.24  2007/01/04 16:37:27  alexandre_tb
-
 
740
* ajout d'un test pour savoir si la fonction inscription_validee existe déjà (peut être inutile à vérifier)
720
* $Log: not supported by cvs2svn $
741
*
721
* Revision 1.23  2006/12/01 13:23:15  florian
742
* Revision 1.23  2006/12/01 13:23:15  florian
722
* integration annuaire backoffice
743
* integration annuaire backoffice
723
*
744
*
724
* Revision 1.22  2006/10/05 13:53:53  florian
745
* Revision 1.22  2006/10/05 13:53:53  florian