Last active
August 29, 2015 14:00
-
-
Save ivanchuryumov/7d47cbd09349d6f7f1cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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