/branches/v1.5-cisaille/widget/modules/carto/config.defaut.ini |
---|
2,4 → 2,4 |
; Chemin vers le dossier contenant les fichiers kmz des limites communales |
communesKmzChemin = "/home/telabotap/www/commun/google/map/3/kmz/communes/,/home/telabotap/www/commun/google/map/3/kmz/communes_incompletes/" |
; Template de l'url où charger les fichiers kml des limites communales. |
limitesCommunaleUrlTpl = "http://www.tela-botanica.org/eflore/cel2/widget/modules/carto/squelettes/kml/%s" |
limitesCommunaleUrlTpl = "http://www.tela-botanica.org/eflore/cel2/widget/modules/carto/squelettes/kml/%s/%s" |
/branches/v1.5-cisaille/widget/modules/carto/Carto.php |
---|
31,26 → 31,29 |
*/ |
class Carto extends WidgetCommun { |
const DS = DIRECTORY_SEPARATOR; |
const SERVICE_DEFAUT = 'carte-defaut'; |
const SERVICE_CARTO_NOM = 'CelWidgetMap'; |
const SERVICE_CARTO_ACTION_DEFAUT = 'carte-defaut'; |
private $carte = null; |
private $utilisateur = null; |
private $projet = null; |
private $dept = null; |
private $num_taxon = null; |
private $station = null; |
private $format = null;// Format des obs pour les stations (tableau/liste) |
/** |
* Méthode appelée par défaut pour charger ce widget. |
*/ |
public function executer() { |
$retour = null; |
extract($this->parametres); |
if (!isset($carte)) { |
$carte = self::SERVICE_DEFAUT; |
} |
$methode = $this->traiterNomMethodeExecuter($carte); |
$this->extraireParametres(); |
$methode = $this->traiterNomMethodeExecuter($this->carte); |
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); |
60,6 → 63,24 |
$this->envoyer($html); |
} |
} |
public function extraireParametres() { |
extract($this->parametres); |
$this->carte = (isset($carte) ? $carte : self::SERVICE_CARTO_ACTION_DEFAUT); |
$this->utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$this->projet = (isset($projet) ? $projet : '*'); |
$this->tag = (isset($tag) ? $tag : '*'); |
$this->dept = (isset($dept) ? $dept : '*'); |
$this->commune = (isset($commune) ? $commune : '*'); |
$this->num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
$this->date = (isset($date) ? $date : '*'); |
$this->taxon = (isset($taxon) ? $taxon : '*'); |
$this->commentaire = (isset($commentaire) ? $commentaire : null); |
$this->station = (isset($station) ? $station : null); |
$this->format = (isset($format) ? $format : null); |
$this->start = (isset($start) ? $start : null); |
$this->limit = (isset($limit) ? $limit : null); |
} |
/** |
* Carte par défaut |
66,87 → 87,76 |
*/ |
public function executerCarteDefaut() { |
$widget = null; |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
// Création url données json |
$url_cel_carto = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetMap'); |
$url_json = "$url_cel_carto/carte-defaut-json/$utilisateur/$projet/$dept/$num_taxon"; |
$url_stations = $this->contruireUrlServiceCarto('stations'); |
$url_base = sprintf($this->config['chemins']['baseURLAbsoluDyn'], ''); |
// Création des infos du widget |
$widget['donnees']['url_cel_carto'] = $url_cel_carto; |
$widget['donnees']['url_json'] = $url_json; |
$widget['donnees']['url_cel_carto'] = $this->contruireUrlServiceCarto(); |
$widget['donnees']['url_stations'] = $url_stations; |
$widget['donnees']['url_base'] = $url_base; |
$widget['donnees']['jquery_version'] = '1.4.4'; |
$widget['donnees']['utilisateur'] = $utilisateur; |
$widget['donnees']['projet'] = $projet; |
$widget['donnees']['dept'] = $dept; |
$widget['donnees']['num_taxon'] = $num_taxon; |
$widget['donnees']['taxons'] = $this->chargerTaxons(); |
if ($num_taxon != '*') { |
$taxon_courrant = current($widget['donnees']['taxons']); |
$widget['donnees']['taxon_nom'] = $taxon_courrant['nom']; |
} |
$widget['donnees']['utilisateur'] = $this->utilisateur; |
$widget['donnees']['projet'] = $this->projet; |
$widget['donnees']['tag'] = $this->tag; |
$widget['donnees']['dept'] = $this->dept; |
$widget['donnees']['commune'] = $this->commune; |
$widget['donnees']['num_taxon'] = $this->num_taxon; |
$widget['donnees']['date'] = $this->date; |
$widget['donnees']['taxon'] = $this->taxon; |
$widget['donnees']['commentaire'] = $this->commentaire; |
$widget['donnees']['url_limites_communales'] = $this->obtenirUrlsLimitesCommunales(); |
$widget['squelette'] = 'carte_defaut'; |
if (isset($dept)) { |
// si on veut afficher les limites départemmentales on va compter et chercher les noms de fichiers |
$fichiersKml = $this->chercherFichierKml($dept); |
foreach ($fichiersKml as $kml => $dossier){ |
$url_limites_communales = sprintf($this->config['carto']['limitesCommunaleUrlTpl'], $dossier, $kml); |
$widget['donnees']['url_limites_communales'][] = $url_limites_communales; |
} |
} |
return $widget; |
} |
private function chargerTaxons() { |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
// Récupération des données au format Json |
$service = "CelWidgetMap/taxons/$utilisateur/$projet/$dept/$num_taxon"; |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
// Post-traitement des données |
$taxons = $this->traiterTaxons($donnees); |
return $taxons; |
private function contruireUrlServiceCarto($action = null) { |
// Création url données json |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::SERVICE_CARTO_NOM); |
if ($action) { |
$url .= "/$action"; |
$parametres_retenus = array(); |
$parametres_a_tester = array('station', 'utilisateur', 'projet', 'tag', 'dept', 'commune', |
'num_taxon', 'taxon', 'date', 'commentaire', |
'start', 'limit'); |
foreach ($parametres_a_tester as $param) { |
if (isset($this->$param) && $this->$param != '*') { |
$parametres_retenus[$param] = $this->$param; |
} |
} |
if (count($parametres_retenus) > 0) { |
$parametres_url = array(); |
foreach ($parametres_retenus as $cle => $valeur) { |
$parametres_url[] = $cle.'='.$valeur; |
} |
$url .= '?'.implode('&', $parametres_url); |
} |
} |
return $url; |
} |
private function traiterTaxons($donnees) { |
$taxons = array(); |
if (is_array($donnees) && count($donnees) > 0) { |
foreach ($donnees as $donnee) { |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreVide($donnee->nom_ret)) { |
$taxon = array(); |
$taxon['nn'] = $donnee->num_nom_ret; |
$taxon['nt'] = $donnee->num_taxon; |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret); |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille); |
$taxons[$donnee->num_taxon] = $taxon; |
private function obtenirUrlsLimitesCommunales() { |
$urls = null; |
if (isset($this->dept)) { |
// si on veut afficher les limites départemmentales on va compter et chercher les noms de fichiers |
$fichiersKml = $this->chercherFichierKml(); |
if (count($fichiersKml) > 0) { |
foreach ($fichiersKml as $kml => $dossier){ |
$url_limites_communales = sprintf($this->config['carto']['limitesCommunaleUrlTpl'], $dossier, $kml); |
$urls[] = $url_limites_communales; |
} |
} |
} |
return $taxons; |
$urls = json_encode($urls); |
return $urls; |
} |
private function chercherFichierKml($dept){ |
private function chercherFichierKml(){ |
$fichiers = array(); |
$chemins = explode(',', $this->config['carto']['communesKmzChemin']); |
$departements = explode(',', $dept);// plrs code de départements peuvent être demandés séparés par des virgules |
$departements = explode(',', $this->dept);// plrs code de départements peuvent être demandés séparés par des virgules |
$departements_trouves = array(); |
$fichiers = array(); |
foreach ($chemins as $dossier_chemin) { |
if ($dossier_ressource = opendir($dossier_chemin)) { |
while ($element = readdir($dossier_ressource)) { |
171,129 → 181,6 |
} |
/** |
* Tableau des observations d'une station |
*/ |
public function executerObservations() { |
$widget = null; |
extract($this->parametres); |
$observations = $this->chargerObservation($station); |
// Création des infos du widget |
if (isset($observations['commune'])) { |
$commune = $observations['commune']; |
unset($observations['commune']); |
$widget['donnees']['commune'] = $commune; |
} |
$obs_ids = null; |
if (isset($observations['ids'])) { |
$obs_ids = $observations['ids']; |
unset($observations['ids']); |
} |
$widget['squelette'] = $this->choisirFormatSortie(count($observations)); |
if ($widget['squelette'] == 'obs_liste' && $obs_ids != null && count($obs_ids) > 0) { |
$widget['donnees']['images'] = $this->chargerImages($obs_ids); |
} |
$widget['donnees']['observations'] = $observations; |
$widget['donnees']['station_id'] = $station; |
return $widget; |
} |
private function chargerObservation($station) { |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
// Récupération des données au format Json |
$service = "CelWidgetMap/observations/$station/$utilisateur/$projet/$dept/$num_taxon"; |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
// Post-traitement des données |
$observations = $this->traiterObservations($donnees); |
return $observations; |
} |
private function traiterObservations($donnees) { |
$observations = array(); |
if (is_array($donnees) && count($donnees) > 0) { |
foreach ($donnees as $donnee) { |
$observation = array(); |
$observation['id'] = $donnee->id; |
$observation['nn'] = $this->etreVide($donnee->num_nom_sel) ? null : $donnee->num_nom_sel; |
$observation['nom'] = $this->nettoyerTexte($donnee->nom_sel); |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y'); |
$observation['lieu'] = $this->traiterLieu($donnee); |
$observation['observateur'] = $this->tronquerCourriel($donnee->identifiant); |
$observations[] = $observation; |
$observations['commune'] = $this->nettoyerTexte($donnee->location); |
$observations['ids'][] = $donnee->id; |
} |
} |
return $observations; |
} |
private function traiterLieu($donnee) { |
$lieu = array(); |
if (isset($donnee->lieudit) && ! empty($donnee->lieudit)) { |
$lieu[] = $donnee->lieudit; |
} |
if (isset($donnee->milieu) && ! empty($donnee->milieu)) { |
$lieu[] = $donnee->milieu; |
} |
return implode(', ', $lieu); |
} |
private function choisirFormatSortie($observations_nbre) { |
extract($this->parametres); |
$sortie = 'obs_tableau'; |
if (isset($format) && $format != '*') { |
$sortie = ($format == 'tableau' ) ? 'obs_tableau' : 'obs_liste'; |
} else { |
$sortie = ($observations_nbre > 4) ? 'obs_tableau' : 'obs_liste'; |
} |
return $sortie; |
} |
private function chargerImages($obs_ids) { |
// Récupération des données au format Json |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids); |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
// Post-traitement des données |
$images = $this->traiterImages($donnees); |
return $images; |
} |
private function traiterImages($donnees) { |
$images = array(); |
//echo '<br/><pre>'.print_r($donnees,true).'</pre>'; |
if (count($donnees) > 0) { |
foreach ($donnees as $id_obs => $id_images) { |
foreach ($id_images as $id_img) { |
$urls['id'] = $id_img; |
$urls['miniature'] = $this->getUrlImage($id_img, 'CXS'); |
$urls['normale'] = $this->getUrlImage($id_img, 'XL'); |
$images[$id_obs][] = $urls; |
} |
} |
} |
return $images; |
} |
/** |
* Afficher message d'avertissement. |
*/ |
public function executerAvertissement() { |
/branches/v1.5-cisaille/widget/modules/carto/squelettes/css/carto.css |
---|
36,6 → 36,7 |
/* Présentation des listes de définitions */ |
dl { |
width:100%; |
margin:0; |
} |
dt { |
float:left; |
42,10 → 43,12 |
font-weight:bold; |
text-align:top left; |
margin-right:0.3em; |
line-height:0.8em; |
} |
dd { |
width:auto; |
margin:0.5em 0; |
line-height:0.8em; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Tableau : */ |
52,6 → 55,7 |
table { |
border:1px solid gray; |
border-collapse:collapse; |
width:100%; |
} |
table thead, table tfoot, table tbody { |
background-color:Gainsboro; |
118,9 → 122,10 |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Message de chargement */ |
#chargement { |
display:none; |
margin:25px; |
text-align:center; |
} |
#chargement-copie img{ |
#chargement img{ |
display:block; |
margin:auto; |
} |
150,7 → 155,7 |
width:100%; |
height:35px; |
overflow:hidden; |
background:url(http://www.tela-botanica.org/sites/commun/generique/images/favicones/tela_botanica.png) no-repeat 8px 8px #4A4B4C; |
background-color:#4A4B4C; |
} |
#zone-info { |
position:absolute; |
167,7 → 172,7 |
} |
#carte-titre { |
display:inline-block; |
margin:0 0 0 24px; |
margin:0; |
padding:0.2em; |
color:#CCCCCC; |
} |
214,6 → 219,7 |
#pl-ouverture { |
left:0; |
background:url(../images/ouverture.png) no-repeat top left #4A4B4C; |
height:100%; |
} |
#pl-fermeture { |
display:none; |
231,32 → 237,69 |
#taxons { |
color:#999; |
} |
#taxons .taxon-actif, #taxons .taxon-actif a { |
color:#56B80E;} |
#taxons .taxon-actif, #taxons .taxon-actif span { |
color:#56B80E; |
} |
#taxons li span { |
border-bottom:1px dotted #666; |
color:#CCC; |
} |
#taxons li span:focus { |
outline:thin dotted; |
} |
#taxons li span:hover { |
color:#56B80E; |
border-bottom:1px dotted #56B80E; |
cursor:pointer; |
} |
.nt { |
display:none; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Pop-up observations */ |
.info-bulle-contenu { |
margin:0; |
padding:0; |
#info-bulle{ |
min-height:300px; |
/*width:géstion via le Javascript;*/ |
} |
#observations { |
margin:23px 0 0 0; |
padding:5px; |
border:1px solid black; |
border-radius:0 0 10px 10px;-moz-border-radius:0 0 10px 10px;-webkit-border-radius:0 0 10px 10px; |
border-top:none !important; |
overflow:none; |
margin:-1px 0 0 0; |
border: 1px solid #AAA; |
border-radius:0 0 4px 4px; |
} |
#observations ol { |
padding-left:20px; |
} |
.champ_nom_latin { |
display:none; |
} |
#obs-msg-info { |
#obs-pieds-page { |
font-size:10px; |
color:#CCC; |
clear:both; |
} |
.ui-tabs { |
padding:0; |
} |
.ui-widget-content { |
border:0; |
} |
.ui-widget-header { |
background:none; |
border:0; |
border-bottom:1px solid #AAA; |
border-radius:0; |
} |
.ui-tabs-selected a { |
border-bottom:1px solid white; |
} |
.ui-tabs-selected a:focus { |
outline:0; |
} |
.ui-tabs .ui-tabs-panel { |
padding:0.2em; |
} |
.ui-tabs .ui-tabs-nav li a { |
padding: 0.5em 0.6em; |
} |
#obs h2 { |
margin:0; |
text-align:center; |
} |
#observations a { |
color:#333; |
border-bottom:1px dotted gainsboro; |
265,64 → 308,141 |
color:#56B80E; |
border-bottom:1px dotted #56B80E; |
} |
.nom-sci{ |
color:#454341; |
font-weight:bold; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Onglets */ |
.onglets { |
position:absolute; |
top:0; |
float:left; |
height:22px; |
padding:0; |
margin:0; |
border-bottom:1px solid black; |
width:100%; |
/* Pop-up observations : liste */ |
.cel-img-principale { |
height:0;/*Pour IE*/ |
} |
.onglets ul { |
.cel-img-principale img{ |
float:right; |
height:75px; |
width:75px; |
padding:1px; |
border:1px solid white; |
} |
#observations .cel-img:hover img{ |
border: 1px dotted #56B80E; |
} |
.cel-img-secondaire, .cel-infos{ |
display: none; |
} |
ol#obs-liste-lignes { |
padding:5px; |
margin:0; |
padding:0; |
list-style:none; |
} |
.onglets li { |
.champ-nom-sci { |
display:none; |
} |
#obs-liste-lignes li dl {/*Pour IE*/ |
width:350px; |
} |
.obs-conteneur{ |
counter-reset: item; |
} |
.obs-conteneur .nom-sci:before { |
content: counter(item) ". "; |
counter-increment: item; |
display:block; |
float:left; |
text-transform:uppercase; |
text-align:center; |
} |
.onglets .onglet { |
display:block; |
padding:5px 15px 4px 15px; |
margin:0; |
font-size:12px; |
line-height:12px; |
border:1px solid black; |
border-radius:10px 10px 0 0;-moz-border-radius:10px 10px 0 0;-webkit-border-radius:10px 10px 0 0; |
.obs-conteneur li { |
display: block; |
margin-bottom:1em; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Diaporama */ |
.cel-legende{ |
text-align:left; |
} |
.cel-legende-vei{ |
float:right; |
} |
.cel-legende p{ |
color: black; |
font-size: 12px; |
line-height: 18px; |
margin: 0; |
} |
.cel-legende a, .cel-legende a:active, .cel-legende a:visited { |
border-bottom:1px dotted gainsboro; |
color:#333; |
text-decoration:none; |
background-image:none; |
} |
.onglets .actif .onglet { |
border-bottom:1px solid white; |
color:black; |
background-color:white; |
font-weight:bold; |
.cel-legende a:hover { |
color:#56B80E; |
border-bottom:1px dotted #56B80E; |
} |
.onglets .inactif .onglet { |
border-bottom:1px solid #000000; |
color:white; |
background-color:gray;/*rgba(29,30,32,0.8);*/ |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Plugin Jquery Pagination */ |
.navigation { |
padding:5px; |
float:right; |
} |
.onglets .inactif .onglet:hover { |
color:black; |
background-color:Gainsboro; |
.pagination { |
font-size: 80%; |
} |
.pagination a { |
text-decoration: none; |
border: solid 1px #666; |
color: #666; |
background:gainsboro; |
} |
.pagination a:hover { |
color: white; |
background: #56B80E; |
} |
.pagination a, .pagination span { |
display: block; |
float: left; |
padding: 0.3em 0.5em; |
margin-right: 5px; |
margin-bottom: 5px; |
min-width:1em; |
text-align:center; |
} |
.pagination .current { |
background: #4A4B4C; |
color: white; |
border: solid 1px gainsboro; |
} |
.pagination .current.prev, .pagination .current.next{ |
color: #999; |
border-color: #999; |
background: gainsboro; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Pop-up : liste */ |
.cel-img-principale img{ |
/* Formulaire de contact */ |
#form-contact input{ |
width:300px; |
} |
#form-contact textarea{ |
width:300px; |
height:200px; |
} |
#form-contact #fc_envoyer, #fc_annuler, #fc_effacer{ |
width:75px; |
} |
#fc_envoyer{ |
float:right; |
height:75px; |
padding:1px; |
border:1px solid white; |
} |
#observations .cel-img:hover img{ |
border:1px dotted #56B80E; |
#fc_annuler{ |
float:left; |
} |
.cel-img-secondaire{ |
display:none; |
} |
#form-contact label.error { |
color:red; |
font-weight:bold; |
} |
#form-contact .info { |
padding:5px; |
background-color: #4A4B4C; |
border: solid 1px #666; |
color: white; |
white-space: pre-wrap; |
width: 300px; |
} |
/branches/v1.5-cisaille/widget/modules/carto/squelettes/avertissement.tpl.html |
---|
23,7 → 23,7 |
<!-- CSS --> |
<link href="<?=$url_base?>modules/carto/squelettes/css/carto.css" rel="stylesheet" type="text/css" media="screen" /> |
<style type=""> |
<style> |
html { |
overflow:auto; |
} |
/branches/v1.5-cisaille/widget/modules/carto/squelettes/carte_defaut.tpl.html |
---|
22,278 → 22,71 |
<link rel="shortcut icon" type="image/x-icon" href="http://www.tela-botanica.org/sites/commun/generique/images/favicones/tela_botanica.ico" /> |
<!-- Javascript : bibliothèques --> |
<!-- <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script> --> |
<!-- Google Map v3 --> |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.3&sensor=true"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/google/map/3/markerclusterer/1.0/markerclusterer-1.0.pack.js"></script> |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=true&language=fr&region=FR"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/google/map/3/markerclusterer/2.0.1/markerclusterer-2.0.1.pack.js"></script> |
<!-- Jquery --> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/<?=$jquery_version?>/jquery-<?=$jquery_version?>.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/1.6.2/jquery-1.6.2.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.15/js/jquery-ui-1.8.15.custom.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/tablesorter/2.0.5/jquery.tablesorter.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/fancybox/1.3.4/jquery.fancybox-1.3.4.pack.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/pagination/2.2/jquery.pagination.js"></script> |
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/validate/1.8.1/jquery.validate.min.js"></script> |
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/validate/1.8.1/messages_fr.js"></script> |
<!-- Javascript : données --> |
<script src="<?=$url_json?>" type="text/javascript"></script> |
<script src="<?=$url_stations?>" type="text/javascript"></script> |
<!-- Javascript : appli carto --> |
<script type="text/javascript"> |
//<![CDATA[ |
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png'; |
var pointsOrigine = null; |
var boundsOrigine = null; |
var markerClusterer = null; |
var map = null; |
var urlsLimitesCommunales = <?=$url_limites_communales?>; |
var nt = '<?=$num_taxon?>'; |
var infoBulle = new google.maps.InfoWindow(); |
google.maps.event.addListener(infoBulle, 'domready', function() { |
// Onglet Tableau : Jquery => TableSorter |
if ($("#observations table").get() != '') { |
// add parser through the tablesorter addParser method |
$.tablesorter.addParser({ |
// Définition d'un id unique pour ce parsseur |
id: 'date_cel', |
is: function(s) { |
// retourne false si le parsseur n'est pas autodétecté |
return false; |
}, |
format: function(s) { |
// Transformation date jj/mm/aaaa en aaaa/mm/jj |
s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); |
// Remplace la date par un nombre de millisecondes pour trier numériquement |
return $.tablesorter.formatFloat(new Date(s).getTime()); |
}, |
// set type, either numeric or text |
type: 'numeric' |
}); |
$("#observations table").tablesorter({ |
headers: { |
1: { |
sorter:'date_cel' |
} |
} |
}); |
} |
// Onglet Liste : Jquery => FancyBox |
if ($("#observations ol").get() != '') { |
$("a.cel-img").fancybox({ |
transitionIn : 'elastic', |
transitionOut : 'elastic', |
speedIn : 600, |
speedOut : 200, |
overlayShow : true |
}).bind('click', function(e) { |
if (e.stopPropagation) { |
e.stopPropagation(); |
} |
return false; |
}); |
} |
}); |
google.maps.event.addListener(infoBulle, 'closeclick', function() { |
map.panTo(pointClique.position); |
}); |
var pointClique = null; |
var carteCentre = new google.maps.LatLng(46.4, 3.10); |
var carteOptions = { |
zoom: 6, |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
mapTypeControlOptions: { |
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU} |
}; |
var ctaLayer = null; |
function refreshMap() { |
var points = []; |
var bounds = new google.maps.LatLngBounds(); |
for (var i = 0; i < obs.nombre; ++i) { |
var maLatLng = new google.maps.LatLng(obs.points[i].coord_x, obs.points[i].coord_y); |
var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32)); |
var point = new google.maps.Marker({ |
position: maLatLng, |
map: map, |
icon: pointImage, |
stationId: obs.points[i].id |
}); |
bounds.extend(maLatLng); |
google.maps.event.addListener(point, 'click', function() { |
pointClique = this; |
infoBulle.open(map, this); |
var limites = map.getBounds(); |
var centre = limites.getCenter(); |
var nordEst = limites.getNorthEast(); |
var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng()); |
map.panTo(centreSudLatLng); |
afficherMsgChargement(); |
chargerFormatObs(this.stationId, '*'); |
}); |
points.push(point); |
} |
if (pointsOrigine == null && boundsOrigine == null) { |
pointsOrigine = points; |
boundsOrigine = bounds; |
} |
executerMarkerClusterer(points, bounds); |
} |
function executerMarkerClusterer(points, bounds) { |
if (markerClusterer) { |
markerClusterer.clearMarkers(); |
} |
markerClusterer = new MarkerClusterer(map, points); |
map.fitBounds(bounds); |
} |
function afficherMsgChargement() { |
var chargement = document.getElementById('chargement').cloneNode(true); |
chargement.setAttribute('id', 'chargement-copie'); |
infoBulle.setContent(chargement); |
} |
function chargerFormatObs(stationId, format) { |
var url = '<?=$url_base?>carto?carte=observations'+ |
'&utilisateur=<?=$utilisateur?>'+ |
'&projet=<?=$projet?>'+ |
'&num_taxon='+nt+ |
'&dept=<?=$dept?>'+ |
'&format='+format+'&station='+stationId; |
$.get(url, function(observations){ |
infoBulle.setContent(observations); |
}); |
} |
function arreter(event) { |
if (event.stopPropagation) { |
event.stopPropagation(); |
} |
return false; |
} |
function afficher() { |
document.getElementById('panneau-lateral').style.width = '300px'; |
document.getElementById('pl-contenu').style.display = 'block'; |
document.getElementById('pl-ouverture').style.display = 'none'; |
document.getElementById('pl-fermeture').style.display = 'block'; |
document.getElementById('carte').style.left = '300px'; |
google.maps.event.trigger(map, 'resize'); |
}; |
function cacher() { |
document.getElementById('panneau-lateral').style.width = '24px'; |
document.getElementById('pl-contenu').style.display = 'none'; |
document.getElementById('pl-ouverture').style.display = 'block'; |
document.getElementById('pl-fermeture').style.display = 'none'; |
document.getElementById('carte').style.left = '24px'; |
google.maps.event.trigger(map, 'resize'); |
}; |
function ouvrirPopUp(url, nom) { |
window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no'); |
}; |
function filtrerParTaxon(ntAFiltrer) { |
infoBulle.close(); |
$('#taxon-'+nt).removeClass('taxon-actif'); |
if (nt == ntAFiltrer) { |
nt = '*'; |
executerMarkerClusterer(pointsOrigine, boundsOrigine); |
} else { |
var url = '<?=$url_cel_carto?>/carte-defaut-json/<?=$utilisateur?>/<?=$projet?>/<?=$dept?>/'+ntAFiltrer+'?formatRetour=jsonp&callback=?'; |
$.getJSON(url, function (observations) { |
obs = observations; |
nt = ntAFiltrer; |
$('#taxon-'+nt).addClass('taxon-actif'); |
refreshMap(); |
}); |
} |
}; |
function initialize() { |
map = new google.maps.Map(document.getElementById('carte'), carteOptions); |
// Ajout des limites communales sur la carte |
<? if (isset($url_limites_communales)) : ?> |
<? foreach ($url_limites_communales as $url) : ?> |
ctaLayer = new google.maps.KmlLayer('<?=$url?>', {preserveViewport: true}); |
ctaLayer.setMap(map); |
<? endforeach ?> |
<? endif ?> |
<? if ($num_taxon == '*') : ?> |
var ouvertureDiv = document.getElementById('pl-ouverture'); |
google.maps.event.addDomListener(ouvertureDiv, 'click', afficher); |
var fermetureDiv = document.getElementById('pl-fermeture'); |
google.maps.event.addDomListener(fermetureDiv, 'click', cacher); |
<? endif ?> |
refreshMap(); |
} |
// Déclenchement d'actions pour JQuery |
$(document).ready(function() { |
// Ajout du nombre de communes où des observations ont eu lieu |
$('#commune-nbre').append(obs.nombre); |
}); |
var filtreCommun = |
'&taxon=<?=$taxon?>'+ |
'&utilisateur=<?=$utilisateur?>'+ |
'&projet=<?=$projet?>'+ |
'&tag=<?=$tag?>'+ |
'&date=<?=$date?>'+ |
'&dept=<?=$dept?>'+ |
'&commune=<?=$commune?>'+ |
'&commentaire=<?=$commentaire?>'; |
var stationsUrl = '<?=$url_cel_carto?>/stations'+'?'+ |
'num_taxon='+nt+ |
filtreCommun; |
var taxonsUrl = '<?=$url_cel_carto?>/taxons'+'?'+ |
'num_taxon='+nt+ |
filtreCommun; |
var observationsUrl = '<?=$url_cel_carto?>/observations'+'?'+ |
'station={stationId}'+ |
'&num_taxon={nt}'+ |
filtreCommun; |
//]]> |
</script> |
<script type="text/javascript" src="<?=$url_base?>modules/carto/squelettes/scripts/carto.js"></script> |
<!-- CSS --> |
<link rel="stylesheet" href="http://www.tela-botanica.org/commun/jquery/fancybox/1.3.4/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> |
<link rel="stylesheet" href="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.15/css/smoothness/jquery-ui-1.8.15.custom.css" type="text/css" media="screen" /> |
<link href="<?=$url_base?>modules/carto/squelettes/css/carto.css" rel="stylesheet" type="text/css" media="screen" /> |
<link rel="stylesheet" href="http://www.tela-botanica.org/commun/jquery/fancybox/1.3.4/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> |
<!--[if lt IE 7]> |
<style type="text/css"> |
#carte { |
height:expression(document.body.clientHeight-35); /* 80+20+20=120 */ |
width:expression(document.body.clientWidth-24); /* 200+20+20+20=260 */ |
} |
#panneau-lateral { |
height:expression(document.body.clientHeight-35); /* 80+20+20=120 */ |
} |
</style> |
<![endif]--> |
<? if ($num_taxon != '*') : ?> |
<style type="text/css"> |
#carte { |
left:0; |
} |
</style> |
<? endif ?> |
<!-- Stats : Google Analytics --> |
<script type="text/javascript"> |
//<![CDATA[ |
var _gaq = _gaq || []; |
_gaq.push(['_setAccount', 'UA-20092557-1']); |
_gaq.push(['_trackPageview']); |
(function() { |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
})(); |
//]]> |
</script> |
</head> |
<body onload="initialize()"> |
<body> |
<div id="zone-titre"> |
<h1 id="carte-titre"> |
<? if ($num_taxon == '*') : ?> |
<span id="commune-nbre"> </span> communes contenant des observations du <a href="http://www.tela-botanica.org/appli:cel" title="Carnet en Ligne" onclick="window.open(this.href); arreter(event); return false;">CEL</a> de <a href="http://www.tela-botanica.org/" onclick="window.open(this.href); arreter(event); return false;">Tela Botanica</a> |
<? else : ?> |
<span id="commune-nbre"> </span> communes pour <?=$taxon_nom?> - <a href="http://www.tela-botanica.org/appli:cel" title="Carnet en Ligne" onclick="window.open(this.href); arreter(event); return false;">CEL</a> de <a href="http://www.tela-botanica.org/" onclick="window.open(this.href); arreter(event); return false;">Tela Botanica</a> |
<? endif ?> |
<span id="logo"> |
<a href="http://www.tela-botanica.org/site:accueil" |
title="Aller à l'accueil de Tela Botanica" |
onclick="window.open(this.href); arreter(event); return false;"> |
<img src="http://www.tela-botanica.org/sites/commun/generique/images/favicones/tela_botanica.png" alt="TB" /> |
</a> |
</span> |
<span id="obs-nbre"> </span> observations |
<span class="plante-titre">de <span class="plantes-nbre"> </span> plantes</span> sur |
<span id="commune-nbre"> </span> communes |
- <a href="http://www.tela-botanica.org/appli:cel" title="Carnet en Ligne" onclick="window.open(this.href); arreter(event); return false;">CEL</a> (<a href="http://www.tela-botanica.org/" onclick="window.open(this.href); arreter(event); return false;">Tela Botanica</a>) |
</h1> |
<div id="zone-info"> |
<a href="<?=$url_base?>carto?carte=avertissement" onClick="ouvrirPopUp('<?=$url_base?>carto?carte=avertissement', 'Avertissement'); arreter(event); return false;"> |
308,7 → 101,7 |
<div id="pl-fermeture" title="Fermer le panneau latéral"><span><< Fermer [x]</span></div> |
<div id="pl-contenu"> |
<div id="pl-entete"> |
<h2>Filtre sur <?=count($taxons)?> plantes</h2> |
<h2>Filtre sur <span class="plantes-nbre"> </span> plantes</h2> |
<p> |
Cliquez sur un nom de plante pour filtrer les observations sur la carte.<br /> |
Pour revenir à l'état initial, cliquez à nouveau sur le nom sélectionné. |
315,15 → 108,7 |
</p> |
</div> |
<div id="pl-corps" onMouseOver="map.setOptions({'scrollwheel':false});" onMouseOut="map.setOptions({'scrollwheel':true});"> |
<ol id="taxons"> |
<? foreach ($taxons as $taxon) : ?> |
<li id="taxon-<?=$taxon['nt']?>"> |
<a href="#" onclick="filtrerParTaxon(<?=$taxon['nt']?>);" title="<?=$taxon['famille']?>"> |
<?=$taxon['nom']?> |
</a> |
</li> |
<? endforeach; ?> |
</ol> |
<!-- Insertion des lignes à partir du squelette tpl-taxons-liste --> |
</div> |
</div> |
</div> |
330,10 → 115,209 |
<? endif ?> |
<div id="carte"></div> |
<!-- +-------------------------------------------------------------------------------------------+ --> |
<!-- Blocs chargés à la demande : par défaut avec un style display à none --> |
<div id="chargement"> |
<img src="<?=$url_base?>modules/carto/squelettes/images/chargement.gif" alt="Chargement en cours..." /> |
<p>Chargement des observations en cours...</p> |
<!-- Squelette du message de chargement des observations --> |
<script id="tpl-chargement" type="text/x-jquery-tmpl"> |
<div id="chargement" style="height:500px;"> |
<img src="<?=$url_base?>modules/carto/squelettes/images/chargement.gif" alt="Chargement en cours..." /> |
<p>Chargement des observations en cours...</p> |
</div> |
</script> |
<!-- Squelette du contenu d'une info-bulle observation --> |
<script id="tpl-obs" type="text/x-jquery-tmpl"> |
<div id="info-bulle" style="width:{largeur}px;"> |
<div id="obs"> |
<h2><span id="obs-total"> </span> observations pour <span id="obs-commune"> </span></h2> |
<div class="navigation"> </div> |
<div> |
<ul> |
<li><a href="#obs-vue-tableau">Tableau</a></li> |
<li><a href="#obs-vue-liste">Liste</a></li> |
</ul> |
</div> |
<div id="observations"> |
<div id="obs-vue-tableau" style="display:none;"> |
<table id="obs-tableau"> |
<thead> |
<tr> |
<th title="Nom scientifique défini par l'utilisateur.">Nom</th> |
<th title="Date de l'observation">Date</th> |
<th title="Lieu d'observation">Lieu</th> |
<th title="Auteur de l'observation">Observateur</th> |
</tr> |
</thead> |
<tbody id="obs-tableau-lignes" class="obs-conteneur"> |
<!-- Insertion des lignes à partir du squelette tpl-obs-tableau --> |
</tbody> |
</table> |
</div> |
<div id="obs-vue-liste" style="display:none;"> |
<ol id="obs-liste-lignes" class="obs-conteneur"> |
<!-- Insertion des lignes à partir du squelette tpl-obs-liste --> |
</ol> |
</div> |
</div> |
<div class="navigation"> </div> |
<div id="obs-pieds-page"> |
<p id="obs-msg-info">Les observations de cette carte sont regroupées par commune.</p> |
<p>Id : <span id="obs-station-id"> </span></p> |
</div> |
</div> |
</div> |
</script> |
<!-- Squelette du contenu du tableau des observation --> |
<script id="tpl-obs-tableau" type="text/x-jquery-tmpl"> |
<tr class="cel-obs-${idObs}"> |
<td> |
<span class="nom-sci"> |
{{if nn != 0}} |
<a href="http://www.tela-botanica.org/nn${nn}" |
onclick="window.open(this.href); arreter(event); return false; "> |
${nomSci} |
</a> |
{{else}} |
${nomSci} |
{{/if}} |
</span> |
</td> |
<td class="date">{{if date}}${date}{{else}} {{/if}}</td> |
<td class="lieu">{{if lieu}}${lieu}{{else}} {{/if}}</td> |
<td> |
{{if observateur}} |
{{if observateurId}} |
<a class="contact obs-${idObs} contributeur-${observateurId}" |
href="#form-contact" |
title="Contactez ce contributeur"> |
${observateur} |
</a> |
{{else}} |
${observateur} |
{{/if}} |
{{else}} |
|
{{/if}} |
</td> |
</tr> |
</script> |
<!-- Squelette du contenu de la liste des observations --> |
<script id="tpl-obs-liste" type="text/x-jquery-tmpl"> |
<li> |
<div class="cel-obs-${idObs}"> |
{{if images}} |
{{each(index, img) images}} |
<div{{if index == 0}} class="cel-img-principale" {{else}} class="cel-img-secondaire"{{/if}}> |
<a class="cel-img" |
href="${img.normale}" |
title="${nomSci} {{if nn}} [${nn}] {{/if}} par ${observateur} - Publiée le ${datePubli} - GUID : ${img.guid}" |
rel="cel-obs-${idObs}"> |
<img src="${img.miniature}" alt="Image #${img.idImg} de l'osbervation #${nn}" /> |
</a> |
<p id="cel-info-${img.idImg}" class="cel-infos"> |
<a class="cel-img-titre" href="${urlEflore}" |
onclick="window.open(this.href);return false;" |
title="Cliquez pour accéder à la fiche eFlore"> |
<strong>${nomSci} {{if nn}} [nn${nn}] {{/if}}</strong> par <em>${observateur}</em> |
</a> |
<br /> |
<span class="cel-img-date">Publiée le ${datePubli}</span> |
</p> |
</div> |
{{/each}} |
{{/if}} |
<dl> |
<dt class="champ-nom-sci">Nom</dt> |
<dd title="Nom défini par l'utilisateur{{if nn != 0}}. Cliquez pour accéder à la fiche d'eFlore.{{/if}}"> |
<span class="nom-sci"> |
{{if nn != 0}} |
<a href="http://www.tela-botanica.org/nn${nn}" |
onclick="window.open(this.href); arreter(event); return false; "> |
${nomSci} |
</a> |
{{else}} |
${nomSci} |
{{/if}} |
</span> |
</dd> |
<dt title="Lieu d'observation">Lieu</dt><dd class="lieu"> ${lieu}</dd> |
<dt title="Date d'observation">Le</dt><dd class="date"> ${date}</dd> |
<dt title="Auteur de l'observation">Publié par</dt> |
<dd> |
{{if observateur}} |
{{if observateurId}} |
<a class="contact obs-${idObs} contributeur-${observateurId}" |
href="#form-contact" |
title="Contactez ce contributeur"> |
${observateur} |
</a> |
{{else}} |
${observateur} |
{{/if}} |
{{else}} |
|
{{/if}} |
</dd> |
</dl> |
<hr class="nettoyage"/> |
</div> |
</li> |
</script> |
<!-- Squelette de la liste des taxons --> |
<script id="tpl-taxons-liste" type="text/x-jquery-tmpl"> |
<ol id="taxons"> |
{{each(index, taxon) taxons}} |
<li id="taxon-${taxon.nt}"> |
<span class="taxon" title="Numéro taxonomique : ${taxon.nt} - Famille : ${taxon.famille}"> |
${taxon.nom} <span class="nt" title="Numéro taxonomique">${taxon.nt}</span> |
</span> |
</li> |
{{/each}} |
</ol> |
</script> |
<!-- Squelette du formulaire de contact --> |
<div id="tpl-form-contact" style="display:none;"> |
<form id="form-contact" method="post" action=""> |
<div id="fc-zone-dialogue"></div> |
<dl> |
<dt><label for="fc_sujet">Sujet</label></dt> |
<dd><input id="fc_sujet" name="fc_sujet"/></dd> |
<dt><label for="fc_message">Message</label></dt> |
<dd><textarea id="fc_message" name="fc_message"></textarea></dd> |
<dt><label for="fc_utilisateur_courriel" title="Utilisez le courriel avec lequel vous êtes inscrit à Tela Botanica">Votre courriel</label></dt> |
<dd><input id="fc_utilisateur_courriel" name="fc_utilisateur_courriel"/></dd> |
</dl> |
<p> |
<input id="fc_destinataire_id" name="fc_destinataire_id" type="hidden" value="" /> |
<input id="fc_copies" name="fc_copies" type="hidden" value="eflore_remarques@tela-botanica.org" /> |
<button id="fc_annuler" type="button">Annuler</button> |
|
<button id="fc_effacer" type="reset">Effacer</button> |
|
<input id="fc_envoyer" type="submit" value="Envoyer" /> |
</p> |
</form> |
</div> |
<!-- Stats : Google Analytics --> |
<script type="text/javascript"> |
//<![CDATA[ |
var _gaq = _gaq || []; |
_gaq.push(['_setAccount', 'UA-20092557-1']); |
_gaq.push(['_trackPageview']); |
(function() { |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
})(); |
//]]> |
</script> |
</body> |
</html> |
</html> |
/branches/v1.5-cisaille/widget/modules/carto/squelettes/scripts/carto.js |
---|
New file |
0,0 → 1,736 |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// PARAMÊTRES et CONSTANTES |
// Mettre à true pour afficher les messages de débogage |
var DEBUG = false; |
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png'; |
var pointsOrigine = null; |
var boundsOrigine = null; |
var markerClusterer = null; |
var map = null; |
var infoBulle = new google.maps.InfoWindow(); |
var pointClique = null; |
var carteCentre = new google.maps.LatLng(46.4, 3.10); |
var carteOptions = { |
zoom: 6, |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', |
google.maps.MapTypeId.ROADMAP, |
google.maps.MapTypeId.HYBRID, |
google.maps.MapTypeId.SATELLITE, |
google.maps.MapTypeId.TERRAIN] |
} |
}; |
var ctaLayer = null; |
var osmMapType = new google.maps.ImageMapType({ |
getTileUrl: function(coord, zoom) { |
return "http://tile.openstreetmap.org/" + |
zoom + "/" + coord.x + "/" + coord.y + ".png"; |
}, |
tileSize: new google.maps.Size(256, 256), |
isPng: true, |
alt: "OpenStreetMap", |
name: "OSM", |
maxZoom: 19 |
}); |
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'}; |
var station = {'commune':'', 'obsNbre':0}; |
var obsStation = new Array(); |
var obsPage = new Array(); |
var taxonsCarte = new Array(); |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INITIALISATION DU CODE |
//Déclenchement d'actions quand JQuery et le document HTML sont OK |
$(document).ready(function() { |
initialiserWidget(); |
}); |
function initialiserWidget() { |
afficherStats(); |
definirTailleTitre(); |
initialiserAffichageCarte(); |
initialiserAffichagePanneauLateral(); |
initialiserCarte(); |
initialiserInfoBulle(); |
initialiserFormulaireContact(); |
chargerLimitesCommunales(); |
rafraichirCarte(); |
} |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// AFFICHAGE GÉNÉRAL |
function afficherStats() { |
// Ajout du nombre de communes où des observations ont eu lieu |
$('#commune-nbre').text(stations.stats.communes.formaterNombre()); |
// Ajout du nombre d'observations |
$('#obs-nbre').text(stations.stats.observations.formaterNombre()); |
} |
function definirTailleTitre() { |
var largeurViewPort = $(window).width(); |
var taille = null; |
if (largeurViewPort < 400) { |
taille = '0.8'; |
} else if (largeurViewPort >= 400 && largeurViewPort < 800) { |
taille = '1.0'; |
} else if (largeurViewPort >= 800) { |
taille = '1.6'; |
} |
$("#carte-titre").css('font-size', taille+'em'); |
} |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// CARTE |
function initialiserAffichageCarte() { |
$('#carte').height($(window).height() - 35); |
$('#carte').width($(window).width() - 24); |
if (nt != '*') { |
$('#carte').css('left', 0); |
} |
} |
function initialiserCarte() { |
map = new google.maps.Map(document.getElementById('carte'), carteOptions); |
// Ajout de la couche OSM à la carte |
map.mapTypes.set('OSM', osmMapType); |
} |
function chargerLimitesCommunales() { |
if (urlsLimitesCommunales != null) { |
for (urlId in urlsLimitesCommunales) { |
var url = urlsLimitesCommunales[urlId]; |
ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true}); |
ctaLayer.setMap(map); |
} |
} |
} |
function rafraichirCarte() { |
var points = []; |
var bounds = new google.maps.LatLngBounds(); |
for (var i = 0; i < stations.stats.communes; ++i) { |
var maLatLng = new google.maps.LatLng(stations.points[i].coord_x, stations.points[i].coord_y); |
var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32)); |
var point = new google.maps.Marker({ |
position: maLatLng, |
map: map, |
icon: pointImage, |
stationId: stations.points[i].id |
}); |
bounds.extend(maLatLng); |
google.maps.event.addListener(point, 'click', function() { |
pointClique = this; |
infoBulle.open(map, this); |
var limites = map.getBounds(); |
var centre = limites.getCenter(); |
var nordEst = limites.getNorthEast(); |
var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng()); |
map.panTo(centreSudLatLng); |
afficherInfoBulle(); |
chargerObs(0, 0); |
}); |
points.push(point); |
} |
if (pointsOrigine == null && boundsOrigine == null) { |
pointsOrigine = points; |
boundsOrigine = bounds; |
} |
executerMarkerClusterer(points, bounds); |
} |
function deplacerCartePointClique() { |
map.panTo(pointClique.position); |
} |
function executerMarkerClusterer(points, bounds) { |
if (markerClusterer) { |
markerClusterer.clearMarkers(); |
} |
markerClusterer = new MarkerClusterer(map, points); |
map.fitBounds(bounds); |
} |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INFO BULLE |
function initialiserInfoBulle() { |
google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle); |
google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique); |
} |
function afficherInfoBulle() { |
var obsHtml = $("#tpl-obs").html(); |
var largeur = definirLargeurInfoBulle(); |
obsHtml = obsHtml.replace(/\{largeur\}/, largeur); |
infoBulle.setContent(obsHtml); |
} |
function definirLargeurInfoBulle() { |
var largeurViewPort = $(window).width(); |
var lageurInfoBulle = null; |
if (largeurViewPort < 800) { |
largeurInfoBulle = 400; |
} else if (largeurViewPort >= 800 && largeurViewPort < 1200) { |
largeurInfoBulle = 500; |
} else if (largeurViewPort >= 1200) { |
largeurInfoBulle = 600; |
} |
return largeurInfoBulle; |
} |
function afficherMessageChargement(element) { |
if ($('#chargement').get() == '') { |
$('#tpl-chargement').tmpl().appendTo(element); |
} |
} |
function supprimerMessageChargement() { |
$('#chargement').remove(); |
} |
function chargerObs(depart, total) { |
if (depart == 0 || depart < total) { |
var limite = 300; |
if (depart == 0) { |
obsStation = new Array(); |
} |
//console.log("Chargement de "+depart+" à "+(depart+limite)); |
var urlObs = observationsUrl+'&start={start}&limit='+limite; |
urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId); |
urlObs = urlObs.replace(/\{nt\}/g, nt); |
urlObs = urlObs.replace(/\{start\}/g, depart); |
$.getJSON(urlObs, function(observations){ |
obsStation = obsStation.concat(observations.observations); |
if (depart == 0) { |
actualiserInfosStation(observations); |
actualiserPagineur(); |
creerTitreInfoBulle(); |
} |
//console.log("Chargement ok"); |
chargerObs(depart+limite, station.obsNbre); |
}); |
} else { |
if (pagineur.limite < total) { |
afficherPagination(); |
} else { |
surClicPagePagination(0, null); |
selectionnerOnglet("#obs-vue-"+pagineur.format); |
} |
} |
} |
function actualiserInfosStation(infos) { |
station.commune = infos.commune; |
station.obsNbre = infos.total; |
} |
function actualiserPagineur() { |
pagineur.stationId = pointClique.stationId; |
pagineur.total = station.obsNbre; |
//console.log("Total pagineur: "+pagineur.total); |
if (pagineur.total > 4) { |
pagineur.format = 'tableau'; |
} else { |
pagineur.format = 'liste'; |
} |
} |
function afficherPagination(observations) { |
$(".navigation").pagination(pagineur.total, { |
items_per_page:pagineur.limite, |
callback:surClicPagePagination, |
next_text:'Suivant', |
prev_text:'Précédent', |
prev_show_always:false, |
num_edge_entries:1, |
num_display_entries:4, |
load_first_page:true |
}); |
} |
function surClicPagePagination(pageIndex, paginationConteneur) { |
var index = pageIndex * pagineur.limite; |
var indexMax = index + pagineur.limite; |
pagineur.depart = index; |
obsPage = new Array(); |
for(index; index < indexMax; index++) { |
obsPage.push(obsStation[index]); |
} |
supprimerMessageChargement(); |
mettreAJourObservations(); |
return false; |
} |
function mettreAJourObservations() { |
$("#obs-"+pagineur.format+"-lignes").empty(); |
$("#obs-vue-"+pagineur.format).css('display', 'block'); |
$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart); |
$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes"); |
// Actualisation de Fancybox |
ajouterFomulaireContact("a.contact"); |
if (pagineur.format == 'liste') { |
ajouterGaleriePhoto("a.cel-img"); |
} |
} |
function creerTitreInfoBulle() { |
$("#obs-total").text(station.obsNbre); |
$("#obs-commune").text(station.commune); |
} |
function initialiserContenuInfoBulle() { |
afficherOnglets(); |
afficherMessageChargement('#observations'); |
ajouterTableauTriable("#obs-tableau"); |
afficherTextStationId(); |
corrigerLargeurInfoWindow(); |
} |
function afficherOnglets() { |
var $tabs = $('#obs').tabs(); |
$('#obs').bind('tabsselect', function(event, ui) { |
if (ui.panel.id == 'obs-vue-tableau') { |
surClicAffichageTableau(); |
} else if (ui.panel.id == 'obs-vue-liste') { |
surClicAffichageListe(); |
} |
}); |
$tabs.tabs('select', "#obs-vue-"+pagineur.format); |
} |
function selectionnerOnglet(onglet) { |
$('#obs').tabs('select', onglet); |
} |
function afficherTextStationId() { |
$('#obs-station-id').text(pointClique.stationId); |
} |
function corrigerLargeurInfoWindow() { |
$("#info-bulle").width($("#info-bulle").width() - 17); |
} |
function surClicAffichageTableau(event) { |
//console.log('tableau'); |
pagineur.format = 'tableau'; |
mettreAJourObservations(); |
mettreAJourTableauTriable("#obs-tableau"); |
} |
function surClicAffichageListe(event) { |
//console.log('liste'); |
pagineur.format = 'liste'; |
mettreAJourObservations(); |
ajouterGaleriePhoto("a.cel-img"); |
} |
function ajouterTableauTriable(element) { |
// add parser through the tablesorter addParser method |
$.tablesorter.addParser({ |
// Définition d'un id unique pour ce parsseur |
id: 'date_cel', |
is: function(s) { |
// doit retourner false si le parsseur n'est pas autodétecté |
return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s); |
}, |
format: function(date) { |
// Transformation date jj/mm/aaaa en aaaa/mm/jj |
date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1"); |
// Remplace la date par un nombre de millisecondes pour trier numériquement |
return $.tablesorter.formatFloat(new Date(date).getTime()); |
}, |
// set type, either numeric or text |
type: 'numeric' |
}); |
$(element).tablesorter({ |
headers: { |
1: { |
sorter:'date_cel' |
} |
} |
}); |
} |
function mettreAJourTableauTriable(element) { |
$(element).trigger('update'); |
} |
function ajouterGaleriePhoto(element) { |
$(element).fancybox({ |
transitionIn:'elastic', |
transitionOut:'elastic', |
speedIn :600, |
speedOut:200, |
overlayShow:true, |
titleShow:true, |
titlePosition:'inside', |
titleFormat:function (titre, currentArray, currentIndex, currentOpts) { |
var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/; |
motif.exec(titre); |
var id = RegExp.$1; |
var info = $('#cel-info-'+id).clone().html(); |
var tpl = |
'<div class="cel-legende">'+ |
'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+ |
(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+ |
'<\/div>'; |
return tpl; |
} |
}).live('click', function(e) { |
if (e.stopPropagation) { |
e.stopPropagation(); |
} |
return false; |
}); |
} |
function ajouterFomulaireContact(element) { |
$(element).fancybox({ |
transitionIn:'elastic', |
transitionOut:'elastic', |
speedIn :600, |
speedOut:200, |
scrolling: 'no', |
titleShow: false, |
onStart: function(selectedArray, selectedIndex, selectedOpts) { |
var element = selectedArray[selectedIndex]; |
var motif = / contributeur-([0-9]+)$/; |
motif.exec($(element).attr('class')); |
var id = RegExp.$1; |
//console.log('Destinataire id : '+id); |
$("#fc_destinataire_id").attr('value', id); |
var motif = / obs-([0-9]+) /; |
motif.exec($(element).attr('class')); |
var id = RegExp.$1; |
//console.log('Obs id : '+id); |
chargerInfoObsPourMessage(id); |
}, |
onCleanup: function() { |
//console.log('Avant fermeture fancybox'); |
$("#fc_destinataire_id").attr('value', ''); |
$("#fc_sujet").attr('value', ''); |
$("#fc_message").text(''); |
}, |
onClosed: function(e) { |
//console.log('Fermeture fancybox'); |
if (e.stopPropagation) { |
e.stopPropagation(); |
} |
return false; |
} |
}); |
} |
function chargerInfoObsPourMessage(idObs) { |
var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text()); |
var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text()); |
var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text()); |
var sujet = "Observation #"+idObs+" de "+nomSci; |
var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".'; |
$("#fc_sujet").attr('value', sujet); |
$("#fc_message").text(message); |
} |
function initialiserFormulaireContact() { |
//console.log('Initialisation du form contact'); |
$("#form-contact").validate({ |
rules: { |
fc_sujet : "required", |
fc_message : "required", |
fc_utilisateur_courriel : { |
required : true, |
email : true} |
} |
}); |
$("#form-contact").bind("submit", envoyerCourriel); |
$("#fc_annuler").bind("click", function() {$.fancybox.close();}); |
} |
function envoyerCourriel() { |
//console.log('Formulaire soumis'); |
if ($("#form-contact").valid()) { |
//console.log('Formulaire valide'); |
//$.fancybox.showActivity(); |
var destinataireId = $("#fc_destinataire_id").attr('value'); |
var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message" |
var erreurMsg = ""; |
var donnees = new Array(); |
$.each($(this).serializeArray(), function (index, champ) { |
var cle = champ.name; |
cle = cle.replace(/^fc_/, ''); |
if (cle == 'sujet') { |
champ.value += " - Carnet en ligne - Tela Botanica"; |
} |
if (cle == 'message') { |
champ.value += "\n--\n"+ |
"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+ |
"du Carnet en Ligne du réseau Tela Botanica.\n"+ |
"http://www.tela-botanica.org/widget:cel:carto"; |
} |
donnees[index] = {'name':cle,'value':champ.value}; |
}); |
$.ajax({ |
type : "POST", |
cache : false, |
url : urlMessage, |
data : donnees, |
beforeSend : function() { |
$(".msg").remove(); |
}, |
success : function(data) { |
$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>'); |
}, |
error : function(jqXHR, textStatus, errorThrown) { |
erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n"; |
reponse = jQuery.parseJSON(jqXHR.responseText); |
if (reponse != null) { |
$.each(reponse, function (cle, valeur) { |
erreurMsg += valeur + "\n"; |
}); |
} |
}, |
complete : function(jqXHR, textStatus) { |
var debugMsg = ''; |
if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') { |
debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data")); |
if (debugInfos != null) { |
$.each(debugInfos, function (cle, valeur) { |
debugMsg += valeur + "\n"; |
}); |
} |
} |
if (erreurMsg != '') { |
$("#fc-zone-dialogue").append('<p class="msg">'+ |
'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+ |
'Vous pouvez signaler le disfonctionnement à <a href="'+ |
'mailto:cel@tela-botanica.org'+'?'+ |
'subject=Disfonctionnement du widget de Cartographie'+ |
"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+ |
'">cel@tela-botanica.org</a>.'+ |
'</p>'); |
} |
if (DEBUG) { |
console.log('Débogage : '+debugMsg); |
} |
//console.log('Débogage : '+debugMsg); |
//console.log('Erreur : '+erreurMsg); |
} |
}); |
} |
return false; |
} |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// PANNEAU LATÉRAL |
function initialiserAffichagePanneauLateral() { |
$('#panneau-lateral').height($(window).height() - 35); |
if (nt == '*') { |
$('#pl-ouverture').bind('click', afficherPanneauLateral); |
$('#pl-fermeture').bind('click', cacherPanneauLateral); |
} |
chargerTaxons(0, 0); |
} |
function chargerTaxons(depart, total) { |
if (depart == 0 || depart < total) { |
var limite = 7000; |
//console.log("Chargement des taxons de "+depart+" à "+(depart+limite)); |
var urlTax = taxonsUrl+'&start={start}&limit='+limite; |
urlTax = urlTax.replace(/\{start\}/g, depart); |
$.getJSON(urlTax, function(infos) { |
taxonsCarte = taxonsCarte.concat(infos.taxons); |
//console.log("Nbre taxons :"+taxonsCarte.length); |
chargerTaxons(depart+limite, infos.total); |
}); |
} else { |
if (nt == '*') { |
afficherTaxons(); |
} else { |
afficherNomPlante(); |
} |
} |
} |
function afficherTaxons() { |
// Ajout du nombre de plantes au titre |
$('.plantes-nbre').text(taxonsCarte.length.formaterNombre()); |
$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps"); |
$('.taxon').live('click', filtrerParTaxon); |
} |
function afficherNomPlante() { |
if (nt != '*') { |
var taxon = taxonsCarte[0]; |
$('.plante-titre').text('pour '+taxon.nom); |
} |
} |
function afficherPanneauLateral() { |
$('#panneau-lateral').width(300); |
$('#pl-contenu').css('display', 'block'); |
$('#pl-ouverture').css('display', 'none'); |
$('#pl-fermeture').css('display', 'block'); |
$('#carte').css('left', '300px'); |
google.maps.event.trigger(map, 'resize'); |
}; |
function cacherPanneauLateral() { |
$('#panneau-lateral').width(24); |
$('#pl-contenu').css('display', 'none'); |
$('#pl-ouverture').css('display', 'block'); |
$('#pl-fermeture').css('display', 'none'); |
$('#carte').css('left', '24px'); |
google.maps.event.trigger(map, 'resize'); |
}; |
function ouvrirPopUp(url, nom) { |
window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no'); |
}; |
function filtrerParTaxon() { |
var ntAFiltrer = $('.nt', this).text(); |
infoBulle.close(); |
$('#taxon-'+nt).removeClass('taxon-actif'); |
if (nt == ntAFiltrer) { |
nt = '*'; |
executerMarkerClusterer(pointsOrigine, boundsOrigine); |
} else { |
var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+ |
'&formatRetour=jsonP'+ |
'&callback=?'; |
$.getJSON(url, function (stationsFiltrees) { |
stations = stationsFiltrees; |
nt = ntAFiltrer; |
$('#taxon-'+nt).addClass('taxon-actif'); |
rafraichirCarte(); |
}); |
} |
}; |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// FONCTIONS UTILITAIRES |
function arreter(event) { |
if (event.stopPropagation) { |
event.stopPropagation(); |
} else if (window.event) { |
window.event.cancelBubble = true; |
} |
return false; |
} |
/** |
* +-------------------------------------+ |
* Number.prototype.formaterNombre |
* +-------------------------------------+ |
* Params (facultatifs): |
* - Int decimales: nombre de decimales (exemple: 2) |
* - String signe: le signe precedent les decimales (exemple: "," ou ".") |
* - String separateurMilliers: comme son nom l'indique |
* Returns: |
* - String chaine formatee |
* @author ::mastahbenus:: |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant |
* @souce http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx |
*/ |
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) { |
var _sNombre = String(this), i, _sRetour = "", _sDecimales = ""; |
function is_int(nbre) { |
nbre = nbre.replace(',', '.'); |
return !(parseFloat(nbre)-parseInt(nbre) > 0); |
} |
if (decimales == undefined) { |
if (is_int(_sNombre)) { |
decimales = 0; |
} else { |
decimales = 2; |
} |
} |
if (signe == undefined) { |
if (is_int(_sNombre)) { |
signe = ''; |
} else { |
signe = '.'; |
} |
} |
if (separateurMilliers == undefined) { |
separateurMilliers = ' '; |
} |
function separeMilliers (sNombre) { |
var sRetour = ""; |
while (sNombre.length % 3 != 0) { |
sNombre = "0"+sNombre; |
} |
for (i = 0; i < sNombre.length; i += 3) { |
if (i == sNombre.length-1) separateurMilliers = ''; |
sRetour += sNombre.substr(i, 3) + separateurMilliers; |
} |
while (sRetour.substr(0, 1) == "0") { |
sRetour = sRetour.substr(1); |
} |
return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers)); |
} |
if (_sNombre.indexOf('.') == -1) { |
for (i = 0; i < decimales; i++) { |
_sDecimales += "0"; |
} |
_sRetour = separeMilliers(_sNombre) + signe + _sDecimales; |
} else { |
var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1)); |
if (sDecimalesTmp.length > decimales) { |
var nDecimalesManquantes = sDecimalesTmp.length - decimales; |
var nDiv = 1; |
for (i = 0; i < nDecimalesManquantes; i++) { |
nDiv *= 10; |
} |
_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv); |
} |
_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales; |
} |
return _sRetour; |
} |
function debug(objet) { |
var msg = ''; |
if (objet != null) { |
$.each(objet, function (cle, valeur) { |
msg += cle+":"+valeur + "\n"; |
}); |
} else { |
msg = "La variable vaut null."; |
} |
console.log(msg); |
} |
function trim (chaine) { |
return chaine.replace(/^\s+/g, '').replace(/\s+$/g, ''); |
} |