| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Misha v.3 21.06.2014 06:01 / 21.06.2014 08:35
на самом деле я обманул: на схеме evgine v.4 не указаны некоторые поля, т.к. они были добавлены только в v.5, но это случилось ещё в 2008 году, просто лень было обновлять описание.@findObjectByURI[sURI;hParams][...объявление локальных переменных...]
$hParams[^hash::create[$hParams]]
$hRewrite[^hash::create[]]
$bFound(false)
$result[
$.hRewrite[$hRewrite]
$.bFound(false)
$.sError[]
$.hOrigin[^hash::create[]]
$.hCurrent[^hash::create[]]
$.hLog[^hash::create[]]
]
$bContinue(true)
$iWatchDogCount(20)
$hRewrited[^hash::create[]]
^while($bContinue && $iWatchDogCount){
$bContinue(false)
$bFound(false)
$tVisible[^self.getObjectsByFullPath[^self.getParentsFullPaths[$sURI];$hParams]]
^if($tVisible){
^if(^tVisible.locate[full_path;$sURI]){
^rem{ *** object with specified URI exists *** }
$result.hCurrent[$tVisible.fields]
$bFound(true)
}{
^rem{ *** object with specified URI does not exist. check if engine's rewrites are used *** }
^tVisible.offset[set](-1)
$iTypeID($tVisible.child_handling_type_id)
^if($iTypeID){
^if($hRewrited.[$tVisible.id]){
$result.sError[Infinite recursion while processing rewrites is detected]
}{
$hRewrited.[$tVisible.id](true)
$hObject[$tVisible.fields]
$sOriginURI[$sURI]
$sTail[^sURI.mid(^hObject.full_path.length[])]
^if(!def $hRewrite.sTail){
^rem{ *** the 1st rewrite iteration *** }
$hRewrite.sTail[$sTail]
$result.hOrigin[$hObject]
}
^switch($iTypeID){
^case(1){
^rem{ *** handle nonexistent child by itself *** }
$hRewrite._[^sTail.trim[both;/]]
$result.hCurrent[$hObject]
$bFound(true)
}
^case(2){
^rem{ *** another object will handle nonexistent child => modify URL and search again *** }
^rem{ *** cut 1st 'subdir' *** }
$iPieceLength(^sTail.pos[/])
^if($iPieceLength>0){
$sPiece[^sTail.left($iPieceLength)]
$sTail[^sTail.mid($iPieceLength+1)]
}{
$sPiece[$sTail]
$sTail[]
}
$hHandler[^self.getObjectById($hObject.child_handler_object_id)]
^if($hHandler){
^if(^hRewrite.contains[$hHandler.path]){
^rem{ *** for simplicity don't allow to have 2 handlers with the same path *** }
$result.sError[Duplicate path while processing rewrites is found]
}{
$hRewrite.[$hHandler.path][$sPiece]
$sURI[${hHandler.full_path}$sTail]
$bContinue(true)
}
}{
$result.sError[Link to not existed handler ($hObject.child_handler_object_id) is found]
}
}
^case[DEFAULT]{
$result.sError[Unknown rewrite type ($iTypeID)]
}
}
$result.hLog.[^result.hLog._count[]][
$.sOriginURI[$sOriginURI]
$.iTypeID($iTypeID)
$.sURI[$sURI]
$.hRewrite[^hash::create[$hRewrite]]
]
}
}
}
}
^iWatchDogCount.dec[]
}
^if($iWatchDogCount==0){
$result.sError[Too many cycles while processing rewrites]
}
$result.bFound($bFound)
@getParentsFullPaths[sFullPath][sURI;tURI]
$result[^table::create{sUri
/}]
$sFullPath[^sFullPath.trim[both;/]]
^if(def $sFullPath){
$sURI[]
$tURI[^sFullPath.split[/][vl]]
^tURI.menu{
$sURI[$sURI/$tURI.piece]
^result.append{$sURI}
}
}
@getObjectsByFullPath[tFullPath;hParams]
$reault[^table::sql{
SELECT
...
FROM
object
WHERE
full_path IN (^if($tFullPath){^tFullPath.menu{'$tFullPath.sUri'}[,]}{''})
...
ORDER BY
full_path
}]
@getObjectById[iID]
$reault[^table::sql{
SELECT
...
FROM
object
WHERE
object_id = $iID
...
}]