40,13 → 40,14 |
class Textes { |
// paramètres autorisés |
static $allow_params = array( |
'txt.format', 'retour.format', 'retour.champs', |
'txt.format', 'retour.format', 'retour.champs', 'retour.indexBy', |
'recherche', |
'masque.ns', 'masque.txt', 'masque.page', 'masque.tome', 'masque.famille', 'masque.nt', |
'masque.titre', // masque sur titre de la page wiki correspondante (page "clef" OR page "description") |
'navigation.depart', 'navigation.limite'); |
// et valeurs par défaut |
static $default_params = array('txt.format' => 'txt', 'retour.format' => 'max', 'recherche' => 'stricte', |
static $default_params = array('txt.format' => 'txt', 'retour.format' => 'max', 'retour.indexBy' => 'coste', |
'recherche' => 'stricte', |
'retour.champs' => 'titre,texte,determination,tag', |
'navigation.depart' => 0, 'navigation.limite' => 50); |
|
162,10 → 163,13 |
$matches = intval($matches['total']); |
} |
|
// reformate les résultats pour les indexer par coste:nn |
// reformate les résultats pour les indexer par coste:nn par défaut |
// cependant le paramètre retour.indexBy permet de choisir une indexation par num_nom de bdtfx |
$clef_index = $params['retour.indexBy'] == 'coste' ? 'coste:nn' : 'bdtfx:nn'; |
$res2 = array(); |
foreach($res as $v) { |
$res2[$v['coste:nn']] = $v; |
if(!$v[$clef_index]) throw new Exception('format error: index NULL, use retour.indexBy=coste', 400); |
$res2[$v[$clef_index]] = $v; |
} |
|
// l'appelant s'occupera du json_encode() |
373,6 → 377,7 |
$p = array_intersect_key($params, array_flip(self::$allow_params)); |
self::unsetIfInvalid($p, 'txt.format', array('txt', 'htm')); |
self::unsetIfInvalid($p, 'retour.format', array('min','max')); |
self::unsetIfInvalid($p, 'retour.indexBy', array('coste', 'bdtfx')); |
self::unsetIfInvalid($p, 'recherche', array('stricte','etendue','floue')); |
|
if(isset($params['masque.ns'])) $p['masque.ns'] = trim($params['masque.ns']); |