Subversion Repositories Sites.obs-saisons.fr

Compare Revisions

No changes between revisions

Ignore whitespace Rev 206 → Rev 207

/trunk/applications/jrest/jrest.ini.php
1,6 → 1,22
;<?/*
[settings]
baseURL = "/obs_saisons/applications/jrest/"
; URL de base absolue du Jrest ODS
baseURLAbsolu = "http://www.obs-saisons.fr/redesign/applications/jrest/"
; URL de base absolue du Jrest du ODS construit dynamiquement
baseURLAbsoluDyn = "http://www.obs-saisons.fr/redesign/applications/jrest/%s"
; Url absolue du CEL
odsSaisieUrlAbsolu = "http://www.obs-saisons.fr/redesign/node/15"
; Indication du nom de l'éditeur pour les flux de syndication
editeur = "Observatoire des saisons"
; Format du Guid du CEL pour les flux de syndication principalement
guidObsTpl = "urn:lsid:obs-saisons.fr:saisie:%s"
;Format du Guid des images pour les flux de syndication
guidImgTpl = "%s"
; Indication de la locale (setLocale(LC_ALL, ?)) pour les classes héritant
locale = "fr_FR.UTF-8"
; Indication du fuseau horraire par d�faut date_default_timezone_set(?)pour les classes héritant
fuseauHoraire = "Europe/Paris"
 
; Default
[appli]
9,6 → 25,19
password = Canard
hostspec = localhost
database = ods_saisie
format_date = d/m/Y
locale = fr_FR
chemin_fichiers_temp = /home/aurelien/web/file_tmp
id_participant_demo = 4
 
format_M = 400_300
format_S = 150_100
format_XS = 75_50
format_CXS = 60_60
taille_max = 2097152
couleur_fond_carre = CFCFCF
chemin_stockage_images_especes = /opt/lampp/htdocs/obs_saisons/documents/images_especes
 
; LOGS
[log]
cheminlog = "/home/aurelien/Logs/"
/trunk/applications/jrest/services/GestionTriple.php
File deleted
\ No newline at end of file
/trunk/applications/jrest/services/OdsEspece.php
165,6 → 165,24
return $especes_par_type;
}
public function getToutesEspeces() {
$requete_toute_espece = 'SELECT * FROM ods_especes';
$liste_espece = $this->executerRequete($requete_toute_espece);
$liste_type_espece = $this->obtenirValeursListeParAbreviation(self::ABBR_LISTE_TYPE_ESPECE);
$especes_par_id = array();
foreach($liste_espece as $espece) {
$espece = $this->formaterTableauEspecePourEnvoi($espece);
$especes_par_id[$espece['id_espece']] = $espece;
}
return $especes_par_id;
}
private function formaterTableauEspecePourEnvoi($espece) {
return array(
/trunk/applications/jrest/services/Utilisateur.php
New file
0,0 → 1,38
<?php
class Utilisateur {
public function getIdentifiantNumerique() {
return $GLOBALS['user']->uid;
}
public function getEmail() {
return $GLOBALS['user']->mail;
}
public function getNom() {
return $GLOBALS['user']->name;
}
public function getPrenom() {
return '';
}
public function estAdmin() {
return in_array('3',array_keys($GLOBALS['user']->roles));
}
public function estIdentifie() {
return user_is_logged_in();
}
public function getFormulaireIdentification() {
return drupal_get_form('user_login_block');
}
public function getFormulaireInscription() {
return drupal_get_form('user_register');
}
}
?>
/trunk/applications/jrest/services/OdsUtilisateur.php
New file
0,0 → 1,18
<?php
 
class OdsUtilisateur extends JRestService {
/**
* Méthode appelée avec une requête de type GET.
*
*/
function getElement($param = array()) {
$chaine_utilisateur = $param[0];
// Envoi sur la sortie standard
$this->envoyer($info);
}
}
 
?>
/trunk/applications/jrest/services/OdsExport.php
New file
0,0 → 1,267
<?php
 
class OdsExport extends OdsTriple {
const PREFIXE = 'get';
const ABBR_LISTE_EVENEMENTS = 'evenement';
const ABBR_LISTE_ESPECES = 'espece';
/**
* Méthodes d'extractions d'informations
*/
/**
* Méthode appelée avec une requête de type GET.
*
*/
function getElement($param = array()) {
$type = $param[0];
if ($type == '*' || is_numeric($type)) {
$info = $this->getElementParDefaut($param);
} else {
$methode = self::PREFIXE.$type;
if (method_exists($this, $methode)) {
array_shift($param);
$info = $this->$methode($param);
} else {
$this->messages[] = "Le type d'information demandé '$type' n'est pas disponible.";
}
}
// Envoi sur la sortie standard
$this->envoyer($info);
}
public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') {
$requete_selection_observations = 'SELECT * FROM ods_observations '.
' LEFT JOIN ods_individus '.
' ON oi_id_individu = oo_ce_individu'.
' LEFT JOIN ods_stations '.
' ON oi_ce_station = os_id_station ';
$requete_selection_observations .= $this->construireConditionRequete();
$requete_selection_observations .= ' ORDER BY oo_date DESC';
$res_selection_observations = $this->executerRequete($requete_selection_observations);
return $res_selection_observations;
}
public function construireConditionRequete() {
$condition = ' WHERE oo_date != "0000-00-00" AND ';
foreach($_GET as $cle => $valeur) {
switch($cle) {
case 'type_espece':
$condition .= 'oi_ce_espece IN (SELECT oe_id_espece FROM ods_especes WHERE oe_ce_type = '.$this->proteger($valeur).')';
break;
case 'annee':
$condition .= 'YEAR(oo_date) = '.$this->proteger($valeur);
break;
case 'mois':
$condition .= 'MONTH(oo_date) <= '.$this->proteger($valeur);
break;
case 'espece':
$condition .= 'oi_ce_espece = '.$this->proteger($valeur);
break;
case 'evenement':
$condition .= 'oo_ce_evenement = '.$this->proteger($valeur);
break;
case 'departement':
$condition .= 'os_ce_commune LIKE "'.$valeur.'%" ';
break;
case 'utilisateur':
$condition .= 'oo_ce_participant = '.$this->proteger($valeur);
break;
default:
break;
}
$condition .= ' AND ';
}
$condition = rtrim($condition,'AND ');
$condition .= ' AND oo_ce_participant != 4';
return $condition;
}
public function getExportObservationJson() {
$donnees = $this->getExportObservation();
$donnees_formatees = $this->formaterPourExportJson($donnees);
return $donnees_formatees;
}
public function formaterPourExportJson($tableau_observations_infos) {
$gestionnaire_especes = new OdsEspece($this->config);
$gestionnaire_communes = new OdsCommune($this->config);
$especes = $gestionnaire_especes->getToutesEspeces();
$evenements = $this->obtenirValeursListeParAbreviation(self::ABBR_LISTE_EVENEMENTS);
$resultats_formates = array();
foreach($tableau_observations_infos as $observations_infos) {
$id_espece = $observations_infos['oi_ce_espece'];
$nom_espece = $especes[$id_espece]['nom_scientifique'];
$id_evenement = $observations_infos['oo_ce_evenement'];
$chaine_evenement = $evenements[$id_evenement]['ot_cle'];
$infos_evenement = $this->renvoyerInformationStadeAPartirChaineTriple($chaine_evenement);
$date_observation_formatee = date($this->config['appli']['format_date'], strtotime($observations_infos['oo_date']));
$id_observation = $observations_infos['oo_id_observation'];
$infos_formatees = array(
'date' => $date_observation_formatee,
'evenenement' => $infos_evenement['nom'],
'code_bbch' => $infos_evenement['numero'],
'nom_scientifique' => $nom_espece,
);
$id_station = $observations_infos['oi_ce_station'];
if(!isset($resultats_formates[$id_station])) {
$resultats_formates[$id_station]['station'] = $observations_infos['os_nom'];
$resultats_formates[$id_station]['code_commune'] = $observations_infos['os_ce_commune'];
//$resultats_formates[$id_station]['nom_commune'] = $gestionnaire_communes->obtenirNomCommuneParCodeInsee($observations_infos['os_ce_commune']);
$resultats_formates[$id_station]['latitude'] = $observations_infos['os_latitude'];
$resultats_formates[$id_station]['longitude'] = $observations_infos['os_longitude'];
$resultats_formates[$id_station]['altitude'] = $observations_infos['os_altitude'];
$resultats_formates[$id_station]['milieu'] = $observations_infos['os_milieu'];
$resultats_formates[$id_station]['participant'] = $observations_infos['os_ce_participant'];
}
$resultats_formates[$id_station]['obs'][$id_observation] = $infos_formatees;
}
return $resultats_formates;
}
public function getExportObservationCsv() {
$utilisateur = new Utilisateur();
$est_admin = $utilisateur->estAdmin();
if($est_admin) {
$donnees = $this->getExportObservation();
$donnees_formatees = $this->formaterPourExportCSV($donnees);
$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees);
$this->envoyerFichier($chaine_csv);
} else {
echo "echo non non non non non, vous êtes pas admin !!!!";
}
}
public function formaterPourExportCSV($tableau_observations_infos) {
$gestionnaire_especes = new OdsEspece($this->config);
$gestionnaire_communes = new OdsCommune($this->config);
$especes = $gestionnaire_especes->getToutesEspeces();
$evenements = $this->obtenirValeursListeParAbreviation(self::ABBR_LISTE_EVENEMENTS);
$resultats_formates = array();
foreach($tableau_observations_infos as $observations_infos) {
$id_espece = $observations_infos['oi_ce_espece'];
$nom_espece = $especes[$id_espece]['nom_scientifique'];
$id_evenement = $observations_infos['oo_ce_evenement'];
$chaine_evenement = $evenements[$id_evenement]['ot_cle'];
$infos_evenement = $this->renvoyerInformationStadeAPartirChaineTriple($chaine_evenement);
$date_observation_formatee = date($this->config['appli']['format_date'], strtotime($observations_infos['oo_date']));
$id_observation = $observations_infos['oo_id_observation'];
$infos_formatees = array(
'id_observation' => $id_observation,
'date' => $date_observation_formatee,
'evenenement' => $infos_evenement['nom'],
'code_bbch' => $infos_evenement['numero'],
'nom_scientifique' => $nom_espece,
'station' => $observations_infos['os_nom'],
'code_commune' => $observations_infos['os_ce_commune'],
'nom_commune' => $gestionnaire_communes->obtenirNomCommuneParCodeInsee($observations_infos['os_ce_commune']),
'latitude' => $observations_infos['os_latitude'],
'longitude' => $observations_infos['os_longitude'],
'altitude' => $observations_infos['os_altitude'],
'milieu' => $observations_infos['os_milieu'],
'participant' => $observations_infos['os_ce_participant']
);
$resultats_formates[] = $infos_formatees;
}
return $resultats_formates;
}
public function convertirTableauAssocVersCSV($tableau) {
$csv = '';
$colonnes = array_keys($tableau[0]);
$csv .= implode(';',$colonnes).";\n";
foreach($tableau as $elements) {
$csv .= implode(';',$elements).";\n";
}
return $csv;
}
public function envoyerFichier($contenu) {
$nom_fichier = "observations_export.csv";
$chemin_fichier = $this->config['appli']['chemin_fichiers_temp'].'/'.$nom_fichier;
file_put_contents($chemin_fichier, $contenu);
$contenu = file_get_contents($chemin_fichier);
$taille_fichier = filesize($chemin_fichier);
unlink($chemin_fichier);
ini_set('zlib.output_compression','Off');
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Content-Tranfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$nom_fichier.'"');
header('Content-Disposition: attachement; filename="'.$nom_fichier.'"');
header('Content-Length: '.$taille_fichier);
echo $contenu;
exit();
}
private function formaterInformationPourEnvoi($tableauinfos) {
 
}
}
?>
/trunk/applications/jrest/services/OdsEvenement.php
72,6 → 72,18
private function getElementParDefaut($param) {
}
private function getTousEvenements($params) {
 
$requete_liste_evenements_pour_espece = 'SELECT * FROM ods_triples '.
'WHERE ot_ce_parent = 12';
$liste_evenements_pour_espece = $this->executerRequete($requete_liste_evenements_pour_espece);
$liste_evenements_pour_espece_formatee = $this->formaterTableauEvenementPourEnvoiParId($liste_evenements_pour_espece);
return $liste_evenements_pour_espece_formatee;
}
private function getEvenementsPourEspece($params) {
101,6 → 113,30
return $liste_evenements_pour_espece_formatee;
}
private function formaterTableauEvenementPourEnvoiParId($liste_evenements) {
$tableau_evenements_formate = array();
foreach($liste_evenements as $evenement) {
$identifiant_stade = $evenement['ot_id_triple'];
$stade_observation_complet = $evenement['ot_cle'];
$infos_stades = $this->renvoyerInformationStadeAPartirChaineTriple($stade_observation_complet);
$titre_stade = $infos_stades['nom'];
$numero_stade = $infos_stades['numero'];
$abreviation_stade = $infos_stades['abreviation'];
$tableau_evenements_formate[$identifiant_stade]['code'] = $numero_stade;
$tableau_evenements_formate[$identifiant_stade]['nom'] = $titre_stade;
}
return $tableau_evenements_formate;
}
private function formaterTableauEvenementPourEnvoi($liste_evenements) {
$tableau_evenements_formate = array();
/trunk/applications/jrest/services/gPoint.php
New file
0,0 → 1,534
<?php
/*------------------------------------------------------------------------------
** File: gPoint.php
** Description: PHP class to convert Latitude & Longitude coordinates into
** UTM & Lambert Conic Conformal Northing/Easting coordinates.
** Version: 1.3
** Author: Brenor Brophy
** Email: brenor dot brophy at gmail dot com
** Homepage: brenorbrophy.com
**------------------------------------------------------------------------------
** COPYRIGHT (c) 2005, 2006, 2007, 2008 BRENOR BROPHY
**
** The source code included in this package is free software; you can
** redistribute it and/or modify it under the terms of the GNU General Public
** License as published by the Free Software Foundation. This license can be
** read at:
**
** http://www.opensource.org/licenses/gpl-license.php
**
** This program is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**------------------------------------------------------------------------------
**
** Code for datum and UTM conversion was converted from C++ code written by
** Chuck Gantz (chuck dot gantz at globalstar dot com) from
** http://www.gpsy.com/gpsinfo/geotoutm/ This URL has many other references to
** useful information concerning conversion of coordinates.
**
** Rev History
** -----------------------------------------------------------------------------
** 1.0 08/25/2005 Initial Release
** 1.1 05/15/2006 Added software license language to header comments
** Fixed an error in the convertTMtoLL() method. The latitude
** calculation had a bunch of variables without $ symbols.
** Fixed an error in convertLLtoTM() method, The $this-> was
** missing in front of a couple of variables. Thanks to Bob
** Robins of Maryland for catching the bugs.
** 1.2 05/18/2007 Added default of NULL to $LongOrigin arguement in convertTMtoLL()
** and convertLLtoTM() to eliminate warning messages when the
** methods are called without a value for $LongOrigin.
** 1.3 02/21/2008 Fixed a bug in the distanceFrom method, where the input parameters
** were not being converted to radians prior to calculating the
** distance. Thanks to Enrico Benco for finding pointing it out.
*/
define ("meter2nm", (1/1852));
define ("nm2meter", 1852);
 
/*------------------------------------------------------------------------------
** class gPoint ... for Geographic Point
**
** This class encapsulates the methods for representing a geographic point on the
** earth in three different coordinate systema. Lat/Long, UTM and Lambert Conic
** Conformal.
*/
class gPoint
{
/* Reference ellipsoids derived from Peter H. Dana's website-
** http://www.colorado.edu/geography/gcraft/notes/datum/datum_f.html
** email: pdana@pdana.com, web page: www.pdana.com
**
** Source:
** Defense Mapping Agency. 1987b. DMA Technical Report: Supplement to Department
** of Defense World Geodetic System 1984 Technical Report. Part I and II.
** Washington, DC: Defense Mapping Agency
*/
var $ellipsoid = array(//Ellipsoid name, Equatorial Radius, square of eccentricity
"Airy" =>array (6377563, 0.00667054),
"Australian National" =>array (6378160, 0.006694542),
"Bessel 1841" =>array (6377397, 0.006674372),
"Bessel 1841 Nambia" =>array (6377484, 0.006674372),
"Clarke 1866" =>array (6378206, 0.006768658),
"Clarke 1880" =>array (6378249, 0.006803511),
"Everest" =>array (6377276, 0.006637847),
"Fischer 1960 Mercury" =>array (6378166, 0.006693422),
"Fischer 1968" =>array (6378150, 0.006693422),
"GRS 1967" =>array (6378160, 0.006694605),
"GRS 1980" =>array (6378137, 0.00669438),
"Helmert 1906" =>array (6378200, 0.006693422),
"Hough" =>array (6378270, 0.00672267),
"International" =>array (6378388, 0.00672267),
"Krassovsky" =>array (6378245, 0.006693422),
"Modified Airy" =>array (6377340, 0.00667054),
"Modified Everest" =>array (6377304, 0.006637847),
"Modified Fischer 1960" =>array (6378155, 0.006693422),
"South American 1969" =>array (6378160, 0.006694542),
"WGS 60" =>array (6378165, 0.006693422),
"WGS 66" =>array (6378145, 0.006694542),
"WGS 72" =>array (6378135, 0.006694318),
"WGS 84" =>array (6378137, 0.00669438));
 
// Properties
var $a; // Equatorial Radius
var $e2; // Square of eccentricity
var $datum; // Selected datum
var $Xp, $Yp; // X,Y pixel location
var $lat, $long; // Latitude & Longitude of the point
var $utmNorthing, $utmEasting, $utmZone; // UTM Coordinates of the point
var $lccNorthing, $lccEasting; // Lambert coordinates of the point
var $falseNorthing, $falseEasting; // Origin coordinates for Lambert Projection
var $latOfOrigin; // For Lambert Projection
var $longOfOrigin; // For Lambert Projection
var $firstStdParallel; // For lambert Projection
var $secondStdParallel; // For lambert Projection
 
// constructor
function gPoint($datum='WGS 84') // Default datum is WGS 84
{
$this->a = $this->ellipsoid[$datum][0]; // Set datum Equatorial Radius
$this->e2 = $this->ellipsoid[$datum][1]; // Set datum Square of eccentricity
$this->datum = $datum; // Save the datum
}
//
// Set/Get X & Y pixel of the point (used if it is being drawn on an image)
//
function setXY($x, $y)
{
$this->Xp = $x; $this->Yp = $y;
}
function Xp() { return $this->Xp; }
function Yp() { return $this->Yp; }
//
// Set/Get/Output Longitude & Latitude of the point
//
function setLongLat($long, $lat)
{
$this->long = $long; $this->lat = $lat;
}
function Lat() { return $this->lat; }
function Long() { return $this->long; }
function printLatLong() { printf("Latitude: %1.5f Longitude: %1.5f",$this->lat, $this->long); }
//
// Set/Get/Output Universal Transverse Mercator Coordinates
//
function setUTM($easting, $northing, $zone='') // Zone is optional
{
$this->utmNorthing = $northing;
$this->utmEasting = $easting;
$this->utmZone = $zone;
}
function N() { return $this->utmNorthing; }
function E() { return $this->utmEasting; }
function Z() { return $this->utmZone; }
function printUTM() { print( "Northing: ".(int)$this->utmNorthing.", Easting: ".(int)$this->utmEasting.", Zone: ".$this->utmZone); }
//
// Set/Get/Output Lambert Conic Conformal Coordinates
//
function setLambert($easting, $northing)
{
$this->lccNorthing = $northing;
$this->lccEasting = $easting;
}
function lccN() { return $this->lccNorthing; }
function lccE() { return $this->lccEasting; }
function printLambert() { print( "Northing: ".(int)$this->lccNorthing.", Easting: ".(int)$this->lccEasting); }
 
//------------------------------------------------------------------------------
//
// Convert Longitude/Latitude to UTM
//
// Equations from USGS Bulletin 1532
// East Longitudes are positive, West longitudes are negative.
// North latitudes are positive, South latitudes are negative
// Lat and Long are in decimal degrees
// Written by Chuck Gantz- chuck dot gantz at globalstar dot com, converted to PHP by
// Brenor Brophy, brenor dot brophy at gmail dot com
//
// UTM coordinates are useful when dealing with paper maps. Basically the
// map will can cover a single UTM zone which is 6 degrees on longitude.
// So you really don't care about an object crossing two zones. You just get a
// second map of the other zone. However, if you happen to live in a place that
// straddles two zones (For example the Santa Babara area in CA straddles zone 10
// and zone 11) Then it can become a real pain having to have two maps all the time.
// So relatively small parts of the world (like say California) create their own
// version of UTM coordinates that are adjusted to conver the whole area of interest
// on a single map. These are called state grids. The projection system is the
// usually same as UTM (i.e. Transverse Mercator), but the central meridian
// aka Longitude of Origin is selected to suit the logitude of the area being
// mapped (like being moved to the central meridian of the area) and the grid
// may cover more than the 6 degrees of lingitude found on a UTM map. Areas
// that are wide rather than long - think Montana as an example. May still
// have to have a couple of maps to cover the whole state because TM projection
// looses accuracy as you move further away from the Longitude of Origin, 15 degrees
// is usually the limit.
//
// Now, in the case where we want to generate electronic maps that may be
// placed pretty much anywhere on the globe we really don't to deal with the
// issue of UTM zones in our coordinate system. We would really just like a
// grid that is fully contigious over the area of the map we are drawing. Similiar
// to the state grid, but local to the area we are interested in. I call this
// Local Transverse Mercator and I have modified the function below to also
// make this conversion. If you pass a Longitude value to the function as $LongOrigin
// then that is the Longitude of Origin that will be used for the projection.
// Easting coordinates will be returned (in meters) relative to that line of
// longitude - So an Easting coordinate for a point located East of the longitude
// of origin will be a positive value in meters, an Easting coordinate for a point
// West of the longitude of Origin will have a negative value in meters. Northings
// will always be returned in meters from the equator same as the UTM system. The
// UTMZone value will be valid for Long/Lat given - thought it is not meaningful
// in the context of Local TM. If a NULL value is passed for $LongOrigin
// then the standard UTM coordinates are calculated.
//
function convertLLtoTM($LongOrigin = NULL)
{
$k0 = 0.9996;
$falseEasting = 0.0;
 
//Make sure the longitude is between -180.00 .. 179.9
$LongTemp = ($this->long+180)-(integer)(($this->long+180)/360)*360-180; // -180.00 .. 179.9;
$LatRad = deg2rad($this->lat);
$LongRad = deg2rad($LongTemp);
 
if (!$LongOrigin)
{ // Do a standard UTM conversion - so findout what zone the point is in
$ZoneNumber = (integer)(($LongTemp + 180)/6) + 1;
// Special zone for South Norway
if( $this->lat >= 56.0 && $this->lat < 64.0 && $LongTemp >= 3.0 && $LongTemp < 12.0 ) // Fixed 1.1
$ZoneNumber = 32;
// Special zones for Svalbard
if( $this->lat >= 72.0 && $this->lat < 84.0 )
{
if( $LongTemp >= 0.0 && $LongTemp < 9.0 ) $ZoneNumber = 31;
else if( $LongTemp >= 9.0 && $LongTemp < 21.0 ) $ZoneNumber = 33;
else if( $LongTemp >= 21.0 && $LongTemp < 33.0 ) $ZoneNumber = 35;
else if( $LongTemp >= 33.0 && $LongTemp < 42.0 ) $ZoneNumber = 37;
}
$LongOrigin = ($ZoneNumber - 1)*6 - 180 + 3; //+3 puts origin in middle of zone
//compute the UTM Zone from the latitude and longitude
$this->utmZone = sprintf("%d%s", $ZoneNumber, $this->UTMLetterDesignator());
// We also need to set the false Easting value adjust the UTM easting coordinate
$falseEasting = 500000.0;
}
$LongOriginRad = deg2rad($LongOrigin);
 
$eccPrimeSquared = ($this->e2)/(1-$this->e2);
 
$N = $this->a/sqrt(1-$this->e2*sin($LatRad)*sin($LatRad));
$T = tan($LatRad)*tan($LatRad);
$C = $eccPrimeSquared*cos($LatRad)*cos($LatRad);
$A = cos($LatRad)*($LongRad-$LongOriginRad);
 
$M = $this->a*((1 - $this->e2/4 - 3*$this->e2*$this->e2/64 - 5*$this->e2*$this->e2*$this->e2/256)*$LatRad
- (3*$this->e2/8 + 3*$this->e2*$this->e2/32 + 45*$this->e2*$this->e2*$this->e2/1024)*sin(2*$LatRad)
+ (15*$this->e2*$this->e2/256 + 45*$this->e2*$this->e2*$this->e2/1024)*sin(4*$LatRad)
- (35*$this->e2*$this->e2*$this->e2/3072)*sin(6*$LatRad));
$this->utmEasting = ($k0*$N*($A+(1-$T+$C)*$A*$A*$A/6
+ (5-18*$T+$T*$T+72*$C-58*$eccPrimeSquared)*$A*$A*$A*$A*$A/120)
+ $falseEasting);
 
$this->utmNorthing = ($k0*($M+$N*tan($LatRad)*($A*$A/2+(5-$T+9*$C+4*$C*$C)*$A*$A*$A*$A/24
+ (61-58*$T+$T*$T+600*$C-330*$eccPrimeSquared)*$A*$A*$A*$A*$A*$A/720)));
if($this->lat < 0)
$this->utmNorthing += 10000000.0; //10000000 meter offset for southern hemisphere
}
//
// This routine determines the correct UTM letter designator for the given latitude
// returns 'Z' if latitude is outside the UTM limits of 84N to 80S
// Written by Chuck Gantz- chuck dot gantz at globalstar dot com, converted to PHP by
// Brenor Brophy, brenor dot brophy at gmail dot com
//
function UTMLetterDesignator()
{
if((84 >= $this->lat) && ($this->lat >= 72)) $LetterDesignator = 'X';
else if((72 > $this->lat) && ($this->lat >= 64)) $LetterDesignator = 'W';
else if((64 > $this->lat) && ($this->lat >= 56)) $LetterDesignator = 'V';
else if((56 > $this->lat) && ($this->lat >= 48)) $LetterDesignator = 'U';
else if((48 > $this->lat) && ($this->lat >= 40)) $LetterDesignator = 'T';
else if((40 > $this->lat) && ($this->lat >= 32)) $LetterDesignator = 'S';
else if((32 > $this->lat) && ($this->lat >= 24)) $LetterDesignator = 'R';
else if((24 > $this->lat) && ($this->lat >= 16)) $LetterDesignator = 'Q';
else if((16 > $this->lat) && ($this->lat >= 8)) $LetterDesignator = 'P';
else if(( 8 > $this->lat) && ($this->lat >= 0)) $LetterDesignator = 'N';
else if(( 0 > $this->lat) && ($this->lat >= -8)) $LetterDesignator = 'M';
else if((-8 > $this->lat) && ($this->lat >= -16)) $LetterDesignator = 'L';
else if((-16 > $this->lat) && ($this->lat >= -24)) $LetterDesignator = 'K';
else if((-24 > $this->lat) && ($this->lat >= -32)) $LetterDesignator = 'J';
else if((-32 > $this->lat) && ($this->lat >= -40)) $LetterDesignator = 'H';
else if((-40 > $this->lat) && ($this->lat >= -48)) $LetterDesignator = 'G';
else if((-48 > $this->lat) && ($this->lat >= -56)) $LetterDesignator = 'F';
else if((-56 > $this->lat) && ($this->lat >= -64)) $LetterDesignator = 'E';
else if((-64 > $this->lat) && ($this->lat >= -72)) $LetterDesignator = 'D';
else if((-72 > $this->lat) && ($this->lat >= -80)) $LetterDesignator = 'C';
else $LetterDesignator = 'Z'; //This is here as an error flag to show that the Latitude is outside the UTM limits
 
return($LetterDesignator);
}
 
//------------------------------------------------------------------------------
//
// Convert UTM to Longitude/Latitude
//
// Equations from USGS Bulletin 1532
// East Longitudes are positive, West longitudes are negative.
// North latitudes are positive, South latitudes are negative
// Lat and Long are in decimal degrees.
// Written by Chuck Gantz- chuck dot gantz at globalstar dot com, converted to PHP by
// Brenor Brophy, brenor dot brophy at gmail dot com
//
// If a value is passed for $LongOrigin then the function assumes that
// a Local (to the Longitude of Origin passed in) Transverse Mercator
// coordinates is to be converted - not a UTM coordinate. This is the
// complementary function to the previous one. The function cannot
// tell if a set of Northing/Easting coordinates are in the North
// or South hemesphere - they just give distance from the equator not
// direction - so only northern hemesphere lat/long coordinates are returned.
// If you live south of the equator there is a note later in the code
// explaining how to have it just return southern hemesphere lat/longs.
//
function convertTMtoLL($LongOrigin = NULL)
{
$k0 = 0.9996;
$e1 = (1-sqrt(1-$this->e2))/(1+sqrt(1-$this->e2));
$falseEasting = 0.0;
$y = $this->utmNorthing;
 
if (!$LongOrigin)
{ // It is a UTM coordinate we want to convert
sscanf($this->utmZone,"%d%s",$ZoneNumber,$ZoneLetter);
if($ZoneLetter >= 'N')
$NorthernHemisphere = 1;//point is in northern hemisphere
else
{
$NorthernHemisphere = 0;//point is in southern hemisphere
$y -= 10000000.0;//remove 10,000,000 meter offset used for southern hemisphere
}
$LongOrigin = ($ZoneNumber - 1)*6 - 180 + 3; //+3 puts origin in middle of zone
$falseEasting = 500000.0;
}
 
// $y -= 10000000.0; // Uncomment line to make LOCAL coordinates return southern hemesphere Lat/Long
$x = $this->utmEasting - $falseEasting; //remove 500,000 meter offset for longitude
 
$eccPrimeSquared = ($this->e2)/(1-$this->e2);
 
$M = $y / $k0;
$mu = $M/($this->a*(1-$this->e2/4-3*$this->e2*$this->e2/64-5*$this->e2*$this->e2*$this->e2/256));
 
$phi1Rad = $mu + (3*$e1/2-27*$e1*$e1*$e1/32)*sin(2*$mu)
+ (21*$e1*$e1/16-55*$e1*$e1*$e1*$e1/32)*sin(4*$mu)
+(151*$e1*$e1*$e1/96)*sin(6*$mu);
$phi1 = rad2deg($phi1Rad);
 
$N1 = $this->a/sqrt(1-$this->e2*sin($phi1Rad)*sin($phi1Rad));
$T1 = tan($phi1Rad)*tan($phi1Rad);
$C1 = $eccPrimeSquared*cos($phi1Rad)*cos($phi1Rad);
$R1 = $this->a*(1-$this->e2)/pow(1-$this->e2*sin($phi1Rad)*sin($phi1Rad), 1.5);
$D = $x/($N1*$k0);
 
$tlat = $phi1Rad - ($N1*tan($phi1Rad)/$R1)*($D*$D/2-(5+3*$T1+10*$C1-4*$C1*$C1-9*$eccPrimeSquared)*$D*$D*$D*$D/24
+(61+90*$T1+298*$C1+45*$T1*$T1-252*$eccPrimeSquared-3*$C1*$C1)*$D*$D*$D*$D*$D*$D/720); // fixed in 1.1
$this->lat = rad2deg($tlat);
 
$tlong = ($D-(1+2*$T1+$C1)*$D*$D*$D/6+(5-2*$C1+28*$T1-3*$C1*$C1+8*$eccPrimeSquared+24*$T1*$T1)
*$D*$D*$D*$D*$D/120)/cos($phi1Rad);
$this->long = $LongOrigin + rad2deg($tlong);
}
 
//------------------------------------------------------------------------------
// Configure a Lambert Conic Conformal Projection
//
// falseEasting & falseNorthing are just an offset in meters added to the final
// coordinate calculated.
//
// longOfOrigin & LatOfOrigin are the "center" latitiude and longitude of the
// area being projected. All coordinates will be calculated in meters relative
// to this point on the earth.
//
// firstStdParallel & secondStdParallel are the two lines of longitude (that
// is they run east-west) that define where the "cone" intersects the earth.
// Simply put they should bracket the area being projected.
//
// google is your friend to find out more
//
function configLambertProjection ($falseEasting, $falseNorthing,
$longOfOrigin, $latOfOrigin,
$firstStdParallel, $secondStdParallel)
{
$this->falseEasting = $falseEasting;
$this->falseNorthing = $falseNorthing;
$this->longOfOrigin = $longOfOrigin;
$this->latOfOrigin = $latOfOrigin;
$this->firstStdParallel = $firstStdParallel;
$this->secondStdParallel = $secondStdParallel;
}
 
//------------------------------------------------------------------------------
//
// Convert Longitude/Latitude to Lambert Conic Easting/Northing
//
// This routine will convert a Latitude/Longitude coordinate to an Northing/
// Easting coordinate on a Lambert Conic Projection. The configLambertProjection()
// function should have been called prior to this one to setup the specific
// parameters for the projection. The Northing/Easting parameters calculated are
// in meters (because the datum used is in meters) and are relative to the
// falseNorthing/falseEasting coordinate. Which in turn is relative to the
// Lat/Long of origin The formula were obtained from URL:
// http://www.ihsenergy.com/epsg/guid7_2.html.
// Code was written by Brenor Brophy, brenor dot brophy at gmail dot com
//
function convertLLtoLCC()
{
$e = sqrt($this->e2);
 
$phi = deg2rad($this->lat); // Latitude to convert
$phi1 = deg2rad($this->firstStdParallel); // Latitude of 1st std parallel
$phi2 = deg2rad($this->secondStdParallel); // Latitude of 2nd std parallel
$lamda = deg2rad($this->long); // Lonitude to convert
$phio = deg2rad($this->latOfOrigin); // Latitude of Origin
$lamdao = deg2rad($this->longOfOrigin); // Longitude of Origin
 
$m1 = cos($phi1) / sqrt(( 1 - $this->e2*sin($phi1)*sin($phi1)));
$m2 = cos($phi2) / sqrt(( 1 - $this->e2*sin($phi2)*sin($phi2)));
$t1 = tan((pi()/4)-($phi1/2)) / pow(( ( 1 - $e*sin($phi1) ) / ( 1 + $e*sin($phi1) )),$e/2);
$t2 = tan((pi()/4)-($phi2/2)) / pow(( ( 1 - $e*sin($phi2) ) / ( 1 + $e*sin($phi2) )),$e/2);
$to = tan((pi()/4)-($phio/2)) / pow(( ( 1 - $e*sin($phio) ) / ( 1 + $e*sin($phio) )),$e/2);
$t = tan((pi()/4)-($phi /2)) / pow(( ( 1 - $e*sin($phi ) ) / ( 1 + $e*sin($phi ) )),$e/2);
$n = (log($m1)-log($m2)) / (log($t1)-log($t2));
$F = $m1/($n*pow($t1,$n));
$rf = $this->a*$F*pow($to,$n);
$r = $this->a*$F*pow($t,$n);
$theta = $n*($lamda - $lamdao);
 
$this->lccEasting = $this->falseEasting + $r*sin($theta);
$this->lccNorthing = $this->falseNorthing + $rf - $r*cos($theta);
}
//------------------------------------------------------------------------------
//
// Convert Easting/Northing on a Lambert Conic projection to Longitude/Latitude
//
// This routine will convert a Lambert Northing/Easting coordinate to an
// Latitude/Longitude coordinate. The configLambertProjection() function should
// have been called prior to this one to setup the specific parameters for the
// projection. The Northing/Easting parameters are in meters (because the datum
// used is in meters) and are relative to the falseNorthing/falseEasting
// coordinate. Which in turn is relative to the Lat/Long of origin The formula
// were obtained from URL http://www.ihsenergy.com/epsg/guid7_2.html. Code
// was written by Brenor Brophy, brenor dot brophy at gmail dot com
//
function convertLCCtoLL()
{
$e = sqrt($this->e2);
 
$phi1 = deg2rad($this->firstStdParallel); // Latitude of 1st std parallel
$phi2 = deg2rad($this->secondStdParallel); // Latitude of 2nd std parallel
$phio = deg2rad($this->latOfOrigin); // Latitude of Origin
$lamdao = deg2rad($this->longOfOrigin); // Longitude of Origin
$E = $this->lccEasting;
$N = $this->lccNorthing;
$Ef = $this->falseEasting;
$Nf = $this->falseNorthing;
 
$m1 = cos($phi1) / sqrt(( 1 - $this->e2*sin($phi1)*sin($phi1)));
$m2 = cos($phi2) / sqrt(( 1 - $this->e2*sin($phi2)*sin($phi2)));
$t1 = tan((pi()/4)-($phi1/2)) / pow(( ( 1 - $e*sin($phi1) ) / ( 1 + $e*sin($phi1) )),$e/2);
$t2 = tan((pi()/4)-($phi2/2)) / pow(( ( 1 - $e*sin($phi2) ) / ( 1 + $e*sin($phi2) )),$e/2);
$to = tan((pi()/4)-($phio/2)) / pow(( ( 1 - $e*sin($phio) ) / ( 1 + $e*sin($phio) )),$e/2);
$n = (log($m1)-log($m2)) / (log($t1)-log($t2));
$F = $m1/($n*pow($t1,$n));
$rf = $this->a*$F*pow($to,$n);
$r_ = sqrt( pow(($E-$Ef),2) + pow(($rf-($N-$Nf)),2) );
$t_ = pow($r_/($this->a*$F),(1/$n));
$theta_ = atan(($E-$Ef)/($rf-($N-$Nf)));
 
$lamda = $theta_/$n + $lamdao;
$phi0 = (pi()/2) - 2*atan($t_);
$phi1 = (pi()/2) - 2*atan($t_*pow(((1-$e*sin($phi0))/(1+$e*sin($phi0))),$e/2));
$phi2 = (pi()/2) - 2*atan($t_*pow(((1-$e*sin($phi1))/(1+$e*sin($phi1))),$e/2));
$phi = (pi()/2) - 2*atan($t_*pow(((1-$e*sin($phi2))/(1+$e*sin($phi2))),$e/2));
$this->lat = rad2deg($phi);
$this->long = rad2deg($lamda);
}
 
//------------------------------------------------------------------------------
// This is a useful function that returns the Great Circle distance from the
// gPoint to another Long/Lat coordinate
//
// Result is returned as meters
//
function distanceFrom($lon1, $lat1)
{
$lon1 = deg2rad($lon1); $lat1 = deg2rad($lat1); // Added in 1.3
$lon2 = deg2rad($this->Long()); $lat2 = deg2rad($this->Lat());
$theta = $lon2 - $lon1;
$dist = acos(sin($lat1) * sin($lat2) + cos($lat1) * cos($lat2) * cos($theta));
 
// Alternative formula supposed to be more accurate for short distances
// $dist = 2*asin(sqrt( pow(sin(($lat1-$lat2)/2),2) + cos($lat1)*cos($lat2)*pow(sin(($lon1-$lon2)/2),2)));
return ( $dist * 6366710 ); // from http://williams.best.vwh.net/avform.htm#GCF
}
 
//------------------------------------------------------------------------------
// This function also calculates the distance between two points. In this case
// it just uses Pythagoras's theorm using TM coordinates.
//
function distanceFromTM(&$pt)
{
$E1 = $pt->E(); $N1 = $pt->N();
$E2 = $this->E(); $N2 = $this->N();
$dist = sqrt(pow(($E1-$E2),2)+pow(($N1-$N2),2));
return $dist;
}
 
//------------------------------------------------------------------------------
// This function geo-references a geoPoint to a given map. This means that it
// calculates the x,y pixel coordinate that coresponds to the Lat/Long value of
// the geoPoint. The calculation is done using the Transverse Mercator(TM)
// coordinates of the gPoint with respect to the TM coordinates of the center
// point of the map. So this only makes sense if you are using Local TM
// projection.
//
// $rX & $rY are the pixel coordinates that corespond to the Northing/Easting
// ($rE/$rN) coordinate it is to this coordinate that the point will be
// geo-referenced. The $LongOrigin is needed to make sure the Easting/Northing
// coordinates of the point are correctly converted.
//
function gRef($rX, $rY, $rE, $rN, $Scale, $LongOrigin)
{
$this->convertLLtoTM($LongOrigin);
$x = (($this->E() - $rE) / $Scale) // The easting in meters times the scale to get pixels
// is relative to the center of the image so adjust to
+ ($rX); // the left coordinate.
$y = $rY - // Adjust to bottom coordinate.
(($rN - $this->N()) / $Scale); // The northing in meters
// relative to the equator. Subtract center point northing
// to get relative to image center and convert meters to pixels
$this->setXY((int)$x,(int)$y); // Save the geo-referenced result.
}
} // end of class gPoint
 
?>
/trunk/applications/jrest/services/OdsSpipVersDrupalMigration.php
New file
0,0 → 1,504
<?php
 
class OdsSpipVersDrupalMigration extends OdsTriple {
 
const PREFIXE = 'get';
const BDD_DRUPAL = 'ods_redesign';
const BDD_ANCIEN_ODS = 'ods';
const BDD_NOUVEAU_ODS = 'ods_saisie';
/**
* Méthode appelée avec une requête de type GET.
*
*/
function getElement($param = array()) {
$type = $param[0];
if ($type == '*' || is_numeric($type)) {
$info = $this->getElementParDefaut($param);
} else {
$methode = self::PREFIXE.$type;
echo $methode;
if (method_exists($this, $methode)) {
array_shift($param);
$info = $this->$methode($param);
} else {
$this->messages[] = "Le type d'information demandé '$type' n'est pas disponible.";
}
}
// Envoi sur la sortie standard
$this->envoyer($info);
}
/**
* Méthode appelée pour ajouter un élément.
*/
public function createElement($params) {
print_r($params);
$this->envoyer();
}
private function getElementParDefaut($param) {
}
private function getReparationCommunes() {
$requete_stations_sans_communes = 'SELECT * FROM ods_saisie.ods_stations WHERE os_ce_commune = "NULL"';
$stations_sans_communes = $this->executerRequete($requete_stations_sans_communes);
$z = 0;
$nb_com = count($stations_sans_communes);
$ct = 0 ;
foreach($stations_sans_communes as $station_sans_commune) {
echo $ct.' ';
$nom_station = $station_sans_commune['os_nom'];
$id_station = $station_sans_commune['os_id_station'];
$nom_station_joker = str_replace('-','_',$nom_station);
$nom_station_joker = str_replace(' ','_',$nom_station);
$requete_recherche_nom = 'SELECT oc_code_insee FROM ods_saisie.ods_communes WHERE oc_nom LIKE "'.$nom_station_joker.'"';
 
$recherche_nom = $this->executerRequete($requete_recherche_nom);
if(!empty($recherche_nom)) {
$requete_maj_nom = 'UPDATE ods_stations set os_ce_commune = '.$recherche_nom[0]['oc_code_insee'].' WHERE os_id_station = '.$id_station;
echo $requete_maj_nom.'<br />';
$modif_nom = $this->executerRequeteSimple($requete_maj_nom);
$z++;
} else {
echo "rien trouvé pour la station ".$nom_station.'<br />';
}
$ct++;
}
echo $z.' stations réparées sur '.$nb_com;
 
$requete_altitude_communes = 'SELECT * FROM ods_communes_temp';
$res_alt_communes = $this->executerRequete($requete_altitude_communes);
}
private function getMigrationParticipants() {
$requete_participants_spip = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.PARTICIPANT WHERE PARTICIPANT_ID > 4';
$participants_spip = $this->executerRequete($requete_participants_spip);
$requete_insertion_participants_drupal = 'INSERT INTO '.self::BDD_DRUPAL.'.drupal_users '.
'(uid, name, pass, mail, created, access, login, status, timezone, language, init) '.
'VALUES ';
foreach($participants_spip as $participant_spip) {
$requete_insertion_participants_drupal .= '('.
$this->proteger($participant_spip['PARTICIPANT_ID']).', '.
$this->proteger($participant_spip['PARTICIPANT_PSEUDO']).', '.
$this->proteger(md5($participant_spip['PARTICIPANT_MOTDEPASSE'])).', '.
$this->proteger($participant_spip['PARTICIPANT_EMAIL']).', '.
$this->proteger(strtotime($participant_spip['PARTICIPANT_DATE_INSCRIPTION'])).', '.
$this->proteger(strtotime($participant_spip['PARTICIPANT_DATE_INSCRIPTION'])).', '.
$this->proteger(strtotime($participant_spip['PARTICIPANT_DATE_INSCRIPTION'])).', '.
$this->proteger('1').','.
$this->proteger('7200').', '.
$this->proteger('fr').', '.
$this->proteger($participant_spip['PARTICIPANT_EMAIL']).' '.
'),';
}
 
$requete_insertion_participants_drupal = rtrim($requete_insertion_participants_drupal,',');
 
$this->executerRequeteSimple($requete_insertion_participants_drupal);
}
private function getMigrationStations($liste_evenements) {
$this->supprimerDoublonStation();
$requete_communes_anciennes_stations = 'SELECT STATION_ID, COMMUNE.COMMUNE_ID, COMMUNE.COMMUNE_NOM, COMMUNE.COMMUNE_CODEPOSTAL '.
'FROM '.self::BDD_ANCIEN_ODS.'.SEQUENCE '.
'LEFT JOIN '.self::BDD_ANCIEN_ODS.'.COMMUNE '.
' ON '.self::BDD_ANCIEN_ODS.'.COMMUNE.COMMUNE_ID = '.self::BDD_ANCIEN_ODS.'.SEQUENCE.COMMUNE_ID '.
'GROUP BY STATION_ID';
$res_communes_anciennes_stations = $this->executerRequete($requete_communes_anciennes_stations);
$communes_anciennes_stations = array();
foreach($res_communes_anciennes_stations as $com_stat) {
$id_station = $com_stat['STATION_ID'];
$communes_anciennes_stations[$id_station]['nom_commune'] = $com_stat['COMMUNE_NOM'];
$communes_anciennes_stations[$id_station]['id_commune'] = $com_stat['COMMUNE_ID'];
$communes_anciennes_stations[$id_station]['code_postal_commune'] = $com_stat['COMMUNE_CODEPOSTAL'];
}
$requete_selection_station_ancien = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.STATION WHERE PARTICIPANT_ID > 5';
$stations_anciennes = $this->executerRequete($requete_selection_station_ancien);
$requete_insertion_station_nouveau = 'INSERT INTO '.self::BDD_NOUVEAU_ODS.'.ods_stations '.
'(os_id_station, os_ce_participant, os_nom, os_ce_commune, os_latitude, os_longitude, os_altitude, os_ce_environnement, os_commentaire) '.
'VALUES ';
foreach($stations_anciennes as $station_ancienne) {
$nouvel_id_environnement = $this->getNouvelIdEnvironnement($station_ancienne['STATION_ENVIRONNEMENT_ID']);
$id_commune = $communes_anciennes_stations[$station_ancienne['STATION_ID']]['id_commune'];
$nom_commune = $communes_anciennes_stations[$station_ancienne['STATION_ID']]['nom_commune'];
$cp_commune = $communes_anciennes_stations[$station_ancienne['STATION_ID']]['code_postal_commune'];
$code_insee_commune = $this->getCodeInseePourNomEtCP($nom_commune,$cp_commune);
// Correction des quelques noms de stations vides
if(trim($station_ancienne['STATION_NOM']) == '') {
$station_ancienne['STATION_NOM'] = 'station inconnue';
}
$requete_insertion_station_nouveau .= '('.
$this->proteger($station_ancienne['STATION_ID']).', '.
$this->proteger($station_ancienne['PARTICIPANT_ID']).', '.
$this->proteger($station_ancienne['STATION_NOM']).', '.
$this->proteger($code_insee_commune).', '.
$this->proteger($station_ancienne['STATION_LATITUDE']).', '.
$this->proteger($station_ancienne['STATION_LONGITUDE']).', '.
$this->proteger($station_ancienne['STATION_ALTITUDE']).', '.
$this->proteger($nouvel_id_environnement).', '.
'""'.
'),';
 
}
$requete_insertion_station_nouveau = rtrim($requete_insertion_station_nouveau,',');
$this->executerRequeteSimple($requete_insertion_station_nouveau);
}
private function getMigrationIndividus() {
$anciennes_espece = $this->getAnciennesEspeceGroupeesParNomSci();
$nouvelles_especes = $this->getEspeceGroupeesParNomSci();
$requete_selection_sequence = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.SEQUENCE ';
$sequences = $this->executerRequete($requete_selection_sequence);
$requete_insertion_sequence_nouveau = 'INSERT INTO '.self::BDD_NOUVEAU_ODS.'.ods_individus '.
'(oi_ce_espece, oi_ce_station, oi_nom) '.
'VALUES ';
$compteur_nom = 1;
$obs_a_migrer_par_individu = array();
foreach($sequences as $sequence) {
$nom_sci_espece = $anciennes_espece[$sequence['ESPECE_ID']];
$id_nouvelle_espece = $nouvelles_especes[$nom_sci_espece];
$requete_insertion_sequence_nouveau .= '('.
$this->proteger($id_nouvelle_espece).', '.
$this->proteger($sequence['STATION_ID']).', '.
$this->proteger('individu_'.$compteur_nom).' '.
'),';
$obs_a_migrer_par_individu['individu_'.$compteur_nom]['sequence'] = $sequence['SEQUENCE_ID'];
$compteur_nom++;
}
$requete_insertion_sequence_nouveau = rtrim($requete_insertion_sequence_nouveau,',');
$this->executerRequeteSimple($requete_insertion_sequence_nouveau);
}
private function getMigrationObservations() {
$anciennes_espece = $this->getAnciennesEspeceGroupeesParNomSci();
$nouvelles_especes = $this->getEspeceGroupeesParNomSci();
$requete_selection_mesure = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.MESURE ORDER BY MESURE_DATE';
$mesures = $this->executerRequete($requete_selection_mesure);
$requete_selection_sequence = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.SEQUENCE';
$sequences = $this->executerRequete($requete_selection_sequence);
$requete_selection_station = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.STATION';
$stations = $this->executerRequete($requete_selection_station);
$sequences_en_bordel = array();
$mesures_a_debordeliser = array();
$stations_a_classer = array();
foreach($stations as $station) {
$stations_a_classer[$station['STATION_ID']] = $station['PARTICIPANT_ID'];
}
foreach($sequences as $sequence) {
$sequences_en_bordel[$sequence['SEQUENCE_ID']]['station'] = $sequence['STATION_ID'];
$sequences_en_bordel[$sequence['SEQUENCE_ID']]['espece'] = $sequence['ESPECE_ID'];
}
foreach($mesures as $mesure) {
$station_de_mesure = $sequences_en_bordel[$mesure['SEQUENCE_ID']]['station'];
$espece_de_mesure = $sequences_en_bordel[$mesure['SEQUENCE_ID']]['espece'];
$individu_de_mesure = $mesure['MESURE_INDIVIDU'];
$evenement = $mesure['EVENEMENT_ID'];
$date_evenement = $mesure['MESURE_DATE'];
$id_participant = $stations_a_classer[$sequences_en_bordel[$mesure['SEQUENCE_ID']]['station']];
$mesures_a_debordeliser[$id_participant][$station_de_mesure][$espece_de_mesure][$individu_de_mesure][$evenement][] = $date_evenement;
}
$requete_insertion_individus_nouveau = 'INSERT INTO '.self::BDD_NOUVEAU_ODS.'.ods_individus '.
'(oi_id_individu, oi_ce_espece, oi_ce_station, oi_nom) '.
'VALUES ';
$requete_insertion_observations_nouveau = 'INSERT INTO '.self::BDD_NOUVEAU_ODS.'.ods_observations '.
'(oo_ce_participant, oo_ordre, oo_ce_individu, oo_ce_evenement,oo_date,oo_commentaire,oo_date_saisie,oo_date_modification) '.
'VALUES ';
$compteur_id_temp = 1;
$tableau_ancien_id_individu_nom_individu = array();
foreach($mesures_a_debordeliser as $id_participant => $stations_participant) {
$compteur_ordre_obs = 1;
foreach($stations_participant as $station => $especes) {
$id_station_individu = $station;
foreach($especes as $id_espece => $individus_espece) {
$nom_sci_espece = $anciennes_espece[$id_espece];
$id_nouvelle_espece = $nouvelles_especes[$nom_sci_espece];
foreach($individus_espece as $num_individu => $evenements) {
$nom_individu = 'individu_'.$num_individu;
$id_individu_temp = $compteur_id_temp;
foreach($evenements as $id_evenement => $evenement_individu) {
$nouvel_id_evenement = $this->getNouvelIdEvenement($id_evenement);
foreach($evenement_individu as $date_evenement) {
$requete_insertion_observations_nouveau .= '('.$this->proteger($id_participant).', '.
$this->proteger($compteur_ordre_obs).', '.
$this->proteger($compteur_id_temp).', '.
$this->proteger($nouvel_id_evenement).', '.
$this->proteger($date_evenement).', '.
"'',".
$this->proteger($date_evenement).', '.
$this->proteger($date_evenement).
'),';
$compteur_ordre_obs++;
}
}
$requete_insertion_individus_nouveau .= '('.
$this->proteger($compteur_id).', '.
$this->proteger($id_nouvelle_espece).', '.
$this->proteger($id_station_individu).', '.
$this->proteger($nom_individu).
'),';
$compteur_id_temp++;
}
}
}
}
$requete_insertion_individus_nouveau = rtrim($requete_insertion_individus_nouveau,',');
$this->executerRequeteSimple($requete_insertion_individus_nouveau);
$requete_insertion_observations_nouveau = rtrim($requete_insertion_observations_nouveau,',');
$this->executerRequeteSimple($requete_insertion_observations_nouveau);
}
private function getMigrationCommunes() {
$requete_communes = 'SELECT * FROM locations';
$communes = $this->executerRequete($requete_communes);
$requete_altitude_communes = 'SELECT * FROM ods_communes_temp';
$res_alt_communes = $this->executerRequete($requete_altitude_communes);
$altitudes_communes = array();
foreach($res_alt_communes as $commune_alt) {
$altitudes_communes[$commune_alt['oc_code_insee']] = $commune_alt['oc_altitude'];
}
$requete_insertion_communes_ods = 'INSERT INTO ods_communes '.
'(oc_code_insee, oc_nom, oc_secteur, oc_x_utm, oc_y_utm, oc_latitude, oc_longitude, oc_altitude) '.
'VALUES ';
foreach($communes as $commune) {
$lat_long = $this->convertirUtmVersLatLong($commune['x_utm'], $commune['y_utm'], $commune['sector']);
$altitude = $altitudes_communes[$commune['insee_code']];
$requete_insertion_communes_ods .= '('.
$this->proteger($commune['insee_code']).','.
$this->proteger($commune['name']).','.
$this->proteger($commune['sector']).','.
$this->proteger($commune['x_utm']).','.
$this->proteger($commune['y_utm']).','.
$this->proteger($lat_long['lat']).','.
$this->proteger($lat_long['long']).','.
$this->proteger($altitude).
'),';
}
$requete_insertion_communes_ods = rtrim($requete_insertion_communes_ods,',');
$this->executerRequeteSimple($requete_insertion_communes_ods);
}
private function convertirUtmVersLatLong($x, $y, $sector) {
$lat_long = array();
$convertisseur = new gPoint();
$convertisseur->setUTM($x, $y, $sector);
$convertisseur->convertTMtoLL();
$lat_long['lat'] = $convertisseur->Lat();
$lat_long['long'] = $convertisseur->Long();
return $lat_long;
}
private function getNouvelIdEnvironnement($ancien_id_environnement) {
$ids_env = array('1' => '7','2' => '8','3' => '9','4' => '10','6' => '11');
return $ids_env[$ancien_id_environnement];
}
private function getNouvelIdEvenement($ancien_id_evenement) {
$ids_evts = array('1' => '13',
'2' => '14',
'3' => '15',
'4' => '16',
'5' => '17',
'6' => '18',
'7' => '19',
'8' => '20');
return $ids_evts[$ancien_id_evenement];
}
private function getEspeceGroupeesParNomSci() {
$requete_espece = 'SELECT * FROM '.self::BDD_NOUVEAU_ODS.'.ods_especes';
$especes = $this->executerRequeteSimple($requete_espece);
$especes_ordonnees = array();
foreach($especes as $espece) {
$indice = strtolower(str_replace(' ','_', $espece['oe_nom_scientifique']));
$especes_ordonnees[$indice] = $espece['oe_id_espece'];
}
return $especes_ordonnees;
}
private function getAnciennesEspeceGroupeesParNomSci() {
$requete_espece = 'SELECT * FROM '.self::BDD_ANCIEN_ODS.'.ESPECE';
$especes = $this->executerRequete($requete_espece);
$especes_ordonnees = array();
foreach($especes as $espece) {
$nom_sci = strtolower(str_replace(' ','_', $espece['ESPECE_NOM_SCIENTIFIQUE']));
$especes_ordonnees[$espece['ESPECE_ID']] = $nom_sci;
}
return $especes_ordonnees;
}
private function getCodeInseePourNomEtCP($nom_commune, $cp) {
if(trim($nom_commune) == '') {
return 'NULL';
}
$limite = 2;
if(strlen($cp) == 4) {
$limite = 1;
}
$dpt = substr($cp,0,$limite);
$requete_code_insee = 'SELECT oc_code_insee '.
'FROM '.self::BDD_NOUVEAU_ODS.'.ods_communes '.
'WHERE oc_nom = '.$this->proteger($nom_commune).' '.
'AND oc_code_insee LIKE "'.$dpt.'___" '.
'LIMIT 1';
$infos_code_insee_commune = $this->executerRequete($requete_code_insee);
if(empty($infos_code_insee_commune)) {
// a migrer manuellement
return '_migrer_manu_'.$nom_commune;
}
return $infos_code_insee_commune[0]['oc_code_insee'];
}
private function supprimerDoublonStation() {
$requete = 'SELECT STATION_ID, STATION_NOM, PARTICIPANT_ID FROM '.self::BDD_ANCIEN_ODS.'.STATION ORDER BY PARTICIPANT_ID, STATION_NOM, STATION_ID ';
$res = $this->executerRequete($requete);
$stations = array();
foreach($res as $station) {
$stations[$station['PARTICIPANT_ID']][$station['STATION_NOM']][] = $station['STATION_ID'];
}
foreach($stations as $participant => $stations) {
foreach($stations as $station_nom => $doublons) {
if(count($doublons) > 1) {
$id_garde = $doublons[0];
$ids_a_supprimer = implode(',',array_slice($doublons, 1));
$requete_fusion_stations = 'DELETE FROM '.self::BDD_ANCIEN_ODS.'.STATION WHERE STATION_ID IN ('.$ids_a_supprimer.') AND PARTICIPANT_ID = '.$participant;
$this->executerRequeteSimple($requete_fusion_stations);
$requete_fusion_stations_obs = 'UPDATE '.self::BDD_ANCIEN_ODS.'.SEQUENCE
SET STATION_ID = '.$id_garde.' '.
'WHERE STATION_ID IN ('.$ids_a_supprimer.') '.
'AND PARTICIPANT_ID = '.$participant;
$this->executerRequeteSimple($requete_fusion_stations_obs);
}
}
}
}
}
?>
/trunk/applications/jrest/services/OdsSyndicationObservation.php
188,6 → 188,7
// Construction de la requête
$requete = 'SELECT * '.
'FROM ods_observations '.
'WHERE oo_ce_participant != '.$this->config['appli']['id_participant_demo'].' '.
'ORDER BY oo_date_modification DESC '.
"LIMIT $this->start,$this->limit ";
291,7 → 292,7
private function creerAuteur($element) {
//TODO externaliser les champs dans le fichier de config
$requete_selection_auteur = 'SELECT name FROM ods_redesign.drupal_users '.
$requete_selection_auteur = 'SELECT name FROM drupal_users '.
'WHERE uid = '.$this->proteger($element);
$resultat_auteur = $this->executerRequete($requete_selection_auteur);
310,11 → 311,15
$resultat_commune = $this->executerRequete($requete_commune_pour_station);
$commune = $resultat_commune[0]['os_ce_commune'];
$requete_lieu = 'SELECT * FROM ods.COMMUNE '.
'WHERE COMMUNE_NOM = '.$this->proteger($commune);
if(is_numeric($commune)) {
$requete_lieu = 'SELECT * FROM ods_communes '.
'WHERE oc_code_insee = '.$this->proteger($commune);
$resultat_lieu = $this->executerRequete($requete_lieu);
$lieu = $resultat_lieu[0]['COMMUNE_NOM']. ' ('.$resultat_lieu[0]['COMMUNE_CODEPOSTAL'].')';
$resultat_lieu = $this->executerRequete($requete_lieu);
$lieu = $resultat_lieu[0]['oc_nom']. ' ('.substr($commune,0,2).')';
} else {
$lieu = $commune;
}
$description = "Observé à $lieu";
$description = $this->nettoyerTexte($description);
/trunk/applications/jrest/services/JRestService.php
163,7 → 163,7
return $sortie;
}
 
protected function traiterParametresUrl($params_attendu, $params, $pourBDD = true) {
protected function traiterParametres($params_attendu, $params, $pourBDD = true) {
$sortie = array();
foreach ($params_attendu as $num => $nom) {
if (isset($params[$num]) && $params[$num] != '*') {
176,12 → 176,10
return $sortie;
}
 
protected function traiterParametresPost($params) {
$sortie = array();
foreach ($params as $cle => $valeur) {
$sortie[$cle] = $this->bdd->quote($valeur);
}
return $sortie;
protected function traiterNomMethodeGet($nom) {
$methode = 'get';
$methode .= str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($nom))));
return $methode;
}
 
protected function getIdentification(&$params) {
263,6 → 261,56
// Retourne le contenu
return $sortie;
}
/**
* Fonction nettoyant les caractères spéciaux HTML pour les champs de saisie libre du CEL.
*/
protected function protegerCaracteresHtmlDansChamps($donnees) {
$champs = array('ci_meta_mots_cles', 'ci_meta_comment',
'mots_cles', 'location', 'lieudit', 'station', 'milieu', 'commentaire', 'nom_sel');
foreach ($champs as $champ) {
if (isset($donnees[$champ])) {
$donnees[$champ] = htmlspecialchars($donnees[$champ]);
}
}
return $donnees;
}
protected function convertirDateHeureMysqlEnTimestamp($date_heure_mysql){
$val = explode(' ', $date_heure_mysql);
$date = explode('-', $val[0]);
$heure = explode(':', $val[1]);
return mktime((int)$heure[0], $heure[1], $heure[2], $date[1], $date[2], $date[0]);
}
protected function etreNull($valeur) {
$etre_null = false;
if ($valeur == '' || $valeur == null || $valeur == '000null' || $valeur == 'null') {
$etre_null = true;
}
return $etre_null;
}
protected function formaterDate($date_heure_mysql, $format = '%A %d %B %Y à %H:%M') {
$date_formatee = '';
if (!$this->etreNull($date_heure_mysql)) {
$timestamp = $this->convertirDateHeureMysqlEnTimestamp($date_heure_mysql);
$date_formatee = strftime($format, $timestamp);
}
return $date_formatee;
}
/**
* Fonction nettoyant les caractères spéciaux (&,<) et les valeurs nulles du CEL dans un texte comprenant du HTML.
*/
protected function nettoyerTexte($txt) {
$txt = preg_replace('/&(?!([a-z]+|#[0-9]+|#x[0-9][a-f]+);)/i', '&amp;', $txt);
// TODO : trouver une regexp qui permet de remplacer les symboles < et > isolés
//$txt = preg_replace('/<(?!([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>|\/\s*([a-z][a-z0-9]*)\s*>)/i', '&lt;', $txt);
//$txt = preg_replace('/(?!<([a-z][a-z0-9]*)\b[^>]*)>(?!(.*?)<\/\1>)/i', '&gt;', $txt);
$txt = preg_replace('/(?:000null|null)/i', '', $txt);
return $txt;
}
 
/**
* Fonction chargeant le contenu du squelette et remplaçant les tags court php (<?= ...) par un tag long avec echo.
/trunk/applications/jrest/services/squelettes/rss1.tpl.xml
14,7 → 14,7
 
<channel rdf:about="<?=$guid?>">
<title><?=$titre?></title>
<link><?=$lien_coel?></link>
<link><?=$lien_ods?></link>
<description><?=$description?></description>
<dc:publisher><?=$editeur?></dc:publisher>
<dc:date><?=$date_maj_W3C?></dc:date>
/trunk/applications/jrest/services/squelettes/rss2.tpl.xml
1,19 → 1,19
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?=$titre?></title>
<link><?=$lien_coel?></link>
<atom:link href="<?=$lien_service?>" rel="self" type="application/rss+xml" />
<description><?=$description?></description>
<title><?=$titre; ?></title>
<link><?=$lien_ods; ?></link>
<atom:link href="<?= $lien_service; ?>" rel="self" type="application/rss+xml" />
<description><?=$description; ?></description>
<?php if (isset($items)) : ?>
<?php foreach ($items as $item) : ?>
<item>
<guid><?=$item['guid']?></guid>
<title><?=$item['titre']?></title>
<link><?=$item['lien']?></link>
<description><?=$item['description_encodee']?></description>
<pubDate><?=$item['date_maj_RSS']?></pubDate>
<guid><?=$item['guid']; ?></guid>
<title><?=$item['titre']; ?></title>
<link><?=$item['lien']; ?></link>
<description><?=$item['description_encodee']; ?></description>
<pubDate><?=$item['date_maj_RSS']; ?></pubDate>
</item>
<?php endforeach; ?>
<?php endif; ?>
/trunk/applications/jrest/services/squelettes/atom.tpl.xml
2,7 → 2,7
<feed xmlns="http://www.w3.org/2005/Atom">
<title><?=$titre?></title>
<link href="<?=$lien_coel?>" rel="alternate" type="text/html" hreflang="fr" />
<link href="<?=$lien_ods?>" rel="alternate" type="text/html" hreflang="fr" />
<link href="<?=$lien_service?>" rel="self" type="application/atom+xml"/>
<updated><?=$date_maj_ATOM?></updated>
<author>
/trunk/applications/jrest/services/OdsCommune.php
66,6 → 66,42
return $infos_communes_formatees;
}
private function getEstUneCommunePhenoclim() {
return $this->estUneCommunePhenoclim($_GET);
}
private function estUneCommunePhenoclim($params) {
$code_insee = null;
$code_postal = null;
if(!isset($params['code_postal']) && !isset($params['code_insee'])) {
return false;
}
if(isset($params['code_postal'])) {
$code_postal = $params['code_postal'];
}
if(isset($params['code_insee'])) {
$code_insee = $params['code_insee'];
}
if($code_postal != null) {
$requete_commune_phenoclim = 'SELECT occ_code_insee FROM ods_communes_crea WHERE occ_code_postal = '.$this->proteger($code_postal);
} else {
$requete_commune_phenoclim = 'SELECT occ_code_insee FROM ods_communes_crea WHERE occ_code_insee = '.$this->proteger($code_insee);
}
$resultat_requete_phenoclim = $this->executerRequete($requete_commune_phenoclim);
if(!empty($resultat_requete_phenoclim)) {
return true;
}
return false;
}
private function remplacerNomCommunePourRecherche($nom) {
$nom = str_replace(' ','_',$nom);
$nom = str_replace('-','_',$nom);
92,6 → 128,8
if(strlen($cp_recherche) == 4) {
$cp_recherche = '0'.$cp_recherche;
}
$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_postal' => $cp_recherche));
 
$cp_recherche = substr($cp_recherche,0,2);
100,14 → 138,17
$code_insee = $this->obtenirCodeInseeCommune($commune, $cp_recherche);
}
return array(
$infos_communes = array(
'commune' => $commune,
'dpt' => $dpt,
'lat' => $lat,
'lon' => $lon,
'alt' => $altitude,
'code_insee' => $code_insee
'code_insee' => $code_insee,
'commune_phenoclim' => $commune_phenoclim
);
return $infos_communes;
}
129,17 → 170,32
$dpt = '0'.$dpt;
}
$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_insee' => $commune['oc_code_insee']));
$infos_formatees[] = array(
'commune' => $commune['oc_nom'],
'dpt' => $dpt,
'code_insee' => $commune['oc_code_insee'],
'lat' => $commune['oc_latitude'],
'lon' => $commune['oc_longitude']
'lon' => $commune['oc_longitude'],
'alt' => $commune['oc_altitude'],
'code_insee' => $commune['oc_code_insee'],
'commune_phenoclim' => $commune_phenoclim
);
}
return $infos_formatees;
}
public function obtenirNomCommuneParCodeInsee($code_insee_commune) {
if(!is_numeric($code_insee_commune)) {
return '';
}
$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_code_insee = '.$this->proteger($code_insee_commune);
$infos_commune = $this->executerRequete($requete_infos_commune);
return $infos_commune[0]['oc_nom'];
}
private function obtenirCodeInseeCommune($commune, $cp) {
$commune = $this->remplacerNomCommunePourRecherche($commune);
/trunk/applications/rendu/rendu.php
45,7 → 45,7
// Lancement du débogage si nécessaire
if (Config::get('chronometrage')) {
Chronometre::chrono('Saisie.php - début');
Chronometre::chrono('Rendu.php - début');
}
// Lancement de l'application
AppControleur::initialiser();
/trunk/applications/rendu/squelettes/js/rendu.js
8,6 → 8,7
var evenement = '0';
var annee = '0';
var mois = '1';
var departement = '0';
 
function getUrlBaseJrest() {
69,6 → 70,10
mois = date.getMonth() + 1;
}
if(vars['departement'] != null) {
departement = vars['departement'];
}
if(vars['cacher_criteres'] != null && vars['cacher_criteres'] == '1') {
$(".criteres").hide();
}
272,6 → 277,10
requete += '&evenement='+evenement;
}
if(departement != '0') {
requete += '&departement='+departement;
}
$.get(getUrlBaseJrest()+'OdsExport/ExportObservationJson/'+requete, function(data) {
infos_observations = jQuery.parseJSON(data);
/trunk/applications/saisie/controleurs/Liens.php
67,6 → 67,7
$credit = '';
} else {
$credit = file_get_contents(Config::get('dossier_images_especes').'/'.$nom_sci_formate.'.txt');
$credit = htmlentities($credit);
}
if(trim($credit) != '') {
/trunk/applications/saisie/controleurs/Utilisateur.php
1,6 → 1,21
<?php
abstract class Utilisateur extends aControleur {
public function setIdentite($identite) {
$_SESSION['ods_saisie']['identite'] = $identite;
}
public function getIdentite() {
if($this->estAdmin()) {
if(!isset($_SESSION['ods_saisie']['identite']) || $_SESSION['ods_saisie']['identite'] == '') {
return $this->getIdentifiantNumerique();
}
return $_SESSION['ods_saisie']['identite'];
} else {
return $this->getIdentifiantNumerique();
}
}
public function getIdentifiantNumerique() {
return 0;
}
/trunk/applications/saisie/controleurs/AppControleur.php
82,10 → 82,14
private static function gererSession() {
if (Config::get('session_demarrage')) {
// Attribution d'un nom à la session
session_name(Config::get('session_nom'));
// Démarrage de la session
session_start();
if(!isset($_SESSION)){
// Démarrage de la session si besoin
session_start();
}
}
}
99,6 → 103,10
}
self::$utilisateur = new $classe_utilisateur();
if(self::$utilisateur->estAdmin()) {
self::afficherBarreAdmin();
}
}
}
124,9 → 132,24
self::$parametres['sortie']['corps'] = $formulaire;
}
private static function afficherBarreAdmin() {
$barre_admin = self::$instance->getVue('navigation/barre_admin', $donnees);
self::$parametres['sortie']['tete'] = $barre_admin;
}
public static function getIdUtilisateur() {
return self::getUtilisateur()->getIdentifiantNumerique();
return self::getUtilisateur()->getIdentite();
//return self::getUtilisateur()->getIdentifiantNumerique();
}
public static function getNomUtilisateur() {
return self::getUtilisateur()->getNom();
//return self::getUtilisateur()->getIdentifiantNumerique();
}
public static function changerUtilisateur() {
return self::getUtilisateur()->setIdentite();
}
/**
* Fusionne un tableau de sortie par défaut avec le tableau renvoyé par l'action du module.
/trunk/applications/saisie/controleurs/DrupalUtilisateur.php
2,7 → 2,9
class DrupalUtilisateur extends Utilisateur {
public function getIdentifiantNumerique() {
return $GLOBALS['user']->uid;
return $GLOBALS['user']->uid;
}
public function getEmail() {
22,7 → 24,6
}
public function estIdentifie() {
 
return user_is_logged_in();
}
/trunk/applications/saisie/configurations/config.ini
19,9 → 19,9
;Encodage de l'application
appli_encodage = "UTF-8"
; Nom de domaine pour l'URL de base de l'application : 162.38.234.9
domaine = "www.tela-botanica.org"
domaine = "www.obs-saisons.fr"
; URL de base de l'application, si elle est laissée vide, l'application fonctionnera en Stand-alone
url_base = "http://{ref:domaine}/client/collection/v{ref:info.version.code.num}-{ref:info.version.code.alpha}/"
url_base = ""
; URL de base de l'application avec l'indication du fichier de départ
url_base_index = "{ref:url_base}index.php"
; URL de base où se situe le .htacces réalisant la réecriture d'URL pour les permaliens de l'application
51,3 → 51,6
; Spécifique à l'application
; Url du Jrest utilisé pour les services web fournissant les données à l'application
url_jrest = "http://162.38.234.9/obs_saisons/applications/jrest/"
; Emplacement du dossier de base des images pour illustrer les espèces
dossier_images_especes = "/home/aurelien/web/obs_saisons/documents/images_especes/"
url_images_especes = "http://162.38.234.9/obs_saisons/documents/images_especes/"
/trunk/applications/saisie/framework.defaut.php
3,4 → 3,4
// Renomer ce fichier en "framework.php"
// Indiquer ci-dessous le chemin vers le fichier autoload.inc.php de la bonne version du Framework
require_once '/framework/0.2/autoload.inc.php';
?>
?>
/trunk/applications/saisie/bibliotheque/dao/ObservationDao.php
32,7 → 32,7
}
public function getListeObservationsPourIndividu($id_individu, $annee = null) {
if (is_numeric($id_individu)) {
$url = $this->url_jrest.self::SERVICE_OBSERVATION.'/'.self::METHODE_OBSERVATION_INDIVIDU.'/'.$id_individu;
$json = $this->envoyerRequeteConsultation($url);
/trunk/applications/saisie/index.php
70,4 → 70,4
</div>
</div>
</body>
</html>
</html>
/trunk/applications/saisie/squelettes/navigation/barre_admin.tpl.html
New file
0,0 → 1,7
<!-- ODS_SAISIE - DEBUT BARRE ADMIN -->
<div id="barre_admin">
 
Vous regardez les données de : <input type="text" name="identite_utilisateur" value="<?= AppControleur::getNomUtilisateur(); ?>" id="identite_utilisateur">
 
</div>
<!-- ODS_SAISIE - FIN MENU NAVIGATION -->
/trunk/applications/saisie/squelettes/pied.tpl.html
12,7 → 12,7
<p>
Merci de signaler
<a href="http://www.tela-botanica.net/suivi/index.php?do=newtask&project=32" class="lien_ext">
les bogues et améliorations pour l'application <?php echo I18n::get('test.truc'); ?>
les bogues et améliorations pour l'application
<span class="saisie-appli-info">
Application de saisie D'ODS
</span>
/trunk/applications/saisie/squelettes/images/localiser.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/applications/saisie/squelettes/images/localiser.png
New file
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/trunk/applications/saisie/squelettes/images/retour.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/applications/saisie/squelettes/images/retour.png
New file
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/trunk/applications/saisie/squelettes/images/chargement.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/applications/saisie/squelettes/images/chargement.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/applications/saisie/squelettes/images/attention.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/applications/saisie/squelettes/images/attention.png
New file
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/trunk/applications/saisie/squelettes/formulaires/espece_saisie.tpl.html
1,6 → 1,6
<!-- ODS_SAISIE - DEBUT SAISIE ESPECE -->
<div id="saisie_espece">
<h2 class="etape"> Etape 2 : choisissez une nouvelle espece </h2>
<h2 class="etape"> Etape 2 : choisissez une nouvelle espèce </h2>
<form action="<?= Liens::getUrlValidationFormulaireSaisieEspece($id_station); ?>" method="post" id="form_saisie_espece">
<div class="element_formulaire">
<div id="onglets">
/trunk/applications/saisie/squelettes/js/.directory
New file
0,0 → 1,3
[Dolphin]
ShowPreview=true
Timestamp=2010,12,1,15,3,34
/trunk/applications/saisie/squelettes/js/saisie.js
1,5 → 1,16
var urlBaseJrest = 'http://localhost/obs_saisons/applications/jrest/';
var urlBaseJrest = 'http://162.38.234.9/obs_saisons/applications/jrest/';
 
function getUrlBaseJrest() {
url_page_courante = document.URL;
if(url_page_courante.indexOf('http://www.') != -1) {
return urlBaseJrest;
} else {
return urlBaseJrest.replace('http://www.','http://');
}
}
 
/**
************************************************************************************************
************************************************************************************************
15,7 → 26,7
 
$('.pliage ul').hide();
$('.pliage > ul:first-child').hide();
 
$('.1er_element_date ul').show();
$('.1er_element_date > ul:first-child').show();
 
30,24 → 41,7
initialiserElementsPliables();
});
 
/**
************************************************************************************************
************************************************************************************************
 
Fonctions pour la fiche individu
 
************************************************************************************************
************************************************************************************************
**/
 
observations = $('.observations_individu');
window.alert(dump(observations));
observations[0].ready(function() {
window.alert(dump(observations));
$(this).nextAll('ul').show();
});
 
 
/**
************************************************************************************************
************************************************************************************************
100,6 → 94,8
});
 
 
 
 
/**
************************************************************************************************
************************************************************************************************
375,7 → 371,7
}
cacherElementsRafraichissables();
 
$.get(urlBaseJrest+'OdsCommune/informationsPourCoordonnees/?lat='+lat+'&lon='+lon, function(data) {
infos_localites = jQuery.parseJSON(data);