* @package Mammut */ /* $Id$ */ (defined('USE_MAMMUT') && (basename(__FILE__) != basename($_SERVER['PHP_SELF']))) or die('ACCESS DENIED'); /** * MAMMUT framework main version */ define('MAMMUT', '1.1.0.0'); // check some basic requirements version_compare(PHP_VERSION, '5.4.0', '>=') or die('PHP >= 5.4 required'); extension_loaded('SPL') or die('SPL extension missing'); extension_loaded('pcre') or die('pcre extension missing'); if(defined('__DS__') && constant('__DS__') != DIRECTORY_SEPARATOR) die('incompartible environment, __DS__ constant is defined but dosen\'t match the directory separator'); elseif(!defined('__DS__')) /** * Shorthand for directory separator */ define('__DS__', DIRECTORY_SEPARATOR); // load other libaries require_once (__DIR__ . __DS__ . 'lib.array.php'); // array functions require_once (__DIR__ . __DS__ . 'lib.string.php'); // string functions require_once (__DIR__ . __DS__ . 'lib.file.php'); // file functions /** * Loads a library defined by a dotted libpath. * * This function is used to load libaries from the default lib dir. It caches loaded * libaries in * $GLOBALS['MF']['import'] to improve performens (experimental). * * @param string $libpath * dotted libpath of the library that should be included * @since 1.0.0.0 */ function importlib($libpath) { static $loaded; if(!isset($loaded)) $loaded = array(); if(array_search($libpath, $loaded)) return; $parts = explode('.', $libpath); $path = ''; for($i = 0; $i < count($parts) - 1; $i++) $path .= $parts[$i] . __DS__; $path .= 'lib.' . strtolower($parts[count($parts) - 1]) . '.php'; if(!include_exists($path)) throw new Exception('importlib failed: library file not found for ' . $libpath); require_once ($path); $loaded[] = $libpath; } /** * Check if a mammut styled library file exists which could be loaded * * @param string $libpath * @return boolean true if a library exists */ function lib_exists($libpath) { $parts = explode('.', $libpath); $path = ''; for($i = 0; $i < count($parts) - 1; $i++) $path .= $parts[$i] . __DS__; $path .= 'lib.' . strtolower($parts[count($parts) - 1]) . '.php'; return include_exists($path); } // this method should not exist, but if you want to write your own, do it if(!function_exists('__autoload')) { require_once (__DIR__ . __DS__ . 'AutoLoader' . __DS__ . 'cls.iautoloader.php'); require_once (__DIR__ . __DS__ . 'AutoLoader' . __DS__ . 'cls.mfautoloader.php'); spl_autoload_register(array('\Mammut\AutoLoader\MFAutoLoader','loadClass')); }