PHP on T R A X
Rapid Application Development Made Easy
Show
Ignore:
Timestamp:
03/13/06 21:10:15 (4 years ago)
Author:
haas
Message:

ActionController? doc done

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/trax/vendor/trax/router.php

    r162 r174  
    106106     *  empty string, it matches a path that is an empty string. 
    107107     *  Otherwise, try to match $url to the path part of the table 
    108      *  entry according to {@link http://www.php.net/manual/en/ref.pcre.php Perl regular expression} 
    109      *  rules.  Return the first matching route to the caller, and 
    110      *  also save a copy in {@link $selected_route}. 
     108     *  entry according to 
     109     *  {@link http://www.php.net/manual/en/ref.pcre.php Perl regular expression} 
     110     *  rules.  If a matching route is found, return it any to the caller, and 
     111     *  also save a copy in {@link $selected_route}; if no matching 
     112     *  route is found return null. 
    111113     *  @param string $url 
    112114     *  @uses build_route_regexp() 
     
    115117     *  @uses $routes_count 
    116118     *  @uses $selected_route 
    117      *  @return string[] Selected route. Path is in return['path'], 
     119     *  @return mixed Matching route or null. Path is in return['path'], 
    118120     *                   params in return['params'], 
    119121     */ 
    120122    function find_route($url) { 
     123        //error_log('url='.$url); 
    121124        // ensure at least one route (the default route) exists 
    122125        if($this->routes_count == 0) { 
     
    130133            unset($reg_exp); 
    131134            $route_regexp = $this->build_route_regexp($route['path']); 
     135            //error_log("route regexp=/$route_regexp/"); 
    132136            if($url == "" && $route_regexp == "") { 
     137                //error_log('selected'); 
    133138                $this->selected_route = $route; 
    134139                break; 
    135140            } elseif(preg_match("/$route_regexp/",$url) && $route_regexp != "") { 
     141                //error_log('selected'); 
    136142                $this->selected_route = $route; 
    137143                break; 
    138144            } elseif($route['path'] == $this->default_route_path) { 
     145                //error_log('defaulted'); 
    139146                $this->selected_route = $route; 
    140147                break; 
    141148            } 
    142149        } 
    143  
     150        //error_log('selected route='.var_export($this->selected_route,true)); 
    144151        return $this->selected_route; 
    145152    }                                 // function find_route($url) 
     
    148155     *  Build a regular expression that matches a route 
    149156     * 
    150      *  <b>FIXME:</b> Should this method be private? 
     157     *  @todo <b>FIXME:</b> Should this method be private? 
     158     *  @todo <b>FIXME:</b> Shouldn't the regexp match be the same as 
     159     *  for a PHP variable name? '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' 
    151160     *  @param string $route_path  A route path. 
    152161     *  @return string Regular expression that matches the route in 
     
    161170            $route_path = explode("/",$route_path); 
    162171        } 
    163         //        echo "route path:\n"; 
    164         //        var_dump($route_path); 
     172        //error_log("route path:\n".var_export($route_path,true)); 
    165173        if(count($route_path) > 0) { 
    166174            foreach($route_path as $path_element) { 
     
    175183            } 
    176184        } 
    177  
    178185        return $route_regexp; 
    179186    }