2 |
jp_milcent |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of Herbier. |
|
|
|
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: hb_collection.class.php,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
|
|
|
25 |
/**
|
|
|
26 |
* Classe H_collection
|
|
|
27 |
*
|
|
|
28 |
* Classe permettant de récupérer les données concernant les collections de la base de données.
|
|
|
29 |
*
|
|
|
30 |
*@package Herbier
|
|
|
31 |
*@subpackage Classes
|
|
|
32 |
//Auteur original :
|
|
|
33 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
34 |
//Autres auteurs :
|
|
|
35 |
*@author Jean-Pascal MILCENT <jpm@clapas.org>
|
|
|
36 |
*@copyright Tela-Botanica 2000-2005
|
|
|
37 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
*/
|
|
|
40 |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
// | ENTETE du PROGRAMME |
|
|
|
43 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
44 |
|
|
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
46 |
// | CORPS du PROGRAMME |
|
|
|
47 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
48 |
/**
|
|
|
49 |
* class H_organisation contient la structure nécessaire pour
|
|
|
50 |
* représenter une table HERBIERS_COLLECTION dont voici
|
|
|
51 |
* la structure
|
|
|
52 |
* @package herbiers
|
|
|
53 |
*/
|
|
|
54 |
class H_collection {
|
|
|
55 |
var $indic;
|
|
|
56 |
var $included_type;
|
|
|
57 |
var $preservation_method;
|
|
|
58 |
/**
|
|
|
59 |
* Constructeur de H_collection
|
|
|
60 |
*
|
|
|
61 |
* @param aucun
|
|
|
62 |
* @return void
|
|
|
63 |
* @access public
|
|
|
64 |
*/
|
|
|
65 |
function H_collection($id_collection = null) {
|
|
|
66 |
if (!is_null($id_collection)) {
|
|
|
67 |
$this->setId($id_collection);
|
|
|
68 |
}
|
|
|
69 |
$indic = array();
|
|
|
70 |
$preservation_method = array();
|
|
|
71 |
}
|
|
|
72 |
/** Accesseur getId() - Retourner l'id de la collection.
|
|
|
73 |
*
|
|
|
74 |
* @return integer l'identifiant de la collection.
|
|
|
75 |
* @access public
|
|
|
76 |
*/
|
|
|
77 |
function getId()
|
|
|
78 |
{
|
|
|
79 |
return $this->id;
|
|
|
80 |
}
|
|
|
81 |
/** Accesseur setId() - Attribuer un id à la collection.
|
|
|
82 |
*
|
|
|
83 |
* @param integer l'identifiant de la collection.
|
|
|
84 |
* @return void l'identifiant est ajouté à l'objet.
|
|
|
85 |
* @access public
|
|
|
86 |
*/
|
|
|
87 |
function setId($id)
|
|
|
88 |
{
|
|
|
89 |
$this->id = $id;
|
|
|
90 |
}
|
|
|
91 |
/** Renvoie un objet de type H_collection
|
|
|
92 |
*
|
|
|
93 |
* Renvoie un objet de type H_collection dont
|
|
|
94 |
* l'identificateur est spécifié en paramètre.
|
|
|
95 |
* L'objet correspond à une collection décrite
|
|
|
96 |
* par la table HERBIERS_COLLECTION
|
|
|
97 |
*
|
|
|
98 |
* @param integer $id l'identifiant de la table HERBIERS_COLLECTION
|
|
|
99 |
* @return H_collection un objet de la classe H_collection
|
|
|
100 |
* @access public
|
|
|
101 |
*/
|
|
|
102 |
function getFromSQL($id) {
|
|
|
103 |
$requete = 'SELECT HERBIERS_COLLECTION.*, HERBIERS_COLL_STATUT.LABEL, '.
|
|
|
104 |
'HERBIERS_DATE_DEBUT_CARAC.LABEL_DATE_DEBUT_CARAC, HERBIERS_DATE_FIN_CARAC.LABEL_DATE_FIN_CARAC, '.
|
|
|
105 |
'HERBIERS_DENOMBREMENT_CARAC_SP.HDC_LABEL AS SPECIES_LABEL, '.
|
|
|
106 |
'HERBIERS_DENOMBREMENT_CARAC_SC.HDC_LABEL AS SPECIMENS_LABEL '.
|
|
|
107 |
'FROM HERBIERS_COLLECTION, HERBIERS_COLL_STATUT, HERBIERS_DATE_DEBUT_CARAC, HERBIERS_DATE_FIN_CARAC, '.
|
|
|
108 |
'HERBIERS_DENOMBREMENT_CARAC_SC, HERBIERS_DENOMBREMENT_CARAC_SP '.
|
|
|
109 |
'WHERE ID = '.$id.' '.
|
|
|
110 |
'AND HERBIERS_COLLECTION.STATUT = HERBIERS_COLL_STATUT.ID_COLL_STATUT '.
|
|
|
111 |
'AND HERBIERS_COLLECTION.DATE_DEBUT_CARAC = HERBIERS_DATE_DEBUT_CARAC.ID_DATE_CARAC '.
|
|
|
112 |
'AND HERBIERS_COLLECTION.DATE_FIN_CARAC = HERBIERS_DATE_FIN_CARAC.ID_DATE_CARAC '.
|
|
|
113 |
'AND HERBIERS_COLLECTION.PREC_SPECIES = HERBIERS_DENOMBREMENT_CARAC_SC.HDC_ID '.
|
|
|
114 |
'AND HERBIERS_COLLECTION.PREC_SPECIMENS = HERBIERS_DENOMBREMENT_CARAC_SP.HDC_ID';
|
|
|
115 |
$resultat = mysql_query($requete) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
|
|
|
116 |
$ligne = mysql_fetch_object($resultat);
|
|
|
117 |
|
|
|
118 |
foreach (get_object_vars($ligne) as $cle => $valeur) {
|
|
|
119 |
$this->$cle = $valeur;
|
|
|
120 |
}
|
|
|
121 |
mysql_free_result($resultat);
|
|
|
122 |
|
|
|
123 |
$requete_02 = 'SELECT ID_INDIC '.
|
|
|
124 |
'FROM HERBIERS_INDIC '.
|
|
|
125 |
'WHERE ID = '.$id;
|
|
|
126 |
|
|
|
127 |
$resultat_02 = mysql_query($requete_02) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_02));
|
|
|
128 |
while ($ligne_02 = mysql_fetch_object($resultat_02)){
|
|
|
129 |
$temp_indic = new H_indic();
|
|
|
130 |
$this->indic[] = $temp_indic->getFromSQL($ligne_02->ID_INDIC);
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
switch ($this->INCLUDED_TYPE) {
|
|
|
134 |
case 1 :
|
|
|
135 |
$this->included_type = 'non';
|
|
|
136 |
break;
|
|
|
137 |
case 2 :
|
|
|
138 |
$this->included_type = 'oui';
|
|
|
139 |
break;
|
|
|
140 |
case 0 :
|
|
|
141 |
$this->included_type = 'indéterminé';
|
|
|
142 |
break;
|
|
|
143 |
}
|
|
|
144 |
unset($this->INCLUDED_TYPE);
|
|
|
145 |
|
|
|
146 |
// Récupération de la méthode de préservation
|
|
|
147 |
$this->preservation_method = getPreservationMethod($ligne->ID);
|
|
|
148 |
|
|
|
149 |
// Transformation des chiffres des champs ETAT en label
|
|
|
150 |
$label_etat = array('1' => 'Inconnu', '2' => 'mauvais', '3' => 'moyen', '4' => 'très bon');
|
|
|
151 |
|
|
|
152 |
if (!isset($label_etat[$this->ETAT_SPECIMENS])) {
|
|
|
153 |
$label_etat[$this->ETAT_SPECIMENS] = '';
|
|
|
154 |
}
|
|
|
155 |
if (!isset($label_etat[$this->ETAT_PRESENTATION])) {
|
|
|
156 |
$label_etat[$this->ETAT_PRESENTATION] = '';
|
|
|
157 |
}
|
|
|
158 |
if (!isset($label_etat[$this->ETAT_CLASSEMENT])) {
|
|
|
159 |
$label_etat[$this->ETAT_CLASSEMENT] = '';
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
$this->ETAT_SPECIMENS = $label_etat[$this->ETAT_SPECIMENS];
|
|
|
163 |
$this->ETAT_PRESENTATION = $label_etat[$this->ETAT_PRESENTATION];
|
|
|
164 |
$this->ETAT_CLASSEMENT = $label_etat[$this->ETAT_CLASSEMENT];
|
|
|
165 |
|
|
|
166 |
return H_Herbier::remplacerEsperluette($this);
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
171 |
// | PIED du PROGRAMME |
|
|
|
172 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
176 |
*
|
|
|
177 |
* $Log: not supported by cvs2svn $
|
|
|
178 |
* Revision 1.3 2005/04/06 13:29:17 jpm
|
|
|
179 |
* Ajout et modifications des objets représentant la base de données Herbier.
|
|
|
180 |
*
|
|
|
181 |
* Revision 1.2 2005/03/09 15:57:33 jpm
|
|
|
182 |
* Modification de la forme.
|
|
|
183 |
*
|
|
|
184 |
*
|
|
|
185 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
186 |
*/
|
|
|
187 |
?>
|