| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
agat 29.08.2007 16:01 / 29.08.2007 16:06
вам передается $request:query и $request:uri. Обычным сплитом разобрали строки, посмотрели что от нас хотят. Если хотят в том порядке, в котором мы можем отдать - отдаем страничку с переданными в нее параметрами. Если порядок не такой, какой мы ждем - 404.################################################
@main[][result]
^if(^request:uri.match[process\.html]){
^Lib:location[/404/]
}{
^Request:process[]
}
# end of @main[]Request.p @CLASS
Request
################################################
@auto[][sUri;tUri;sClearPath]
$sQuery[$request:query]
$sUri[$request:uri]
$tUri[^sUri.split[?;lh]]
$sPath[$tUri.0]
$sClearPath[^sPath.trim[both;/]]
$tBasePath[^sClearPath.split[/]]
^if($tBasePath.piece eq "ru" || $tBasePath.piece eq "en" || $tBasePath.piece eq "tr"){
$sLanguage[$tBasePath.piece]
}
^if(def $sLanguage){
$tPath[^tBasePath.select(^tBasePath.line[] > 1)]
$sPath[/^if($tPath){^tPath.menu{$tPath.piece/}}]
}{
$tPath[$tBasePath]
}
^tPath.offset(-1)
^if(^tPath.piece.int(0)){
$iScrollerPage(^tPath.piece.int(0))
$tPath[^tPath.select(^tPath.line[] < ^tPath.count[])]
$sPath[/^if($tPath){^tPath.menu{$tPath.piece/}}]
}{
^tPath.offset[set](0)
}
# end of @auto[]
################################################
@makePath[hParams]
$result[^makeUri[
$.targetUrl[^if(def $hParams.sLanguage){/$hParams.sLanguage}/^tPath.menu{$tPath.piece/}^if($iScrollerPage && $iScrollerPage != $hParams.iScrollerPage){$iScrollerPage/}]
$.hExclude[
$.groupUri[]
$.itemID[]
]
]]
# end of @makePath[]
################################################
@process[][bFound;sGroupUri;iItemID]
$bFound(0)
^if(-f $sPath || -d $sPath){
$bFound(1)
^Lib:location[$sPath^makeUri[]]
}{
^if($tPath){
^if($tPath.piece eq "item"){
$iItemID($iScrollerPage)
^if($iItemID){
$bFound(1)
^Lib:location[/?itemID=$iItemID]
}
}{
^tPath.menu{
$sGroupUri[$tPath.piece]
}
^if(def $sGroupUri){
$bFound(1)
^Lib:location[/?groupUri=$sGroupUri]
}
}
}
}
^if(!$bFound){
^Lib:location[/404/]
}
# end of @process[]
################################################
@makeUri[hParams][hFields]
$hParams[^hash::create[$hParams]]
$hFields[$hParams]
$hFields[^hFields.union[$form:tables]]
$hFields[^hFields.union[$form:fields]]
^if(def $hParams.hExclude && $hParams.hExclude is "hash"){
^hFields.sub[$hParams.hExclude]
^hFields.sub[$.hExclude[]]
}
$sTarget[$hParams.targetUrl]
^hFields.sub[$.targetUrl[]]
$result[$sTarget^if($hFields){?^hFields.foreach[sField;uValue]{^if($uValue is "table"){^uValue.menu{$sField=^taint[uri][$uValue.field]}[&]}{$sField=^taint[uri][^if($uValue is "file"){^getNameFromFile[$uValue]}{$uValue}]}}[&]}]
# end of @makeUri[]Объяснять не стану - думаю разберетесь. Код не идеален, т.к. сам только учусь использовать данный подход. Но на текущем проекте он работает идельно. Пока багов не нашел.