protected function loadLibrary($libraryName, $parameters = null, array $directory = null, $newInstance = false) 
	{
		// First get the directories where the library can be located
		$directories = (is_null($directory) ? $this->libraryPaths : $directory);

		// Now figure out the className and subdir
		$class = trim($libraryName, '/');
		if (($last_slash = strrpos($class, '/')) !== FALSE)
		{
			// Extract the path
			$subdir = substr($class, 0, ++$last_slash);

			// Get the filename from the path
			$class = substr($class, $last_slash);
		}
		else
		{
			$subdir = '';
		}

		$class = ucfirst($class);

		// Is the library a core library, then load a core library
		if (file_exists(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php'))
		{
			// Load base library
			return $this->loadCoreLibrary($class, $subdir, $parameters, $directories, $newInstance);
		}

		// Otherwise try and load an Application Library
		return $this->loadAppLibrary($class, $subdir, $parameters, $directories, $newInstance);
	}
protected function loadLibrary($libraryName, $parameters = null, array $directory = null, $newInstance = false) 
	{
		// First get the directories where the library can be located
		$directories = (is_null($directory) ? $this->libraryPaths : $directory);

		// Now figure out the className and subdir
		$class = trim($libraryName, '/');
		if (($last_slash = strrpos($class, '/')) !== FALSE)
		{
			// Extract the path
			$subdir = substr($class, 0, ++$last_slash);

			// Get the filename from the path
			$class = substr($class, $last_slash);
		}
		else
		{
			$subdir = '';
		}

		$class = ucfirst($class);

		// Is the library a core library, then load a core library
		if (file_exists(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php'))
		{
			// Load base library
			return $this->loadCoreLibrary($class, $subdir, $parameters, $directories, $newInstance);
		}

		// Otherwise try and load an Application Library
		return $this->loadAppLibrary($class, $subdir, $parameters, $directories, $newInstance);
	}
protected function loadLibrary ( $ libraryName , $ parameters = null , array $ directory = null , $ newInstance = false ) { // First get the directories where the library can be located $ directories = ( is_null ( $ directory ) ? $ this -> libraryPaths : $ directory ) ; // Now figure out the className and subdir $ class = trim ( $ libraryName , '/' ) ; if ( ( $ last_slash = strrpos ( $ class , '/' ) ) !== FALSE ) { // Extract the path $ subdir = substr ( $ class , 0 , ++ $ last_slash ) ; // Get the filename from the path $ class = substr ( $ class , $ last_slash ) ; } else { $ subdir = '' ; } $ class = ucfirst ( $ class ) ; // Is the library a core library, then load a core library if ( file_exists ( Core :: $ coreDir . DS . 'Libraries' . DS . $ subdir . $ class . '.php' ) ) { // Load base library return $ this -> loadCoreLibrary ( $ class , $ subdir , $ parameters , $ directories , $ newInstance ) ; } // Otherwise try and load an Application Library return $ this -> loadAppLibrary ( $ class , $ subdir , $ parameters , $ directories , $ newInstance ) ; }
Internal Library Loader

Determines what type of library needs to be loaded

@param	string	$library		Library name
@param	array	$params			Optional parameters to pass to the library class constructor
@param	array	$directory 		Optional list of directories where the library can be found. Overrides default list
@param   bool 	$newInstance 	Whether to return a new instance of the library or the same one
@return	object
@throws 	LibraryException
Internal Library Loader