Subversion Repositories DevTools

Rev

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

<%
'=============================================================
'//
'//                                     PersistanceModule
'//
'// version:            2.0
'//     last modified:  29-Apr-2004 14:19 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
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub SinglePersistInQryString ( sParName )
                If Request( sParName ) <> "" Then
                        mobjURL.Item ( CStr(sParName) ) = Request( sParName )
                End If

        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub PersistInCookie ( sParName )
                If Request( sParName ) <> "" Then
                        Response.Cookies( COOKIE_NAME )( sParName ) = Request( sParName )
                End If

        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub StoreParameter ( sParName, sParVal )
                mobjURL.Item ( CStr(sParName) ) = sParVal

                mbReCompose = TRUE
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Function GetParamValue ( sParName )
                GetParamValue = mobjURL.Item ( CStr(sParName) )
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        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
%>