<?php

	function lt_include( $filename )
	{ 
		if(!isset($GLOBALS['included_files'][$filename] )) { 
			$GLOBALS['included_files'][$filename] = TRUE; 
			include($filename);
		}
	}

	// preload the class loader map to reduce the SPL searching time
	lt_include( PLOG_CLASS_PATH."class/classloadermap.properties.php" );
	
	/**
	 * Lifetype's own autolaoder class
	 *
	 * Please register it with spl_autoload_register instead of defining your own
	 * __autoload method so that we can have more than one autoload function. SPL
	 * will automatically take care of that for you.
	 */
	class LTClassLoader
	{
		static public $folderList = Array(
			'action',
			'action/admin',
			'action/admin/ajax',
			'action/admin/chooser',
			'bayesian',
			'cache',
			'cache/Cache_Lite',
			'cache/Memcached_Client',
			'config',
			'controller',
			'dao',
			'dao/customfields',
			'dao/misc',
			'dao/status',
			'dao/userdata',
			'data',
			'data/captcha',
			'data/Date',
			'data/filter',
			'data/forms',
			'data/pager',
			'data/serialize',
			'data/serialize/json',
			'data/utf8',
			'data/utf8/mbstring',
			'data/utf8/native',
			'data/utf8/utils',
			'data/validator',
			'data/validator/rules',
			'database',
			'database/pdb',
			'database/pdb/datadict',
			'database/pdb/drivers',
			'file',
			'file/finder',
			'file/unpacker',
			'gallery',
			'gallery/dao',
			'gallery/data',
			'gallery/getid3',
			'gallery/helperapps',
			'gallery/resizers',
			'gallery/template',
			'locale',
			'logger',
			'logger/appender',
			'logger/config',
			'logger/layout',
			'logger/logger',
			'mail',
			'misc',
			'net',
			'net/http',
			'net/http/session',
			'net/xmlrpc',
			'object',
			'plugin',
			'security',
			'summary',
			'summary/action',
			'summary/controller',
			'summary/dao',
			'summary/data',
			'summary/data/validator',
			'summary/mail',
			'summary/net',
			'summary/view',
			'template',
			'template/editor',
			'template/menu',
			'template/smarty',
			'template/smarty/internals',
			'template/smarty/plugins',
			'template/templatesets',
			'test',
			'test/helpers',
			'test/PHPUnit',
			'test/PHPUnit/GUI',
			'test/tests',
			'test/tests/config',
			'test/tests/dao',
			'test/tests/data',
			'test/tests/data/filter',
			'test/tests/data/validator',
			'test/tests/data/validator/rules',
			'test/tests/extra',
			'test/tests/file',
			'test/tests/file/unpacker',
			'test/tests/locale',
			'test/tests/logger',
			'test/tests/mail',
			'test/tests/misc',
			'test/tests/net',
			'test/tests/net/http',
			'test/tests/net/xmlrpc',
			'test/tests/summary',
			'test/tests/summary/action',
			'test/tests/summary/dao',
			'test/tests/summary/data',
			'test/tests/ui',
			'view',
			'view/admin',
			'view/admin/ajax',
			'view/admin/chooser',
			'view/ajax',
			'view/renderer',
			'xml',
			'xml/parser',
			'xml/rssparser',
			'xml/rssparser/magpierss',
			'xml/rssparser/magpierss/extlib',
			'xml/tree'			
		);
		
		static function load( $className )
		{			
			global $LTClassLoaderMap;

			$fileName = strtolower( $className );
			if( isset( $LTClassLoaderMap[$fileName] ) )
			{
				lt_include( PLOG_CLASS_PATH.$LTClassLoaderMap[$fileName] );
			} else {
				foreach( self::$folderList as $folder ) {
					$path = PLOG_CLASS_PATH."class/".$folder."/".$fileName.".class.php";
					if( file_exists( $path ))
						lt_include( $path );
				}
			}
		}
	}

?>