New file |
0,0 → 1,187 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: type_fichier_mime.class.php,v 1.1 2005-09-22 14:02:47 ddelon Exp $ |
/** |
* Application projet |
* |
* La classe type_fichier_mime |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
/** |
* class type_fichier_mime |
* |
*/ |
class type_fichier_mime |
{ |
/*** Attributes: ***/ |
|
/** |
* Le nom du type en français (ex Image jpg) |
* @access private |
*/ |
var $_nom; |
/** |
* L'extension du fichier (ex: png) |
* @access private |
*/ |
var $_extension; |
/** |
* Le nom du fichier de l'icône représentant ce fichier. |
* @access private |
*/ |
var $_icone; |
/** |
* Le type mime. |
* @access private |
*/ |
var $_type_mime; |
/** |
* |
* @access private |
*/ |
var $_description; |
/** |
* Le chemin UNIX ou Windows vers le dossier des icônes. Il ne commence pas par un |
* slash et termine par slash. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* Un objet PEAR:DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant du type dans la table gen_type_de_fichier |
* @access private |
*/ |
var $_id_type; |
|
/** |
* Renvoie le chemin vers les icônes. |
* |
* @return string |
* @access public |
*/ |
function getCheminIcone( ) |
{ |
return $this->_chemin_icone.$this->_icone ; ; |
} // end of member function getCheminIcone |
|
/** |
* |
* |
* @param string chemin Le chemin vers l'icône. |
* @return void |
* @access public |
*/ |
function setCheminIcone( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} // end of member function setCheminIcone |
|
/** |
* |
* |
* @param DB objetDB un objet PEAR:DB |
* @param int id_type |
* @return void |
* @access public |
*/ |
function type_fichier_mime( &$objetDB, $id_type = '', $chemin_icones = "icones/" ) |
{ |
$this->_db = $objetDB ; |
$requete = 'select * from gen_type_de_fichier where ' ; |
if (is_numeric ($id_type)) { |
$requete .= 'gtf_id_type='.$id_type ; |
} else { |
$requete .= 'gtf_type_mime="'.$id_type.'"' ; |
} |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_chemin_icone = $chemin_icones ; |
$this->_icone = $ligne->gtf_type_icone ; |
$this->_id_type = $ligne->gtf_id_type ; |
} // end of member function type_fichier_mime |
|
/** |
* Tente de renvoyer un objet type_fichier_mime à partir de l'extension passé en |
* paramètre. S'il elle n'y arrive pas, elle renvoie 'inconnue'. |
* |
* @param string extension On passe un extension en paramètre, pour déterminer le type mime. |
* @param DB objetDB un objet PEAR:DB |
* @return type_fichier_mime |
* @static |
* @access public |
*/ |
function factory( $extension, &$objetDB ) |
{ |
$requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() != 0) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return new type_fichier_mime ($objetDB, $ligne->gtf_id_type) ; |
} else { |
// si il n'y a pas de résultat, on renvoie inconnue |
return new type_fichier_mime ($objetDB, 12) ; |
} |
} // end of member function factory |
|
/** |
* Renvoie l'identifiant du type Mime de la table gen_type_de_fichier |
* |
* @return int |
* @access public |
*/ |
function getIdType( ) |
{ |
return $this->_id_type; |
} // end of member function getIdType |
|
|
} // end of type_fichier_mime |
?> |