Subversion Repositories Applications.dictionnaire

Rev

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

Rev 10 Rev 14
Line 1... Line 1...
1
<?php
1
<?php
2
class Dictionnaire extends RestService {
2
class Dictionnaire extends RestService {
Line 3... Line -...
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);
-
 
7
 
3
 
8
//+----------------------------------------------------------------------------------------------------------------+	
4
//+----------------------------------------------------------------------------------------------------------------+	
9
// Consulter
5
// Consulter
10
	public function consulter($ressources, $parametres) {
6
	public function consulter($ressources, $parametres) {
11
    	$entete_http = RestServeur::HTTP_CODE_CONTENU_REQUIS;
7
    	$entete_http = RestServeur::HTTP_CODE_CONTENU_REQUIS;
Line 20... Line 16...
20
    			case 'mots':
16
    			case 'mots':
21
    				$retour = $this->getMots();
17
    				$retour = $this->getMots();
22
    			break;
18
    			break;
Line 23... Line 19...
23
 
19
 
24
    			case 'zglossary':
20
    			case 'zglossary':
25
    				$retour = $this->getMots_zglossary();
21
    				$retour = $this->getMotsZglossary();
Line 26... Line 22...
26
    			break;
22
    			break;
27
 
23
 
28
    			case 'autoabbr':
24
    			case 'autoabbr':
Line 29... Line 25...
29
    				$retour = $this->getMots_autoabbr();
25
    				$retour = $this->getMotsAutoAbbr();
30
    			break;
26
    			break;
31
    			
27
    			
Line 69... Line 65...
69
		return $this->bdd->recupererTous('SELECT valeur FROM definitions');
65
		return $this->bdd->recupererTous('SELECT valeur FROM definitions');
70
    }
66
    }
Line 71... Line 67...
71
    
67
    
72
 
-
 
73
    private function getMots() {
-
 
74
		/*
-
 
75
		$requete = sprintf('SELECT cle FROM definitions WHERE id NOT IN (%s) ORDER BY LENGTH(cle) DESC',
-
 
76
						   implode(",", self::$sous_mots));
-
 
77
		$requete = sprintf('SELECT cle FROM definitions WHERE id NOT IN (%s)',
-
 
78
						   implode(",", self::$sous_mots));
68
 
79
		*/
69
    private function getMots() {
Line 80... Line 70...
80
		$requete = 'SELECT TRIM(cle) as cle FROM definitions';  // certaines cles ont des espaces
70
		$requete = 'SELECT TRIM(cle) as cle FROM definitions';  // certaines cles ont des espaces
81
		$assoc = $this->bdd->recupererTous($requete);
71
		$assoc = $this->bdd->recupererTous($requete);
82
 
72
 
Line 83... Line 73...
83
		array_walk($assoc, function(&$item) { $item = $item['cle']; });
73
		array_walk($assoc, function(&$item) { $item = $item['cle']; });
84
		return $assoc;
74
		return $assoc;
85
    }
75
    }
86
 
76
 
87
    private function getMots_zglossary() {
77
    private function getMotsZglossary() {
Line 88... Line 78...
88
		$assoc = $this->bdd->recupererTous('SELECT cle as term, 0 as type, valeur as definition FROM definitions' .
78
		$assoc = $this->bdd->recupererTous('SELECT cle as term, 0 as type, valeur as definition FROM definitions' .
89
										   ' WHERE valeur != ""');
79
										   ' WHERE valeur != ""');
90
		return $assoc;
80
		return $assoc;
91
    }
81
    }
92
 
82
 
93
    private function getMots_autoabbr() {
83
    private function getMotsAutoAbbr() {