Subversion Repositories DevTools

Rev

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

<%
'=============================================================
'//
'//                                             Repeater
'//
'// version:            1.1
'//     last modified:  09-May-2004 03:03 by Sasha Vukovic
'=============================================================
%>
<%
Class Repeater
        
        'Private mobjAccessControl
        
        Private mTableName
        Private mRowId
        Private mEnabled
        Private mDisabled
        Private mControlObject
        
        Private mStartPosition
        Private mTotalRecords
        Private mLastRecord
        Private mNavigator
        Private MAX_ROWS
        
        Private objRs
        Private RS_NAME
        
        
        Public Property Let TableName ( sTableName )
                mTableName = sTableName
        End Property
        
        Public Property Let RowId ( sRowId )
                mRowId = sRowId
        End Property
        
        Public Property Let Row ( sRow )
                mEnabled = ConstructRow( sRow )
        End Property
        
        Public Property Let Enabled ( sEnabled )
                mEnabled = sEnabled
        End Property
        
        Public Property Let Disabled ( sDisabled )
                mDisabled = sDisabled
        End Property
        
        Public Property Let ControlObject ( sControlObject )
                mControlObject = sControlObject
        End Property
        
        Public Property Let MaxRows ( nMaxRows )
                MAX_ROWS = nMaxRows
        End Property
        
        Public Property Let RecordSet ( ByRef oRs )
                Set objRs = oRs
                Call InitialiseNavigator()
        End Property
        
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub Render ( ByRef oAccessControl )
                '--- Exit if Control Object is not supplied ---
                If IsNull(mControlObject) Then
                        Err.Raise 8, "Repeater requires Access Control object name before Render!", "" 
                        Exit Sub
                End If
                
                
                ' Access Control module supplied
                
                If oAccessControl.IsDataVisible ( mTableName, mRowId, mControlObject ) Then
                        
                        If oAccessControl.IsDataActive ( mTableName, mRowId, mControlObject ) Then
                                Response.write mEnabled
                                
                        Else
                                Response.write mDisabled  
                                
                        End If
                        
                End If
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub RenderDataGrid ()
                '--- Render rows ---
                Do While (NOT objRs.BOF) AND (NOT objRs.EOF)
                        If objRs.RowPosition => (mStartPosition + MAX_ROWS) Then Exit Do        ' Limit the number of rows displayed
                        
                        Response.write Eval( mEnabled )
                        
                        objRs.MoveNext
                Loop
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Public Sub Navigator ( bResults, bNavigator )
                '== Definition ==
                Dim sResults, sNavigator
                
                
                '-- Create Results String
                sResults = ""
                If bResults Then
                        If mTotalRecords > 0 Then 
                                sResults = "Showing "& mStartPosition &" - "& mLastRecord &" of "& mTotalRecords
                        Else
                                sResults = "No Results."
                        End If
                End If
                
                
                '-- Create Navigator String
                sNavigator = ""
                If bNavigator Then
                        sNavigator = mNavigator
                End If
                
                
                '-- Display Navigator
                Response.write _
            "<table width='100%'  border='0' cellspacing='5' cellpadding='0'>"&_
        "  <tr>"&_
        "    <td align='left' class='body_row'>"& sResults &"</td>"&_
        "    <td align='right' class='body_scol'>"& sNavigator &"</td>"&_
        "  </tr>"&_
        "</table>"
                
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------\
        Private Sub InitialiseNavigator ()
                Dim pageNumber
                
                
                '--- Get page number ---
                pageNumber = 0
                If Request("reppg") <> "" Then 
                pageNumber = CInt(Request("reppg"))
                End If
                
                
                '--- Set Cursor start position ---
                mStartPosition = pageNumber * MAX_ROWS + 1
                If (NOT objRs.BOF) AND (NOT objRs.EOF) Then
                        objRs.MoveTo ( mStartPosition )         ' Set starting cursor point
                        
                End If
                
                
                '--- Construct mNavigator
                mNavigator = ""
                If (NOT objRs.BOF) AND (NOT objRs.EOF) Then
                        mTotalRecords = objRs.RecordCount       ' Get total number of records
                        
                        '--- Create "Previous" link
                        If pageNumber > 0 Then
                                mNavigator = mNavigator &"<a href='"& SCRIPT_NAME &"?reppg="& pageNumber - 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Previous Page'>&laquo; Previous</a>"
                        End If
                        
                        '--- Create "Next" link
                        If ( mStartPosition + MAX_ROWS ) <= mTotalRecords Then
                                mNavigator = mNavigator &"&nbsp;&nbsp;<a href='"& SCRIPT_NAME &"?reppg="& pageNumber + 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Next Page'>Next &raquo;</a>"
                        End If
                        
                End If
                
                
                '--- Calculate Last Record ---
                If mTotalRecords > 0 Then
                        mLastRecord = ( mStartPosition - 1 + MAX_ROWS ) _
                                                + ( CInt( ( mStartPosition - 1 + MAX_ROWS )/mTotalRecords > 1) ) * ( ( mStartPosition - 1 + MAX_ROWS ) - mTotalRecords )
                End If
                
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Private Function ConstructRow ( sRow )
                Dim tempSTR
                
                tempSTR = sRow
                tempSTR = Replace (tempSTR, "<#", " objRs(""" )
                tempSTR = Replace (tempSTR, "#>", """) " )
                
                ConstructRow = """"& tempSTR &""""
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub Class_Initialize()
                '// Perform action on creation of object. e.g. Set myObj = New ThisClassName
                mControlObject = NULL
                MAX_ROWS = 50   ' Max rows rendered
                RS_NAME = "objRs"       ' Variable Name of the record set in this class
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub Class_Terminate()
                '// Perform action on object disposal. e.g. Set myObj = Nothing
                Set objRs = Nothing ' Record set object
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
End Class
%>