Subversion Repositories eFlore/Archives.chorologie

Rev

Rev 4 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 9
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 5.0.3                                                                                    |
4
// | PHP version 4.3                                                                                    |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Cartographie.                                                                   |
8
// | This file is part of Cartographie.                                                                   |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: carto_action.class.php,v 1.1 2005-02-22 12:02:57 jpm Exp $
24
// CVS : $Id: carto_action.class.php,v 1.2 2005-02-22 16:35:16 jpm Exp $
25
/**
25
/**
26
* Classe ActionCarte.
26
* Classe ActionCarte.
27
*
27
*
28
* Calsse permettant de connaître les actions à réaliser sur une carte.
28
* Calsse permettant de connaître les actions à réaliser sur une carte.
29
*
29
*
30
*@package Cartographie
30
*@package Cartographie
31
//Auteur original :
31
//Auteur original :
32
*@author        Nicolas MATHIEU
32
*@author        Nicolas MATHIEU
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
34
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
35
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
35
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
36
*@copyright     Tela-Botanica 2000-2004
36
*@copyright     Tela-Botanica 2000-2004
37
*@version       $Revision: 1.1 $ $Date: 2005-02-22 12:02:57 $
37
*@version       $Revision: 1.2 $ $Date: 2005-02-22 16:35:16 $
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
*/
39
*/
40
 
40
 
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
// |                                            ENTETE du PROGRAMME                                       |
42
// |                                            ENTETE du PROGRAMME                                       |
43
// +------------------------------------------------------------------------------------------------------+
43
// +------------------------------------------------------------------------------------------------------+
44
 
44
 
45
 
45
 
46
// +------------------------------------------------------------------------------------------------------+
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                            CORPS du PROGRAMME                                        |
47
// |                                            CORPS du PROGRAMME                                        |
48
// +------------------------------------------------------------------------------------------------------+
48
// +------------------------------------------------------------------------------------------------------+
-
 
49
 
49
 
50
/**
-
 
51
* Classe Carto_Action() - Recueille les infos sur l'action à réaliser pour une zone géo donnée.
50
//================================================================================================
52
*
51
//La classe Carto_Action sert a definir les paramètres nécessaires pour recueillir l'action a réaliser en 
53
* La classe Carto_Action sert a definir les paramètres nécessaires pour recueillir l'action a réaliser en 
52
// fonction des coordonnées du point, du masque et du niveau.
54
* fonction des coordonnées du point, du masque et du niveau.
53
//Elle remplace la fonction get_cartoAction() que l'on peut trouver dans le fichier carto_commun.php
55
* Elle remplace la fonction get_cartoAction() que l'on peut trouver dans le fichier carto_commun.php
54
//des différentes application utilisant la carto.
56
* des différentes application utilisant la carto.
55
// Les champs a renseigner sont les suivants :
57
* Les champs a renseigner sont les suivants :
56
//   -le nom de la table ($nom_table_carto_action) où sont stokée les actions à réalisées 
58
*   -le nom de la table ($nom_table_carto_action) où sont stokée les actions à réalisées 
57
//      en fonction des couleurs
59
*      en fonction des couleurs
58
//   -les 5 champs principaux de la table :
60
*   -les 5 champs principaux de la table :
59
//      -l'identifiant de la zone géographique (un nom, un numéro ou une abréviation) -> $nom_champ_cle 
61
*      -l'identifiant de la zone géographique (un nom, un numéro ou une abréviation) -> $nom_champ_cle 
60
//      -les couleurs -> $nom_champ_rouge, $nom_champ_vert, $nom_champ_bleu
62
*      -les couleurs -> $nom_champ_rouge, $nom_champ_vert, $nom_champ_bleu
61
//      -l'action -> $nom_champ_action
63
*      -l'action -> $nom_champ_action
62
// Elle possède une seule méthode : get_cartoAction().
-
 
63
//================================================================================================
64
* Elle possède une seule méthode : get_cartoAction().
64
 
65
*/
65
class Carto_Action
66
class Carto_Action
-
 
67
{
-
 
68
    // +--------------------------------------------------------------------------------------------------+
66
{
69
    //                                      LES ATTRIBUTS DE LA CLASSE                                    
67
        var $_table_zone_geo;
70
    var $_table_zone_geo;
68
        var $_id_zone_geo_zone;
71
    var $_id_zone_geo_zone;
69
        var $_rouge;
72
    var $_rouge;
70
        var $_vert;
73
    var $_vert;
71
        var $_bleu;
74
    var $_bleu;
72
        var $_table_action;
75
    var $_table_action;
73
        var $_id_carte_action;
76
    var $_id_carte_action;
74
        var $_id_zone_geo_action;
77
    var $_id_zone_geo_action;
75
        var $_type_zone_geo_action;
78
    var $_type_zone_geo_action;
76
        var $_action;
79
    var $_action;
-
 
80
    var $_id_carte_destination;
77
        var $_id_carte_destination;
81
    
-
 
82
    // +--------------------------------------------------------------------------------------------------+
-
 
83
    //                                     LE CONSTRUCTEUR DE LA CLASSE                                    
-
 
84
    /**
78
    
85
    * Constructeur Carto_Action()
-
 
86
    *
79
    function Carto_Action ($table_zone_geo, $zone_chp_id_zone, $chp_rouge,
87
    * Constructeur initialisant les attributs de la classe Carto_Action().
80
                                    $chp_vert, $chp_bleu, $table_carto_action, $action_chp_id_carte, $action_chp_id_zone,
88
    */
81
                                    $action_chp_type_zone, $chp_action, $chp_destination) 
89
    function Carto_Action($info_table_zone_geo, $info_table_action) 
82
    {
90
    {
83
        $this->_table_zone_geo = $table_zone_geo;
91
        $this->_table_zone_geo = $info_table_zone_geo['nom_table_zone'];
84
        $this->_id_zone_geo_zone = $zone_chp_id_zone;
92
        $this->_id_zone_geo_zone = $info_table_zone_geo['nom_chp_id_zone'];
85
        $this->_rouge = $chp_rouge;
93
        $this->_rouge = $info_table_zone_geo['nom_chp_rouge'];
86
        $this->_vert = $chp_vert;
94
        $this->_vert = $info_table_zone_geo['nom_chp_vert'];
87
        $this->_bleu = $chp_bleu;
95
        $this->_bleu = $info_table_zone_geo['nom_chp_bleu'];
88
        $this->_table_action = $table_carto_action;
96
        $this->_table_action = $info_table_action['nom_table_action'];
89
        $this->_id_carte_action = $action_chp_id_carte;
97
        $this->_id_carte_action = $info_table_action['nom_chp_id_carte'];
90
        $this->_id_zone_geo_action = $action_chp_id_zone;
98
        $this->_id_zone_geo_action = $info_table_action['nom_chp_id_zg_action'];
91
        $this->_type_zone_geo_action = $action_chp_type_zone;
99
        $this->_type_zone_geo_action = $info_table_action['nom_chp_type_zg'];
92
        $this->_action = $chp_action;
100
        $this->_action = $info_table_action['nom_chp_action'];
93
        $this->_id_carte_destination = $chp_destination;
101
        $this->_id_carte_destination = $info_table_action['nom_chp_id_carte_destination'];
-
 
102
    }
-
 
103
    
94
    }
104
    // +--------------------------------------------------------------------------------------------------+
95
    
105
    //                                       LES METHODES PRIVÉES                                         
96
    //**********************************************************************************************************
106
    /**
97
    // Méthode get_cartoAction($imageX, $imageY, $masque, $id_carte)
107
    * Méthode _consulterActionImage($imageX, $imageY, $masque, $id_carte)
98
    
108
    *
99
    // Elle renvoit l'action a réaliser.
109
    * Elle renvoit l'action a réaliser.
100
    // Nous passons les paramètres suivant :     
110
    * Nous passons les paramètres suivant :     
101
    //      -les coordonnees du point ($imageX et $imageY)
-
 
102
    //      -le masque pour recuperer la couleur ($masque)
111
    *      -les coordonnees du point ($imageX et $imageY)
103
    //      -l'identifiant de la carte où nous nous trouvons ($id_carte)
112
    *      -le masque pour recuperer la couleur ($masque)
104
    //**********************************************************************************************************
113
    *      -l'identifiant de la carte où nous nous trouvons ($id_carte)
105
    
114
    */
106
    function _consulterActionImage($imageX, $imageY, $masque, $id_carte) 
115
    function _consulterActionImage($imageX, $imageY, $masque, $id_carte) 
107
    {
116
    {
108
        // Nous récuperons les valeurs RVB de la couleur sur laquelle l'utilisateur a cliqué.
117
        // Nous récuperons les valeurs RVB de la couleur sur laquelle l'utilisateur a cliqué.
109
        // Les valeurs RVB sont stockées dans le tableau associatif $valeurs_RVB.
118
        // Les valeurs RVB sont stockées dans le tableau associatif $valeurs_RVB.
110
        
119
        
111
        $masque_courant = imagecreatefrompng($masque);
120
        $masque_courant = imagecreatefrompng($masque);
112
        $index_couleur = imagecolorat($masque_courant,$imageX,$imageY);
121
        $index_couleur = imagecolorat($masque_courant,$imageX,$imageY);
113
        $valeurs_RVB = imagecolorsforindex($masque_courant, $index_couleur);
122
        $valeurs_RVB = imagecolorsforindex($masque_courant, $index_couleur);
114
        
123
        
115
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
124
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
116
        // du champ "action", afin de savoir quoi faire.
125
        // du champ "action", afin de savoir quoi faire.
117
        $requete = 
126
        $requete = 
118
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
127
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
119
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
128
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
120
        ' WHERE '.$this->_table_zone_geo.'.'.$this->_rouge.' = '.$valeurs_RVB['red'].
129
        ' WHERE '.$this->_table_zone_geo.'.'.$this->_rouge.' = '.$valeurs_RVB['red'].
121
        ' AND '.$this->_table_zone_geo.'.'.$this->_vert.' = '.$valeurs_RVB['green'].
130
        ' AND '.$this->_table_zone_geo.'.'.$this->_vert.' = '.$valeurs_RVB['green'].
122
        ' AND '.$this->_table_zone_geo.'.'.$this->_bleu.' = '.$valeurs_RVB['blue'].
131
        ' AND '.$this->_table_zone_geo.'.'.$this->_bleu.' = '.$valeurs_RVB['blue'].
123
        ' AND '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
132
        ' AND '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
124
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
133
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
125
        
134
        
126
        $resultat=mysql_query($requete) or die('
135
        $resultat=mysql_query($requete) or die('
127
            <H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'.
136
            <H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'.
128
            '<b>Requete : </b>'.$requete.
137
            '<b>Requete : </b>'.$requete.
129
            '<br/><br/><b>Erreur : </b>'.mysql_error());
138
            '<br/><br/><b>Erreur : </b>'.mysql_error());
130
        
139
        
131
        $ligne = mysql_fetch_object ($resultat);
140
        $ligne = mysql_fetch_object ($resultat);
132
        
141
        
133
        if (mysql_num_rows ($resultat) != 0) {
142
        if (mysql_num_rows ($resultat) != 0) {
134
            
143
            
135
            $chp_id_zone_geo = $this->_id_zone_geo_action;
144
            $chp_id_zone_geo = $this->_id_zone_geo_action;
136
            $chp_action = $this->_action;
145
            $chp_action = $this->_action;
137
            $chp_id_carte_destination = $this->_id_carte_destination;
146
            $chp_id_carte_destination = $this->_id_carte_destination;
138
            
147
            
139
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
148
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
140
            $action['type_action'] = $ligne->$chp_action;
149
            $action['type_action'] = $ligne->$chp_action;
141
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
150
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
142
            
151
            
143
            return $action;
152
            return $action;
144
        }
153
        }
145
    }//Fin de la méthode _consulterActionImage().
154
    }//Fin de la méthode _consulterActionImage().
146
    
-
 
-
 
155
    
147
    //**********************************************************************************************************
156
    /**
148
    // Méthode _consulterActionListe($id_zone_carte, $id_carte)
157
    * Méthode _consulterActionListe($id_zone_carte, $id_carte)
149
    
158
    *
150
    // Elle renvoit l'action a réaliser.
159
    * Elle renvoit l'action a réaliser.
151
    // Nous passons les paramètres suivant :     
160
    * Nous passons les paramètres suivant :     
152
    //      -l'identifiant de la zone que l'on veut afficher
161
    *      -l'identifiant de la zone que l'on veut afficher
153
    //      -l'identifiant de la carte où nous nous trouvons ($id_carte)
-
 
154
    //**********************************************************************************************************
162
    *      -l'identifiant de la carte où nous nous trouvons ($id_carte)
155
    
163
    */
156
    function _consulterActionListe($id_zone_carte, $id_carte) 
164
    function _consulterActionListe($id_zone_carte, $id_carte) 
157
    {
165
    {
158
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
166
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
159
        // du champ "action", afin de savoir quoi faire.
167
        // du champ "action", afin de savoir quoi faire.
160
        $requete = 
168
        $requete = 
161
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
169
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
162
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
170
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
163
        ' WHERE '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
171
        ' WHERE '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
164
        ' AND '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.' = "'.$id_zone_carte.'"'.
172
        ' AND '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.' = "'.$id_zone_carte.'"'.
165
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
173
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
166
        
174
        
167
        $resultat=mysql_query($requete) or die('
175
        $resultat=mysql_query($requete) or die('
168
            <H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'.
176
            <H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'.
169
            '<b>Requete : </b>'.$requete.
177
            '<b>Requete : </b>'.$requete.
170
            '<br/><br/><b>Erreur : </b>'.mysql_error());
178
            '<br/><br/><b>Erreur : </b>'.mysql_error());
171
        
179
        
172
        $ligne = mysql_fetch_object ($resultat);
180
        $ligne = mysql_fetch_object ($resultat);
173
        
181
        
174
        if (mysql_num_rows ($resultat) != 0) {
182
        if (mysql_num_rows ($resultat) != 0) {
175
            
183
            
176
            $chp_id_zone_geo = $this->_id_zone_geo_action;
184
            $chp_id_zone_geo = $this->_id_zone_geo_action;
177
            $chp_action = $this->_action;
185
            $chp_action = $this->_action;
178
            $chp_id_carte_destination = $this->_id_carte_destination;
186
            $chp_id_carte_destination = $this->_id_carte_destination;
179
            
187
            
180
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
188
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
181
            $action['type_action'] = $ligne->$chp_action;
189
            $action['type_action'] = $ligne->$chp_action;
182
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
190
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
183
            
191
            
184
            return $action;
192
            return $action;
185
        }
193
        }
186
    }//Fin de la méthode get_cartoAction().
194
    }//Fin de la méthode get_cartoAction().
187
}//Fin de la classe Carto_Action.
195
}//Fin de la classe Carto_Action.
188
 
-
 
189
 
-
 
190
// +------------------------------------------------------------------------------------------------------+
-
 
191
// |                                           LISTE de FONCTIONS                                         |
-
 
192
// +------------------------------------------------------------------------------------------------------+
-
 
193
 
-
 
194
    // +--------------------------------------------------------------------------------------------------+
-
 
195
 
-
 
196
 
196
 
197
// +------------------------------------------------------------------------------------------------------+
197
// +------------------------------------------------------------------------------------------------------+
198
// |                                            PIED du PROGRAMME                                         |
198
// |                                            PIED du PROGRAMME                                         |
199
// +------------------------------------------------------------------------------------------------------+
199
// +------------------------------------------------------------------------------------------------------+
200
 
200
 
201
 
201
 
202
/* +--Fin du code ----------------------------------------------------------------------------------------+
202
/* +--Fin du code ----------------------------------------------------------------------------------------+
203
*
203
*
204
* $Log: not supported by cvs2svn $
204
* $Log: not supported by cvs2svn $
205
* Revision 1.1  2005/02/17 10:58:00  jpm
205
* Revision 1.1  2005/02/22 12:02:57  jpm
206
* Ajout des fichiers pour permettre au serveur de réaliser des cartes. Ils sont à revoir complétement!
206
* Ajout des fichiers de la bibliothèque cartographique.
207
*
-
 
208
*
207
*
209
* +-- Fin du code ----------------------------------------------------------------------------------------+
208
* +-- Fin du code ----------------------------------------------------------------------------------------+
210
*/
209
*/
211
?>
210
?>