Source for file _filetype.class.php
Documentation is available at _filetype.class.php
* This file implements the file type class.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2008 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
* PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
* @author mbruneau: Marc BRUNEAU / PROGIDISTRI
* @version $Id: _filetype.class.php,v 1.2 2008/01/21 09:35:29 fplanque Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class('_core/model/dataobjects/_dataobject.class.php');
* @param table Database row
// Call parent constructor:
parent::DataObject( 'T_filetypes', 'ftyp_', 'ftyp_ID' );
$this->ID =
$db_row->ftyp_ID ;
$this->name =
$db_row->ftyp_name ;
$this->mimetype =
$db_row->ftyp_mimetype ;
$this->icon =
$db_row->ftyp_icon ;
$this->viewtype =
$db_row->ftyp_viewtype ;
$this->allowed =
$db_row->ftyp_allowed ;
{ // Create a new filetype:
$this->set( 'viewtype', 'browser' );
* Load data from Request form fields.
* @return boolean true if loaded data seems valid.
global $force_upload_forbiddenext;
{ // Check if estensions has a valid format
$GLOBALS['ftyp_extensions'] =
strtolower( trim( $GLOBALS['ftyp_extensions'] ) );
$reg_exp =
'/^[a-z0-9]+( [a-z0-9]+)*$/';
if( !preg_match( $reg_exp, $GLOBALS['ftyp_extensions'], $res ) )
{ // Extensiosn has an invalid format
param_error( 'ftyp_extensions', T_( 'Invalid file extensions format.' ) );
// Icon for the mime type
if( param( 'ftyp_icon', 'string', '' ) )
param( 'ftyp_viewtype', 'string' );
// Allowed to upload theses extensions
param( 'ftyp_allowed', 'integer', '0' );
if( $GLOBALS['ftyp_allowed'] )
// Check if the extension is in the array of the not allowed extensions (_advanced.php)
$extensions =
explode ( ' ', $GLOBALS['ftyp_extensions'] );
foreach($extensions as $extension)
if( in_array( $extension, $force_upload_forbiddenext ) )
{ // this extension is not allowed
$GLOBALS['ftyp_allowed'] =
0;
* By default, all values will be considered strings
* @param string parameter name
* @param mixed parameter value
function set( $parname, $parvalue )
$this->set_param( $parname, 'string', $parvalue );
* Return the img html code of the icon
return '<img src="'.
$rsc_url.
'icons/fileicons/'.
$icon.
'" alt="" title="'.
$this->dget('name', 'htmlattr').
'" class="middle" />';
* $Log: _filetype.class.php,v $
* Revision 1.2 2008/01/21 09:35:29 fplanque
* Revision 1.1 2007/06/25 10:59:57 fplanque
* MODULES (refactored MVC)