<!-- #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/StateControl/CNCStateControl.inc"-->

<!-- #include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/MLSDisplayConfig/RevisionBrowserConfig.inc" -->

<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/RevisionCompare/CNCStateRenderer_Insertion.inc" -->
<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/RevisionCompare/CNCStateRenderer_Deletion.inc" -->
<!-- #include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/RevisionBrowser/Page/RevisionCompare/CNCStateRenderer_TabView.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/RevisionCompare/CNCASPPageManager_PageCompare.asp
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
' Purpose:	Encapsulate the ASP logic associated with PageRevisionCompareInfor.asp
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'
' Exposes the following properties:
'	- Property CurrentPage
'	- Property TabviewStateControl
'	- Property DropListStateControl
' ********************************************************************

Class CNCASPPageManager_PageCompare

	' -- Objects needed for Page Compare
	Public CurrentPage
	Public TabviewStateControl
	Public InsertionStateControl
	Public DeletionStateControl
	Public DateCompareFrom
	Public DateCompareTo
	Public CompareFromURL
	Public CompareToURL
	Public CompareInfoURL
	Public CompareResultURL
	Public TypeCompareFrom
	Public TypeCompareTo
	Public CodePage
	Public Charset

	private m_pFormReader
	Private m_pCompareFromPage
	Private m_pCompareToPage
	Private m_pASPUtils

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

		' set up a form reader object
		Call SetupFormReader()

		' -- Set up a set of StateControls to keep the tab view and dropdown option status
		Call SetupTabViewStateControl()
		Call SetupInsertionOptionstateControl()
		Call SetupDeletionOptionstateControl()

		' -- Set up Page and Page configure control to control the list view of the Page Revision
		Call SetupComparePageInfo()
		Call SetupMLSInfo()
		Call SetupCompareURL()
		Call SetupCompareInfoURL()
		Call SetupCompareResultURL()
	End Sub

	' ---- [Private] get the Reader form
	Private Sub SetupFormReader()
		Set m_pFormReader = GetInitializedFormReaderSafe( false )
	End Sub

	' ---- [Private] Set up the MLS info this ASP page will be running under
	Private Sub SetupMLSInfo()
		Set m_pASPUtils = GetInitializedASPUtils()
		CodePage = GetCodePageForRevisionComparison( m_pCompareFromPage, m_pCompareToPage, m_pASPUtils )
		If GetCharacterSetForRevisionComparison( m_pCompareFromPage, m_pCompareToPage ) = "" Then
			Charset = CurrentPage.Charset
		Else
			Charset = GetCharacterSetForRevisionComparison( m_pCompareFromPage, m_pCompareToPage )
		End If
	End Sub

	' ---- [Private] Sets up a set of state control for tab view
	Private Sub SetupTabViewStateControl()
		Dim pStateRenderer
		Set pStateRenderer = New CNCStateRenderer_TabView
		Set TabviewStateControl = New CNCStateControl

		Call TabviewStateControl.InitStateControl( IDS_TAB_STATE_INSTANCE_ID, pStateRenderer, IDS_DISPLAY_APPEARANCE, true )
		Call TabviewStateControl.AddState( IDS_DISPLAY_APPEARANCE )
		Call TabviewStateControl.AddState( IDS_DISPLAY_SOURCE )
		Call TabviewStateControl.AddState( IDS_DISPLAY_PROPS )
	End Sub

	' ---- [Private] Sets up a set of state control for insertion options
	Private Sub SetupInsertionOptionstateControl()
		Dim pStateRenderer
		Set pStateRenderer = New CNCStateRenderer_Insertion
		Set InsertionStateControl = New CNCStateControl

		Call InsertionStateControl.InitStateControl( IDS_INSERTION_STATE_INSTANCE_ID, pStateRenderer, IDS_INSERTION_GREEN, true )
		Call InsertionStateControl.AddState( IDS_INSERTION_BLUE )
		Call InsertionStateControl.AddState( IDS_INSERTION_DARKBLUE )
		Call InsertionStateControl.AddState( IDS_INSERTION_DARKRED )
		Call InsertionStateControl.AddState( IDS_INSERTION_GREEN )
		Call InsertionStateControl.AddState( IDS_INSERTION_PINK )
		Call InsertionStateControl.AddState( IDS_INSERTION_PURPLE )
		Call InsertionStateControl.AddState( IDS_INSERTION_RED )
		Call InsertionStateControl.AddState( IDS_INSERTION_TURQUOISE )
		Call InsertionStateControl.AddState( IDS_INSERTION_WHITE )
		Call InsertionStateControl.AddState( IDS_INSERTION_YELLOW )
		Call InsertionStateControl.AddState( IDS_INSERTION_NONE )

		' update the insertion state
		If ( m_pFormReader.Form( IDS_OPTIONS_INSERTION ) <> "") Then
			InsertionStateControl.CurrentState = CStr( m_pFormReader.Form( IDS_OPTIONS_INSERTION ) )
		End If
	End Sub

	' ---- [Private] Sets up a set of state control for deletion options
	Private Sub SetupDeletionOptionstateControl()
		Dim pStateRenderer
		Set pStateRenderer = New CNCStateRenderer_Deletion
		Set DeletionStateControl = New CNCStateControl

		Call DeletionStateControl.InitStateControl( IDS_DELETION_STATE_INSTANCE_ID, pStateRenderer, IDS_DELETION_BLUE, true )
		Call DeletionStateControl.AddState( IDS_DELETION_BLUE )
		Call DeletionStateControl.AddState( IDS_DELETION_DARKBLUE )
		Call DeletionStateControl.AddState( IDS_DELETION_DARKRED )
		Call DeletionStateControl.AddState( IDS_DELETION_GREEN )
		Call DeletionStateControl.AddState( IDS_DELETION_PINK )
		Call DeletionStateControl.AddState( IDS_DELETION_PURPLE )
		Call DeletionStateControl.AddState( IDS_DELETION_RED )
		Call DeletionStateControl.AddState( IDS_DELETION_TURQUOISE )
		Call DeletionStateControl.AddState( IDS_DELETION_WHITE )
		Call DeletionStateControl.AddState( IDS_DELETION_YELLOW )
		Call DeletionStateControl.AddState( IDS_DELETION_NONE )

		' update the insertion state
		If ( m_pFormReader.Form( IDS_OPTIONS_DELETION ) <> "") Then
			DeletionStateControl.CurrentState = CStr( m_pFormReader.Form( IDS_OPTIONS_DELETION ) )
		End If
	End Sub

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

	Private Sub SetupComparePageInfo()

		' get the revision object
		If (Request.QueryString( IDS_QSTR_COMPARETO_DATE ) <> "") Then
			If (CDate(Request.QueryString( IDS_QSTR_COMPAREFROM_DATE )) = DATE_NEVER) Then
				Set m_pCompareFromPage = CurrentPage.WorkingRevision
				DateCompareFrom = FormatDate( m_pCompareFromPage.LastModifiedDate )
			Else
				Set m_pCompareFromPage = CurrentPage.RevisionForDate( CDate( Request.QueryString( IDS_QSTR_COMPAREFROM_DATE ) ) )
				DateCompareFrom = FormatDate( m_pCompareFromPage.RevisionDate )
			End If

			Set m_pCompareToPage = CurrentPage.RevisionForDate( CDate( Request.QueryString(IDS_QSTR_COMPARETO_DATE) ) )
			DateCompareTo = FormatDate( m_pCompareToPage.RevisionDate )
		Else
			Set m_pCompareFromPage = CurrentPage.WorkingRevision
			Set m_pCompareToPage = CurrentPage.RevisionForDate( CDate( Request.QueryString( IDS_QSTR_COMPAREFROM_DATE ) ) )
			DateCompareFrom = FormatDate( m_pCompareFromPage.LastModifiedDate )
			DateCompareTo = FormatDate( m_pCompareToPage.RevisionDate )
		End If

		' get the revision type
		If (Request.QueryString( IDS_QSTR_COMPAREFROM_TYPE ) <> "") Then
			TypeCompareFrom = "(" & Request.QueryString( IDS_QSTR_COMPAREFROM_TYPE ) & ")"
		End If

		' get the revision type
		If (Request.QueryString( IDS_QSTR_COMPARETO_TYPE ) <> "") Then
			TypeCompareTo = "(" & Request.QueryString( IDS_QSTR_COMPARETO_TYPE ) & ")"
		End If

	End Sub

	' ---- [Private] get the Compare Infor frame URL
	Private Sub SetupCompareInfoURL()
		CompareInfoURL = IDS_COMPAREINFO_URL & CurrentPage.QueryString
	End Sub

	' ---- [Private] get the Compare Result frame URL
	Private Sub SetupCompareResultURL()
		CompareResultURL = IDS_COMPARERESULT_URL & URLEncodedQueryString()
	End Sub

	' ---- [Private] get the two Compare URL for download
	Private Sub SetupCompareURL()
		' get the URL from the compare revision page
		CompareFromURL = m_pCompareFromPage.URLPostingFrame
		CompareToURL = m_pCompareToPage.URLPostingFrame

		' construct the URL to get the content of the page
		CompareFromURL = CompareFromURL & "&" & IDS_QSTR_PACKAGE & "&" & IDS_QSTR_VARNAME & IDS_NC_COMPARE_FROM & "&" _
				& IDS_QSTR_INPUTCODEPAGE & m_pCompareFromPage.CodePage & "&" & IDS_QSTR_OUTPUTCODEPAGE & CodePage & "&" & IDS_QSTR_ENCODEHTML
		CompareToURL = CompareToURL & "&" & IDS_QSTR_PACKAGE & "&" & IDS_QSTR_VARNAME & IDS_NC_COMPARE_TO & "&" _
				& IDS_QSTR_INPUTCODEPAGE & m_pCompareToPage.CodePage & "&" & IDS_QSTR_OUTPUTCODEPAGE & CodePage & "&" & IDS_QSTR_ENCODEHTML

	End Sub

End Class


%>