Commits

Greg Aker committed 2df8c15 Merge

Comments (0)

Files changed (3)

system/core/Controller.php

 
 		$this->load =& load_class('Loader', 'core');
 
-		$this->load->_base_classes =& is_loaded();
-
-		$this->load->ci_autoloader();
-
+		$this->load->set_base_classes()->ci_autoloader();
+		
 		log_message('debug', "Controller Class Initialized");
-
 	}
 
 	public static function &get_instance()

system/core/Loader.php

 class CI_Loader {
 
 	// All these are set automatically. Don't mess with them.
-	var $_ci_ob_level;
-	var $_ci_view_paths		= array();
+	protected $_ci_ob_level;
+	protected $_ci_view_paths		= array();
 	protected $_ci_library_paths	= array();
-	var $_ci_model_paths	= array();
-	var $_ci_helper_paths	= array();
-	var $_base_classes		= array(); // Set by the controller class
-	var $_ci_cached_vars	= array();
-	var $_ci_classes		= array();
-	var $_ci_loaded_files	= array();
-	var $_ci_models			= array();
-	var $_ci_helpers		= array();
-	var $_ci_varmap			= array('unit_test' => 'unit', 'user_agent' => 'agent');
-
+	protected $_ci_model_paths		= array();
+	protected $_ci_helper_paths		= array();
+	protected $_base_classes		= array(); // Set by the controller class
+	protected $_ci_cached_vars		= array();
+	protected $_ci_classes			= array();
+	protected $_ci_loaded_files		= array();
+	protected $_ci_models			= array();
+	protected $_ci_helpers			= array();
+	protected $_ci_varmap			= array('unit_test' => 'unit', 
+											'user_agent' => 'agent');
 
 	/**
 	 * Constructor
 	}
 
 	// --------------------------------------------------------------------
+	
+	/**
+	 * Set _base_classes variable
+	 *
+	 * This method is called once in CI_Controller.
+	 *
+	 * @param 	array 	
+	 * @return 	object
+	 */
+	public function set_base_classes()
+	{
+		$this->_base_classes =& is_loaded();
+		
+		return $this;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Is Loaded
+	 *
+	 * A utility function to test if a class is in the self::$_ci_classes array.
+	 * This function returns the object name if the class tested for is loaded,
+	 * and returns FALSE if it isn't.
+	 *
+	 * It is mainly used in the form_helper -> _get_validation_object()
+	 *
+	 * @param 	string	class being checked for
+	 * @return 	mixed	class object name on the CI SuperObject or FALSE
+	 */
+	public function is_loaded($class)
+	{
+		if (isset($this->_ci_classes[$class]))
+		{
+			return $this->_ci_classes[$class];
+		}
+				
+		return FALSE;
+	}
+
+	// --------------------------------------------------------------------
 
 	/**
 	 * Class Loader
 	 * This function lets users load and instantiate classes.
 	 * It is designed to be called from a user's app controllers.
 	 *
-	 * @access	public
 	 * @param	string	the name of the class
 	 * @param	mixed	the optional parameters
 	 * @param	string	an optional object name
 	 * @return	void
 	 */
-	function library($library = '', $params = NULL, $object_name = NULL)
+	public function library($library = '', $params = NULL, $object_name = NULL)
 	{
 		if (is_array($library))
 		{
 	/**
 	 * Instantiates a class
 	 *
-	 * @access	private
 	 * @param	string
 	 * @param	string
 	 * @param	string	an optional object name
 	 * @return	null
 	 */
-	function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
+	protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
 	{
 		// Is there an associated config file for this class?  Note: these should always be lowercase
 		if ($config === NULL)
 			return $filename;
 		}
 	}
-
-
 }
 
 /* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
+/* Location: ./system/core/Loader.php */

system/helpers/form_helper.php

 	{
 		$CI =& get_instance();
 
-		// We set this as a variable since we're returning by reference
+		// We set this as a variable since we're returning by reference.
 		$return = FALSE;
-
-		if ( ! isset($CI->load->_ci_classes) OR  ! isset($CI->load->_ci_classes['form_validation']))
+		
+		if ( ! ($object = $CI->load->is_loaded('form_validation')))
 		{
-			return $return;
+			if ( ! isset($CI->$object) OR ! is_object($CI->$object))
+			{
+				return $return;
+			}
+			
+			return $CI->$object;
 		}
-
-		$object = $CI->load->_ci_classes['form_validation'];
-
-		if ( ! isset($CI->$object) OR ! is_object($CI->$object))
-		{
-			return $return;
-		}
-
-		return $CI->$object;
+		
+		return $return;
 	}
 }