Rev 4 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?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_action.class.php,v 1.2 2005-02-22 16:35:16 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.2 $ $Date: 2005-02-22 16:35:16 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | 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 CLASSEvar $_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>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.// +------------------------------------------------------------------------------------------------------+// | PIED du PROGRAMME |// +------------------------------------------------------------------------------------------------------+/* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: not supported by cvs2svn $* Revision 1.1 2005/02/22 12:02:57 jpm* Ajout des fichiers de la bibliothèque cartographique.** +-- Fin du code ----------------------------------------------------------------------------------------+*/?>