Part of the EllisLab Network
   
 
Libraries multi-folders
Posted: 16 November 2006 10:13 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  10-04-2006

Hello !

As you’ve done well for controllers, models and viexs, would it be possible to do so for libraries.
I began to have lots of libraries and I think I am not the only one !

function _ci_load_class($class, $params = NULL)
    
{    
        
// Prep the class name
        
$class = ucfirst(strtolower(str_replace(EXT, '', $class)));

        
// Is this a class extension request?
        
if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
        
{
            
if ( ! file_exists(BASEPATH.'libraries/'.$class.EXT))
            
{
                log_message
('error', "Unable to load the requested class: ".$class);
                
show_error("Unable to load the requested class: ".$class);
            
}

            
include(BASEPATH.'libraries/'.ucfirst($class).EXT);
            include(
APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);

            return
$this->_ci_init_class($class, config_item('subclass_prefix'), $params);            
        
}

        
// Lets search for the requested library file and load it.
        
for ($i = 1; $i < 3; $i++)
        
{
            $path
= ($i % 2) ? APPPATH : BASEPATH;        
            if (
file_exists($path.'libraries/'.$class.EXT))
            
{
                                
/** ACTUAL LINE **/
                
include_once($path.'libraries/'.$class.EXT);

                                
/** WOULD BE NICE **/
                                
if ( isset($params['directory']) && $path == BASEPATH ) {
                                    $postPath
= $params['directory'].'/';
                                
}else{
                                    $postPath
= '';
                                
}
                
include_once($path.'libraries/'.$postPath.$class.EXT);
                return
$this->_ci_init_class($class, '', $params);
            
}
        }
        
        
// If we got this far we were unable to find the requested class
        
log_message('error', "Unable to load the requested class: ".$class);
        
show_error("Unable to load the requested class: ".$class);
    
}

 

It will be very nice to do so if possible.

Thanks in advance whatever is done.

have a good day ... or night wink

 Signature 

Sylvain Gourvil
PHP Developer
French scuba divingMotivation and team building

Profile
 
 
Posted: 16 November 2006 02:04 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  7
Joined  09-26-2006

You’re not the only one indeed !
This feature should really be included in CI next version.
Thanks for sharing your code smile

Profile
 
 
Posted: 26 November 2006 10:53 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  157
Joined  05-19-2006

I agree,
rapyd library, and other contributions, would be easy to install..  (just a drop a folder)

 Signature 

rapyd framework

Profile
 
 
   
 
 
‹‹ CI 1.5 - init files      CI_Input ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120447 Total Logged-in Users: 29
Total Topics: 126531 Total Anonymous Users: 3
Total Replies: 665334 Total Guests: 367
Total Posts: 791865    
Members ( View Memberlist )