Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1297 → Rev 1343

/branches/v5.8-seynes/widget/modules/recherche/config.defaut.ini
New file
0,0 → 1,15
[url]
efloreScriptUrl = "http://www.tela-botanica.org/eflore/consultation/presentations/scripts/recherche.js"
; url vers l'application utilisée par défaut
efloreConsultationUrl = "http://www.tela-botanica.org/page:eflore"
; url spécifique à un référentiel
efloreConsultationBdtfxUrl = "http://www.tela-botanica.org/page:eflore_bdtfx"
; url spécifique à un référentiel
efloreConsultationBdtxaUrl = "http://www.tela-botanica.org/page:isfgm"
efloreRechercheSciUrlTpl = "http://www.tela-botanica.org/service:eflore:0.1/{referentiel}/noms"
efloreRechercheVernaUrlTpl = "http://www.tela-botanica.org/service:eflore:0.1/{referentiel}/noms-vernaculaires"
ficheTaxonUrlTpl = "?referentiel={referentiel}&niveau=2&module=fiche&action=fiche&num_nom={num_taxon}&type_nom=nom_scientifique&nom="
 
[referentiel]
referentielsSciDispos = bdtfx#France : métropole,bdtxa#France : Antilles,isfan#Afrique du Nord,apd#Afrique tropicale
referentielsVernaDispos = bdtfx:nvjfl,bdtxa:nva
/branches/v5.8-seynes/widget/modules/recherche/Recherche.php
New file
0,0 → 1,105
<?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']['ficheTaxonUrlTpl'];
$widget['donnees']['referentielsSciDispos'] = $this->traiterReferentielSciDispos();
$widget['donnees']['referentielsConsultationUrls'] = $this->traiterUrlsConsultationReferentiels($widget['donnees']['referentielsSciDispos']);
$widget['donnees']['referentielsVernasDispos'] = $this->traiterReferentielsSciVernasDispos();
$ref_sci_defaut = array_shift(array_keys($widget['donnees']['referentielsSciDispos']));
$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['donnees']['ficheTaxonUrlTplDefaut'] = str_replace('{referentiel}', $ref_sci_defaut, $this->config['url']['ficheTaxonUrlTpl']);
$widget['squelette'] = 'recherche';
return $widget;
}
private function traiterReferentielSciDispos() {
$refs_sci_fmt = array();
$refs_sci = $this->config['referentiel']['referentielsSciDispos'];
$refs_sci = explode(',', $refs_sci);
foreach($refs_sci as $ref) {
$ref_code_desc = explode('#', $ref);
$refs_sci_fmt[$ref_code_desc[0]] = $ref_code_desc[1];
}
return $refs_sci_fmt;
}
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;
}
private function traiterUrlsConsultationReferentiels($referentiels) {
$urls = array();
foreach($referentiels as $code_ref => $nom) {
$config_url_ref = 'efloreConsultation'.ucwords($code_ref).'Url';
if(isset($this->config['url'][$config_url_ref])) {
$urls[$code_ref] = $this->config['url'][$config_url_ref];
} else {
$urls[$code_ref] = $this->config['url']['efloreConsultationUrl'];
}
}
return $urls;
}
}
?>
/branches/v5.8-seynes/widget/modules/recherche/squelettes/css/recherche.css
New file
0,0 → 1,72
#conteneur-recherche {
width: 660px;
}
 
#conteneur-recherche h1.titre-widget {
margin-top: 5px;
margin-bottom: 0px;
color: black;
background: none;
}
 
#conteneur-recherche {
background-color: #FFFFFF;
border-radius: 10px 10px 10px 10px;
box-shadow: 1px 6px 6px 6px #C3C0AD;
color: #3A3633;
font-family: arial;
font-size: 11px;
margin: 10px 10px 20px;
padding: 8px;
}
 
#conteneur-recherche h1 {
font-size: 14px;
}
 
#conteneur-recherche h1.titre-widget {
padding-left: 15px;
}
 
#conteneur-recherche .zone-choix-referentiel {
padding: 3px;
padding-bottom : 5px;
padding-left: 10px;
}
 
#conteneur-recherche .label-referentiel {
color: #FD8C13;
font-weight: bold;
letter-spacing: 0;
padding: 0 0 0 5px;
text-transform: uppercase;
}
 
#conteneur-recherche .selection-referentiel {
background: none repeat scroll 0 0 white;
cursor: pointer;
height: 25px;
}
 
#conteneur-recherche .referentiel-selectionne {
background-color: #EEE;
border-color: #EB8F00;
color: #C87A00;
cursor: default;
font-weight: bold;
text-decoration: underline;
height: 35px;
}
 
#ef-form-nomenclature label {
display: inline;
}
 
#eflore_nomenclature_fiche {
color: black;
border-color: black;
}
 
.ef-groupe-champs {
border: none;
}
/branches/v5.8-seynes/widget/modules/recherche/squelettes/recherche.tpl.html
New file
0,0 → 1,95
<!-- DEBUT FORM_NOM -->
<script type="text/javascript">
<!--
var AUTOCOMPLETION_ELEMENTS_NBRE = 50;
var URL_SERVICE_AUTOCOMPLETION_NOM_SCI_TPL = "<?= $efloreRechercheSciUrlTpl; ?>";
var URL_SERVICE_AUTOCOMPLETION_NOM_VERNA_TPL = "<?= $efloreRechercheVernaUrlTpl; ?>";
var URL_BASE_FICHE_TAXON_TPL = "<?= $ficheTaxonUrlTpl; ?>";
var VALEUR_DEFAUT_NOM_SCI = "Saisir un nom scientifique (sans auteur)";
var VALEUR_DEFAUT_NOM_VERNA = "Saisir un nom commun";
var VALEUR_DEFAUT_AU = "";
var VALEUR_DEFAUT_BIB = "";
var VALEUR_DEFAUT_DATE = "";
var URL_BASE_FICHE_TAXON = "<?= $ficheTaxonUrlTplDefaut; ?>";
<?php $refs_urls = json_encode($referentielsConsultationUrls); ?>
var REFERENTIELS_CONSULTATION_URLS = <?= $refs_urls; ?>;
<?php $refs_verna = json_encode($referentielsVernasDispos); ?>
var REFERENTIELS_VERNA_DISPOS = <?= $refs_verna; ?>;
var URL_SERVICE_AUTOCOMPLETION_NOM_SCI = "<?= $efloreRechercheSciUrlDefaut; ?>";
var URL_SERVICE_AUTOCOMPLETION_NOM_VERNA = "<?= $efloreRechercheVernaUrlDefaut; ?>";
function gererVisibiliteSelecteurNom() {
ref_sci = $(".selection-referentiel[disabled=disabled]").attr("name");
$("#eflore_nomenclature_referentiel").val(ref_sci);
URL_SERVICE_AUTOCOMPLETION_NOM_SCI = URL_SERVICE_AUTOCOMPLETION_NOM_SCI_TPL.replace("{referentiel}", ref_sci);
URL_BASE_FICHE_TAXON = REFERENTIELS_CONSULTATION_URLS[ref_sci]+URL_BASE_FICHE_TAXON_TPL.replace("{referentiel}", ref_sci);
console.log(URL_BASE_FICHE_TAXON);
if(REFERENTIELS_VERNA_DISPOS[ref_sci] != undefined) {
URL_SERVICE_AUTOCOMPLETION_NOM_VERNA = URL_SERVICE_AUTOCOMPLETION_NOM_VERNA_TPL.replace("{referentiel}", REFERENTIELS_VERNA_DISPOS[ref_sci]);
$("#type_nom_vernaculaire").parent().css("visibility","visible");
} else {
$("#type_nom_vernaculaire").parent().css("visibility","hidden");
$("#type_nom_scientifique").attr('checked', 'checked');
$('#nom').val();
$('#nom').attr("placeholder", "");
}
$('#ef-form-nomenclature').attr("action", REFERENTIELS_CONSULTATION_URLS[ref_sci]);
}
function mettreEnValeurReferentielSelectionne(bouton) {
$(".selection-referentiel").removeAttr("disabled");
$(".selection-referentiel").removeClass("referentiel-selectionne");
bouton.attr("disabled","disabled");
bouton.addClass("referentiel-selectionne");
gererVisibiliteSelecteurNom();
}
function initialiser() {
$.getScript("<?= $efloreScriptUrl; ?>").done(function(script, textStatus) {
// la fonction initialiserMoteur est la fonction d'initialisation du script de recherche tiré d'eflore
// elle utilise les variable définies ci dessus, et elle est donc chargée après.
initialiserMoteur();
$(".selection-referentiel").click(function () {
mettreEnValeurReferentielSelectionne($(this));
});
mettreEnValeurReferentielSelectionne($($(".selection-referentiel")[0]));
});
}
 
// -->
</script>
<div class="importance1" id="conteneur-recherche">
<h1 class="titre-widget">Cherchez une plante de <span class="zone-choix-referentiel">
<?php $premier_ref = true; ?>
<?php foreach($referentielsSciDispos as $code => $intitule) : ?>
<span class="referentiel">
<input type="button" class="selection-referentiel" id="referentiel_<?= $code ?>" name="<?= $code; ?>" value="<?= $intitule; ?>" <?= $premier_ref ? 'disabled="disabled"' : ""; ?> />
</span>
<?php $premier_ref = false; ?>
<?php endforeach; ?>
</span> </h1>
<form id="ef-form-nomenclature" name="ef-form-nomenclature" action="<?= $efloreConsultationUrl; ?>" method="get">
<fieldset class="ef-groupe-champs">
<span class="zone-choix-type-nom">
<span class="type-nom">
<input type="radio" id="type_nom_scientifique" name="type_nom" value="nom_scientifique" checked="checked" />
<label for="type_nom_scientifique">Nom scientifique</label>
</span>
<span class="type-nom">
<input type="radio" id="type_nom_vernaculaire" name="type_nom" value="nom_vernaculaire" />
<label for="type_nom_vernaculaire" title="(en français, allemand, anglais, catalan, espagnol, italien ou néerlandais)">Nom commun</label>
</span>
</span>
<input type="text" aria-haspopup="true" aria-autocomplete="list" role="textbox" autocomplete="off" id="nom" name="nom" class="champ ui-autocomplete-input" size="30" maxlength="255" />
<span id="zone-liens-recherche">
<input type="hidden" id="eflore_nomenclature_niveau" name="niveau" value="2" />
<input type="hidden" id="eflore_nomenclature_module" name="module" value="recherche" />
<input type="hidden" id="eflore_nomenclature_referentiel" name="referentiel" value="<?= array_shift(array_keys($referentielsSciDispos)); ?>" />
<input type="hidden" id="eflore_nomenclature_action" name="action" value="rechercheSimple" />
<input type="submit" id="eflore_nomenclature_submit" name="submit" value="OK" class="ok" />
<input type="submit" id="eflore_nomenclature_fiche" name="acces_fiche" value="Accès fiche" />
</span>
</fieldset>
</form>
</div>
<!-- FIN FORM_NOM -->
/branches/v5.8-seynes/widget/modules/recherche/squelettes/exemple.tpl.html
New file
0,0 → 1,15
<div id="recherche-eflore-1">
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/1.7.1/jquery-1.7.1.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<link xmlns:xh="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rel="xh:stylesheet stylesheet" href="http://localhost/eflore-consultation/presentations/styles/eflore.css" media="screen" type="text/css" />
<link xmlns:xh="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rel="xh:stylesheet stylesheet" href="http://localhost/eflore-consultation/widget/modules/recherche/squelettes/css/recherche.css" media="screen" type="text/css" />
<link href="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("http://localhost/eflore-consultation/widget/recherche/?mode=ajax&callback=?", function (moteur) {
$("#recherche-eflore-1").append(moteur.contenu);
initialiser();
});
});
</script>
</div>
/branches/v5.8-seynes/widget/modules/recherche
New file
Property changes:
Added: svn:ignore
+config.ini