Subversion Repositories DevTools

Rev

Rev 13 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%
'=============================================================
'//
'//                                     PersistanceModule
'//
'// version:            2.0
'//     last modified:  24-Aug-2004 10:16 by Sasha Vukovic
'=============================================================
%>
<%
Class PersistanceModule
        
        Private mobjURL
        Private mbReCompose                     ' Used in Compose() to increase performance.
                                                                ' When mbReCompose = FALSE, msCompose will already contain composed URL
        Private msCompose
        
        
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub PersistInQryString ( ParNames )
                Dim param
                
                If IsArray( ParNames ) Then
                        For Each param In ParNames
                                Call SinglePersistInQryString ( param )
                        Next
                        
                Else
                        Call SinglePersistInQryString ( ParNames )
                        
                End If
                
                mbReCompose = TRUE
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub PersistInQryStringWithValue ( sParName, sVal )
                mobjURL.Item ( CStr(sParName) ) = sVal
                
                mbReCompose = TRUE
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub SinglePersistInQryString ( sParName )
                If mobjURL.Exists ( CStr(sParName) ) Then
                        mobjURL.Item ( CStr(sParName) ) = Request( sParName )
                        
                Else
                        mobjURL.Add ( CStr(sParName) ), Request( sParName )
                        
                End If
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub PersistInCookie ( sParName )
                If Request( sParName ) <> "" Then
                        Response.Cookies( enumCOOKIE_NAME )( sParName ) = Request( sParName )
                End If
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub StoreParameter ( sParName, sParVal )
                If mobjURL.Exists ( CStr(sParName) ) Then
                        mobjURL.Item ( CStr(sParName) ) = sParVal
                        
                Else
                        mobjURL.Add ( CStr(sParName) ), sParVal
                        
                End If
                
                mbReCompose = TRUE
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Function ComposeURL ()
                Dim arrParNames, ParName, tempSTR
                
                If mbReCompose Then
                        arrParNames = mobjURL.Keys
                        
                        For Each ParName In arrParNames
                                If mobjURL.Item( ParName ) <> "" Then
                                        tempSTR = tempSTR & ParName &"="& mobjURL.Item( ParName ) &"&"
                                End If
                        Next
                        If Right( tempSTR, 1 ) = "&" Then tempSTR = Left ( tempSTR, Len( tempSTR ) - 1 )                ' Remove last &
                        
                        msCompose = tempSTR
                        ComposeURL = tempSTR
                        
                        mbReCompose = FALSE
                Else
                        ComposeURL = msCompose
                        
                End If
                
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Public Function ComposeHiddenTags ()
                Dim arrParNames, ParName, tempSTR
                
                arrParNames = mobjURL.Keys
                
                For Each ParName In arrParNames
                        If mobjURL.Item( ParName ) <> "" Then
                                tempSTR = tempSTR & "<input type='hidden' name='"& ParName &"' value='"& mobjURL.Item( ParName ) &"'>" & VBNewLine
                        End If
                Next
                
                ComposeHiddenTags = tempSTR
                
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Public Function ComposeHiddenTagsWithout ( sWithout )
                Dim arrParNames, ParName, tempSTR, objWithout, tempArr, fieldname
                Set objWithout = CreateObject("Scripting.Dictionary")
                
                tempArr = Split( sWithout, "," )
                
                For Each fieldname In tempArr
                        objWithout.Item (fieldname) = fieldname
                Next
                
                arrParNames = mobjURL.Keys
                
                For Each ParName In arrParNames
                        If (mobjURL.Item( ParName ) <> "") AND ( NOT objWithout.Exists ( ParName ) ) Then
                                tempSTR = tempSTR & "<input type='hidden' name='"& ParName &"' value='"& mobjURL.Item( ParName ) &"'>" & VBNewLine
                        End If
                Next
                
                ComposeHiddenTagsWithout = tempSTR
                
                Set objWithout = Nothing
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Public Function ComposeURLWith ( sParamList )
                Dim arrParNames, ParName, tempSTR
                
                arrParNames = Split( sParamList, "," )
                
                For Each ParName In arrParNames
                        If mobjURL.Item( ParName ) <> "" Then
                                
                                tempSTR = tempSTR & ParName &"="& mobjURL.Item( ParName ) &"&"
                        End If
                Next
                If Right( tempSTR, 1 ) = "&" Then tempSTR = Left ( tempSTR, Len( tempSTR ) - 1 )                ' Remove last &
                
                ComposeURLWith = tempSTR
                
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Public Function ComposeURLWithout ( ByVal sParamList )
                Dim arrParNames, ParName, tempSTR
                sParamList = ","& sParamList &","
                arrParNames = mobjURL.Keys
                
                For Each ParName In arrParNames
                        If mobjURL.Item( ParName ) <> "" AND ( InStr( sParamList, ","& ParName &"," ) < 1 ) Then
                                
                                tempSTR =  tempSTR &"&"& ParName &"="& mobjURL.Item( ParName ) 
                        End If
                Next
                'If Left( tempSTR, 1 ) = "&" Then tempSTR = Right ( tempSTR, Len( tempSTR ) - 1 )               ' Remove first &
                
                ComposeURLWithout = tempSTR
                
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub Class_Initialize()
                Set mobjURL = CreateObject("Scripting.Dictionary")
                mbReCompose = TRUE
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub Class_Terminate()
                Set mobjURL = Nothing
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
End Class
%>