New file |
0,0 → 1,208 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 5.0.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_action.class.php,v 1.1 2005-02-17 10:58:00 jpm 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-2004 |
*@version $Revision: 1.1 $ $Date: 2005-02-17 10:58:00 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
//================================================================================================ |
//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 |
{ |
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; |
|
function Carto_Action ($table_zone_geo, $zone_chp_id_zone, $chp_rouge, |
$chp_vert, $chp_bleu, $table_carto_action, $action_chp_id_carte, $action_chp_id_zone, |
$action_chp_type_zone, $chp_action, $chp_destination) |
{ |
$this->_table_zone_geo = $table_zone_geo; |
$this->_id_zone_geo_zone = $zone_chp_id_zone; |
$this->_rouge = $chp_rouge; |
$this->_vert = $chp_vert; |
$this->_bleu = $chp_bleu; |
$this->_table_action = $table_carto_action; |
$this->_id_carte_action = $action_chp_id_carte; |
$this->_id_zone_geo_action = $action_chp_id_zone; |
$this->_type_zone_geo_action = $action_chp_type_zone; |
$this->_action = $chp_action; |
$this->_id_carte_destination = $chp_destination; |
} |
|
//********************************************************************************************************** |
// Méthode get_cartoAction($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>Requete : </b>'.$requete. |
'<br/><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>Requete : </b>'.$requete. |
'<br/><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. |
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
|
// +--------------------------------------------------------------------------------------------------+ |
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |