Beispiel #1
0
 /**
  * Compile the config route to regex match
  *
  * @param string $route
  * @return array regex
  */
 private static function compile_route($route)
 {
     self::$compile_tokens = array();
     // internel call back function for regex replacement
     if (!function_exists('_callback')) {
         function _callback($match)
         {
             mfRoute::$compile_tokens[] = $match[1];
             //var_dump(Router::$compile_tokens);echo "<br />";
             return "([a-zA-Z0-9\\-_%]+)";
         }
     }
     $compile_tokens = array();
     // Strip regex chars: / + ? . and _ -
     $reg_strip_parten = "/([\\/\\._-])/";
     $reg_strip_repalce = '\\\\$1';
     // replace with \(regex char)
     $route = preg_replace($reg_strip_parten, $reg_strip_repalce, $route);
     // FIXME more characters should allowed in match parten
     $route = preg_replace_callback("/:([a-zA-Z0-9\\-_%]+)/", '_callback', $route);
     $route = "/^{$route}\$/";
     // add regex slash
     //		echo $route . "<br />";
     return array($route, self::$compile_tokens);
 }