Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 164 → Rev 165

/trunk/tests/metier/NomsVernaculairesTest.php
13,6 → 13,16
$this->assertEquals('3', $resultats['entete']['total']);
}
public function testRechercheEtendueDetermination() {
Registre::set('parametres.referentiel', 'nvjfl');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'config.ini');
$noms = new NomsVernaculaires();
$resultats = $noms->getRechercheEtendue('abricotier', 'determination');
$this->assertNotEmpty($resultats);
$this->assertEquals('3', $resultats['entete']['total']);
}
public function testRechercheFloue() {
Registre::set('parametres.referentiel', 'nvjfl');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
/trunk/tests/metier/NomsTest.php
11,8 → 11,46
$resultats = $noms->getRechercheEtendue('aceras');
$this->assertNotEmpty($resultats);
$this->assertEquals('15', $resultats['entete']['total']);
$this->assertNotEmpty($resultats['resultat']['243']);
$this->assertEquals('Aceras hircina', $resultats['resultat']['243']['nom_sci']);
$this->assertArrayNotHasKey('nom_retenu.id', $resultats['resultat']['243']);
$this->assertArrayNotHasKey('auteur', $resultats['resultat']['243']);
$this->assertArrayNotHasKey('annee', $resultats['resultat']['243']);
$this->assertArrayNotHasKey('biblio_origine', $resultats['resultat']['243']);
}
public function testRechercheEtendueDetermination() {
Registre::set('parametres.referentiel', 'bdtfx');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'config.ini');
$noms = new Noms();
$resultats = $noms->getRechercheEtendue('aceras', 'determination');
$this->assertNotEmpty($resultats);
$this->assertEquals('15', $resultats['entete']['total']);
$this->assertNotEmpty($resultats['resultat']['243']);
$this->assertEquals('Aceras hircina', $resultats['resultat']['243']['nom_sci']);
$this->assertEquals('32023', $resultats['resultat']['243']['nom_retenu.id']);
$this->assertArrayNotHasKey('auteur', $resultats['resultat']['243']);
$this->assertArrayNotHasKey('annee', $resultats['resultat']['243']);
$this->assertArrayNotHasKey('biblio_origine', $resultats['resultat']['243']);
}
public function testRechercheEtendueDecompo() {
Registre::set('parametres.referentiel', 'bdtfx');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'config.ini');
$noms = new Noms();
$resultats = $noms->getRechercheEtendue('aceras', 'decompo');
$this->assertNotEmpty($resultats);
$this->assertEquals('15', $resultats['entete']['total']);
$this->assertNotEmpty($resultats['resultat']['243']);
$this->assertEquals('Aceras hircina', $resultats['resultat']['243']['nom_sci']);
$this->assertArrayNotHasKey('nom_retenu.id', $resultats['resultat']['243']);
$this->assertArrayHasKey('auteur', $resultats['resultat']['243']);
$this->assertArrayHasKey('annee', $resultats['resultat']['243']);
$this->assertArrayHasKey('biblio_origine', $resultats['resultat']['243']);
}
public function testRechercheFloue() {
Registre::set('parametres.referentiel', 'bdtfx');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
/trunk/tests/modules/RechercheSimpleTest.php
3,34 → 3,6
 
class RechercheSimpleTest extends ConsultationEflorePhpUnit {
public function testMoteurRechercheSimple() {
$moteur = '<!-- DEBUT FORM_NOM -->
<script type="text/javascript">
<!--
var urlServiceAutocompletionNomsSci = "http://localhost/service:eflore:0.1/bdtfx/noms";
var urlServiceAutocompletionNomsVerna = "";
var urlBaseFicheTaxon = "http://localhost/opt/lampp/bin/phpunit?referentiel=bdtfx&module=fiche&action=fiche&nn={num_taxon}";
var valeurDefautNomSci = "Rechercher un nom scientifique";
var valeurDefautNomVerna = "Rechercher un nom commun";
// -->
</script>
<form id="ef-form-nomenclature" name="ef-form-nomenclature" action="http://localhost/opt/lampp/bin/phpunit?referentiel=bdtfx&amp;module=fiche&amp;action=fiche&amp;nn={num_taxon}" method="get" class="importance1">
<fieldset>
<h1>Rechercher une plante</h1>
<span class="zone-choix-type-nom">
<input id="type-nom-scientifique" name="type_nom" type="hidden" value="nom_scientifique" />
Nom scientifique </span>
<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" autocomplete="off" />
<span id="zone-liens-recherche">
<input id="referentiel" name="referentiel" type="hidden" value="bdtfx" />
<input id="module" name="module" type="hidden" value="recherche" />
<input id="action" name="action" type="hidden" value="rechercheSimple" />
<input id="eflore_nomenclature_submit" name="submit" type="submit" value="OK" class="ok"/>
<input id="eflore_nomenclature_fiche" name="submit" type="submit" value="Accès fiche" />
</span>
</fieldset>
</form>
<!-- FIN FORM_NOM -->';
 
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
/trunk/tests/modules/RechercheTest.php
6,6 → 6,7
public function testExecuterRechercheSimple() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
Registre::set('niveau', '1');
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
22,10 → 23,35
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
$this->assertArrayHasNotKey('auteur', $resultat['resultat']['182']);
$this->assertNotEmpty($sortie, print_r($sortie, true));
$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" autocomplete="off" value="acer mons" />', $sortie);
$this->assertContains('<strong class="nom-sci-retenu"><span class="surlignage">Acer</span> <span class="surlignage">mons</span>pessullanum</strong>', $sortie);
 
}
public function testExecuterRechercheSimpleResDecompo() {
$_GET['type_nom'] = 'nom_scientifique';
$_GET['nom'] = 'acer mons';
$_GET['resultat'] = 'decompo';
$cheminRacine = realpath(dirname(__FILE__).'/../configurations/').'/';
Config::charger($cheminRacine.'bdtfx.ini');
Registre::set('eFlore.urlBase', new Url(Config::get('base_url_application_index')));
Registre::set('parametres.referentiel', 'bdtfx');
$recherche = new Recherche();
$recherche->initialiser();
$recherche->executerRechercheSimple();
$donnees = Registre::get('donneesMoteur');
$resultat = Registre::get('resultats');
$sortie = implode('', $recherche->getSortie());
$this->assertEmpty($donnees, print_r($donnees, true));
$this->assertNotEmpty($resultat, print_r($resultat, true));
$this->assertEquals('6', $resultat['entete']['total']);
$this->assertEquals('6', count($resultat['resultat']));
$this->assertArrayHasKey('auteur', $resultat['resultat']['182']);
$this->assertNotEmpty($sortie, print_r($sortie, true));
$this->assertContains('<input id="nom" name="nom" class="champ" size="30" maxlength="255" type="text" autocomplete="off" value="acer mons" />', $sortie);
}
}
?>
/trunk/metier/api_0.1/Noms.php
14,8 → 14,14
*/
class Noms extends Eflore {
 
public function getRechercheEtendue($nom) {
$url = $this->getUrlRecherche($nom, 'etendue');
public function getRechercheEtendue($nom, $type_resultat = '') {
$methode = 'getUrlRecherche'.$type_resultat;
if (method_exists($this, $methode)) {
$url = $this->$methode($nom, 'etendue');
} else {
$url = $this->getUrlRecherche($nom, 'etendue');
Debug::printr("Le type de recherche demandé '$type_resultat' n'est pas disponible.");
}
return $this->chargerDonneesRecursivement($url);
}
 
24,6 → 30,7
return $this->chargerDonnees($url);
}
 
// retourne les champs par defaut
private function getUrlRecherche($nom, $typeRech) {
$tpl = Config::get('nomsRechercheTpl');
$params = array('valeur' => $nom, 'type' => $typeRech);
30,5 → 37,21
$url = $this->formaterUrl($tpl, $params);
return $url;
}
// retourne les champs par defaut + nom retenu
private function getUrlRechercheDetermination($nom, $typeRech) {
$tpl = Config::get('nomsRechercheDeterminationTpl');
$params = array('valeur' => $nom, 'type' => $typeRech);
$url = $this->formaterUrl($tpl, $params);
return $url;
}
// retourne les champs par defaut + nom decompose (au, an et bib)
private function getUrlRechercheDecompo($nom, $typeRech) {
$tpl = Config::get('nomsRechercheDecompoTpl');
$params = array('valeur' => $nom, 'type' => $typeRech);
$url = $this->formaterUrl($tpl, $params);
return $url;
}
}
?>
/trunk/metier/api_0.1/NomsVernaculaires.php
15,12 → 15,18
class NomsVernaculaires extends Eflore {
public function getRechercheEtendue($nom) {
$url = $this->getUrlRecherche($nom, 'etendue');
public function getRechercheEtendue($nom, $type_resultat = '') {
$methode = 'getUrlRecherche'.$type_resultat;
if (method_exists($this, $methode)) {
$url = $this->$methode($nom, 'etendue');
} else {
$url = $this->getUrlRecherche($nom, 'etendue');
Debug::printr("Le type de recherche demandé '$type_resultat' n'est pas disponible.");
}
return $this->chargerDonnees($url);
}
public function getRechercheFloue($nom) {
public function getRechercheFloue($nom, $type_resultat = '') {
$url = $this->getUrlRecherche($nom, 'floue');
return $this->chargerDonnees($url);
}
34,5 → 40,15
Debug::printr($url,'URL');
return $url;
}
private function getUrlRechercheDetermination($nom, $typeRech) {
$tpl = Config::get('nomsVernaRechercheTpl');
$params = array('valeur' => $nom, 'type' => $typeRech);
Debug::printr($params,'Params');
$url = $this->formaterUrl($tpl, $params);
Debug::printr($tpl,'TPL');
Debug::printr($url,'URL');
return $url;
}
}
?>
/trunk/modules/recherche/Recherche.php
5,6 → 5,7
// Méthodes
protected $nom = null;
protected $type_nom = 'nom_scientifique';
protected $type_resultat = '';
protected $submit = '';
public function initialiser() {
$this->capturerParametres();
47,7 → 48,7
? new NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna'))
: new Noms(Registre::get('parametres.referentiel'));
$approche = '';
$res = $noms->getRechercheEtendue($this->nom);
$res = $noms->getRechercheEtendue($this->nom, $this->type_resultat);
$form = I18n::get('Recherche-form-nom');
if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché
$approche = $this->rechercherNomApproche($noms);
90,7 → 91,29
if (isset($_GET['submit'])) {
$this->submit = urldecode($_GET['submit']);
}
if (isset($_GET['resultat'])) {
$this->type_resultat = urldecode($_GET['resultat']);
} else {
$onglet_resultat = $this->recupererTableauConfig('affich_resultats');
$this->type_resultat = $onglet_resultat[Registre::get('parametres.niveau').'_'.$this->type_nom];
}
}
protected function recupererTableauConfig($param) {
$tableau = array();
$tableauPartiel = explode(',', Config::get($param));
$tableauPartiel = array_map('trim', $tableauPartiel);
foreach ($tableauPartiel as $champ) {
if (strpos($champ, '=') === false) {
$tableau[] = $champ;
} else {
list($cle, $val) = explode('=', $champ);
$tableau[$cle] = $val;
}
}
return $tableau;
}
}
?>