Source for file _filetypecache.class.php
Documentation is available at _filetypecache.class.php
* This file implements the file type cache class.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2010 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: _filetypecache.class.php,v 1.6 2010/02/08 17:52:18 efy-yury Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( '_core/model/dataobjects/_dataobjectcache.class.php', 'DataObjectCache' );
// Call parent constructor:
parent::DataObjectCache( 'Filetype', true, 'T_filetypes', 'ftyp_', 'ftyp_ID', 'ftyp_extensions' );
* Add a dataobject to the cache
$Debuglog->add( 'No object to add!', 'dataobjects' );
if( isset
($this->cache[$Obj->ID]) )
$Debuglog->add( $this->objtype.
': Object with ID '.
$Obj->ID.
' is already cached', 'dataobjects' );
// If the object is valid and not already cached:
$this->cache[$Obj->ID] =
& $Obj;
$extensions =
explode( ' ', $Obj->extensions );
foreach( $extensions as $extension )
$this->mimetype_cache[$Obj->mimetype] =
$Obj; // not & $Obj
* Get an object from cache by extensions ID
* Load the cache if necessary (all at once if allowed).
* @param string Extension string of object to load
* @param boolean true if function should die on error
* @param boolean true if function should die on empty/null
* @return reference on cached object
function & get_by_extension( $req_ID, $halt_on_error =
true, $halt_on_empty =
true )
{ // Requested object does not exist
// $Debuglog->add( 'failure', 'dataobjects' );
* Get an object from cache by mimetype.
* Load the cache if necessary (all at once if allowed).
* @todo dh> this copies nearly the whole code of get_by_extension! Have not checked DataObjectCache, but this needs refactoring.
* @param string Mimetype string of object to load
* @param boolean true if function should die on error
* @param boolean true if function should die on empty/null
* @return reference on cached object
function & get_by_mimetype( $mimetype, $halt_on_error =
true, $halt_on_empty =
true )
if( empty( $this->mimetype_cache[ $mimetype ] ) )
{ // Requested object does not exist
return $this->mimetype_cache[ $mimetype ];
* $Log: _filetypecache.class.php,v $
* Revision 1.6 2010/02/08 17:52:18 efy-yury
* Revision 1.5 2009/10/02 20:34:32 blueyed
* Improve handling of wrong file extensions for image.
* - load_image: if the wrong mimetype gets passed, return error, instead of letting imagecreatefrom* fail
* - upload: detect wrong extensions, rename accordingly and add a warning
* Revision 1.4 2009/09/14 13:04:53 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.3 2009/03/08 23:57:43 fplanque
* Revision 1.2 2008/01/21 09:35:29 fplanque
* Revision 1.1 2007/06/25 10:59:57 fplanque
* MODULES (refactored MVC)