Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 862 → Rev 863

/trunk/services/modules/0.1/coste/Textes.php
35,18 → 35,19
// SELECT MAX(num_nom) FROM bdtfx_v1_02;
define('_COSTE_TEXTE_MAX_BDTFX_NN', 103386 + 10000);
 
/*restore_error_handler();
error_reporting(E_ALL);*/
/* restore_error_handler();
error_reporting(E_ALL); */
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']);