Subversion Repositories Applications.dictionnaire

Compare Revisions

Ignore whitespace Rev HEAD → Rev 1

/services/modules/0.1/Dictionnaire.php
1,4 → 1,5
<?php
 
class Dictionnaire extends RestService {
 
//+----------------------------------------------------------------------------------------------------------------+
16,14 → 17,6
case 'mots':
$retour = $this->getMots();
break;
 
case 'zglossary':
$retour = $this->getMotsZglossary();
break;
 
case 'autoabbr':
$retour = $this->getMotsAutoAbbr();
break;
case 'def':
if(isset($ressources[1])) {
48,14 → 41,15
$entete_http = RestServeur::HTTP_CODE_CONTENU_REQUIS;
}
RestServeur::envoyerEnteteStatutHttp($entete_http);
header('Content-type: application/json; charset=UTF-8');
//RestServeur::envoyerEnteteStatutHttp($entete_http);
header('Content-type : application/json; charset=UTF-8');
echo $corps_http;
exit;
}
private function getDefinition($mot) {
$requete_selection_definition = 'SELECT valeur FROM definitions WHERE cle = "'. self::simplifier($mot).'"';
$requete_selection_definition = 'SELECT valeur FROM onto_triples WHERE cle = "'.$this->simplifier($mot).'"';
$definition = $this->bdd->recuperer($requete_selection_definition);
return $definition;
62,38 → 56,36
}
private function getToutesDefinitions() {
return $this->bdd->recupererTous('SELECT valeur FROM definitions');
$requete_selection_toutes_definitions = 'SELECT valeur FROM onto_triples';
$definitions = $this->bdd->recupererTous($requete_selection_toutes_definitions);
return $definitions;
}
private function getMots() {
$requete = 'SELECT TRIM(cle) as cle FROM definitions'; // certaines cles ont des espaces
$assoc = $this->bdd->recupererTous($requete);
array_walk($assoc, array($this,"formaterTableauDefinitions"));
return $assoc;
$requete_selection_mots = 'SELECT cle FROM onto_triples';
$mots = $this->bdd->recupererTous($requete_selection_mots);
foreach($mots as &$mot) {
$mot['cle'] = $mot['cle'];
}
return $mots;
}
private function formaterTableauDefinitions(&$item) {
$item = $item['cle'];
}
 
private function getMotsZglossary() {
$assoc = $this->bdd->recupererTous('SELECT cle as term, 0 as type, valeur as definition FROM definitions' .
' WHERE valeur != ""');
return $assoc;
}
 
private function getMotsAutoAbbr() {
$assoc = $this->bdd->recupererTous("SELECT CONCAT(cle, '*') as cle FROM definitions WHERE valeur != ''");
$assoc2 = Array();
foreach($assoc as $v) {
$assoc2[$v['cle']] = true;
}
return $assoc2;
}
static function simplifier($chaine){
return trim(strtolower(iconv('UTF-8', 'ASCII//TRANSLIT', $chaine)), " \t\n\r\0\x0b*");
function simplifier($chaine){
$sans_accent = strtr($chaine,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ',
'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
$en_minuscule = strtolower($sans_accent);
return $en_minuscule;
}
}
?>
?>
/services/configurations/config.defaut.ini
33,6 → 33,6
; Mot de passe de l'utilisateur de la base de données.
bdd_mot_de_passe = ""
; Nom de la base de données principale.
bdd_nom = "dictionnaire"
bdd_nom = "commentaires"
; Encodage de la base de données principale. (Pour l'utf-8 ne pas mettre le tiret!)
bdd_encodage = "UTF8"