Exemple #1
0
 private static function advanced()
 {
     self::$rout_types = get_config_item('route_types');
     $matches = [];
     $url_parts = explode('/', self::$url);
     $url_count = count($url_parts);
     foreach (self::$routes as $key => $value) {
         $key_parts = explode('/', $key);
         $key_count = count($key_parts);
         if ($key_count == $url_count) {
             for ($i = 0; $i < $key_count; $i++) {
                 if (array_key_exists($key_parts[$i], self::$rout_types)) {
                     if (preg_match(self::$rout_types[$key_parts[$i]], $url_parts[$i])) {
                         $matches[] = $url_parts[$i];
                     } else {
                         exit('Not defined rout type check your app/config/config' . EXT . ' $config["route_types"] content');
                     }
                 } else {
                     exit('Not allowed character (s) in url');
                 }
             }
             if (is_callable($value)) {
                 $value = $value();
             }
             $value_parts = explode('/', $value);
             $val_count = count($value_parts);
             $rout_result = $value_parts[0] . '/' . $value_parts[1];
             for ($j = 2; $j < $val_count; $j++) {
                 $cur_param = str_replace('$', '', $value_parts[$j]);
                 $rout_result .= '/' . $matches[$cur_param - 1];
             }
             self::explode_rout($rout_result);
             break;
         }
     }
     return false;
 }