public static function parse($url = null)
{
$here = self::normalize(is_null($url) ? self::here() : $url);
$url = self::getRoute($here);
$prefixes = join('|', self::prefixes());
$path = array();
$parts = array('here', 'prefix', 'controller', 'action', 'extension', 'params', 'queryString');
preg_match('/^\\/(?:(' . $prefixes . ')(?:\\/|(?!\\w)))?(?:([a-z_-]*)\\/?)?(?:([a-z_-]*)\\/?)?(?:\\.([\\w]+))?(?:\\/?([^?]+))?(?:\\?(.*))?/i', $url, $reg);
foreach ($parts as $k => $key) {
$path[$key] = isset($reg[$k]) ? $reg[$k] : null;
}
$path['named'] = $path['params'] = array();
if (isset($reg[5])) {
foreach (explode('/', $reg[5]) as $param) {
if (preg_match('/([^:]*):([^:]*)/', $param, $reg)) {
$path['named'][$reg[1]] = urldecode($reg[2]);
} else {
if ($param != '') {
$path['params'][] = urldecode($param);
}
}
}
}
$path['here'] = $here;
if (empty($path['controller'])) {
$path['controller'] = self::root();
}
if (empty($path['action'])) {
$path['action'] = 'index';
}
if ($filtered = self::filterAction($path['action'])) {
$path['prefix'] = $filtered['prefix'];
$path['action'] = $filtered['action'];
}
if (!empty($path['prefix'])) {
$path['action'] = $path['prefix'] . '_' . $path['action'];
}
if (empty($path['id'])) {
$path['id'] = null;
}
if (empty($path['extension'])) {
$path['extension'] = 'htm';
}
if (!empty($path['queryString'])) {
parse_str($path['queryString'], $queryString);
$path['named'] = array_merge($path['named'], $queryString);
}
return $path;
}