Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1038 → Rev 1039

/trunk/widget/modules/recherche/config.defaut.ini
New file
0,0 → 1,10
[url]
efloreScriptUrl = http://tela-botanica.org/eflore-test/consultation/presentations/scripts/recherche.js
efloreConsultationUrl = http://www.tela-botanica.org/eflore-test/consultation/
efloreRechercheSciUrlTpl = http://tela-botanica.org/service:eflore:0.1/{referentiel}/noms;
efloreRechercheVernaUrlTpl = http://tela-botanica.org/service:eflore:0.1/{referentiel}/noms-vernaculaires;
ficheTaxonTplUrlTpl = http://www.tela-botanica.org/{referentiel}-nn-{num_nom};
 
[referentiel]
referentielsSciDispos = bdtfx,bdtxa,isfan
referentielsVernaDispos = bdtfx:nvjfl,bdtxa:nva
/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;
}
}
?>
/trunk/widget/modules/recherche/squelettes/css/recherche.css
New file
0,0 → 1,36
#conteneur-recherche {
width: 750px;
}
 
h1.titre-widget {
margin-top: 5px;
}
 
.importance1 {
background-color: #EAEDCD;
border-radius: 10px 10px 10px 10px;
box-shadow: 2px 2px 5px #AAAAAA;
color: #3A3633;
font-family: arial;
font-size: 11px;
margin: 10px 10px 20px;
padding: 8px;
}
 
.zone-choix-referentiel {
padding: 3px;
padding-bottom : 5px;
padding-left: 10px;
}
 
.label-referentiel {
color: #FD8C13;
font-weight: bold;
letter-spacing: 0;
padding: 0 0 0 5px;
text-transform: uppercase;
}
 
#ef-form-nomenclature label {
display: inline;
}
/trunk/widget/modules/recherche/squelettes/recherche.tpl.html
New file
0,0 → 1,82
<!-- 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 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 = "<?= $ficheTaxonUrlTpl; ?>";
<?php $js = json_encode($referentielsVernasDispos); ?>
var REFERENTIELS_VERNA_DISPOS = <?= $js ; ?>;
var URL_SERVICE_AUTOCOMPLETION_NOM_SCI = "<?= $efloreRechercheSciUrlDefaut; ?>";
var URL_SERVICE_AUTOCOMPLETION_NOM_VERNA = "<?= $efloreRechercheVernaUrlDefaut; ?>";
function gererVisibiliteSelecteurNom() {
ref_sci = $("input[name=referentiel]:checked").val();
URL_SERVICE_AUTOCOMPLETION_NOM_SCI = URL_SERVICE_AUTOCOMPLETION_NOM_SCI_TPL.replace("{referentiel}", ref_sci);
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", "");
}
}
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();
$("input[name=referentiel]").change(function () {
gererVisibiliteSelecteurNom();
});
gererVisibiliteSelecteurNom();
});
}
 
// -->
</script>
<div class="importance1" id="conteneur-recherche">
<h1 class="titre-widget">Rechercher un nom</h1>
<form id="ef-form-nomenclature" name="ef-form-nomenclature" action="<?= $efloreConsultationUrl; ?>" method="get">
<fieldset>
<div class="zone-choix-referentiel">
<label class="label-referentiel">Référentiel :</label>
<?php $premier_ref = true; ?>
<?php foreach($referentielsSciDispos as $ref_sci) : ?>
<span class="referentiel">
<input type="radio" class="selection-referentiel" id="referentiel_<?= $ref_sci ?>" name="referentiel" value="<?= $ref_sci; ?>" <?= $premier_ref ? 'checked="checked"' : ""; ?> />
<label for="referentiel_<?= $ref_sci; ?>"><?= $ref_sci; ?></label>
</span>
<?php $premier_ref = false; ?>
<?php endforeach; ?>
</div>
<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_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 -->
/trunk/widget/modules/recherche/squelettes/exemple.tpl.html
New file
0,0 → 1,13
<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">
$.getJSON("http://localhost/eflore-consultation/widget/recherche/?mode=ajax&callback=?", function (moteur) {
$("#recherche-eflore-1").append(moteur.contenu);
initialiser();
});
</script>
</div>