Subversion Repositories eFlore/Applications.bibliobota

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jp_milcent 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.3                                                                                    |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 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-11-23 10:22:25 jp_milcent 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-2005
37
*@version       $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $
38
// +------------------------------------------------------------------------------------------------------+
39
*/
40
 
41
// +------------------------------------------------------------------------------------------------------+
42
// |                                            ENTETE du PROGRAMME                                       |
43
// +------------------------------------------------------------------------------------------------------+
44
 
45
 
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                            CORPS du PROGRAMME                                        |
48
// +------------------------------------------------------------------------------------------------------+
49
 
50
/**
51
* Classe Carto_Action() - Recueille les infos sur l'action à réaliser pour une zone géo donnée.
52
*
53
* La classe Carto_Action sert a definir les paramètres nécessaires pour recueillir l'action a réaliser en
54
* fonction des coordonnées du point, du masque et du niveau.
55
* Elle remplace la fonction get_cartoAction() que l'on peut trouver dans le fichier carto_commun.php
56
* des différentes application utilisant la carto.
57
* Les champs a renseigner sont les suivants :
58
*   -le nom de la table ($nom_table_carto_action) où sont stokée les actions à réalisées
59
*      en fonction des couleurs
60
*   -les 5 champs principaux de la table :
61
*      -l'identifiant de la zone géographique (un nom, un numéro ou une abréviation) -> $nom_champ_cle
62
*      -les couleurs -> $nom_champ_rouge, $nom_champ_vert, $nom_champ_bleu
63
*      -l'action -> $nom_champ_action
64
* Elle possède une seule méthode : get_cartoAction().
65
*/
66
class Carto_Action
67
{
68
    // +--------------------------------------------------------------------------------------------------+
69
    //                                      LES ATTRIBUTS DE LA CLASSE
70
    var $_table_zone_geo;
71
    var $_id_zone_geo_zone;
72
    var $_rouge;
73
    var $_vert;
74
    var $_bleu;
75
    var $_table_action;
76
    var $_id_carte_action;
77
    var $_id_zone_geo_action;
78
    var $_type_zone_geo_action;
79
    var $_action;
80
    var $_id_carte_destination;
81
 
82
    // +--------------------------------------------------------------------------------------------------+
83
    //                                     LE CONSTRUCTEUR DE LA CLASSE
84
    /**
85
    * Constructeur Carto_Action()
86
    *
87
    * Constructeur initialisant les attributs de la classe Carto_Action().
88
    */
89
    function Carto_Action($info_table_zone_geo, $info_table_action)
90
    {
91
        $this->_table_zone_geo = $info_table_zone_geo['nom_table_zone'];
92
        $this->_id_zone_geo_zone = $info_table_zone_geo['nom_chp_id_zone'];
93
        $this->_rouge = $info_table_zone_geo['nom_chp_rouge'];
94
        $this->_vert = $info_table_zone_geo['nom_chp_vert'];
95
        $this->_bleu = $info_table_zone_geo['nom_chp_bleu'];
96
        $this->_table_action = $info_table_action['nom_table_action'];
97
        $this->_id_carte_action = $info_table_action['nom_chp_id_carte'];
98
        $this->_id_zone_geo_action = $info_table_action['nom_chp_id_zg_action'];
99
        $this->_type_zone_geo_action = $info_table_action['nom_chp_type_zg'];
100
        $this->_action = $info_table_action['nom_chp_action'];
101
        $this->_id_carte_destination = $info_table_action['nom_chp_id_carte_destination'];
102
    }
103
 
104
    // +--------------------------------------------------------------------------------------------------+
105
    //                                       LES METHODES PRIVÉES
106
    /**
107
    * Méthode _consulterActionImage($imageX, $imageY, $masque, $id_carte)
108
    *
109
    * Elle renvoit l'action a réaliser.
110
    * Nous passons les paramètres suivant :
111
    *      -les coordonnees du point ($imageX et $imageY)
112
    *      -le masque pour recuperer la couleur ($masque)
113
    *      -l'identifiant de la carte où nous nous trouvons ($id_carte)
114
    */
115
    function _consulterActionImage($imageX, $imageY, $masque, $id_carte)
116
    {
117
        // Nous récuperons les valeurs RVB de la couleur sur laquelle l'utilisateur a cliqué.
118
        // Les valeurs RVB sont stockées dans le tableau associatif $valeurs_RVB.
119
 
120
        $masque_courant = imagecreatefrompng($masque);
121
        $index_couleur = imagecolorat($masque_courant, $imageX, $imageY);
122
        $valeurs_RVB = imagecolorsforindex($masque_courant, $index_couleur);
123
 
124
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
125
        // du champ "action", afin de savoir quoi faire.
126
        $requete =
127
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
128
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
129
        ' WHERE '.$this->_table_zone_geo.'.'.$this->_rouge.' = '.$valeurs_RVB['red'].
130
        ' AND '.$this->_table_zone_geo.'.'.$this->_vert.' = '.$valeurs_RVB['green'].
131
        ' AND '.$this->_table_zone_geo.'.'.$this->_bleu.' = '.$valeurs_RVB['blue'].
132
        ' AND '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
133
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
134
 
135
        $resultat=mysql_query($requete) or die('
136
            <h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'.
137
            '<b>Fichier : </b>'.__FILE__.'<br />'.
138
            '<b>Ligne : </b>'.__LINE__.'<br />'.
139
            '<b>Requete : </b>'.$requete.'<br />'.
140
            '<b>Erreur : </b>'.mysql_error());
141
 
142
        $ligne = mysql_fetch_object ($resultat);
143
 
144
        if (mysql_num_rows ($resultat) != 0) {
145
 
146
            $chp_id_zone_geo = $this->_id_zone_geo_action;
147
            $chp_action = $this->_action;
148
            $chp_id_carte_destination = $this->_id_carte_destination;
149
 
150
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
151
            $action['type_action'] = $ligne->$chp_action;
152
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
153
 
154
            return $action;
155
        }
156
    }//Fin de la méthode _consulterActionImage().
157
 
158
    /**
159
    * Méthode _consulterActionListe($id_zone_carte, $id_carte)
160
    *
161
    * Elle renvoit l'action a réaliser.
162
    * Nous passons les paramètres suivant :
163
    *      -l'identifiant de la zone que l'on veut afficher
164
    *      -l'identifiant de la carte où nous nous trouvons ($id_carte)
165
    */
166
    function _consulterActionListe($id_zone_carte, $id_carte)
167
    {
168
        // Nous effectuons une requete dans la table carto_ACTION pour récupérer la valeur
169
        // du champ "action", afin de savoir quoi faire.
170
        $requete =
171
        'SELECT '.$this->_action.', '.$this->_id_carte_destination.', '.$this->_id_zone_geo_action.
172
        ' FROM '.$this->_table_action.', '.$this->_table_zone_geo.
173
        ' WHERE '.$this->_table_action.'.'.$this->_id_zone_geo_action.' = '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.
174
        ' AND '.$this->_table_zone_geo.'.'.$this->_id_zone_geo_zone.' = "'.$id_zone_carte.'"'.
175
        ' AND '.$this->_table_action.'.'.$this->_id_carte_action.' = "'.$id_carte.'"';
176
 
177
        $resultat=mysql_query($requete) or die('
178
            <h2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</h2>'.
179
            '<b>Fichier : </b>'.__FILE__.'<br />'.
180
            '<b>Ligne : </b>'.__LINE__.'<br />'.
181
            '<b>Requete : </b>'.$requete.'<br />'.
182
            '<b>Erreur : </b>'.mysql_error());
183
 
184
        $ligne = mysql_fetch_object ($resultat);
185
 
186
        if (mysql_num_rows ($resultat) != 0) {
187
 
188
            $chp_id_zone_geo = $this->_id_zone_geo_action;
189
            $chp_action = $this->_action;
190
            $chp_id_carte_destination = $this->_id_carte_destination;
191
 
192
            $action['id_zone_geo'] = $ligne->$chp_id_zone_geo;
193
            $action['type_action'] = $ligne->$chp_action;
194
            $action['id_carte_destination'] = $ligne->$chp_id_carte_destination;
195
 
196
            return $action;
197
        }
198
    }//Fin de la méthode get_cartoAction().
199
}//Fin de la classe Carto_Action.
200
 
201
// +------------------------------------------------------------------------------------------------------+
202
// |                                            PIED du PROGRAMME                                         |
203
// +------------------------------------------------------------------------------------------------------+
204
 
205
 
206
/* +--Fin du code ----------------------------------------------------------------------------------------+
207
*
208
* $Log: not supported by cvs2svn $
209
* Revision 1.2  2005/03/01 15:20:34  jpm
210
* Modification des fichiers au niveau des infos d'erreur de requete sql.
211
*
212
* Revision 1.1  2005/02/28 15:03:49  jpm
213
* Ajout des fichiers de la bibliothèque cartographique.
214
*
215
*
216
* +-- Fin du code ----------------------------------------------------------------------------------------+
217
*/
218
?>