Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1617 → Rev 1622

/trunk/jrest/services/CelWidgetMap.php
135,7 → 135,7
$requete = 'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, '.
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
' utm_secteur, utm_x, utm_y, id_zone_geo, date_transmission '.
' utm_secteur, utm_x, utm_y, id_zone_geo, date_transmission, nom_referentiel '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
" ON (l.id_zone_geo = co.ce_zone_geo) ".
180,7 → 180,8
$observation['lieu'] = $this->traiterLieu($donnee);
$observation['observateur'] = $donnee->courriel_utilisateur;
$observation['observateurId'] = $donnee->ce_utilisateur;
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_sel_nn);
$observation['referentiel'] = $this->supprimerVersionDuReferentiel($donnee->nom_referentiel);
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_referentiel, $donnee->nom_sel_nn);
if (isset($donnee->zone_geo)) {
$observations['commune'] = $this->nettoyerTexte($donnee->zone_geo);
194,14 → 195,6
return $observations;
}
private function getUrlEflore($nn) {
$urlEflore = null;
if (! $this->etreNull($nn)) {
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
}
return $urlEflore;
}
private function traiterLieu($donnee) {
$lieu = array();
if (!$this->etreNull($donnee->lieudit)) {
/trunk/jrest/services/CelSyndicationImage.php
238,7 → 238,7
$donnees['guid'] = $this->getUrlServiceBase();
$donnees['lien_service'] = $this->creerUrlService();
$donnees['lien_cel'] = (isset($infos['nom_sel_nn']) && $infos['nom_sel_nn'] != '' && $infos['nom_sel_nn'] != 0) ?
sprintf($this->config['settings']['efloreUrlTpl'], $infos['nom_sel_nn'], 'illustration') : '';
$this->getUrlEflore($infos['nom_referentiel'], $infos['nom_sel_nn']) : '';
$donnees['editeur'] = $this->config['settings']['editeur'];
$derniere_info_en_date = reset($infos);
$date_modification_timestamp = strtotime($derniere_info_en_date['date_creation']);
296,7 → 296,7
$lien = $this->getUrlImage($element['id_image'], $this->format_image);
} else {
// Lien vers fiche eFlore onglet Illustration
$lien = sprintf($this->config['settings']['efloreUrlTpl'], $element['nom_sel_nn'], 'illustration');
$lien = $this->getUrlEflore($element['nom_referentiel'], $element['nom_sel_nn'], 'illustration');
}
return $lien;
}
332,7 → 332,7
// Construction de la requête
$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
' cim.id_image, cim.ce_utilisateur, nom_original, cim.date_creation, cim.mots_cles_texte as mots_cles_texte_images,
ci.mots_cles_texte as mots_cles_texte_images_obs, cim.commentaire, note_qualite '.
ci.mots_cles_texte as mots_cles_texte_images_obs, cim.commentaire, note_qualite, nom_referentiel '.
'FROM cel_obs_images AS coi '.
'LEFT JOIN cel_obs AS ci '.
'ON (coi.id_observation = ci.id_observation) '.
362,7 → 362,7
}
 
private function creerDescriptionSimple($donnees, $item) {
$description = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($donnees['nom_sel_nn']), 'illustration');
$description = $this->getUrlEflore($element['nom_referentiel'], $element['nom_sel_nn'], 'illustration');
return $description;
}
 
371,7 → 371,7
// Construction de la requête
$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
' cim.id_image, ci.ce_utilisateur, nom_original, cim.date_creation, cim.mots_cles_texte as mots_cles_texte_images, '.
' ci.mots_cles_texte as mots_cles_texte_obs, cim.commentaire as commentaire_img, note_qualite, '.
' ci.mots_cles_texte as mots_cles_texte_obs, cim.commentaire as commentaire_img, note_qualite, nom_referentiel, '.
' ci.commentaire as commentaire_obs '.
'FROM cel_images AS cim '.
' LEFT JOIN cel_obs_images AS coi '.
438,7 → 438,7
 
// Construction de la requête
$requete = 'SELECT *, b.mots_cles_texte as mots_cles_texte_obs, c.mots_cles_texte as mots_cles_texte_images, '.
' b.commentaire as commentaire_obs, c.commentaire as commentaire_img '.
' b.commentaire as commentaire_obs, c.commentaire as commentaire_img, nom_referentiel '.
'FROM ('.$sous_requete.') as c '.
' INNER JOIN cel_obs_images AS a '.
' ON (a.id_image = c.id_image) '.
451,7 → 451,7
private function creerRequeteAvecParametres() {
// Construction de la requête
$requete = 'SELECT *, b.mots_cles_texte as mots_cles_texte_obs, c.mots_cles_texte as mots_cles_texte_images, '.
' b.commentaire as commentaire_obs, c.commentaire as commentaire_img '.
' b.commentaire as commentaire_obs, c.commentaire as commentaire_img, nom_referentiel '.
'FROM cel_obs_images AS a '.
' INNER JOIN cel_obs AS b '.
' ON (a.id_observation = b.id_observation) '.
/trunk/jrest/services/CelWidgetMapPoint.php
90,38 → 90,43
}
 
public function getTout($params) {
$emplacements = null;
 
$emplacements = null;
$concatenation_id = "CONCAT(IFNULL(latitude,''),IFNULL(longitude,''), IFNULL(wgs84_latitude,''),IFNULL(wgs84_longitude,'')) ";
 
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
' mots_cles_texte, latitude, wgs84_latitude, longitude, wgs84_longitude, '.
" $concatenation_id AS id_coord ".
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
' GROUP BY id_coord';
 
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
"mots_cles_texte, ".
"latitude, ".
"wgs84_latitude, ".
"longitude, ".
"wgs84_longitude, ".
$concatenation_id." as id_coord ".
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
' GROUP BY id_coord';
$resultats_emplacements = $this->executerRequete($requete);
$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
return $emplacements;
}
 
private function afficherRequeteFormatee($requete) {
$requete = str_replace(')',')<br />',$requete);
$requete = str_replace('(',' <br /> (',$requete);
133,25 → 138,25
 
private function compterObservations($params) {
$requete = 'SELECT COUNT(*) as nb '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours();
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours();
 
$resultats_nb_obs = $this->executerRequete($requete);
return $resultats_nb_obs[0]['nb'];
244,7 → 249,7
if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
$ne = $this->decomposerLatLng($this->parametres['ne']);
$sw = $this->decomposerLatLng($this->parametres['sw']);
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
} else {
$marqueurs['points'] = $points;
}
299,14 → 304,14
}
return $sensible;
}
 
private function communeEstDemandee() {
$station_infos = $this->decomposerParametreStation();
$commune_demandee = true;
if ($station_infos['type'] == self::MARQUEUR_STATION) {
$station_infos = $this->decomposerParametreStation();
$commune_demandee = true;
if($station_infos['type'] == self::MARQUEUR_STATION) {
$commune_demandee = false;
}
return $commune_demandee;
}
return $commune_demandee;
}
 
/**
317,27 → 322,27
$total = 0;
if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
$requete = 'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, nom_utilisateur, prenom_utilisateur, '.
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
' utm_secteur, utm_x, utm_y, code, date_transmission '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
" ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) ".
"WHERE transmission = '1' ".
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
$this->construireWhereDept().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_sel ASC '.
"LIMIT {$this->start},{$this->limit} ";
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
' utm_secteur, utm_x, utm_y, code, date_transmission, nom_referentiel '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
" ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) ".
"WHERE transmission = '1' ".
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
$this->construireWhereDept().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_sel ASC '.
"LIMIT {$this->start},{$this->limit} ";
//echo $requete;exit;
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
$requete = 'SELECT FOUND_ROWS()';
368,7 → 373,7
$observation['lieu'] = $this->traiterLieu($donnee);
$observation['observateur'] = $donnee->courriel_utilisateur;
$observation['observateurId'] = $donnee->ce_utilisateur;
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_sel_nn);
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_referentiel, $donnee->nom_sel_nn);
 
if (isset($donnee->zone_geo)) {
$observations['commune'] = $this->nettoyerTexte($donnee->zone_geo);
383,14 → 388,6
return $observations;
}
 
private function getUrlEflore($nn) {
$urlEflore = null;
if (! $this->etreNull($nn)) {
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
}
return $urlEflore;
}
 
private function traiterLieu($donnee) {
$lieu = array();
if (!$this->etreNull($donnee->lieudit)) {
441,7 → 438,7
}
return $observations;
}
 
private function ajouterAuteursAuxObs($observations) {
$observateurs = $this->recupererUtilisateursIdentite(array_keys($observations['observateurs']));
unset($observations['observateurs']);
473,25 → 470,25
$json = null;
 
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, nom_ret_nn, nt, famille '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND nom_ret != '' ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxon().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_ret ASC '.
"LIMIT {$this->start},{$this->limit} ";
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND nom_ret != '' ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxon().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_ret ASC '.
"LIMIT {$this->start},{$this->limit} ";
//$this->debug[] = $requete;
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
//echo $requete;exit;
539,7 → 536,7
}
return $sql;
}
 
private function construireWhereCoordonneesSansSensibles() {
$sql = '(';
// Récupération des coordonnées depuis l'id station
613,7 → 610,7
}
return $sql;
}
 
private function construireWhereReferentiel() {
$sql = '';
extract($this->parametres);
832,12 → 829,12
$sql = "( (latitude != 0 AND longitude != 0) ".
" AND latitude BETWEEN $latMin AND $latMax ".
" AND longitude BETWEEN $lngMin AND $lngMax )";
 
/*$sql = " MBRWithin(mon_point, GeomFromText('POLYGON((".$latMin.' '.$lngMin.','.
$latMax.' '.$lngMin.','.
$latMax.' '.$lngMax.','.
$latMax.' '.$lngMin.','.
$latMin.' '.$lngMin."))')) "; */
$latMin.' '.$lngMin."))')) "; */
}
return $sql;
}
876,7 → 873,7
$sql = "( wgs84_longitude != 0 AND wgs84_latitude != 0 ".
" AND wgs84_latitude BETWEEN $latMin AND $latMax ".
" AND wgs84_longitude BETWEEN $lngMin AND $lngMax )";
 
/*$sql = " MBRWithin(point_commune, GeomFromText('POLYGON((".$latMin.' '.$lngMin.','.
$latMax.' '.$lngMin.','.
$latMax.' '.$lngMax.','.
926,12 → 923,12
')'.
' OR mots_cles_texte LIKE "%sensible%"'.
') ';
 
}
return $sql;
}
 
 
private function construireWherePhotosSeulement() {
$sql = '';
if (isset($this->parametres['photos']) && $this->parametres['photos'] == 1) {
951,8 → 948,8
}
return $sql;
}
 
 
private function construireWhereNumTaxon() {
$sql = '';
// Récupération des coordonnées depuis l'id station
963,7 → 960,7
}
return $sql;
}
 
private function construireWhereNumTaxonAvecSousTaxons() {
$sql = '';
// Récupération des coordonnées depuis l'id station
984,7 → 981,7
}
return $sql;
}
 
private function obtenirSousTaxons($nt) {
$referentiel = 'bdtfx';
if($this->parametres['referentiel'] && $this->parametres['referentiel'] != "" && $this->parametres['referentiel'] != '*') {
1008,7 → 1005,7
}
return $sql;
}
 
/**
* Traitement de $projet pour construction du filtre dans la requête
*/
1019,7 → 1016,7
}
return $sql;
}
 
private function construireWhereTag() {
$sql = '';
extract($this->parametres);
1029,7 → 1026,7
}
return $sql;
}
 
private function construireWhereNombreDeJours() {
$sql = null;
extract($this->parametres);
1038,7 → 1035,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1067,10 → 1064,10
//$this->debug[] = $requete;
//die($requete);
$elements_tag = $this->executerRequete($requete);
 
$requete_tag = array();
if ($elements_tag != false && count($elements_tag) > 0) {
 
$filtres = array();
foreach ($elements_tag as $occurence) {
$utilisateur = $occurence['utilisateur'];
1082,13 → 1079,13
$filtres[$utilisateur][$id_obs] = $id_obs;
}
}
 
// Pré-construction du where de la requête
$tpl_where = "(id_observation IN (%s))";
foreach ($filtres as $utilisateur => $id_obs) {
$requete_tag[] = sprintf($tpl_where, implode(',', $id_obs));
}
 
} else {
$this->messages[] = "Aucune observation ne possède d'images avec ce mot-clé.";
}
1098,7 → 1095,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1110,7 → 1107,7
//$this->debug[] = $sql;
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1122,9 → 1119,9
$where_mots_cles_images = implode(' '.$mots_cles_encodes['type'].' ', $where_mots_cles_images);
return $where_mots_cles_images;
}
 
private function decomposerParametreTag($tags) {
 
$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
if (preg_match('/.+OU.+/', $tags)) {
$mots_cles['type'] = 'OR';
1135,7 → 1132,7
} else {
$mots_cles['motsCles'][] = $tags;
}
 
foreach ($mots_cles['motsCles'] as $mot) {
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote('%'.$mot.'%');
}
/trunk/jrest/services/CelSyndicationObservation.php
490,7 → 490,7
private function creerLienItem($element) {
$lien = null;
if ($element['nom_sel_nn'] != 0) {
$lien = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($element['nom_sel_nn']), 'cel');
$lien = $this->getUrlEflore($element['nom_referentiel'], $element['nom_sel_nn'], 'cel');
}
return $lien;
}