<!-- #include virtual="/NR/System/WBC/Internals/Main/WBCApp.inc"-->

<!-- #include virtual="/NR/System/WBC/Internals/ServerControls/GridControl/CNCGridControl.inc"-->
<!-- #include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingControl.inc"-->
<!-- #include virtual="/NR/System/WBC/Internals/ServerControls/PagingConfigControl/CNCPagingConfigControl.inc"-->

<!-- #include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingRenderer_Common.inc"-->
<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/RevisionHistory/CNCGridDecorator_PageRevision.inc"-->

<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/Common/PageRevisionServer.inc"-->
<!-- #include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/PageRevisionUIStrings.inc" -->
<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/Common/ProgrammingConstants.inc"-->


<%
' ********************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
'	IMPORTANT.  Please read the legal.txt file, located in the
'	"<CMS Install Directory>\Server\httpexec\WBC\Internals"
'	directory, governing the use of this internal file."
' ********************************************************************

' ********************************************************************
' File:		/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/
'			Page/RevisionHistory/CNCASPPageManager_PageRevisionHistory.asp
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
' Purpose:	Encapsulate the ASP logic associated with PageRevisionDlg.asp
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'
' Exposes the following properties:
'	- Property CurrentPage
'	- Property PageRevisionReportURL
'	- Property RevisionPages
'	- Property GridStartItem
'	- Property GridEndItem
'	- Property GridPagingConfigControl
'	- Property GridControl
'	- Property GridPagingControl
' ********************************************************************

Class CNCASPPageManager_PageRevision

	' -- Objects for current Page
	Public CurrentPage

	' -- Objects needed for "List view"
	Public RevisionPages
	Public PageRevisionReportURL
	Public GridStartItem
	Public GridEndItem
	Public GridPagingConfigControl
	Public GridControl
	Public GridPagingControl

	Private m_bCauseByPage

	' ---- [Private] Standard Class_Initialize
	Private Sub Class_Initialize()
		' -- some default values
		m_bCauseByPage = True
	End Sub

	' ---- [Public] InitManaer will take care of all programming logic in the ASP page
	Public Sub InitManager()

		' -- Set up Page and Page configure control to control the list view of the Page Revision
		Call SetupCurrentPage()
		Call SetupPageRevisionReportURL()
		Call SetupPageRevisionCollection()
		Call SetupPagingConfigControl()
		Call SetupPagingControl()
		Call SetupDisplayIndices()
		Call SetupGridControl()
	End Sub

	' ---- [Public] Get the Page Filter or not
	Public Property Get StateCauseByPage()
		StateCauseByPage = m_bCauseByPage
	End Property

	' ---- [Private] Sets up the current Page
	Private Sub SetupCurrentPage()
		Set CurrentPage = AutoSession.ThisPosting
	End Sub

	' ---- [Private] Sets up the Page Revision Report URL
	Private Sub SetupPageRevisionReportURL()
		PageRevisionReportURL = IDS_PAGEREVISION_DLG_URL & CurrentPage.QueryString
	End Sub

	' ---- [Private] Sets up the RevisionPages collection
	Private Sub SetupPageRevisionCollection()
		Dim nFilterState
		Dim bPageChk
		Dim bResourceChk

		' initial the filtering flags
		bPageChk = m_bCauseByPage
		bResourceChk = False
		nFilterState = -1

		' get the current state
		If (Request.QueryString( IDS_QSTR_FILTER_STATE ) <> "") Then
			nFilterState = Request.QueryString( IDS_QSTR_FILTER_STATE )
		End If

		' update the filtering flags base on current state
		If (nFilterState > -1) Then
			bPageChk = ((CInt(nFilterState) And CInt(IDS_CHK_POSTING)) = CInt(IDS_CHK_POSTING))
			bResourceChk = ((CInt(nFilterState) And CInt(IDS_CHK_RESOURCE)) = CInt(IDS_CHK_RESOURCE))
		End If

		m_bCauseByPage = bPageChk
		
		' Note that we are not requesting revisions caused by changes to the Template
		' or Template Resources because this is no longer supported in CMS 2002.
		Set RevisionPages = AutoSession.ThisPosting.Revisions( bPageChk, bResourceChk, False, False )
	End Sub

	' ---- [Private] Sets up GridPagingConfigControl
	Private Sub SetupPagingConfigControl()
		Set GridPagingConfigControl = New CNCPagingConfigControl

		Call GridPagingConfigControl.InitPagingConfigControl( IDS_PAGINGCONFIG_INSTANCE_ID, 5, false )
	End Sub

	' ---- [Private] Set up the GridPagingControl, with input from the GridPagingConfigControl
	Private Sub SetupPagingControl()
		Set GridPagingControl = New CNCPagingControl

		Dim pNCPagingRenderer
		Set pNCPagingRenderer = New CNCPagingRenderer_Common

		Call GridPagingControl.InitPagingControl( pNCPagingRenderer, RevisionPages.Count, GridPagingConfigControl.ItemsPerPage )
		If (GridPagingConfigControl.IsSetNewValue = True) Then
			' PagingConfigControl has just been set a new value, set PagingControl back to Page 1
			GridPagingControl.CurrentPage = 1
		End If

	End Sub

	' ---- [Private] Set up indices which indicate the range of items to be displayed in the Grid
	Private Sub SetupDisplayIndices()

		' -- set the start item
		If (RevisionPages.Count = 0) Then
			GridStartItem = 0
		Else
			GridStartItem = (GridPagingControl.CurrentPage - 1)*(GridPagingConfigControl.ItemsPerPage) + 1
		End If

		' -- set the end item
		If (GridPagingConfigControl.ItemsPerPage < 0) Then
			' -- a minus one value from PagingConfigControl means "All" case
			GridEndItem = RevisionPages.Count
		Else
			GridEndItem = GridPagingControl.CurrentPage * GridPagingConfigControl.ItemsPerPage
		End If
		GridEndItem = Min(RevisionPages.Count, GridEndItem)
	End Sub

	' ---- [Private] Set up Grid control to display the list view.
	Private Sub SetupGridControl()
		Set GridControl = New CNCGridControl

		Dim pNCGridDecorator
		Set pNCGridDecorator = New CNCGridDecorator_PageRevision

		Call GridControl.InitGridControl( IDS_GRIDID_PAGEREVISION, pNCGridDecorator, RevisionPages, True )
		Call GridControl.SetDisplayRange( GridStartItem-1 , GridEndItem-1 )
		GridControl.ColumnHeadAnchorCSSClass = "WBC_styclsHeavyTextColor1"
		Call GridControl.AddColumn( IDS_GRIDINDEX_COMPARE, False )
		Call GridControl.AddColumn( IDS_GRIDINDEX_APPROVALDATE, True )
		Call GridControl.AddColumn( IDS_GRIDINDEX_PROPERTIES, False )
		Call GridControl.AddColumn( IDS_GRIDINDEX_REVISIONTYPE, False )
		Call GridControl.AddColumn( IDS_GRIDINDEX_APPROVALBY, False )

		GridControl.ItemSpacing = 1
		GridControl.ItemPadding = 5
	End Sub
End Class

%>