/tags/2015_03_02/bibliotheque/cartographie/carto.php |
---|
New file |
0,0 → 1,89 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.3 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Cartographie. | |
// | | |
// | Foobar 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; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar 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. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: carto.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Fournie une image cartographique. |
* |
* Fichier permettant de récupérer l'image d'une carte créer par la bibliothèque cartographique |
* et de la faire passer dans les entête HTTP. |
* |
*@package Cartographie |
//Auteur original : |
*@author Nicolas MATHIEU |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
session_name($_GET['session']); |
session_start(); |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
$image = imagecreatefrompng($_SESSION['chemin'].$_SESSION['fichier'].'.png'); |
if (!$image) { |
echo session_name(); |
echo session_id(); |
trigger_error($image); |
} else { |
header("Expires: Wen, 01 Dec 1999 01:00:00 GMT");// Date du passé |
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");// toujours modifié |
header("Cache-Control: no-cache, must-revalidate");// HTTP/1.1 |
header("Pragma: no-cache"); // HTTP/1.0 |
header ("content-type:image/png"); |
chmod($_SESSION['chemin'].$_SESSION['fichier'].'.png', 755); |
imagepng($image); |
unlink($_SESSION['chemin'].$_SESSION['fichier'].'.png'); |
//Nous nettoyons le dossier tmp des fichiers qu'il contient: |
$poignet_de_dossier = opendir($_SESSION['chemin']); |
while ($fichier_dechet = readdir($poignet_de_dossier)) { |
if ($fichier_dechet != '.' && $fichier_dechet != '..') { |
unlink($_SESSION['chemin'].$fichier_dechet); |
} |
} |
closedir($poignet_de_dossier); |
} |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
exit(); |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.1 2005/02/28 15:03:49 jpm |
* Ajout des fichiers de la bibliothèque cartographique. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2015_03_02/bibliotheque/cartographie/carto_historique.class.php |
---|
New file |
0,0 → 1,132 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.3 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Cartographie. | |
// | | |
// | Foobar 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; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar 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. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: carto_historique.class.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Classe Carto_Historique. |
* |
* Classe permettant de réaliser des cartes. |
* |
*@package Cartographie |
//Auteur original : |
*@author Nicolas MATHIEU |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* Classe Carto_Historique() - Affiche les liens avec les carte précédentes. |
* |
* La classe Carto_Historique sert à pouvoir afficher les liens avec les carte précédentes |
* On accède à cette fonctionnalité grâce à la méthode afficherHistoriqueCarte() |
* L'objet Carto_HistoriqueCarte recoit en parametres : |
* - la généalogie du niveau ou on en est (du type monde*europe*france ) |
* - l'url du document |
* - en option : - le caractere de separation (par defaut c'est >) |
* - la classe css des liens |
*/ |
class Carto_Historique |
{ |
// +--------------------------------------------------------------------------------------------------+ |
// LES ATTRIBUTS DE LA CLASSE |
var $historique; |
var $url; |
var $caractere_separation; |
var $class_css; |
var $nom; |
// +--------------------------------------------------------------------------------------------------+ |
// LE CONSTRUCTEUR DE LA CLASSE |
/** |
* Constructeur Carto_Historique() |
* |
* Constructeur initialisant les attributs de la classe Carto_Historique(). |
*/ |
function Carto_Historique($objet_carte, $caractere = '>', $class = '') |
{ |
$this->historique = $objet_carte->historique; |
$this->url = $objet_carte->url; |
$this->nom = $objet_carte->nom; |
unset ($objet_carte); |
$this->caractere_separation = $caractere; |
$this->class_css = $class; |
}//Fin du constructeur Carto_Historique(). |
// +--------------------------------------------------------------------------------------------------+ |
// LES METHODES PUBLIQUES |
function afficherHistoriqueCarte() |
{ |
$res=''; |
$tabonglet = explode ('*', $this->historique); |
$tabnom = explode ('*', $this->nom); |
foreach ($tabonglet as $key=>$value) { |
if ($key == 0) { |
$chemin = $value; |
} |
else { |
$chemin .= '*'.$value; |
} |
$res.= '<a '; |
if (!empty($this->class_css)) { |
$res.='class="'.$this->class_css.'" '; |
} |
$res.='href="'.$this->url.'&historique_cartes='.$chemin.'"> '.$this->caractere_separation.' '.$tabnom[$key].'</a>'; |
} |
return $res; |
}//Fin de la méthode afficherHistoriqueCarte(). |
}//Fin de la classe Carto_Historique. |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.1 2005/02/28 15:03:49 jpm |
* Ajout des fichiers de la bibliothèque cartographique. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2015_03_02/bibliotheque/cartographie/carto_action.class.php |
---|
New file |
0,0 → 1,218 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.3 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Cartographie. | |
// | | |
// | Foobar 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; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar 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. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: carto_action.class.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Classe ActionCarte. |
* |
* Calsse permettant de connaître les actions à réaliser sur une carte. |
* |
*@package Cartographie |
//Auteur original : |
*@author Nicolas MATHIEU |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* Classe Carto_Action() - Recueille les infos sur l'action à réaliser pour une zone géo donnée. |
* |
* La classe Carto_Action sert a definir les paramètres nécessaires pour recueillir l'action a réaliser en |
* fonction des coordonnées du point, du masque et du niveau. |
* Elle remplace la fonction get_cartoAction() que l'on peut trouver dans le fichier carto_commun.php |
* des différentes application utilisant la carto. |
* Les champs a renseigner sont les suivants : |
* -le nom de la table ($nom_table_carto_action) où sont stokée les actions à réalisées |
* en fonction des couleurs |
* -les 5 champs principaux de la table : |
* -l'identifiant de la zone géographique (un nom, un numéro ou une abréviation) -> $nom_champ_cle |
* -les couleurs -> $nom_champ_rouge, $nom_champ_vert, $nom_champ_bleu |
* -l'action -> $nom_champ_action |
* Elle possède une seule méthode : get_cartoAction(). |
*/ |
class Carto_Action |
{ |
// +--------------------------------------------------------------------------------------------------+ |
// LES ATTRIBUTS DE LA CLASSE |
var $_table_zone_geo; |
var $_id_zone_geo_zone; |
var $_rouge; |
var $_vert; |
var $_bleu; |
var $_table_action; |
var $_id_carte_action; |
var $_id_zone_geo_action; |
var $_type_zone_geo_action; |
var $_action; |
var $_id_carte_destination; |
// +--------------------------------------------------------------------------------------------------+ |
// LE CONSTRUCTEUR DE LA CLASSE |
/** |
* Constructeur Carto_Action() |
* |
* Constructeur initialisant les attributs de la classe Carto_Action(). |
*/ |
function Carto_Action($info_table_zone_geo, $info_table_action) |
{ |
$this->_table_zone_geo = $info_table_zone_geo['nom_table_zone']; |
$this->_id_zone_geo_zone = $info_table_zone_geo['nom_chp_id_zone']; |
$this->_rouge = $info_table_zone_geo['nom_chp_rouge']; |
$this->_vert = $info_table_zone_geo['nom_chp_vert']; |
$this->_bleu = $info_table_zone_geo['nom_chp_bleu']; |
$this->_table_action = $info_table_action['nom_table_action']; |
$this->_id_carte_action = $info_table_action['nom_chp_id_carte']; |
$this->_id_zone_geo_action = $info_table_action['nom_chp_id_zg_action']; |
$this->_type_zone_geo_action = $info_table_action['nom_chp_type_zg']; |
$this->_action = $info_table_action['nom_chp_action']; |
$this->_id_carte_destination = $info_table_action['nom_chp_id_carte_destination']; |
} |
// +--------------------------------------------------------------------------------------------------+ |
// LES METHODES PRIVÉES |
/** |
* Méthode _consulterActionImage($imageX, $imageY, $masque, $id_carte) |
* |
* Elle renvoit l'action a réaliser. |
* Nous passons les paramètres suivant : |
* -les coordonnees du point ($imageX et $imageY) |
* -le masque pour recuperer la couleur ($masque) |
* -l'identifiant de la carte où nous nous trouvons ($id_carte) |
*/ |
function _consulterActionImage($imageX, $imageY, $masque, $id_carte) |
{ |
// Nous récuperons les valeurs RVB de la couleur sur laquelle l'utilisateur a cliqué. |
// Les valeurs RVB sont stockées dans le tableau associatif $valeurs_RVB. |
$masque_courant = imagecreatefrompng($masque); |
$index_couleur = imagecolorat($masque_courant, $imageX, $imageY); |
$valeurs_RVB = imagecolorsforindex($masque_courant, $index_couleur); |
// Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur |
// du champ "action", afin de savoir quoi faire. |
$requete = |
'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action. |
' FROM '.$this->_table_action.', '.$this->_table_zone_geo. |
' WHERE '.$this->_table_zone_geo.'.'.$this->_rouge.' = '.$valeurs_RVB['red']. |
' AND '.$this->_table_zone_geo.'.'.$this->_vert.' = '.$valeurs_RVB['green']. |
' AND '.$this->_table_zone_geo.'.'.$this->_bleu.' = '.$valeurs_RVB['blue']. |
' AND '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone. |
' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"'; |
$resultat=mysql_query($requete) or die(' |
<h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'. |
'<b>Fichier : </b>'.__FILE__.'<br />'. |
'<b>Ligne : </b>'.__LINE__.'<br />'. |
'<b>Requete : </b>'.$requete.'<br />'. |
'<b>Erreur : </b>'.mysql_error()); |
$ligne = mysql_fetch_object ($resultat); |
if (mysql_num_rows ($resultat) != 0) { |
$chp_id_zone_geo = $this->_id_zone_geo_action; |
$chp_action = $this->_action; |
$chp_id_carte_destination = $this->_id_carte_destination; |
$action['id_zone_geo'] = $ligne->$chp_id_zone_geo; |
$action['type_action'] = $ligne->$chp_action; |
$action['id_carte_destination'] = $ligne->$chp_id_carte_destination; |
return $action; |
} |
}//Fin de la méthode _consulterActionImage(). |
/** |
* Méthode _consulterActionListe($id_zone_carte, $id_carte) |
* |
* Elle renvoit l'action a réaliser. |
* Nous passons les paramètres suivant : |
* -l'identifiant de la zone que l'on veut afficher |
* -l'identifiant de la carte où nous nous trouvons ($id_carte) |
*/ |
function _consulterActionListe($id_zone_carte, $id_carte) |
{ |
// Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur |
// du champ "action", afin de savoir quoi faire. |
$requete = |
'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action. |
' FROM '.$this->_table_action.', '.$this->_table_zone_geo. |
' WHERE '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone. |
' AND '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.' = "'.$id_zone_carte.'"'. |
' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"'; |
$resultat=mysql_query($requete) or die(' |
<h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'. |
'<b>Fichier : </b>'.__FILE__.'<br />'. |
'<b>Ligne : </b>'.__LINE__.'<br />'. |
'<b>Requete : </b>'.$requete.'<br />'. |
'<b>Erreur : </b>'.mysql_error()); |
$ligne = mysql_fetch_object ($resultat); |
if (mysql_num_rows ($resultat) != 0) { |
$chp_id_zone_geo = $this->_id_zone_geo_action; |
$chp_action = $this->_action; |
$chp_id_carte_destination = $this->_id_carte_destination; |
$action['id_zone_geo'] = $ligne->$chp_id_zone_geo; |
$action['type_action'] = $ligne->$chp_action; |
$action['id_carte_destination'] = $ligne->$chp_id_carte_destination; |
return $action; |
} |
}//Fin de la méthode get_cartoAction(). |
}//Fin de la classe Carto_Action. |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.2 2005/03/01 15:20:34 jpm |
* Modification des fichiers au niveau des infos d'erreur de requete sql. |
* |
* Revision 1.1 2005/02/28 15:03:49 jpm |
* Ajout des fichiers de la bibliothèque cartographique. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2015_03_02/bibliotheque/cartographie/carto_carte.class.php |
---|
New file |
0,0 → 1,825 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.3 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Cartographie. | |
// | | |
// | Foobar 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; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar 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. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: carto_carte.class.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Classe Carto_Carte. |
* |
* Calsse permettant de réaliser des cartes. |
* |
*@package Cartographie |
//Auteur original : |
*@author Nicolas MATHIEU |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
require 'carto_action.class.php'; |
require 'carto_couleur.class.php'; |
require 'carto_historique.class.php'; |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* Classe Carto_Carte() - Classe principale de la cartographie. |
* |
* La classe Carto_Carte permet de travailler les fichiers images des cartes. |
*/ |
class Carto_Carte |
{ |
// +--------------------------------------------------------------------------------------------------+ |
// LES ATTRIBUTS DE LA CLASSE |
var $id; |
var $_id_zone_geo_carte; |
var $nom; |
var $masque; |
var $fond; |
var $chemin; |
var $image; |
var $fils; |
var $url; |
var $_info_table_zg; |
var $filiation; |
var $image_x; |
var $image_y; |
var $historique_cartes; |
var $liste_zone_carte; |
var $historique; |
// La couleur dominante ( $maxiRVB ), la couleur la plus claire ($miniRVB) et la couleur |
// intermédiaire précédant le maximum ( $mediumRVB ) au cas ou il y aurait un trop grand |
//ecart entre les deux plus grandes valeurs. |
var $_zeroR; |
var $_zeroV; |
var $_zeroB; |
var $_miniR; |
var $_miniV; |
var $_miniB; |
var $_mediumR; |
var $_mediumV; |
var $_mediumB; |
var $_maxiR; |
var $_maxiV; |
var $_maxiB; |
//Le type de formule mathématique permettant de colorier la carte |
var $_formule_coloriage; |
//L'action à réaliser |
var $_action; |
// +--------------------------------------------------------------------------------------------------+ |
// LE CONSTRUCTEUR DE LA CLASSE |
function Carto_Carte($id, $id_zone_geo_carte, $nom, $masque, $fond, $chemin, $info_table_zg, $info_table_action) |
{ |
$this->id = $id; |
$this->_id_zone_geo_carte = $id_zone_geo_carte; |
$this->nom = $nom; |
$this->masque = $chemin.$masque; |
$this->fond = $chemin.$fond; |
$this->chemin = $chemin; |
$this->_info_table_zg = $info_table_zg; |
$this->_action = new Carto_Action($info_table_zg, $info_table_action); |
$this->fils = array(); |
$this->filiation = $id; |
$this->historique_cartes = ''; |
$this->liste_zone_carte = ''; |
$this->definirCouleurs(); |
$this->definirFormuleColoriage(); |
} |
// +--------------------------------------------------------------------------------------------------+ |
// LES METHODES PUBLIQUES |
function definirCouleurs ( |
$couleur_zero_R = '255', $couleur_zero_V = '255', $couleur_zero_B = '255', |
$couleur_mini_R = '210', $couleur_mini_V = '230', $couleur_mini_B = '210', |
$couleur_medium_R = '92', $couleur_medium_V = '181', $couleur_medium_B = '92', |
$couleur_maxi_R = '0', $couleur_maxi_V = '127', $couleur_maxi_B = '0') |
{ |
$this->_zeroR = $couleur_zero_R; |
$this->_zeroV = $couleur_zero_V; |
$this->_zeroB = $couleur_zero_B; |
$this->_miniR = $couleur_mini_R; |
$this->_miniV = $couleur_mini_V; |
$this->_miniB = $couleur_mini_B; |
$this->_mediumR = $couleur_medium_R; |
$this->_mediumV = $couleur_medium_V; |
$this->_mediumB = $couleur_medium_B; |
$this->_maxiR = $couleur_maxi_R; |
$this->_maxiV = $couleur_maxi_V; |
$this->_maxiB = $couleur_maxi_B; |
} |
function definirFormuleColoriage ($nomFormuleColoriage = 'defaut') |
{ |
$this->_formule_coloriage = $nomFormuleColoriage; |
} |
/** |
* Méthode donnerImageSimple() - Fournit image non cliquable. |
* |
* La méthode donnerImageSimple ($objet) permet de récupérer une image non cliquable. |
* |
*@param object un objet carto. |
*@return string le code XHTML de l'image non cliquable. |
*/ |
function donnerImageSimple($objet) |
{ |
$nom_fichier_image = $this->_donnerIdUnique(); |
$objet->_lancerColoriage('', $nom_fichier_image); |
$retour = '<img src="cartographie/bibliotheque/lib.carto.extractimg.php?fichier='.$nom_fichier_image.'" alt="Carte" />'; |
return $retour; |
} |
/** |
* Méthode ajouterFils() - Ajoute une sous-carte. |
* |
* La methode ajouterFils() est essentielle. Elle permet d'ajouter toutes les sous cartes voulues. |
* Il faut lui indiquer, comme a la carte du niveau du dessus, son nom, le masque, le fond et info_table_couleur. |
* On a ainsi une inclusion d'objets les uns dans les autres. |
* |
*@return null l'objet carte fils est ajouté.; |
*/ |
function ajouterFils($id, $id_zone_geo_carte, $nom, $masque, $fond, $info_table_zg, $info_table_action) |
{ |
$this->fils[$id] = new Carto_Carte($id, $id_zone_geo_carte, $nom, $masque, $fond, $this->chemin, $info_table_zg, $info_table_action); |
//Si on ajoute à la carte du monde comme fils celle de l'europe, alors |
//on aura comme valeur pour $this->filiation de la carte d'europe : monde*europe |
$this->fils[$id]->filiation = $this->filiation.'*'.$id; |
$this->fils[$id]->url = $this->url; |
//Si on ajoute à la carte du monde dont le nom est 'Monde' comme fils celle de l'europe, |
//dont le nom est 'Europe', alors on aura comme valeur pour $this->nom de la carte d'europe : Monde*Europe |
$this->fils[$id]->nom = $this->nom.'*'.$nom; |
$this->fils[$id]->historique_cartes = $this->historique_cartes; |
} |
//********************************************************************************************************* |
// La methode donnerFormulaireImage() est la methode principale de la carto. C'est elle qui gere ce qu'il y a faire en |
// fonction de l'action de l'utilisateur. |
// Trois cas se distinguent : |
// -soit l'utilisateur a clique sur un point de la carte. |
// -soit il a clique sur un des liens que l'on a afficher avec la méthode afficherHistoriqueCarte de l'objet Carto_HistoriqueCarte. |
// -soit il a sélectionné une zone géographique dans la liste déroulante. |
// Elle renvoit a la fin: |
// -soit une nouvelle carte coloriée |
// -soit false. |
//********************************************************************************************************** |
function donnerFormulaireImage () |
{ |
//global $GS_GLOBAL; |
$res = ''; |
// Nous commençons par tester tout d'abords si nous venons d'une autre carte. Pour cela nous vérifions, |
// si les attributs $this->image_x et $this->image_y de la classe Carte existe ou ne sont pas null. |
// La carte est une image appelée par une balise <input type="image"> et non par une balise classique <img>. |
// Ansi, lorsqu'on clique sur la carte le formulaire appelle (via l'url du formulaire) l'application |
// utilisant la classe carte et lui renvoit deux variables contenant les coordonnées x et y du clic. |
// L'application instancie à nouveau les objets cartes mais cette fois ci la carte affichée dépendra des |
// informations founit par une table de la base de données. |
// La classe carto_action instanciée dans l'application utilisant la classe carte fournit les noms |
// des champs et celui de la table contenant les valeur RVB de chaque zone des cartes, l'identifiant |
// de la zone et l'action à entreprendre pour la zone conssidérée. |
// La méthode imgform() utilise la méthode get_cartoAction() de l'objet Carto_Action pour connaître |
// en fonction des coordonnées du clic l'action à entreprendre. |
// Quoi qu'il arrive, on ouvre la balise formulaire |
$res = '<form id="cartographie" action="'.$this->url.'" method="post">'."\n"; |
$res .= '<p>'; |
if (isset ($this->image_x) && ($this->image_x != '') && isset ($this->image_y) && ($this->image_y != '')) { |
// on regarde ici si l'on a pas un objet de plus bas niveau présent dans la variable de session carte |
//a charger a la place de l'objet de plus haut niveau |
$var_session_retour = $_SESSION['carte']; |
if ($var_session_retour) { |
$image_x = $this->image_x; |
$image_y = $this->image_y; |
$liste_zone_carte = $this->liste_zone_carte; |
// Nous chargons alors l'ojet approprié en descendant grâce a la généalogie |
$historique_cartes = explode('*',$this->historique_cartes); |
foreach ($historique_cartes as $key => $value) { |
if ($key != 0) { |
//$this = $this->fils[$value]; |
foreach (get_object_vars($this->fils[$value]) as $key => $value) { |
$this->$key = $value; |
} |
} |
} |
$this->image_x = $image_x; |
$this->image_y = $image_y; |
$this->liste_zone_carte = $liste_zone_carte; |
unset($_SESSION['carte']) ; |
} |
// on regarde qu'est-ce qu'on doit faire grace a la methode _consulterAction() de l'objet Carto_Action |
$action = $this->_action->_consulterActionImage($this->image_x, $this->image_y, $this->masque, $this->id); |
// Nous distinguons 2 cas : |
//le cas ou il faut afficher une nouvelle carte ... : |
if ($action['type_action'] == 'Aller_a') { |
$id_carte_destination = $action['id_carte_destination'] ; |
$this->fils[$id_carte_destination]->liste_zone_carte = $this->liste_zone_carte; |
$res .= ''.$this->fils[$id_carte_destination]->_donnerListeZoneCarte()."<br />\n"; |
$res .= '<input type="image" src="'; |
$id_image = $this->_donnerIdUnique(); |
$this->fils[$id_carte_destination]->_lancerColoriage($id_image); |
$obj = serialize($this->fils[$id_carte_destination]); |
$_SESSION['carte'] = $obj; |
$this->historique = $this->fils[$id_carte_destination]->filiation; |
$this->id = $this->fils[$id_carte_destination]->id; |
$this->nom = $this->fils[$id_carte_destination]->nom; |
} |
//Dans le cas où l'on veut rappeler une nouvelle carte, il se peut que la nouvelle carte à rappeler |
//soit la même que précédement. |
//Cette possibilité peut se présenter quand on clique sur un zone blanche d'une carte (càd dans la mer) |
//Là, on recharge la carte précédente : |
elseif ($action['type_action'] == 'Recharger') { |
$res .= ''.$this->_donnerListeZoneCarte()."<br />\n"; |
$res .= '<input type="image" src="'; |
$id_image = $this->_donnerIdUnique(); |
$this->_lancerColoriage($id_image); |
$obj = serialize($this); |
$_SESSION['carte'] = $obj ; |
$this->historique = $this->filiation; |
} |
// ... et le cas ou il faut lancer le dernier niveau |
else if ($action['type_action'] == 'Stop') { |
unset ($_SESSION['carte']) ; |
$this->historique = $this->filiation.'*'.$action['id_zone_geo']; |
$obj = serialize($this); |
$_SESSION['carte'] = $obj ; |
return false; |
} |
} |
elseif ($this->liste_zone_carte != '') { |
$liste_zone_carte = $this->liste_zone_carte; |
$historique_cartes = explode('*',$this->historique_cartes); |
foreach ($historique_cartes as $key => $value) { |
if ($key != 0) { |
//$this = $this->fils[$value]; |
foreach (get_object_vars($this->fils[$value]) as $key => $value) { |
$this->$key = $value; |
} |
} |
} |
$this->liste_zone_carte = $liste_zone_carte; |
$res .= ''.$this->_donnerListeZoneCarte($this->liste_zone_carte)."<br />\n"; |
$res .= '<input type="image" src="'; |
$id_image = $this->_donnerIdUnique(); |
$this->_lancerColoriage($id_image, '', $this->liste_zone_carte); |
$this->historique = $this->historique_cartes; |
$obj = serialize($this); |
$_SESSION['carte'] = $obj ; |
} |
// On teste maintenant si l'on vient d'un lien. Si c'est le cas on a recu un argument |
// qui nous donne la "genealogie" de la carte que l'on doit afficher |
else if ($this->historique_cartes) { |
// Nous chargons alors l'ojet approprié en descendant grâce a la généalogie |
$historique_cartes = explode('*',$this->historique_cartes); |
foreach ($historique_cartes as $key => $value) { |
if ($key != 0) { |
//$this = $this->fils[$value]; |
foreach (get_object_vars($this->fils[$value]) as $key => $value) { |
$this->$key = $value; |
} |
} |
} |
// une foit que l'on a charge le bon objet nous le colorions |
$res .= ''.$this->_donnerListeZoneCarte()."<br />\n"; |
$res .= '<input type="image" src="'; |
$id_image = $this->_donnerIdUnique(); |
$this->_lancerColoriage($id_image); |
$this->historique = $this->historique_cartes; |
$obj = serialize($this); |
$_SESSION['carte'] = $obj ; |
} |
// Enfin si on ne vient pas d'une carte ou d'un lien c'est que l'on vient de l'onglet carto du menu |
// et on affiche alors la premiere carte |
else { |
unset ($_SESSION['carte']) ; |
$res .= ''.$this->_donnerListeZoneCarte()."<br />\n"; |
$res .= '<input type="image" src="'; |
$id_image = $this->_donnerIdUnique(); |
$this->_lancerColoriage($id_image); |
$this->historique = $this->id; |
$obj = serialize($this); |
$_SESSION['carte'] = $obj; |
} |
$_SESSION['chemin'] = CAR_CHEMIN_TMP; |
$_SESSION['fichier'] = $this->id.$id_image; |
$res .= CAR_CHEMIN_CARTE.'"'; |
$res .= ' name="image" onmouseover="javascript:show(\'d\');" onmouseout="javascript:show(\'d\');" />'."\n"; |
$res .= '<input type="hidden" name="historique_cartes" value="'.$this->historique.'" />'."\n"; |
$res .= '</p>'."\n"; |
$res .= '</form>'."\n"; |
return $res; |
} |
// +--------------------------------------------------------------------------------------------------+ |
// LES METHODES PRIVÉES |
function _donnerListeZoneCarte($zone_par_defaut = '') |
{ |
$retour = ''; |
$requete = 'SELECT '.$this->_info_table_zg['nom_chp_id_zone'].', '.$this->_info_table_zg['nom_chp_nom_zone'].' '. |
'FROM '.$this->_info_table_zg['nom_table_zone'].' '; |
// Nous éliminons la zone blanche ne correspondant à rien |
if (ereg('[a-z]+', $this->_info_table_zg['nom_chp_id_zone'])) { |
$requete .= 'WHERE '.$this->_info_table_zg['nom_chp_id_zone'].' != "0" '; |
} else { |
$requete .= 'WHERE '.$this->_info_table_zg['nom_chp_id_zone'].' != 0 '; |
} |
// Nous sélectionnons en fonction de la zone géo supérieure. |
if ($this->_info_table_zg['nom_chp_zone_sup'] != '') { |
if (ereg('[a-z]+', $this->_id_zone_geo_carte)) { |
$requete .= 'AND '.$this->_info_table_zg['nom_chp_zone_sup'].' = "'.$this->_id_zone_geo_carte.'" '; |
} else{ |
$requete .= 'AND '.$this->_info_table_zg['nom_chp_zone_sup'].' = '.$this->_id_zone_geo_carte.' '; |
} |
} |
// Nous trions par ordre alphabétique |
$requete .= 'ORDER BY '.$this->_info_table_zg['nom_chp_nom_zone'].' ASC'; |
$resultat = mysql_query ($requete) or die(' |
<h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'. |
'<b>Fichier : </b>'. __FILE__ . |
'<b>Ligne : </b>'. __LINE__ . |
'<b>Requete : </b>'.$requete. |
'<br/><br/><b>Erreur : </b>'.mysql_error()); |
$i=0; |
$retour = '<select id="liste_zone_carte" name="liste_zone_carte" onchange="javascript:this.form.submit();">'."\n"; |
$retour .= '<option value="">Visualiser une zone :</option>'."\n"; |
$nom_chp_nom_zone = $this->_info_table_zg['nom_chp_nom_zone']; |
$nom_chp_id_zone = $this->_info_table_zg['nom_chp_id_zone']; |
while ($ligne = mysql_fetch_object ($resultat)) { |
if ($zone_par_defaut == $ligne->$nom_chp_id_zone) { |
$retour .= '<option value="'.$ligne->$nom_chp_id_zone.'" selected="selected">'.$ligne->$nom_chp_nom_zone.'</option>'."\n"; |
} else { |
$retour .= '<option value="'.$ligne->$nom_chp_id_zone.'">'.$ligne->$nom_chp_nom_zone.'</option>'."\n"; |
} |
$i++; |
} |
$retour .= '</select>'."\n"; |
return $retour; |
} |
//============================================================================== |
// METHODE _lancerColoriage() |
// |
// Elle lance le coloriage de l'image. |
// Elle est lancée toute seule par la méthode donnerFormulaireImage(). |
// Les informations qui lui sont necessaires sont déjà données à l'objet carte (fond, info_table_couleur). |
//============================================================================== |
function _lancerColoriage($id_image = '_00', $nom_fichier = '', $id_zone_a_reperer = '') |
{ |
$this->image = imagecreatefrompng($this->fond); |
$this->_colorierImage ($this->image, $this->_info_table_zg['nom_table_zone'], $this->_info_table_zg['nom_chp_id_zone'], $this->_info_table_zg['nom_chp_rouge'], |
$this->_info_table_zg['nom_chp_vert'], $this->_info_table_zg['nom_chp_bleu'], $this->_info_table_zg['nom_chp_zone_sup'], |
$this->_info_table_zg['tableau_valeurs_zone'], $id_zone_a_reperer) ; |
if ($nom_fichier != '') { |
imagepng(&$this->image, CAR_CHEMIN_TMP.$nom_fichier.'.png'); |
//$this->image = imagepng(&$this->image); |
} |
else { |
imagepng(&$this->image, CAR_CHEMIN_TMP.$this->id.$id_image.'.png'); |
//imagepng(&$this->image); |
} |
} |
//============================================================================== |
// METHODE _colorierImage() |
// |
// Elle réalise le coloriage de l'image. |
//============================================================================== |
function _colorierImage(&$image_fond, $table_zone_geo, $chp_id_zone_couleur, $chp_rouge, $chp_vert, $chp_bleu, $chp_zone_sup, $tableau_valeurs_zone, $id_zone_a_reperer) |
{ |
//---------------------------------------------------------------------------- |
// Cherche les valeurs RVB de la couleur de chaque zone géographique et les rentre dans |
//un tableau d'objets Carto_InformationCouleur (voir la description de la classe ci-dessus. |
$requete_01 = |
'SELECT *'. |
' FROM '.$table_zone_geo; |
if ($chp_zone_sup != ''){ |
if(ereg("[a-z]+",$this->_id_zone_geo_carte)){ |
$requete_01 .= |
' WHERE '.$chp_zone_sup.' = "'.$this->_id_zone_geo_carte.'"'; |
} |
else{ |
$requete_01 .= |
' WHERE '.$chp_zone_sup.' = '.$this->_id_zone_geo_carte; |
} |
} |
$resultat_01 = mysql_query ($requete_01) or die(' |
<H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'. |
'<b>Fichier : </b>'.__FILE__. |
'<b>Ligne : </b>'.__LINE__. |
'<b>Requete : </b>'.$requete_01. |
'<br/><br/><b>Erreur : </b>'.mysql_error()); |
$i=0; |
$attachments = array(); |
while ($ligne_01 = mysql_fetch_object($resultat_01)) { |
$attachments[$i] = new Carto_Couleur($ligne_01->$chp_id_zone_couleur, $ligne_01->$chp_rouge, $ligne_01->$chp_vert, $ligne_01->$chp_bleu); |
$i++; |
} |
//Nous libérons toute la mémoire associée à l'identifiant de résultat. |
mysql_free_result ($resultat_01); |
//---------------------------------------------------------------------------- |
// On realide l'association entre l'index des couleurs et la zone de meme couleur |
$attachments = $this->_construireAssociationIndexZone ($image_fond, $attachments); |
//---------------------------------------------------------------------------- |
//Dans l'application qui utilise la classe carte, nous avons instancié un tableau |
//associatif qui contient en clé l'identifiant d'une zone géographique et en valeur |
//un nombre (qui peut-être un nombre d'inscrit, d'institutions, de taxons...). |
// Nous récupérons ci-dessous la valeur minimum autre que 0 présente dans ce tableau |
//puis une valeur conscidérée comme maximum |
if (!is_array($tableau_valeurs_zone)) { |
$mini = 0; |
$medium = 0; |
$maxi = 0; |
$nbre_valeurs = 0; |
} |
else { |
if (count($tableau_valeurs_zone) == 0) { |
$mini=0; |
$medium = 0; |
$maxi=0; |
} |
else { |
$i=0; |
foreach ($tableau_valeurs_zone as $cle => $valeur) { |
//Nous recherchons le minimum, le maximum et le la valeur médium juste au dessous du maximum. |
if ($valeur != 0) { |
$tablo_valeurs[$i] = $valeur; |
$i++; |
} |
} |
//Nombre d'entrées dans le tableau de valeurs non nulles : |
$nbre_valeurs = count($tablo_valeurs); |
$somme_valeurs = array_sum($tablo_valeurs); |
$tablo_frequences = array_count_values($tablo_valeurs); |
$nbre_frequences = count($tablo_frequences); |
if ($nbre_valeurs > 0){ |
//Nous trions le tableau dans l'ordre croissant : |
sort($tablo_valeurs); |
//Nous récupérons la valeur la plus petite : |
$mini = $tablo_valeurs[0]; |
$maxi = $tablo_valeurs[$nbre_valeurs-1]; |
isset($tablo_valeurs[$nbre_valeurs-2]) ? $medium = $tablo_valeurs[$nbre_valeurs-2] : $medium = 0; |
$moyenne = $somme_valeurs/$nbre_valeurs; |
$ecart_au_carre_moyen = 0; |
for ($i = 0; $i < $nbre_valeurs; $i++) { |
$ecart_au_carre_moyen += pow(($tablo_valeurs[$i] - $moyenne), 2); |
} |
$variance = $ecart_au_carre_moyen/$nbre_valeurs; |
$ecart_type = sqrt($variance); |
$moyenne = round($moyenne, 0); |
$variance = round($variance, 0); |
$ecart_type = round($ecart_type, 0); |
/*echo 'Nombre de valeurs : '.$nbre_valeurs.'<br>'; |
echo 'Nombre de frequences : '.$nbre_frequences.'<br>'; |
echo 'Moyenne : '.$moyenne.'<br>'; |
echo 'Variance : '.$variance.'<br>'; |
echo 'Ecart-type : '.$ecart_type.'<br>'; |
echo 'Formule de coloriage : '.$this->_formule_coloriage.'<br>'; |
echo "mini : $mini medium : $medium maxi : $maxi<br/>"; |
*/ |
} |
} |
} |
//---------------------------------------------------------------------------- |
// Nous réalisons le coloriage de toutes les zones : |
$requete_03 = 'SELECT '.$chp_id_zone_couleur.' '. |
'FROM '.$table_zone_geo; |
$resultat_03 = mysql_query ($requete_03) or die(' |
<h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'. |
'<b>Fichier : </b>'.__FILE__. |
'<b>Ligne : </b>'.__LINE__. |
'<b>Requete : </b>'.$requete_03. |
'<br/><br/><b>Erreur : </b>'.mysql_error()); |
while ($ligne_03 = mysql_fetch_object ($resultat_03)) { |
$id_zone_geo = $ligne_03->$chp_id_zone_couleur; |
if (!isset ($tableau_valeurs_zone[$id_zone_geo])) { |
$tableau_valeurs_zone[$id_zone_geo] = 0; |
} |
//Nous cherchons la couleur a afficher pour chaque zone. |
if ($tableau_valeurs_zone[$id_zone_geo] != 0) { |
//echo 'ZONE:'.$id_zone_geo."<br/>"; |
//echo $tableau_valeurs_zone[$id_zone_geo]."<br/>"; |
$theColor = $this->_donnerCouleur ( |
$this->_miniR, $this->_miniV, $this->_miniB, |
$this->_mediumR , $this->_mediumV , $this->_mediumB , |
$this->_maxiR , $this->_maxiV , $this->_maxiB , |
$mini, $medium, $maxi, $nbre_valeurs, $ecart_type, $moyenne, $tablo_valeurs, |
$tablo_frequences, $nbre_frequences, |
$tableau_valeurs_zone[$id_zone_geo], |
$this->_formule_coloriage); |
//echo $theColor['R'].'<br>'; |
//echo $theColor['V'].'<br>'; |
//echo $theColor['B'].'<br>'; |
} |
else { |
$theColor['R'] = $this->_zeroR; |
$theColor['V'] = $this->_zeroV; |
$theColor['B'] = $this->_zeroB; |
} |
//Nous réalisons le coloriage de toutes les zones de l'image avec la couleur obtenue. |
$this->_remplacerCouleur ($image_fond, $attachments, $id_zone_geo, $theColor['R'], $theColor['V'], $theColor['B'], $id_zone_a_reperer); |
} |
//Nous libérons toute la mémoire associée à l'identifiant de résultat de la requête. |
mysql_free_result ($resultat_03); |
} |
//============================================================================== |
// METHODE _construireAssociationIndexZone ($image, &$att) |
// |
// Le tableau $att est passé par référence. La méthode modifie donc directement |
// le tableau et ne renvoit donc rien. |
// Attache dans un tableau $att, contenant sous forme d'objet (Carto_ColorInfo) |
// les valeurs RVB des zones d'une image, la valeur de l'index correspondant |
// à la couleur de la zone. |
// Note : les images en question sont constituées de zones distincte possédant |
// chacune une couleur unique et unie. |
//============================================================================== |
function _construireAssociationIndexZone(&$image_fond, &$att) |
{ |
// Nous récupérons le nombre de couleur différentes contenues dans l'image. |
//echo $this->fond.'<BR>'; |
$image_fond = imagecreatefrompng($this->fond); |
$taille_palette = imagecolorstotal ($image_fond); |
//echo $taille_palette.'<br>'; |
// Pour chaque couleur contenue dans l'image, nous cherchons l'objet correspondant |
// dans le tableau $att, qui contient des informations sur chaque zone de l'image, |
// et nous attribuons à l'objet la valeur de l'index de sa couleur dans l'image. |
for ($i = 0; $i < $taille_palette; $i++) { |
$valeurs_RVB = array(); |
$valeurs_RVB = imagecolorsforindex ($image_fond, $i); |
for ($j = 0; $j < count ($att); $j++) { |
if (($att[$j]->rouge == $valeurs_RVB['red']) && ($att[$j]->vert == $valeurs_RVB['green']) && ($att[$j]->bleu == $valeurs_RVB['blue'])) { |
$att[$j]->index = $i; |
//echo 'ICI'.$att[$j]->id_zone.$att[$j]->index.'<br>'; |
break; |
} |
} |
} |
return $att; |
}//Fin méthode _construireAssociationIndexZone() |
//============================================================================== |
// METHODE _donnerCouleur() |
//------------------------------------------------------------------------------ |
// Renvoie pour une valeur donnee la couleur a mettre |
//------------------------------------------------------------------------------ |
// ENTREE |
// $miniR : valeur rouge du minimum |
// $miniV : valeur vert du minimum |
// $miniB : valeur blue du minimum |
// $maxiR : valeur rouge du maximum |
// $maxiV : valeur vert du maximum |
// $maxiB : valeur bleu du maximum |
// $mediumR : valeur rouge du deuxieme maximum |
// $mediumV : valeur vert du deuxieme maximum |
// $mediumB : valeur bleu du deuxieme maximum |
// $mini : valeur mini sur l'echelle |
// $medium : valeur juste au dessous du maximum sur l'echelle |
// $maxi : valeur maxi sur l'echelle |
// $val : valeur dont on cherche la couleur |
//------------------------------------------------------------------------------ |
// SORTIE |
// $couleur array donne la couleur pour la valeur demande ($val) |
//------------------------------------------------------------------------------ |
function _donnerCouleur($miniR, $miniV, $miniB, $mediumR, $mediumV, $mediumB, $maxiR, |
$maxiV, $maxiB, $mini, $medium, $maxi, $nbre_valeurs, $ecart_type, $moyenne, $tablo_valeurs, $tablo_frequences, $nbre_frequences, $val, $formuleColoriage) |
{ |
if ($formuleColoriage == 'defaut'){ |
if ($val == $maxi) { |
$couleur['R'] = $maxiR; |
$couleur['V'] = $maxiV; |
$couleur['B'] = $maxiB; |
} |
if ($val == $mini && $val != $maxi) { |
$couleur['R'] = $miniR; |
$couleur['V'] = $miniV; |
$couleur['B'] = $miniB; |
} |
if ($maxi/10 > $medium && $maxi/40 < $medium) { |
$diff = $medium - $mini; |
if ($diff > 0 && $val != $medium && $val != $maxi) { |
$diffR = $mediumR - $miniR; |
$diffV = $mediumV - $miniV; |
$diffB = $mediumB - $miniB; |
$variationR = round ( ($diffR/$diff ), 0 ); |
$variationV = round ( ($diffV/$diff ), 0 ); |
$variationB = round ( ($diffB/$diff ), 0 ); |
$couleur['R'] = Carto_Couleur::couleur_bornerNbre(($miniR + ($val * $variationR)), 0, 255); |
$couleur['V'] = Carto_Couleur::couleur_bornerNbre(($miniV + ($val * $variationV)), 0, 255); |
$couleur['B'] = Carto_Couleur::couleur_bornerNbre(($miniB + ($val * $variationB)), 0, 255); |
} |
else if ($val == $medium) { |
$couleur['R'] = $mediumR; |
$couleur['V'] = $mediumV; |
$couleur['B'] = $mediumB; |
} |
} |
else { |
$diff = $maxi - $mini; |
if ($diff > 0 && $val != $maxi && $val != $mini) { |
$diffR = $maxiR - $miniR; |
$diffV = $maxiV - $miniV; |
$diffB = $maxiB - $miniB; |
$variationR = round ( ($diffR/$diff ), 0 ); |
$variationV = round ( ($diffV/$diff ), 0 ); |
$variationB = round ( ($diffB/$diff ), 0 ); |
$couleur['R'] = Carto_Couleur::couleur_bornerNbre(($miniR + ($val * $variationR)), 0, 255); |
$couleur['V'] = Carto_Couleur::couleur_bornerNbre(($miniV + ($val * $variationV)), 0, 255); |
$couleur['B'] = Carto_Couleur::couleur_bornerNbre(($miniB + ($val * $variationB)), 0, 255); |
} |
else if ($diff == 0){ |
$couleur['R'] = $mediumR; |
$couleur['V'] = $mediumV; |
$couleur['B'] = $mediumB; |
} |
} |
} |
elseif ($formuleColoriage == 'ecart_type') { |
if ($ecart_type == 0) { |
$couleur['R'] = $maxiR; |
$couleur['V'] = $maxiV; |
$couleur['B'] = $maxiB; |
} |
elseif ($ecart_type >= 1 && $ecart_type <= 15) { |
if ($val == $mini) { |
$couleur['R'] = $miniR; |
$couleur['V'] = $miniV; |
$couleur['B'] = $miniB; |
} |
elseif ($val == $medium) { |
$couleur['R'] = $mediumR; |
$couleur['V'] = $mediumV; |
$couleur['B'] = $mediumB; |
} |
elseif ($val == $maxi) { |
$couleur['R'] = $maxiR; |
$couleur['V'] = $maxiV; |
$couleur['B'] = $maxiB; |
} |
else { |
$dif_valeur_maxi_mini = $maxi - $mini; |
$diffR = $maxiR - $miniR; |
$diffV = $maxiV - $miniV; |
$diffB = $maxiB - $miniB; |
$variationR = round ( ($diffR/$dif_valeur_maxi_mini ), 0 ); |
$variationV = round ( ($diffV/$dif_valeur_maxi_mini ), 0 ); |
$variationB = round ( ($diffB/$dif_valeur_maxi_mini ), 0 ); |
$couleur['R']=$miniR + ($val * $variationR); |
$couleur['V']=$miniV + ($val * $variationV); |
$couleur['B']=$miniB + ($val * $variationB); |
} |
} |
elseif ($ecart_type > 15) { |
//Le tableau est trié de la plus petite à la plus grande clé. |
ksort($tablo_frequences); |
$i = 0; |
foreach ($tablo_frequences as $cle => $valeur){ |
//Nous cherchons la correspondance entre la valeur et la clé. |
if ($cle == $val) { |
//Pour faire le Rouge, Vert, Bleu |
$couleur['R'] = $miniR + ($i/$nbre_frequences) * ($maxiR - $miniR); |
$couleur['V'] = $miniV + ($i/$nbre_frequences) * ($maxiV - $miniV); |
$couleur['B'] = $miniB + ($i/$nbre_frequences) * ($maxiB - $miniB); |
} |
$i++; |
} |
} |
} |
return $couleur; |
}//Fin méthode _donnerCouleur() |
//============================================================================== |
// METHODE _remplacerCouleur ($img, $att, $id_zone_geo, $r, $g, $b) |
// |
// $img is the image, $att an array of carto_colorinfo objects, $id_zone_geo the name |
// of an object of $att, ($r, $g, $b) the new color. |
// |
// In the palette of $img, the color matching with $id_zone_geo is modified. |
//============================================================================== |
function _remplacerCouleur (&$image, &$atta, $id_zone_geo, $rouge, $vert, $bleu, $id_zone_a_reperer) |
{ |
// Nous recherchons la valeur de l'index. |
$index = -1; |
for ($i = 0; $i < count ($atta); $i++) { |
if ($atta[$i]->id_zone == $id_zone_geo) { |
$index = $atta[$i]->index; |
//Dans le cas où nous voulons repérer une zone sur la carte : |
if($id_zone_geo == $id_zone_a_reperer) { |
$rouge = 255; |
$vert = 0; |
$bleu = 0; |
} |
break; |
} |
} |
// Nous mettons à jour l'image de la carte avec la valeur de l'index. |
if ($index >= 0) { |
imagecolorset (&$image, $index, $rouge, $vert, $bleu); |
} |
}//Fin de la méthode _remplacerCouleur |
//============================================================================== |
// METHODE _donnerIdUnique () |
// |
// Cette méthode privée retourne un identifiant de 32 caractères unique. |
// |
//============================================================================== |
function _donnerIdUnique () |
{ |
$id = ''; |
$id = md5 (uniqid (rand())); |
return $id; |
}//Fin de la méthode _donnerIdUnique() |
}//Fin de la classe Carto_Carte() |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2005/03/03 08:58:11 jpm |
* Correction erreur dans requête sélection des zones de la carte. |
* |
* Revision 1.2 2005/03/01 15:20:34 jpm |
* Modification des fichiers au niveau des infos d'erreur de requete sql. |
* |
* Revision 1.1 2005/02/28 15:03:49 jpm |
* Ajout des fichiers de la bibliothèque cartographique. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2015_03_02/bibliotheque/cartographie/carto_couleur.class.php |
---|
New file |
0,0 → 1,190 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.3 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This file is part of Cartographie. | |
// | | |
// | Foobar 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; either version 2 of the License, or | |
// | (at your option) any later version. | |
// | | |
// | Foobar 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. | |
// | | |
// | You should have received a copy of the GNU General Public License | |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: carto_couleur.class.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Classe Carto_Couleur. |
* |
* Classe permettant de réaliser des cartes. |
* |
*@package Cartographie |
//Auteur original : |
*@author Nicolas MATHIEU |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2005 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* Classe Carto_Couleur() - Info sur les couleurs. |
* |
* La classe Carto_Couleur n'est utilisée que par la classe carte. |
* C'est une classe privée. |
* Elle sert à stocker les informations (RVB et index) sur la couleur d'une |
* zone d'une image. |
*/ |
class Carto_Couleur |
{ |
// +--------------------------------------------------------------------------------------------------+ |
// LES ATTRIBUTS DE LA CLASSE |
var $id_zone; |
var $rouge; |
var $vert; |
var $bleu; |
var $index; |
// +--------------------------------------------------------------------------------------------------+ |
// LE CONSTRUCTEUR DE LA CLASSE |
/** |
* Constructeur Carto_Couleur() |
* |
* Constructeur initialisant les attributs de la classe Carto_Couleur(). |
*/ |
function Carto_Couleur($id_zone, $rouge, $vert, $bleu) |
{ |
$this->id_zone = $id_zone; |
$this->rouge = $rouge; |
$this->vert = $vert; |
$this->bleu = $bleu; |
$this->index = -1; |
} |
// +--------------------------------------------------------------------------------------------------+ |
// LES METHODES PUBLIQUES |
/** |
* La fonction array couleur_hexadecimalAuRgb(string color) renvoie des valeurs de couleur en RGB. |
* |
*Cette fonction prend une valeur de couleur codée en hexadécimal et retourne |
*les valeurs RGB correspondantes sous forme de tableau. |
*Exemple d'utilisation: |
*$rgb = couleur_hexadecimalAuRgb("fffc49"); |
*echo "<br>couleur_hexadecimalAuRgb de 'fffc49' : ".$rgb['R']." ".$rgb['V']." ".$rgb['B']; |
* |
*@author iubito <sylvain_machefert@yahoo.fr> |
*@copyright iubito - http://iubito.free.fr/ - 2003 |
* |
*@param string $couleur représente une couleur codée en héxadécimal. |
* |
*@return array tableau associatif contenant les 3 valeurs RGB, avec clé du rouge 'R', |
* du vert 'V' et enfin du bleu 'B'. |
*/ |
function couleur_hexadecimalAuRgb($couleur_html) |
{ |
//gestion du #... |
if (substr($couleur_html, 0, 1) == "#") { |
$couleur_html = substr($couleur_html, 1, 6); |
} |
$tablo_rgb['R'] = hexdec(substr($couleur_html, 0, 2)); |
$tablo_rgb['V'] = hexdec(substr($couleur_html, 2, 2)); |
$tablo_rgb['B'] = hexdec(substr($couleur_html, 4, 2)); |
return $tablo_rgb; |
} |
/** |
* La fonction string couleur_rgbAuHexadecimal(array tablo) renvoie la valeur d'une |
*couleur en héxadécimal. |
* |
*Cette fonction prend un tableau de valeurs d'une couleur codées en RGB et retourne |
*la valeur hexadécimal correspondante sous forme de chaîne. |
*C'est la réciproque exacte de la fonction couleur_hexadecimalAuRgb. |
* |
*@author iubito <sylvain_machefert@yahoo.fr> |
*@copyright iubito - http://iubito.free.fr/ - 2003 |
* |
*@param array $tablo_RGB représente un tableau associatif avec les valeurs RGB |
*d'une couleur.Les trois clés du tableau sont : R pour rouge, V pour vert et B pour bleu. |
* |
*@return string chaîne contenant la valeur de la couleur sous forme héxadécimale. |
*/ |
function couleur_rgbAuHexadecimal($tablo_rgb) |
{ |
//Vérification des bornes... |
foreach($tablo_rgb as $cle => $valeur) { |
$tablo_rgb[$cle] = bornes($tablo_rgb[$cle],0,255); |
} |
//Le str_pad permet de remplir avec des 0 |
//parce que sinon couleur_rgbAuHexadecimal(array(0,255,255)) retournerai #0ffff<=manque un 0 ! |
return "#".str_pad(dechex(($tablo_rgb['R']<<16)|($tablo_rgb['V']<<8)|$tablo_rgb['B']),6,"0",STR_PAD_LEFT); |
} |
/** |
* La fonction int couleur_bornerNbre(int nb, int min, int max) borne des nombres. |
* |
*Cette fonction permet de borner la valeur d'un nombre entre un minimum $mini et |
*un maximum $maxi. |
* |
*@author iubito <sylvain_machefert@yahoo.fr> |
*@copyright iubito - http://iubito.free.fr/ - 2003 |
* |
*@param integer $nbre le nombre à borner. |
*@param integer $mini la borne minimum. |
*@param integer $maxi la borne maximum. |
* |
*@return integer le nombre limité aux bornes si nécessaire. |
*/ |
function couleur_bornerNbre($nbre, $mini, $maxi) |
{ |
if ($nbre < $mini) { |
$nbre = $mini; |
} |
if ($nbre > $maxi) { |
$nbre = $maxi; |
} |
return $nbre; |
} |
}//Fin de la classe Carto_Couleur |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.1 2005/02/28 15:03:49 jpm |
* Ajout des fichiers de la bibliothèque cartographique. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2015_03_02/bibliotheque/cartographie/cartes/monde5c.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/monde5c.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/samerique.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/samerique.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/afrique.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/afrique.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/asie_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/asie_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/france.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/france.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/europe.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/europe.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/namerique_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/namerique_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/oceanie.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/oceanie.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/monde_masque5c.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/monde_masque5c.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/samerique_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/samerique_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/afrique_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/afrique_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/moyenorient.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/moyenorient.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/france_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/france_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/europe_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/europe_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/oceanie_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/oceanie_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/asie.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/asie.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/moyenorient_masque.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/moyenorient_masque.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/cartographie/cartes/namerique.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2015_03_02/bibliotheque/cartographie/cartes/namerique.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2015_03_02/bibliotheque/bb_commun.fonct.php |
---|
New file |
0,0 → 1,171 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library 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 | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: bb_commun.fonct.php,v 1.3 2007-02-14 11:37:50 jp_milcent Exp $ |
/** |
* Fonctions communes aux applications de Biblio Bota. |
* |
* Contient des fonctions communes aux applications de Biblio Bota. |
* |
*@package BiblioBota |
*@subpackage Fonctions |
//Auteur original : |
*@author Jean-Charles GRANGER <tela@vecteur.org> |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@clapas.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.3 $ $Date: 2007-02-14 11:37:50 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
// string check_if_modif($table) |
// vérifie dans la table des modifications si une donnée |
// est sujette à modifications |
// entrées : |
// - string $table : nom de la table des modifs |
// - string $field_src : nom du champ source |
// - string $fiche_id : identifiant de la fiche |
// sortie : |
function check_if_modif($table, $tbl_src, $fiche_id) |
{ |
$query = 'SELECT * '. |
'FROM '.$table.' '. |
'WHERE B_MOD_TABLESRC = "'.$tbl_src.'" '. |
'AND B_MOD_FICHESRC = "'.$fiche_id.'"'; |
$resu = mysql_query($query) or die ("<B>Erreur !!!</B> : la vérification des modifications a échoué... $query"); |
$nb_resu = mysql_num_rows($resu); |
mysql_free_result($resu); |
return $nb_resu; |
} |
/** |
* La fonction remplaceEntiteHTLM() remplace des caractères par les entités html. |
* |
* Cette fonction retourne un texte dans lequel touts les caractères correspondant |
* à des entités html sont remplacés par la valeur de l'entité, à l'exception |
* des caractères <, >, & et ". |
* Cela permet de remplacer toutes les entités dans une chaine contenant du html. |
* |
*@param string la chaîne html à parsser. |
*@return string contient la chaîne html avec les entités intégrées. |
*/ |
function remplaceEntiteHTLM($texte) |
{ |
$texte_retour = ''; |
$tab_entites = get_html_translation_table(HTML_ENTITIES); |
unset($tab_entites['"']); |
unset($tab_entites['<']); |
unset($tab_entites['>']); |
unset($tab_entites['&']); |
$tab_entites[' & '] = ' & '; |
return strtr($texte, $tab_entites); |
} |
/** |
* Fonction fournissant une date au format français depuis une date Mysql |
* |
* @param string la date au format Mysql |
* @return string la date au format français |
*/ |
function donnerDateConviviale($chaine) |
{ |
if (preg_match('/^(\d{4})-(\d{2})$/',$chaine, $match)) { |
$annee = $match[1]; |
$mois = $match[2]; |
switch ($mois) { |
case '00' : |
$mois_sortie = ''; |
break; |
case '01' : |
$mois_sortie = 'janvier'; |
break; |
case '02' : |
$mois_sortie = 'février'; |
break; |
case '03' : |
$mois_sortie = 'mars'; |
break; |
case '04' : |
$mois_sortie = 'avril'; |
break; |
case '05' : |
$mois_sortie = 'mai'; |
break; |
case '06' : |
$mois_sortie = 'juin'; |
break; |
case '07' : |
$mois_sortie = 'juillet'; |
break; |
case '08' : |
$mois_sortie = 'août'; |
break; |
case '09' : |
$mois_sortie = 'septembre'; |
break; |
case '10' : |
$mois_sortie = 'octobre'; |
break; |
case '11' : |
$mois_sortie = 'novembre'; |
break; |
case '12' : |
$mois_sortie = 'décembre'; |
break; |
} |
if ($mois_sortie != '') { |
return $mois_sortie.' '.$annee; |
} else { |
return $annee; |
} |
} else { |
return '?'; |
} |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.2 2007/02/13 17:40:22 jp_milcent |
* Ajout d'une fonction pour formater de manière conviviale les dates Mysql. |
* |
* Revision 1.1 2005/11/23 10:22:25 jp_milcent |
* Ajout au dépot de l'application BiblioBota. |
* Elle doit à terme migrer dans eFlore. |
* |
* Revision 1.2 2005/05/17 10:10:08 jpm |
* Correction des bogues avant mise en ligne du site v4. |
* |
* Revision 1.1 2004/09/14 11:12:50 jpm |
* Ajout des fonctions communes aux applications de BiblioBota. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |