Subversion Repositories Applications.dictionnaire

Rev

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

Rev 2 Rev 6
Line 1... Line 1...
1
<?php
1
<?php
2
class Dictionnaire extends RestService {
2
class Dictionnaire extends RestService {
Line -... Line 3...
-
 
3
 
-
 
4
	// SELECT a.id, a.cle, b.id, b.cle FROM definitions a, definitions b WHERE a.id != b.id AND INSTR(b.cle, a.cle) != 0 order by a.cle;
-
 
5
	// SELECT group_concat( distinct a.id) FROM definitions a, definitions b WHERE a.id != b.id AND INSTR(b.cle, a.cle) != 0
-
 
6
	static $sous_mots = array(20,22,33,37,65,103,106,151,160,164,177,202,220,222,230,249,250,257,262,276,284,307,334,352,359,394,397,401,422,437,438,449,452,453,463,469,475,498,517,527,547,549,550,585,603,604,606,607,638,641,660);
3
 
7
 
4
//+----------------------------------------------------------------------------------------------------------------+	
8
//+----------------------------------------------------------------------------------------------------------------+	
5
// Consulter
9
// Consulter
6
	public function consulter($ressources, $parametres) {
10
	public function consulter($ressources, $parametres) {
7
    	$entete_http = RestServeur::HTTP_CODE_CONTENU_REQUIS;
11
    	$entete_http = RestServeur::HTTP_CODE_CONTENU_REQUIS;
Line 45... Line 49...
45
    	echo $corps_http; 
49
    	echo $corps_http; 
46
    	exit;
50
    	exit;
47
    }
51
    }
Line 48... Line 52...
48
    
52
    
49
    private function getDefinition($mot) {
-
 
50
    	
53
    private function getDefinition($mot) {
51
    	$requete_selection_definition = 'SELECT valeur FROM definitions WHERE cle = "'.$this->simplifier($mot).'"';   
54
    	$requete_selection_definition = 'SELECT valeur FROM definitions WHERE cle = "'. self::simplifier($mot).'"';   
Line 52... Line 55...
52
    	$definition = $this->bdd->recuperer($requete_selection_definition);
55
    	$definition = $this->bdd->recuperer($requete_selection_definition);
53
    	
56
    	
Line 54... Line 57...
54
		return $definition; 
57
		return $definition; 
55
    }
-
 
56
    
58
    }
57
    private function getToutesDefinitions() {
-
 
58
    	
-
 
59
    	$requete_selection_toutes_definitions = 'SELECT valeur FROM definitions';
-
 
60
    	$definitions = $this->bdd->recupererTous($requete_selection_toutes_definitions);
59
    
Line -... Line 60...
-
 
60
    private function getToutesDefinitions() {
61
    	
61
		return $this->bdd->recupererTous('SELECT valeur FROM definitions');
62
		return $definitions; 
62
    }
-
 
63
    
-
 
64
 
63
    }
65
    private function getMots() {
64
    
66
		/*
-
 
67
		$requete = sprintf('SELECT cle FROM definitions WHERE id NOT IN (%s) ORDER BY LENGTH(cle) DESC',
-
 
68
						   implode(",", self::$sous_mots));
65
    private function getMots() {	
69
		$requete = sprintf('SELECT cle FROM definitions WHERE id NOT IN (%s)',
66
    	
70
						   implode(",", self::$sous_mots));
67
    	$requete_selection_mots = 'SELECT cle FROM definitions';
71
		*/
68
    	$mots = $this->bdd->recupererTous($requete_selection_mots);
-
 
69
    		    	
72
		$requete = 'SELECT cle FROM definitions';
70
    	foreach($mots as &$mot) {
73
 
Line 71... Line 74...
71
    		$mot['cle'] = $mot['cle'];
74
    	$assoc = $this->bdd->recupererTous($requete);
72
    	} 
-
 
73
		return $mots; 	
-
 
74
    }
75
		array_walk($assoc, function(&$item) { $item = $item['cle']; });
75
    
-
 
76
    function simplifier($chaine){
-
 
77
    	
-
 
78
		$sans_accent = strtr($chaine,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ',
-
 
79
		'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
76
		return $assoc;
80
		
77
    }
81
		$en_minuscule = strtolower($sans_accent);
78
    
82
		
79
    static function simplifier($chaine){