Changeset 2889

Show
Ignore:
Timestamp:
06/24/08 10:18:12 (3 months ago)
Author:
Shadowhand
Message:

Fixing controllers in sub-dirs, hopefully

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Router.php

    r2888 r2889  
    9292                        $controller_path .= $segment; 
    9393 
    94                         if ($path = Kohana::find_file('controllers', $controller_path, FALSE)) 
    95                         { 
    96                                 // Set controller name 
    97                                 self::$controller = $segment; 
    98  
    99                                 // Change controller path 
    100                                 self::$controller_path = $path; 
    101                         } 
    102                         else 
    103                         { 
    104                                 // Stop searching 
     94                        $found = FALSE; 
     95                        foreach (Config::include_paths() as $dir) 
     96                        { 
     97                                // Search within controllers only 
     98                                $dir .= 'controllers/'; 
     99 
     100                                if (file_exists($dir.$controller_path) OR file_exists($dir.$controller_path.EXT)) 
     101                                { 
     102                                        // Valid path 
     103                                        $found = TRUE; 
     104 
     105                                        if (is_file($dir.$controller_path.EXT)) 
     106                                        { 
     107                                                // Set controller name 
     108                                                self::$controller = $segment; 
     109 
     110                                                // Change controller path 
     111                                                self::$controller_path = $dir.$controller_path.EXT; 
     112                                        } 
     113 
     114                                        // Skip remaining controller paths 
     115                                        continue; 
     116                                } 
     117                        } 
     118 
     119                        if ($found === FALSE) 
     120                        { 
     121                                // Stop searching, nothing was found 
    105122                                break; 
    106123                        } 
     
    110127                } 
    111128 
    112                  
    113129                if (self::$controller !== NULL AND isset(self::$rsegments[$key])) 
    114130                { 
    115131                        // Set method 
    116                         self::$method = isset(self::$rsegments[1]) ? self::$rsegments[1] : 'index';  
     132                        self::$method = self::$rsegments[$key]; 
    117133 
    118134                        if (isset(self::$rsegments[$key + 1])) 
     
    122138                        } 
    123139                } 
    124                  
     140 
    125141                // Last chance to set routing before a 404 is triggered 
    126142                Event::run('system.post_routing');