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 4.1 |
|
4 |
// | PHP version 4.1 |
|
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 library is free software; you can redistribute it and/or |
|
8 |
// | This library is free software; you can redistribute it and/or |
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
10 |
// | License as published by the Free Software Foundation; either |
|
10 |
// | License as published by the Free Software Foundation; either |
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
12 |
// | |
|
12 |
// | |
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
// | Lesser General Public License for more details. |
|
16 |
// | Lesser General Public License for more details. |
|
17 |
// | |
|
17 |
// | |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
22 |
// CVS : $Id: bb_commun.fonct.php,v 1.3 2007-02-14 11:37:50 jp_milcent Exp $
|
22 |
// CVS : $Id: bb_commun.fonct.php,v 1.2 2007/02/13 17:40:22 jp_milcent Exp $
|
23 |
/**
|
23 |
/**
|
24 |
* Fonctions communes aux applications de Biblio Bota.
|
24 |
* Fonctions communes aux applications de Biblio Bota.
|
25 |
*
|
25 |
*
|
26 |
* Contient des fonctions communes aux applications de Biblio Bota.
|
26 |
* Contient des fonctions communes aux applications de Biblio Bota.
|
27 |
*
|
27 |
*
|
28 |
*@package BiblioBota
|
28 |
*@package BiblioBota
|
29 |
*@subpackage Fonctions
|
29 |
*@subpackage Fonctions
|
30 |
//Auteur original :
|
30 |
//Auteur original :
|
31 |
*@author Jean-Charles GRANGER <tela@vecteur.org>
|
31 |
*@author Jean-Charles GRANGER <tela@vecteur.org>
|
32 |
//Autres auteurs :
|
32 |
//Autres auteurs :
|
33 |
*@author Jean-Pascal MILCENT <jpm@clapas.org>
|
33 |
*@author Jean-Pascal MILCENT <jpm@clapas.org>
|
34 |
*@copyright Tela-Botanica 2000-2004
|
34 |
*@copyright Tela-Botanica 2000-2004
|
35 |
*@version $Revision: 1.3 $ $Date: 2007-02-14 11:37:50 $
|
35 |
*@version $Revision: 1.2 $ $Date: 2007/02/13 17:40:22 $
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
37 |
*/
|
37 |
*/
|
38 |
|
38 |
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// | ENTETE du PROGRAMME |
|
40 |
// | ENTETE du PROGRAMME |
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
42 |
|
42 |
|
43 |
|
43 |
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
45 |
// | LISTE de FONCTIONS |
|
45 |
// | LISTE de FONCTIONS |
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
47 |
|
47 |
|
48 |
// string check_if_modif($table)
|
48 |
// string check_if_modif($table)
|
49 |
// vérifie dans la table des modifications si une donnée
|
49 |
// vérifie dans la table des modifications si une donnée
|
50 |
// est sujette à modifications
|
50 |
// est sujette à modifications
|
51 |
// entrées :
|
51 |
// entrées :
|
52 |
// - string $table : nom de la table des modifs
|
52 |
// - string $table : nom de la table des modifs
|
53 |
// - string $field_src : nom du champ source
|
53 |
// - string $field_src : nom du champ source
|
54 |
// - string $fiche_id : identifiant de la fiche
|
54 |
// - string $fiche_id : identifiant de la fiche
|
55 |
// sortie :
|
55 |
// sortie :
|
56 |
function check_if_modif($table, $tbl_src, $fiche_id)
|
56 |
function check_if_modif($table, $tbl_src, $fiche_id)
|
57 |
{
|
57 |
{
|
58 |
$query = 'SELECT * '.
|
58 |
$query = 'SELECT * '.
|
59 |
'FROM '.$table.' '.
|
59 |
'FROM '.$table.' '.
|
60 |
'WHERE B_MOD_TABLESRC = "'.$tbl_src.'" '.
|
60 |
'WHERE B_MOD_TABLESRC = "'.$tbl_src.'" '.
|
61 |
'AND B_MOD_FICHESRC = "'.$fiche_id.'"';
|
61 |
'AND B_MOD_FICHESRC = "'.$fiche_id.'"';
|
62 |
$resu = mysql_query($query) or die ("<B>Erreur !!!</B> : la vérification des modifications a échoué... $query");
|
62 |
$resu = mysql_query($query) or die ("<B>Erreur !!!</B> : la vérification des modifications a échoué... $query");
|
63 |
$nb_resu = mysql_num_rows($resu);
|
63 |
$nb_resu = mysql_num_rows($resu);
|
64 |
mysql_free_result($resu);
|
64 |
mysql_free_result($resu);
|
65 |
|
65 |
|
66 |
return $nb_resu;
|
66 |
return $nb_resu;
|
67 |
}
|
67 |
}
|
68 |
/**
|
68 |
/**
|
69 |
* La fonction remplaceEntiteHTLM() remplace des caractères par les entités html.
|
69 |
* La fonction remplaceEntiteHTLM() remplace des caractères par les entités html.
|
70 |
*
|
70 |
*
|
71 |
* Cette fonction retourne un texte dans lequel touts les caractères correspondant
|
71 |
* Cette fonction retourne un texte dans lequel touts les caractères correspondant
|
72 |
* à des entités html sont remplacés par la valeur de l'entité, à l'exception
|
72 |
* à des entités html sont remplacés par la valeur de l'entité, à l'exception
|
73 |
* des caractères <, >, & et ".
|
73 |
* des caractères <, >, & et ".
|
74 |
* Cela permet de remplacer toutes les entités dans une chaine contenant du html.
|
74 |
* Cela permet de remplacer toutes les entités dans une chaine contenant du html.
|
75 |
*
|
75 |
*
|
76 |
*@param string la chaîne html à parsser.
|
76 |
*@param string la chaîne html à parsser.
|
77 |
*@return string contient la chaîne html avec les entités intégrées.
|
77 |
*@return string contient la chaîne html avec les entités intégrées.
|
78 |
*/
|
78 |
*/
|
79 |
function remplaceEntiteHTLM($texte)
|
79 |
function remplaceEntiteHTLM($texte)
|
80 |
{
|
80 |
{
|
81 |
$texte_retour = '';
|
81 |
$texte_retour = '';
|
82 |
$tab_entites = get_html_translation_table(HTML_ENTITIES);
|
82 |
$tab_entites = get_html_translation_table(HTML_ENTITIES);
|
83 |
unset($tab_entites['"']);
|
83 |
unset($tab_entites['"']);
|
84 |
unset($tab_entites['<']);
|
84 |
unset($tab_entites['<']);
|
85 |
unset($tab_entites['>']);
|
85 |
unset($tab_entites['>']);
|
86 |
unset($tab_entites['&']);
|
86 |
unset($tab_entites['&']);
|
87 |
$tab_entites[' & '] = ' & ';
|
87 |
$tab_entites[' & '] = ' & ';
|
88 |
return strtr($texte, $tab_entites);
|
88 |
return strtr($texte, $tab_entites);
|
89 |
}
|
89 |
}
|
90 |
|
90 |
|
91 |
/**
|
91 |
/**
|
92 |
* Fonction fournissant une date au format français depuis une date Mysql
|
92 |
* Fonction fournissant une date au format français depuis une date Mysql
|
93 |
*
|
93 |
*
|
94 |
* @param string la date au format Mysql
|
94 |
* @param string la date au format Mysql
|
95 |
* @return string la date au format français
|
95 |
* @return string la date au format français
|
96 |
*/
|
96 |
*/
|
97 |
function donnerDateConviviale($chaine)
|
97 |
function donnerDateConviviale($chaine)
|
98 |
{
|
98 |
{
|
99 |
if (preg_match('/^(\d{4})-(\d{2})$/',$chaine, $match)) {
|
99 |
if (preg_match('/^(\d{4})-(\d{2})$/',$chaine, $match)) {
|
100 |
$annee = $match[1];
|
100 |
$annee = $match[1];
|
101 |
$mois = $match[2];
|
101 |
$mois = $match[2];
|
102 |
switch ($mois) {
|
102 |
switch ($mois) {
|
103 |
case '00' :
|
103 |
case '00' :
|
104 |
$mois_sortie = '';
|
104 |
$mois_sortie = '';
|
105 |
break;
|
105 |
break;
|
106 |
case '01' :
|
106 |
case '01' :
|
107 |
$mois_sortie = 'janvier';
|
107 |
$mois_sortie = 'janvier';
|
108 |
break;
|
108 |
break;
|
109 |
case '02' :
|
109 |
case '02' :
|
110 |
$mois_sortie = 'février';
|
110 |
$mois_sortie = 'février';
|
111 |
break;
|
111 |
break;
|
112 |
case '03' :
|
112 |
case '03' :
|
113 |
$mois_sortie = 'mars';
|
113 |
$mois_sortie = 'mars';
|
114 |
break;
|
114 |
break;
|
115 |
case '04' :
|
115 |
case '04' :
|
116 |
$mois_sortie = 'avril';
|
116 |
$mois_sortie = 'avril';
|
117 |
break;
|
117 |
break;
|
118 |
case '05' :
|
118 |
case '05' :
|
119 |
$mois_sortie = 'mai';
|
119 |
$mois_sortie = 'mai';
|
120 |
break;
|
120 |
break;
|
121 |
case '06' :
|
121 |
case '06' :
|
122 |
$mois_sortie = 'juin';
|
122 |
$mois_sortie = 'juin';
|
123 |
break;
|
123 |
break;
|
124 |
case '07' :
|
124 |
case '07' :
|
125 |
$mois_sortie = 'juillet';
|
125 |
$mois_sortie = 'juillet';
|
126 |
break;
|
126 |
break;
|
127 |
case '08' :
|
127 |
case '08' :
|
128 |
$mois_sortie = 'août';
|
128 |
$mois_sortie = 'août';
|
129 |
break;
|
129 |
break;
|
130 |
case '09' :
|
130 |
case '09' :
|
131 |
$mois_sortie = 'septembre';
|
131 |
$mois_sortie = 'septembre';
|
132 |
break;
|
132 |
break;
|
133 |
case '10' :
|
133 |
case '10' :
|
134 |
$mois_sortie = 'octobre';
|
134 |
$mois_sortie = 'octobre';
|
135 |
break;
|
135 |
break;
|
136 |
case '11' :
|
136 |
case '11' :
|
137 |
$mois_sortie = 'novembre';
|
137 |
$mois_sortie = 'novembre';
|
138 |
break;
|
138 |
break;
|
139 |
case '12' :
|
139 |
case '12' :
|
140 |
$mois_sortie = 'décembre';
|
140 |
$mois_sortie = 'décembre';
|
141 |
break;
|
141 |
break;
|
142 |
}
|
142 |
}
|
143 |
if ($mois_sortie != '') {
|
143 |
if ($mois_sortie != '') {
|
144 |
return $mois_sortie.' '.$annee;
|
144 |
return $mois_sortie.' '.$annee;
|
145 |
} else {
|
145 |
} else {
|
146 |
return $annee;
|
146 |
return $annee;
|
147 |
}
|
147 |
}
|
148 |
} else {
|
148 |
} else {
|
149 |
return '?';
|
149 |
return '?';
|
150 |
}
|
150 |
}
|
151 |
}
|
151 |
}
|
152 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
152 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
153 |
*
|
153 |
*
|
154 |
* $Log: not supported by cvs2svn $
|
154 |
* $Log: bb_commun.fonct.php,v $
|
155 |
* Revision 1.2 2007/02/13 17:40:22 jp_milcent
|
155 |
* Revision 1.2 2007/02/13 17:40:22 jp_milcent
|
156 |
* Ajout d'une fonction pour formater de manière conviviale les dates Mysql.
|
156 |
* Ajout d'une fonction pour formater de manière conviviale les dates Mysql.
|
157 |
*
|
157 |
*
|
158 |
* Revision 1.1 2005/11/23 10:22:25 jp_milcent
|
158 |
* Revision 1.1 2005/11/23 10:22:25 jp_milcent
|
159 |
* Ajout au dépot de l'application BiblioBota.
|
159 |
* Ajout au dépot de l'application BiblioBota.
|
160 |
* Elle doit à terme migrer dans eFlore.
|
160 |
* Elle doit à terme migrer dans eFlore.
|
161 |
*
|
161 |
*
|
162 |
* Revision 1.2 2005/05/17 10:10:08 jpm
|
162 |
* Revision 1.2 2005/05/17 10:10:08 jpm
|
163 |
* Correction des bogues avant mise en ligne du site v4.
|
163 |
* Correction des bogues avant mise en ligne du site v4.
|
164 |
*
|
164 |
*
|
165 |
* Revision 1.1 2004/09/14 11:12:50 jpm
|
165 |
* Revision 1.1 2004/09/14 11:12:50 jpm
|
166 |
* Ajout des fonctions communes aux applications de BiblioBota.
|
166 |
* Ajout des fonctions communes aux applications de BiblioBota.
|
167 |
*
|
167 |
*
|
168 |
*
|
168 |
*
|
169 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
169 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
170 |
*/
|
170 |
*/
|
171 |
?>
|
171 |
?>
|