| Line 33... |
Line 33... |
| 33 |
// SELECT MAX(num_taxonomique) FROM coste_v2_00;
|
33 |
// SELECT MAX(num_taxonomique) FROM coste_v2_00;
|
| 34 |
define('_COSTE_TEXTE_MAX_BDTFX_NT', 37809);
|
34 |
define('_COSTE_TEXTE_MAX_BDTFX_NT', 37809);
|
| 35 |
// SELECT MAX(num_nom) FROM bdtfx_v1_02;
|
35 |
// SELECT MAX(num_nom) FROM bdtfx_v1_02;
|
| 36 |
define('_COSTE_TEXTE_MAX_BDTFX_NN', 103386 + 10000);
|
36 |
define('_COSTE_TEXTE_MAX_BDTFX_NN', 103386 + 10000);
|
| Line 37... |
Line 37... |
| 37 |
|
37 |
|
| 38 |
/*restore_error_handler();
|
38 |
/* restore_error_handler();
|
| 39 |
error_reporting(E_ALL);*/
|
39 |
error_reporting(E_ALL); */
|
| 40 |
class Textes {
|
40 |
class Textes {
|
| 41 |
// paramètres autorisés
|
41 |
// paramètres autorisés
|
| 42 |
static $allow_params = array(
|
42 |
static $allow_params = array(
|
| 43 |
'txt.format', 'retour.format', 'retour.champs',
|
43 |
'txt.format', 'retour.format', 'retour.champs', 'retour.indexBy',
|
| 44 |
'recherche',
|
44 |
'recherche',
|
| 45 |
'masque.ns', 'masque.txt', 'masque.page', 'masque.tome', 'masque.famille', 'masque.nt',
|
45 |
'masque.ns', 'masque.txt', 'masque.page', 'masque.tome', 'masque.famille', 'masque.nt',
|
| 46 |
'masque.titre', // masque sur titre de la page wiki correspondante (page "clef" OR page "description")
|
46 |
'masque.titre', // masque sur titre de la page wiki correspondante (page "clef" OR page "description")
|
| 47 |
'navigation.depart', 'navigation.limite');
|
47 |
'navigation.depart', 'navigation.limite');
|
| 48 |
// et valeurs par défaut
|
48 |
// et valeurs par défaut
|
| - |
|
49 |
static $default_params = array('txt.format' => 'txt', 'retour.format' => 'max', 'retour.indexBy' => 'coste',
|
| 49 |
static $default_params = array('txt.format' => 'txt', 'retour.format' => 'max', 'recherche' => 'stricte',
|
50 |
'recherche' => 'stricte',
|
| 50 |
'retour.champs' => 'titre,texte,determination,tag',
|
51 |
'retour.champs' => 'titre,texte,determination,tag',
|
| Line 51... |
Line 52... |
| 51 |
'navigation.depart' => 0, 'navigation.limite' => 50);
|
52 |
'navigation.depart' => 0, 'navigation.limite' => 50);
|
| 52 |
|
53 |
|
| Line 160... |
Line 161... |
| 160 |
// nombre de matches (sans LIMIT) utilisé pour l'en-tête
|
161 |
// nombre de matches (sans LIMIT) utilisé pour l'en-tête
|
| 161 |
$matches = $db->recuperer('SELECT FOUND_ROWS() AS total');
|
162 |
$matches = $db->recuperer('SELECT FOUND_ROWS() AS total');
|
| 162 |
$matches = intval($matches['total']);
|
163 |
$matches = intval($matches['total']);
|
| 163 |
}
|
164 |
}
|
| Line 164... |
Line 165... |
| 164 |
|
165 |
|
| - |
|
166 |
// reformate les résultats pour les indexer par coste:nn par défaut
|
| - |
|
167 |
// cependant le paramètre retour.indexBy permet de choisir une indexation par num_nom de bdtfx
|
| 165 |
// reformate les résultats pour les indexer par coste:nn
|
168 |
$clef_index = $params['retour.indexBy'] == 'coste' ? 'coste:nn' : 'bdtfx:nn';
|
| 166 |
$res2 = array();
|
169 |
$res2 = array();
|
| - |
|
170 |
foreach($res as $v) {
|
| 167 |
foreach($res as $v) {
|
171 |
if(!$v[$clef_index]) throw new Exception('format error: index NULL, use retour.indexBy=coste', 400);
|
| 168 |
$res2[$v['coste:nn']] = $v;
|
172 |
$res2[$v[$clef_index]] = $v;
|
| Line 169... |
Line 173... |
| 169 |
}
|
173 |
}
|
| 170 |
|
174 |
|
| 171 |
// l'appelant s'occupera du json_encode()
|
175 |
// l'appelant s'occupera du json_encode()
|
| Line 371... |
Line 375... |
| 371 |
|
375 |
|
| 372 |
static function requestFilterParams(Array $params) {
|
376 |
static function requestFilterParams(Array $params) {
|
| 373 |
$p = array_intersect_key($params, array_flip(self::$allow_params));
|
377 |
$p = array_intersect_key($params, array_flip(self::$allow_params));
|
| 374 |
self::unsetIfInvalid($p, 'txt.format', array('txt', 'htm'));
|
378 |
self::unsetIfInvalid($p, 'txt.format', array('txt', 'htm'));
|
| - |
|
379 |
self::unsetIfInvalid($p, 'retour.format', array('min','max'));
|
| 375 |
self::unsetIfInvalid($p, 'retour.format', array('min','max'));
|
380 |
self::unsetIfInvalid($p, 'retour.indexBy', array('coste', 'bdtfx'));
|
| Line 376... |
Line 381... |
| 376 |
self::unsetIfInvalid($p, 'recherche', array('stricte','etendue','floue'));
|
381 |
self::unsetIfInvalid($p, 'recherche', array('stricte','etendue','floue'));
|
| 377 |
|
382 |
|