Skip to content

Instantly share code, notes, and snippets.

@ivanchuryumov
Last active August 29, 2015 14:00
Show Gist options
  • Save ivanchuryumov/7d47cbd09349d6f7f1cf to your computer and use it in GitHub Desktop.
Save ivanchuryumov/7d47cbd09349d6f7f1cf to your computer and use it in GitHub Desktop.
<?
function ParsePath($node)
{
if(is_string($node))
{
$action = 'default';
$node = str_replace('//', '%2F', $node); // спасибо апачу (при использовании %2F в урле выдает 404)
$t = explode('/', $node);
$id = 0;
while(count($t) > 0)
{
$e = urldecode(array_shift($t));
if(strlen($e) == 0)
continue;
if(strpos($e, '.') === 0)
break;
$tid = STreeMgr::GetSectionIDForParent($id, $e);
if(empty($tid))
break;
$id = $tid;
}
if(strpos($e, '.') === 0)
$action = substr($e, 1);
$path = implode('/', $t);
return array(
'section' => $id,
'action' => $action,
'path' => $path);
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment