Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1038 → Rev 1039

/trunk/widget/modules/recherche/Recherche.php
New file
0,0 → 1,85
<?php
// declare(encoding='UTF-8');
/**
* Service de recherche dans eflore, permettant d'intégrer le moteur dans une page donnée
* Encodage en entrée : utf8
* Encodage en sortie : utf8
*
* Cas d'utilisation et documentation :
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideEfloreWidgetRecherche
*
*
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright Copyright (c) 2013, Tela Botanica (accueil@tela-botanica.org)
*/
class Recherche extends WidgetCommun {
const DS = DIRECTORY_SEPARATOR;
/**
* Méthode appelée par défaut pour charger ce widget.
*/
public function executer() {
$retour = null;
$this->extraireParametres();
$methode = $this->traiterNomMethodeExecuter("recherche");
if (method_exists($this, $methode)) {
$retour = $this->$methode();
} else {
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
}
if (is_null($retour)) {
$info = 'Un problème est survenu : '.print_r($this->messages, true);
$this->envoyer($info);
} else {
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
if (isset($_GET['callback'])) {
$this->envoyerJsonp(array('contenu' => $contenu));
} else {
$this->envoyer($contenu);
}
}
}
public function extraireParametres() {
extract($this->parametres);
}
public function executerRecherche() {
$widget['donnees'] = array();
$widget['donnees']['efloreScriptUrl'] = $this->config['url']['efloreScriptUrl'];
$widget['donnees']['efloreConsultationUrl'] = $this->config['url']['efloreConsultationUrl'];
$widget['donnees']['efloreRechercheSciUrlTpl'] = $this->config['url']['efloreRechercheSciUrlTpl'];
$widget['donnees']['efloreRechercheVernaUrlTpl'] = $this->config['url']['efloreRechercheVernaUrlTpl'];
$widget['donnees']['ficheTaxonUrlTpl'] = $this->config['url']['ficheTaxonTplUrlTpl'];
$widget['donnees']['referentielsSciDispos'] = $this->traiterReferentielSciDispos();
$widget['donnees']['referentielsVernasDispos'] = $this->traiterReferentielsSciVernasDispos();
$ref_sci_defaut = $widget['donnees']['referentielsSciDispos'][0];
$ref_verna_defaut = $widget['donnees']['referentielsVernasDispos'][$ref_sci_defaut];
$widget['donnees']['efloreRechercheSciUrlDefaut'] = str_replace('{referentiel}', $ref_sci_defaut,$this->config['url']['efloreRechercheSciUrlTpl']);
$widget['donnees']['efloreRechercheVernaUrlDefaut'] = str_replace('{referentiel}',$ref_verna_defaut, $this->config['url']['efloreRechercheVernaUrlTpl']);
$widget['squelette'] = 'recherche';
return $widget;
}
private function traiterReferentielSciDispos() {
$refs_sci = $this->config['referentiel']['referentielsSciDispos'];
$refs_sci = explode(',', $refs_sci);
return $refs_sci;
}
private function traiterReferentielsSciVernasDispos() {
$refs_verna = $this->config['referentiel']['referentielsVernaDispos'];
$refs_verna = explode(',', $refs_verna);
$tab_refs_verna = array();
foreach($refs_verna as $ref_verna) {
$ref_sci_a_verna = explode(":", $ref_verna);
$tab_refs_verna[$ref_sci_a_verna[0]] = $ref_sci_a_verna[1];
}
return $tab_refs_verna;
}
}
?>