Location: PHPKode > projects > Mocovie web framework > mocovi/library/autoload/Framework.php
<?php
class_exists('MvcException')	or require $GLOBALS['library'].'autoload/MvcException.php';

class Framework
{
	protected static $name
				   , $path
				   , $fileExtension
				   ;

	private final function __construct() {}

	public static function register($fwname, $fwpath)
	{
		self::$name = $fwname;
		self::$path = self::verifyPath($fwpath);
	}

	public static function load($filename)
	{
		if(!is_file(self::$path.$filename))
			throw new FrameworkException('File "'.$filename.'" not found in '.self::$name.' Framework.');
		require_once self::$path.$filename;
	}

	public static function required($fw)
	{
		if(!Framework::equals($fw))
			throw new MvcException('This control requires '.$fw.' Framework');
	}

	public static function equals($fw)
	{
		return stristr(strtolower(self::name()), strtolower($fw));
	}

	public static function name()
	{
		return self::$name;
	}

	/**
	 *
	 * @todo maybe solve via include_path variable?
	 */
	public static function autosensing()
	{
		if(is_file('PEAR.php')) //Doesn't work
		{
			self::register('PEAR', 'PEAR/');
			return true;
		}
		elseif(is_dir('Zend/'))
		{
			self::register('Zend', 'Zend/');
			return true;
		}
		return false;
	}

	protected static function verifyPath($path)
	{
		if(substr($path, strlen($path) - 1, 1) != '/') $path .= '/';
		if(!is_dir($path)) throw new FrameworkException('"'.$path.'" is no directory.');
		if($handle = opendir($path))
			while($elements = readdir($handle))
				if(substr($elements, 0, 1) != '.')
					return $path;
		throw new FrameworkException('"'.$path.'" is empty.');
	}
}

class FrameworkException extends Exception {}
Return current item: Mocovie web framework