merge nils' changes into 3.2.x (i am still not sure if we want to have them in 3...
[phpbb.git] / phpBB / includes / Zend / loader.php
blob99a55439015c346737fbcbebb785ac19ed2121bf
1 <?php
2 /**
4 * @package zend
5 * @version $Id$
6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 */
11 /**
12 * @ignore
14 if (!defined('IN_PHPBB'))
16 exit;
19 if (version_compare(PHP_VERSION, '5.2.4', '<') || !function_exists('spl_autoload_register'))
21 trigger_error('PHP >= 5.2.4 and spl_autoload_register() required', E_USER_ERROR);
24 /**
25 * Autoload function for Zend framework classes
27 function phpbb_zend_autoload($class_name)
29 global $phpbb_root_path;
31 if (strpos($class_name, '_') !== false)
33 $path = str_replace('_', '/', $class_name) . '.php';
34 require("{$phpbb_root_path}includes/" . $path);
35 return true;
39 /**
40 * @ignore
42 // make sure Zend is in the include path
43 ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . $phpbb_root_path . 'includes' );
45 // check whether a regular autoload function already exists, so we can load it into the spl stack afterwards
46 $register_autoload = false;
47 if (function_exists('__autoload'))
49 $register_autoload = true;
52 spl_autoload_register('phpbb_zend_autoload');
54 // load the old autoload function into the spl stack if necessary
55 if ($register_autoload)
57 spl_autoload_register('__autoload');