Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Details | Last modification | View Log | RSS feed

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