Commits

wiredesignz committed ffedb45

Update MX_Loader & Modules classes to use the cascading views feature

  • Participants
  • Parent commits 8966801
  • Branches default

Comments (0)

Files changed (2)

File third_party/MX/Loader.php

 
 		list($path, $_plugin) = Modules::find($plugin.'_pi', $this->_module, 'plugins/');	
 		
-		if ($path === FALSE) return;
+		if ($path === FALSE AND ! is_file($_plugin = APPPATH.'plugins/'.$_plugin.EXT)) {	
+			show_error("Unable to locate the plugin file: {$_plugin}");
+		}
 
 		Modules::load_file($_plugin, $path);
 		$this->_ci_plugins[$plugin] = TRUE;
 	/** Load a module view **/
 	public function view($view, $vars = array(), $return = FALSE) {
 		list($path, $view) = Modules::find($view, $this->_module, 'views/');
-		$this->_ci_view_path = $path;
+		$this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
 		return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
 	}
 
 		}
 
 		if ($_ci_path == '') {
+			
 			$_ci_file = strpos($_ci_view, '.') ? $_ci_view : $_ci_view.EXT;
-			$_ci_path = $this->_ci_view_path.$_ci_file;
-		} else {
-			$_ci_file = basename($_ci_path);
+			
+			foreach ($this->_ci_view_paths as $path => $cascade) {
+				if (file_exists($view = $path.$_ci_file)) {
+					$_ci_path = $view;
+					break;
+				}
+				
+				if ( ! $cascade) break;
+			}
 		}
 
-		if ( ! file_exists($_ci_path)) 
-			show_error('Unable to load the requested file: '.$_ci_file);
+		if ($_ci_path == '') 
+			show_error('Unable to load the requested view file: '.basename($_ci_path));
 
 		if (is_array($_ci_vars)) 
 			$this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);

File third_party/MX/Modules.php

 			}
 		}
 		
-		/* is the file in an application directory? */
-		if ($base == 'views/' OR $base == 'plugins/') {
-			if (is_file(APPPATH.$base.$path.$file_ext)) return array(APPPATH.$base.$path, $file);	
-			show_error("Unable to locate the {$base} file: {$path}{$file_ext}");
-		}
-
-		log_message('debug', "Unable to locate the {$base} file: {$path}{$file_ext}");
 		return array(FALSE, $file);	
 	}