Subversion Repositories Applications.projet

Rev

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

Rev 431 Rev 442
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 General Public                                                  |
9
// | modify it under the terms of the GNU 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
// | General Public License for more details.                                                             |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
18
// | You should have received a copy of the GNU 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: type_fichier_mime.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $
22
// CVS : $Id: type_fichier_mime.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* La classe type_fichier_mime
26
* La classe type_fichier_mime
27
*
27
*
28
*@package projet
28
*@package projet
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@author        Aucun
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.2 $
34
*@version       $Revision: 1.2 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
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
// |                                            ENTETE du PROGRAMME                                       |
45
// |                                            ENTETE du PROGRAMME                                       |
46
// +------------------------------------------------------------------------------------------------------+
46
// +------------------------------------------------------------------------------------------------------+
47
 
47
 
48
/**
48
/**
49
 * class type_fichier_mime
49
 * class type_fichier_mime
50
 * 
50
 * 
51
 */
51
 */
52
class type_fichier_mime
52
class type_fichier_mime
53
{
53
{
54
    /*** Attributes: ***/
54
    /*** Attributes: ***/
55
 
55
 
56
    /**
56
    /**
57
     * Le nom du type en français (ex Image jpg)
57
     * Le nom du type en fran�ais (ex Image jpg)
58
     * @access private
58
     * @access private
59
     */
59
     */
60
    var $_nom;
60
    var $_nom;
61
    /**
61
    /**
62
     * L'extension du fichier (ex: png)
62
     * L'extension du fichier (ex: png)
63
     * @access private
63
     * @access private
64
     */
64
     */
65
    var $_extension;
65
    var $_extension;
66
    /**
66
    /**
67
     * Le nom du fichier de l'icône représentant ce fichier.
67
     * Le nom du fichier de l'ic�ne repr�sentant ce fichier.
68
     * @access private
68
     * @access private
69
     */
69
     */
70
    var $_icone;
70
    var $_icone;
71
    /**
71
    /**
72
     * Le type mime.
72
     * Le type mime.
73
     * @access private
73
     * @access private
74
     */
74
     */
75
    var $_type_mime;
75
    var $_type_mime;
76
    /**
76
    /**
77
     * 
77
     * 
78
     * @access private
78
     * @access private
79
     */
79
     */
80
    var $_description;
80
    var $_description;
81
    /**
81
    /**
82
     * Le chemin UNIX ou Windows vers le dossier des icônes. Il ne commence pas par un
82
     * Le chemin UNIX ou Windows vers le dossier des ic�nes. Il ne commence pas par un
83
     * slash et termine par slash.
83
     * slash et termine par slash.
84
     * @access private
84
     * @access private
85
     */
85
     */
86
    var $_chemin_icone = "icones/";
86
    var $_chemin_icone = "icones/";
87
    /**
87
    /**
88
     * Un objet PEAR:DB
88
     * Un objet PEAR:DB
89
     * @access private
89
     * @access private
90
     */
90
     */
91
    var $_db;
91
    var $_db;
92
    /**
92
    /**
93
     * L'identifiant du type dans la table gen_type_de_fichier
93
     * L'identifiant du type dans la table gen_type_de_fichier
94
     * @access private
94
     * @access private
95
     */
95
     */
96
    var $_id_type;
96
    var $_id_type;
97
 
97
 
98
    /**
98
    /**
99
     * Renvoie le chemin vers les icônes.
99
     * Renvoie le chemin vers les ic�nes.
100
     *
100
     *
101
     * @return string
101
     * @return string
102
     * @access public
102
     * @access public
103
     */
103
     */
104
    function getCheminIcone( )
104
    function getCheminIcone( )
105
    {
105
    {
106
        return $this->_chemin_icone.$this->_icone ; ;
106
        return $this->_chemin_icone.$this->_icone ; ;
107
    } // end of member function getCheminIcone
107
    } // end of member function getCheminIcone
108
 
108
 
109
    /**
109
    /**
110
     * 
110
     * 
111
     *
111
     *
112
     * @param string chemin Le chemin vers l'icône.
112
     * @param string chemin Le chemin vers l'ic�ne.
113
     * @return void
113
     * @return void
114
     * @access public
114
     * @access public
115
     */
115
     */
116
    function setCheminIcone( $chemin )
116
    function setCheminIcone( $chemin )
117
    {
117
    {
118
        $this->_chemin_icone = $chemin ;
118
        $this->_chemin_icone = $chemin ;
119
    } // end of member function setCheminIcone
119
    } // end of member function setCheminIcone
120
 
120
 
121
    /**
121
    /**
122
     * 
122
     * 
123
     *
123
     *
124
     * @param DB objetDB un objet PEAR:DB
124
     * @param DB objetDB un objet PEAR:DB
125
     * @param int id_type 
125
     * @param int id_type 
126
     * @return void
126
     * @return void
127
     * @access public
127
     * @access public
128
     */
128
     */
129
    function type_fichier_mime(  $id_type = '', $chemin_icones = "icones/" )
129
    function type_fichier_mime(  $id_type = '', $chemin_icones = "icones/" )
130
    {
130
    {
131
        
131
        
132
        $requete = 'select * from gen_type_de_fichier where ' ;
132
        $requete = 'select * from gen_type_de_fichier where ' ;
133
        if (is_numeric ($id_type)) {
133
        if (is_numeric ($id_type)) {
134
            $requete .= 'gtf_id_type='.$GLOBALS['projet_db']->escapeSimple($id_type) ;
134
            $requete .= 'gtf_id_type='.$GLOBALS['projet_db']->escapeSimple($id_type) ;
135
        } else {
135
        } else {
136
            $requete .= 'gtf_type_mime="'.$id_type.'"' ; 
136
            $requete .= 'gtf_type_mime="'.$id_type.'"' ; 
137
        }
137
        }
138
        $resultat = $GLOBALS['projet_db']->query ($requete) ;
138
        $resultat = $GLOBALS['projet_db']->query ($requete) ;
139
        if (DB::isError($resultat)) {
139
        if (DB::isError($resultat)) {
140
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
140
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
141
        }
141
        }
142
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
142
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
143
        $this->_chemin_icone = $chemin_icones ;
143
        $this->_chemin_icone = $chemin_icones ;
-
 
144
        if ($ligne) {
144
        $this->_icone = $ligne->gtf_type_icone ;
145
	        $this->_icone = $ligne->gtf_type_icone ;
145
        $this->_id_type = $ligne->gtf_id_type ;
146
	        $this->_id_type = $ligne->gtf_id_type ;
-
 
147
        }
146
    } // end of member function type_fichier_mime
148
    } // end of member function type_fichier_mime
147
 
149
 
148
    /**
150
    /**
149
     * Tente de renvoyer un objet type_fichier_mime à partir de l'extension passé en
151
     * Tente de renvoyer un objet type_fichier_mime � partir de l'extension pass� en
150
     * paramètre. S'il elle n'y arrive pas, elle renvoie 'inconnue'.
152
     * param�tre. S'il elle n'y arrive pas, elle renvoie 'inconnue'.
151
     *
153
     *
152
     * @param string extension On passe un extension en paramètre, pour déterminer le type mime.
154
     * @param string extension On passe un extension en param�tre, pour d�terminer le type mime.
153
     * @param DB objetDB un objet PEAR:DB
155
     * @param DB objetDB un objet PEAR:DB
154
     * @return type_fichier_mime
156
     * @return type_fichier_mime
155
     * @static
157
     * @static
156
     * @access public
158
     * @access public
157
     */
159
     */
158
    function factory( $extension, $objetDB = '')
160
    function factory( $extension, $objetDB = '')
159
    {
161
    {
160
        if (is_object($objetDB)) {
162
        if (is_object($objetDB)) {
161
        	$GLOBALS['projet_db'] = $objetDB;
163
        	$GLOBALS['projet_db'] = $objetDB;
162
        }
164
        }
163
        $requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ;
165
        $requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ;
164
        $resultat = $GLOBALS['projet_db']->query ($requete) ;
166
        $resultat = $GLOBALS['projet_db']->query ($requete) ;
165
        if (DB::isError($resultat)) {
167
        if (DB::isError($resultat)) {
166
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
168
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
167
        }
169
        }
168
        if ($resultat->numRows() != 0) {
170
        if ($resultat->numRows() != 0) {
169
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
171
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
170
            return new type_fichier_mime ( $ligne->gtf_id_type) ;
172
            return new type_fichier_mime ( $ligne->gtf_id_type) ;
171
        } else {
173
        } else {
172
            // si il n'y a pas de résultat, on renvoie inconnue
174
            // si il n'y a pas de r�sultat, on renvoie inconnue
173
            return new type_fichier_mime (12) ;
175
            return new type_fichier_mime (12) ;
174
        }
176
        }
175
    } // end of member function factory
177
    } // end of member function factory
176
 
178
 
177
    /**
179
    /**
178
     * Renvoie l'identifiant du type Mime de la table gen_type_de_fichier
180
     * Renvoie l'identifiant du type Mime de la table gen_type_de_fichier
179
     *
181
     *
180
     * @return int
182
     * @return int
181
     * @access public
183
     * @access public
182
     */
184
     */
183
    function getIdType( )
185
    function getIdType( )
184
    {
186
    {
185
        return $this->_id_type;
187
        return $this->_id_type;
186
    } // end of member function getIdType
188
    } // end of member function getIdType
187
 
189
 
188
 
190
 
189
} // end of type_fichier_mime
191
} // end of type_fichier_mime
190
?>
192
?>