| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Mizter Egoist 17.11.2015 11:12
Ранее уже спрашивал про Front Controller@path[params]
$path[^params.url.split[/;lh]]
$s[^get.getSections[]]
$_s[^s.hash[url]]
$h[^get.getHeadings[]]
$_h[^h.hash[url]]
$e[^get.getEntries[]]
$_e[^e.hash[link]]
$g[^get.getGoods[]]
$_g[^g.hash[link]]
^switch(true){
^case(def $_s.[$path.1] && def $_h.[$path.2] && def $_e.[$path.3]){
$response[true]
}
^case(def $_s.[$path.1] && def $_h.[$path.2] && def $_g.[$path.3]){
$response[true]
}
^case(def $_s.[$path.1] && def $_e.[$path.2]){
$response[true]
}
^case(def $_s.[$path.1] && def $_g.[$path.2]){
$response[true]
}
^case(def $_s.[$path.1] && def $_h.[$path.2]){
$response[true]
}
^case(def $_s.[$path.1]){
$response[true]
}
^case($request:uri eq '/'){
$response[true]
}
^case[DEFAULT]{
$response[false]
}
}В этой попытке у меня везде false, точнее Страница не найдена @path[params]
$path[^params.url.split[/;lh]]
$s[^get.getSections[]]
$_s[^s.hash[url]]
$h[^get.getHeadings[]]
$_h[^h.hash[url]]
$e[^get.getEntries[]]
$_e[^e.hash[link]]
$g[^get.getGoods[]]
$_g[^g.hash[link]]
^if($_s.[$path.1]){
$response[true]
^if($_h.[$path.2]){
$response[true]
^if($_e.[$path.3]){
$response[true]
}{
^if($_g.[$path.3]){
$response[true]
}{
$response[false]
}
}
}{
^if($_e.[$path.2]){
$response[true]
^if($_g.[$path.2]){
$response[true]
}{
$response[false]
}
}{
$response[false]
}
}
}{
$response[false]
}В этой попытке дальше /foo не идет, пишет false, точнее страница не найдена @path[params]
^if(def $params.url){
$section[^get.getSections[
$.url[$params.url]
]]
^if(def $section){$response[true]}{$response[false]}
^if(def $section && def $params.uri){
$heading[^get.getHeadings[
$.section_id($section.id)
$.url[$params.uri]
]]
^if(def $section && def $heading){$response[true]}{$response[false]}
^if(def $heading && def $params.pid){
$entry[^get.getEntries[
$.SID($section.id)
$.HID($heading.id)
$.link[$params.pid]
]]
^if(def $section && def $heading && def $entry){
$response[true]
}{
$goody[^get.getGoods[
$.SID($section.id)
$.HID($heading.id)
$.link[$params.pid]
]]
^if(def $section && def $heading && def $goody){$response[true]}{$response[false]}
}
}{
$entry[^get.getEntries[
$.SID($section.id)
$.link[$params.uri]
]]
^if(def $section && def $entry){
$response[true]
}{
$goody[^get.getGoods[
$.SID($section.id)
$.link[$params.uri]
]]
^if(def $section && def $goody){$response[true]}{$response[false]}
}
}
}
}Это вообще нерабочий кошмар @path_rules[link]
$parts[^link.uri.split[/;lh]]
^if($parts){
$s[^get.getSections[
$.url[$parts.1]
]]
$h[^get.getHeadings[
$.section_id($s.id)
$.url[$parts.2]
]]
$e[^get.getEntries[
$.SID($s.id)
$.HID($h.id)
$.link[^if($parts.3){${parts.3}}($parts.2){${parts.2}}{}]
]]
$g[^get.getGoods[
$.SID($s.id)
$.HID($h.id)
$.link[^if($parts.3){${parts.3}}($parts.2){${parts.2}}{}]
]]
^if(def $s && def $h && def $e){
$response[true]
}(def $s && def $h && def $g){
$response[true]
}(def $s && def $h){
$response[true]
}(def $s){
$response[true]
}{$response[false]}
}Вот обработка самой страницы @page_rules[]
^path[
$.url[$form:url]
$.uri[$form:uri]
$.pid[$form:pid]
]
^switch(true){
^case($get.auth.gID == 1 && $request:uri eq "/admin${address.1}"){
^admin.page[]
}
^case($get.auth.gID != 1 && $request:uri eq "/admin${address.1}"){
^error_404.page[]
}
^case[DEFAULT]{
^if($request:uri eq '/'){
^deafult.page[]
}($response eq 'true'){
^deafult.page[]
}{
^error_404.page[]
}
}
}