Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 rsolanki 1
<%
2
'=============================================================
3
'//
4
'//						Repeater
5
'//
6
'// version: 		1.0
7
'//	last modified: 	30-Jul-2004 08:58 by Sasha Vukovic
8
'=============================================================
9
%>
10
<%
11
Class Repeater
12
 
13
	'Private mobjAccessControl
14
 
15
	Private mTableName
16
	Private mRowId
17
	Private mEnabled
18
	Private mDisabled
19
	Private mControlObject
20
 
21
	Private mStartPosition
22
	Private mTotalRecords
23
	Private mLastRecord
24
	Private mNavigator
25
	Private MAX_ROWS
26
 
27
	Private objRs
28
	Private RS_NAME
29
 
30
 
31
	Public Property Let TableName ( sTableName )
32
		mTableName = sTableName
33
	End Property
34
 
35
	Public Property Let RowId ( sRowId )
36
		mRowId = sRowId
37
	End Property
38
 
39
	Public Property Let Row ( sRow )
40
		mEnabled = ConstructRow( sRow )
41
	End Property
42
 
43
	Public Property Let Enabled ( sEnabled )
44
		mEnabled = sEnabled
45
	End Property
46
 
47
	Public Property Let Disabled ( sDisabled )
48
		mDisabled = sDisabled
49
	End Property
50
 
51
	Public Property Let ControlObject ( sControlObject )
52
		mControlObject = sControlObject
53
	End Property
54
 
55
	Public Property Let MaxRows ( nMaxRows )
56
		MAX_ROWS = nMaxRows
57
	End Property
58
 
59
	Public Property Let RecordSet ( ByRef oRs )
60
		Set objRs = oRs
61
		Call InitialiseNavigator()
62
	End Property
63
 
64
	'-----------------------------------------------------------------------------------------------------------------
65
	Public Sub Render ( ByRef oAccessControl )
66
		'--- Exit if Control Object is not supplied ---
67
		If IsNull(mControlObject) Then
68
			Err.Raise 8, "Repeater requires Access Control object name before Render!", "" 
69
			Exit Sub
70
		End If
71
 
72
 
73
		' Access Control module supplied
74
 
75
		If oAccessControl.IsDataVisible ( mTableName, mRowId ) Then
76
 
77
			If oAccessControl.IsDataActive ( mTableName, mRowId, mControlObject ) Then
78
				Response.write mEnabled
79
 
80
			Else
81
				Response.write mDisabled  
82
 
83
			End If
84
 
85
		End If
86
 
87
	End Sub
88
	'-----------------------------------------------------------------------------------------------------------------
89
	Public Sub RenderDataGrid ()
90
		'--- Render rows ---
91
		Do While (NOT objRs.BOF) AND (NOT objRs.EOF)
92
			If objRs.RowPosition => (mStartPosition + MAX_ROWS) Then Exit Do	' Limit the number of rows displayed
93
 
94
			Response.write Eval( mEnabled )
95
 
96
			objRs.MoveNext
97
		Loop
98
 
99
	End Sub
100
	'-----------------------------------------------------------------------------------------------------------------
101
	Public Sub Navigator ( bResults, bNavigator )
102
		'== Definition ==
103
		Dim sResults, sNavigator
104
 
105
 
106
		'-- Create Results String
107
		sResults = ""
108
		If bResults Then
109
			If mTotalRecords > 0 Then 
110
				sResults = "Showing "& mStartPosition &" - "& mLastRecord &" of "& mTotalRecords
111
			Else
112
				sResults = "No Results."
113
			End If
114
		End If
115
 
116
 
117
		'-- Create Navigator String
118
		sNavigator = ""
119
		If bNavigator Then
120
			sNavigator = mNavigator
121
		End If
122
 
123
 
124
		'-- Display Navigator
125
		Response.write _
126
	    "<table width='100%'  border='0' cellspacing='5' cellpadding='0'>"&_
127
        "  <tr>"&_
128
        "    <td align='left' class='body_row'>"& sResults &"</td>"&_
129
        "    <td align='right' class='body_scol'>"& sNavigator &"</td>"&_
130
        "  </tr>"&_
131
        "</table>"
132
 
133
 
134
	End Sub
135
	'-----------------------------------------------------------------------------------------------------------------\
136
	Private Sub InitialiseNavigator ()
137
		Dim pageNumber
138
 
139
 
140
		'--- Get page number ---
141
		pageNumber = 0
142
		If Request("reppg") <> "" Then 
143
		pageNumber = CInt(Request("reppg"))
144
		End If
145
 
146
 
147
		'--- Set Cursor start position ---
148
		mStartPosition = pageNumber * MAX_ROWS + 1
149
		If (NOT objRs.BOF) AND (NOT objRs.EOF) Then
150
			objRs.MoveTo ( mStartPosition )		' Set starting cursor point
151
 
152
		End If
153
 
154
 
155
		'--- Construct mNavigator
156
		mNavigator = ""
157
		If (NOT objRs.BOF) AND (NOT objRs.EOF) Then
158
			mTotalRecords = objRs.RecordCount	' Get total number of records
159
 
160
			'--- Create "Previous" link
161
			If pageNumber > 0 Then
162
				mNavigator = mNavigator &"<a href='"& SCRIPT_NAME &"?reppg="& pageNumber - 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Previous Page'>&laquo; Previous</a>"
163
			End If
164
 
165
			'--- Create "Next" link
166
			If ( mStartPosition + MAX_ROWS ) <= mTotalRecords Then
167
				mNavigator = mNavigator &"&nbsp;&nbsp;<a href='"& SCRIPT_NAME &"?reppg="& pageNumber + 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Next Page'>Next &raquo;</a>"
168
			End If
169
 
170
		End If
171
 
172
 
173
		'--- Calculate Last Record ---
174
		If mTotalRecords > 0 Then
175
			mLastRecord = ( mStartPosition - 1 + MAX_ROWS ) _
176
						+ ( CInt( ( mStartPosition - 1 + MAX_ROWS )/mTotalRecords > 1) ) * ( ( mStartPosition - 1 + MAX_ROWS ) - mTotalRecords )
177
		End If
178
 
179
 
180
	End Sub
181
	'-----------------------------------------------------------------------------------------------------------------
182
	Private Function ConstructRow ( sRow )
183
		Dim tempSTR
184
 
185
		tempSTR = sRow
186
		tempSTR = Replace (tempSTR, "<#", " objRs(""" )
187
		tempSTR = Replace (tempSTR, "#>", """) " )
188
 
189
		ConstructRow = """"& tempSTR &""""
190
	End Function
191
	'-----------------------------------------------------------------------------------------------------------------
192
	Private Sub Class_Initialize()
193
		'// Perform action on creation of object. e.g. Set myObj = New ThisClassName
194
		mControlObject = NULL
195
		MAX_ROWS = 50	' Max rows rendered
196
		RS_NAME = "objRs"	' Variable Name of the record set in this class
197
 
198
	End Sub
199
	'-----------------------------------------------------------------------------------------------------------------
200
	Private Sub Class_Terminate()
201
		'// Perform action on object disposal. e.g. Set myObj = Nothing
202
		Set objRs = Nothing ' Record set object
203
 
204
	End Sub
205
	'-----------------------------------------------------------------------------------------------------------------
206
End Class
207
%>