<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,8 +8,8 @@
 
 # Hide the following from the world
 &lt;FilesMatch &quot;\.(htaccess|htpasswd|ini|php|log|sh|sql)$&quot;&gt;
- Order Allow,Deny
- Deny from all
+	Order Allow,Deny
+	Deny from all
 &lt;/FilesMatch&gt;
 
 # Allow the index file though..
@@ -58,12 +58,7 @@ DirectoryIndex index.php index.html
     ####RewriteCond $1 !^(images|themes|favicon\.ico|robots\.txt|index\.php) [NC]
     
 	RewriteRule ^(.*)$ index.php/$1 [QSA,L]
-	
-	
-    # Rewrite for everything else
-    #RewriteRule ^(([A-Za-z\-]+)/)?(([A-Za-z_]+)/)?(.+/)?$ index.php?controller=$2&amp;method=$4&amp;data=$5 [QSA,NC,L]
     
-	
     # Deny any people (or bots) from the following sites: (to stop spam comments)
     #RewriteCond %{HTTP_REFERER} nienschanz\.ru [NC,OR]
     #RewriteCond %{HTTP_REFERER} porn\.com
@@ -77,8 +72,8 @@ DirectoryIndex index.php index.html
 
 
 # implement minimal caching during site development
-&lt;FilesMatch &quot;\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$&quot;&gt;
-ExpiresActive Off
-Header set Cache-Control &quot;max-age=0&quot;
+#&lt;FilesMatch &quot;\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$&quot;&gt;
+#ExpiresActive Off
+#Header set Cache-Control &quot;max-age=0&quot;
 #Header unset Cache-Control
-&lt;/FilesMatch&gt;
\ No newline at end of file
+#&lt;/FilesMatch&gt;
\ No newline at end of file</diff>
      <filename>.htaccess</filename>
    </modified>
    <modified>
      <diff>@@ -61,6 +61,7 @@ function is_ajax_request() {
 	return FALSE;
 }
 
+
 /**
 * Class registry
 *
@@ -75,12 +76,12 @@ function is_ajax_request() {
 * @param	bool	(flag) load class but do not instantiate
 * @return	object
 */
-function load_class($class=null, $path='libraries', $params=null, $location = 1, $instantiate = TRUE) {
+function load_class($class = NULL, $path = 'libraries', $params = NULL, $location = 1, $instantiate = TRUE) {
 
 	static $objects = array();
 
 	//If a class is NOT given
-	if (!$class) { return; }
+	if (!$class) { return FALSE; }
 
 	//If this class is already loaded
 	if(!empty($objects[$class])) {
@@ -92,7 +93,7 @@ function load_class($class=null, $path='libraries', $params=null, $location = 1,
 
 		//Load this file
 		if( ! load_file($class, $path, $location)) {
-			die('Failed to load '. $class);
+			return FALSE;
 		}
 
 	}
@@ -142,17 +143,17 @@ function load_file($name = FALSE, $path = FALSE, $location = 1) {
 		$path = MODULE_PATH. '/'. $name. '.php';
 
 
-	//If this is a module file (3)
-	} elseif($location == 3) {
-		$path = MODULE_PATH. $module. '/'. $path. '/'. $name. '.php';
+	//Else it is a site specific file (1)
+	} elseif ($location == 1) {
+		$path = SITE_PATH. $path . '/'. $name . '.php';
 
 	//If this is a global system file (2)
 	} elseif ($location == 2) {
 		$path = SYSTEM_PATH. $path . '/'. $name . '.php';
 
-	//Else it is a site specific file (1)
-	} else {
-		$path = SITE_PATH. $path . '/'. $name . '.php';
+	//If this is a module file (3)
+	} elseif ($location == 3) {
+		$path = MODULE_PATH. $module. '/'. $path. '/'. $name. '.php';
 	}
 
 	// If the requested file does not exist
@@ -188,7 +189,7 @@ function mvc_error_handler($level='', $message='', $file='', $line='', $variable
 	}
 
 	//Only show the system file that had the problem - not the whole server dir structure!
-	$file = str_replace(SITE_DIR, '', $file);
+	$file = str_replace(SYSTEM_PATH, '', $file);
 
 	//Set error types
 	$error_levels = array(
@@ -235,10 +236,8 @@ function mvc_error_handler($level='', $message='', $file='', $line='', $variable
 
 			//Max of 5 levels deep
 			if(count($backtrace) &gt; 5) {
-				//$backtrace = array_chunk($backtrace, 5, TRUE);
-				//$backtrace = $backtrace[0];
-				//print_pre($backtrace);
-
+				$backtrace = array_chunk($backtrace, 5, TRUE);
+				$backtrace = $backtrace[0];
 			}
 
 			// start backtrace
@@ -302,7 +301,7 @@ function mvc_error_handler($level='', $message='', $file='', $line='', $variable
 				}
 
 				//Add line number and file
-				$string .= ' on line '. $v['line']. ' in '. str_replace(SITE_DIR, '', $v['file']). '&lt;br /&gt;';
+				$string .= ' on line '. $v['line']. ' in '. str_replace(SYSTEM_PATH, '', $v['file']). '&lt;br /&gt;';
 
 				//Create an element containing the trace and function args (only if still an array)
 				$trace[] = array($string, (is_string($args) ? '' : $args));
@@ -327,9 +326,13 @@ function mvc_error_handler($level='', $message='', $file='', $line='', $variable
  *
  * @param mixed $text
  */
-function print_pre($object=null) {
-	print '&lt;pre&gt;';
-	print_r($object);
+function print_pre($data = NULL) {
+	print '&lt;pre style=&quot;padding: 1em; margin: 1em 0;&quot;&gt;';
+	if(func_num_args() &lt; 2) {
+		print_r($data);
+	} else {
+		print_r(func_get_args());
+	}
 	print '&lt;/pre&gt;';
 }
 
@@ -738,7 +741,7 @@ function directory($data, $level=1) {
 					if(!$data['type'] || $data['type'] == 'dir') {
 						//Add the dir to our list
 						$files[$path]['file'] = $file;
-						$files[$path]['dir'] = substr($path, strlen(SITE_DIR), -strlen($file));
+						$files[$path]['dir'] = substr($path, strlen(SYSTEM_PATH), -strlen($file));
 
 						//If we are only getting the file names/paths
 						if(!$data['light']) {
@@ -772,7 +775,7 @@ function directory($data, $level=1) {
 
 						//Add the file to our list
 						$files[$path]['file'] = $file;
-						$files[$path]['dir'] = substr($path, strlen(SITE_DIR), -strlen($file));
+						$files[$path]['dir'] = substr($path, strlen(SYSTEM_PATH), -strlen($file));
 						//Get the LAST &quot;.&quot; followed by 2-4 letters/numbers
 						$files[$path]['ext'] = $ext;
 </diff>
      <filename>functions/common.php</filename>
    </modified>
    <modified>
      <diff>@@ -24,21 +24,24 @@ define('START_MEMORY_USAGE', memory_get_usage());
 $var = preg_replace(&quot;/([^a-z0-9_\-\.]+)/i&quot;, '_', $_SERVER[&quot;REQUEST_URI&quot;]);
 define('PAGE_NAME', ($var ? $var : 'index'));
 
-//Discover the current domain for the whole script
-define('DOMAIN', current_domain());
-
-//Discover whether this is an AJAX request or not
-define('AJAX_REQUEST', is_ajax_request());
-
 //Define the OS file path separator
 define('DS', DIRECTORY_SEPARATOR);
 
 //Define the base file system path to MicroMVC
-define('SYSTEM_PATH', realpath(dirname(__FILE__)));
+define('SYSTEM_PATH', realpath(dirname(__FILE__)). DS);
+
+//Include the common file to continue loading
+require_once(SYSTEM_PATH. 'functions/common.php');
 
 //Define the base file system path to MicroMVC
 define('MODULE_PATH', SYSTEM_PATH. 'modules/');
 
+//Discover the current domain for the whole script
+define('DOMAIN', current_domain());
+
+//Discover whether this is an AJAX request or not
+define('AJAX_REQUEST', is_ajax_request());
+
 //Define the file system path to the current site
 define('SITE_PATH', SYSTEM_PATH. DS. DOMAIN. DS);
 
@@ -48,28 +51,20 @@ define('UPLOAD_PATH', SITE_PATH. 'uploads/');
 //The file system path of the site's cache folder
 define('CACHE_PATH', SITE_PATH. 'cache/');
 
-
-/*
- * Begin loading of the system
- */
+//Override the PHP error handler
+set_error_handler('mvc_error_handler');
 
 //Require the config file for this site name
 require(SITE_PATH. 'config/config.php');
 
-//Include the common file
-require_once(SYSTEM_PATH. 'functions/common.php');
-
-//Override the PHP error handler
-set_error_handler('mvc_error_handler');
+//Require the config file for the hooks
+require(SITE_PATH. 'config/hooks.php');
 
 //Load the caching class
-$cache = load_class('cache');
-
-//Require the config file for the hooks
-require('sites/'. SITE_NAME. '/hooks.php');
+$cache = load_class('cache', 'libraries', NULL, 2);
 
 //Load the hooks class
-$hooks = load_class('hooks', $hooks);
+$hooks = load_class('hooks', 'libraries', $hooks, 2);
 
 //Call first hook
 $hooks-&gt;call('system_startup');
@@ -108,16 +103,16 @@ if (ini_get('magic_quotes_gpc')) {
 
 
 //Include the core file
-require_once(CORE_DIR. 'core.php');
+load_file('core', 'libraries', 2);
 
 //Include the base file
-require_once(CORE_DIR. 'base.php');
+load_file('base', 'libraries', 2);
 
 
 /**
  * Get the controller from the URI
  */
-$routes = load_class('routes');
+$routes = load_class('routes', 'libraries', NULL, 2);
 
 //Set default controller/method if none is set in URL
 $routes-&gt;set_defaults(
@@ -138,31 +133,23 @@ $method		= $routes-&gt;fetch(1);
  * START-UP THE SYSTEM!
  */
 
-//If the file doesn't exist - default to the core
-if(!file_exists(SITE_DIR. 'controllers/'. $controller. '.php')) {
+//If the file doesn't exist - default to the core class
+if( ! load_class($controller, 'controllers', NULL, 1, FALSE)) {
+	$method		= 'requrst_error';
 	$controller = 'core';
-
-	//Else include it
-} else {
-	//Include the file that has the class
-	require_once(SITE_DIR. 'controllers/'. $controller. '.php');
-}
-
-//If that file does NOT contain a matching class name
-if (!class_exists($controller)) {
-	die($controller. ' class not found');
 }
 
 //Make sure someone isn't trying to access core/private functions
 if(($method !== 'request_error' &amp;&amp; method_exists('core', $method))
-//And make sure this method exists (and is public)
-|| !in_array($method, get_class_methods($controller))) {
+	//And make sure this method exists (and is public)
+	|| !in_array($method, get_class_methods($controller))) {
+
 	//Trigger a 404 not found error
 	$method = 'request_error';
 }
 
 //Create a new instance of that controller and pass the $config
-$controller = new $controller($config);
+$controller = load_class($controller, NULL, $config);
 
 //Call the startup hook
 $controller-&gt;hooks-&gt;call('post_constructor');</diff>
      <filename>index.php</filename>
    </modified>
    <modified>
      <diff>@@ -22,8 +22,8 @@ class core {
 	private static $instance;
 	//Site Config
 	public $config = array();
-	
-	
+
+
 	/**
 	 * Load the config values for this system
 	 *
@@ -53,7 +53,7 @@ class core {
 	public function config($name=null) {
 
 		//Only load once
-		if(!empty($this-&gt;config[$name])) { 
+		if(!empty($this-&gt;config[$name])) {
 			return $this-&gt;config[$name];
 		}
 
@@ -70,7 +70,7 @@ class core {
 			$this-&gt;config[$name] = $$name;
 
 		}
-		
+
 		//Return the config array
 		return $this-&gt;config[$name];
 	}
@@ -84,13 +84,13 @@ class core {
 
 		//Don't load the DB object twice!!!
 		if(!empty($this-&gt;db)) { return; }
-		
+
 		//Load the DB class (but don't create it)
 		load_class('db', NULL, 'models', FALSE);
-		
+
 		//Load the config for this database
 		$config = $this-&gt;config('database');
-		
+
 		//Create a new instance of the database child class &quot;mysql&quot;
 		$this-&gt;db = load_class($config['type'], $config);
 
@@ -116,11 +116,11 @@ class core {
 
 		//Load the class
 		$this-&gt;$name = load_class($class, $params, $path);
-		
+
 		return true;
 	}
 
-	
+
 
 	/**
 	 * This function is used to load views files.
@@ -131,11 +131,19 @@ class core {
 	 * @param	boolean	return the output or print it?
 	 * @return	void
 	 */
-	public function view($__file = NULL, $__variables = NULL, $__return = TRUE) {
+	public function view($__file = NULL, $__variables = NULL, $__return = TRUE, $__location = 1) {
 
 		//If no file is given - just return false
 		if(!$__file) { return; }
 
+		if($__location == 1) {
+			//If this is a view in the site view folder
+			$__file = SITE_PATH. 'views/'. $__file. '.php';
+		} else {
+			//It is located in the modules folder
+			$__file = MODULE_PATH. $__file. '.php';
+		}
+
 		if(is_array($__variables)) {
 			//Make each value passed to this view available for use
 			foreach($__variables as $key =&gt; $variable) {
@@ -146,24 +154,24 @@ class core {
 		// Delete them now
 		$__variables = null;
 
-		if (!file_exists(THEME_DIR. $__file. '.php')) {
-			trigger_error('Unable to load the requested file: &lt;b&gt;'. $__file. '.php&lt;/b&gt;');
+		if (!file_exists($__file)) {
+			trigger_error('Unable to load the requested file: &lt;b&gt;'. $__file. '&lt;/b&gt;');
 			return;
 		}
 
 		// We just want to print to the screen
 		if( ! $__return) {
-			include(THEME_DIR. $__file. '.php');
+			include($__file);
 		}
-		
-		
+
+
 		/*
 		 * Buffer the output so we can return it
 		 */
 		ob_start();
 
 		// include() vs include_once() allows for multiple views with the same name
-		include(THEME_DIR. $__file. '.php');
+		include($__file);
 
 		//Get the output
 		$buffer = ob_get_contents();
@@ -173,8 +181,8 @@ class core {
 		return $buffer;
 
 	}
-	
-	
+
+
 
 	/**
 	 * Show a 400-500 Header error within the site theme
@@ -187,7 +195,7 @@ class core {
 
 		//Clean the type of error from XSS stuff
 		//$type = preg_replace('/[^a-z0-9]+/i', '', $type);
-		
+
 		//Check the type of error
 		if ($type == '400') {
 			header(&quot;HTTP/1.0 400 Bad Request&quot;);
@@ -227,10 +235,10 @@ class core {
 
 		// Load the template
 		$output = $this-&gt;view($this-&gt;layout, $this-&gt;data);
-		
+
 		// Cache the file
 		$this-&gt;cache-&gt;create(md5(PAGE_NAME. AJAX_REQUEST), $output);
-		
+
 		// Show the output
 		print $output;
 
@@ -245,29 +253,29 @@ class core {
 		return self::$instance;
 	}
 
-	
-	
+
+
 	/*
 	 * Make all loaded libraries available to the given object
 	 * @author	http://CodeIgniter.com
 	 *
 	public function assign_libraries($name = NULL) {
-		
+
 		//Get all variable keys
 		$object_vars = array_keys(get_object_vars($this));
-		
+
 		foreach ($object_vars as $key) {
-			
+
 			//Only pass objects (other libraries) to this class
 			if(is_object($this-&gt;$key)) {
-			
+
 				//If a propery by this name doesn't already exist -and it is not this classe
 				if (!isset($this-&gt;$name-&gt;$key) AND $key != $name) {
 					$this-&gt;$name-&gt;$key = $this-&gt;$key;
 				}
-				
+
 			}
 		}
 	}*/
-	
+
 }</diff>
      <filename>libraries/core.php</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,7 @@ define('DEBUG_MODE', TRUE);
 define('SITE_URL', '/MicroMVC/');
 
 // Absolute URL path to the themes directory
-define('THEME_URL', SITE_URL. 'views/');
+define('THEME_URL', SITE_URL. DOMAIN. '/views/');
 
 // Absolute URL path to the upload directory
 define('UPLOAD_URL', SITE_URL. 'uploads/');</diff>
      <filename>localhost/config/config.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>48cd2cba572773372b3ec1bc4a6d3ee5d8cfb0db</id>
    </parent>
  </parents>
  <author>
    <name>Xeoncross</name>
    <email>david@xeoncross.com</email>
  </author>
  <url>http://github.com/Xeoncross/micromvc/commit/4ad994fba71666c4b6b239f47b4a6aa61aafefd5</url>
  <id>4ad994fba71666c4b6b239f47b4a6aa61aafefd5</id>
  <committed-date>2009-06-28T21:12:52-07:00</committed-date>
  <authored-date>2009-06-28T21:12:52-07:00</authored-date>
  <message>Finished the first working version of the new file system structure.</message>
  <tree>5d5aeb9c86bdfea21f9b1a405353ab73976f46ef</tree>
  <committer>
    <name>Xeoncross</name>
    <email>david@xeoncross.com</email>
  </committer>
</commit>
