Rev 431 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?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.2 2005-09-27 16:42:00 alexandre_tb 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.2 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | 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( $id_type = '', $chemin_icones = "icones/" ){$requete = 'select * from gen_type_de_fichier where ' ;if (is_numeric ($id_type)) {$requete .= 'gtf_id_type='.$GLOBALS['projet_db']->escapeSimple($id_type) ;} else {$requete .= 'gtf_type_mime="'.$id_type.'"' ;}$resultat = $GLOBALS['projet_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 ;if ($ligne) {$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 = ''){if (is_object($objetDB)) {$GLOBALS['projet_db'] = $objetDB;}$requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ;$resultat = $GLOBALS['projet_db']->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 ( $ligne->gtf_id_type) ;} else {// si il n'y a pas de r�sultat, on renvoie inconnuereturn new type_fichier_mime (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?>