<!--#include virtual="/NR/System/WBC/Internals/Main/WBCApp.inc"-->
<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/AuthPreviewUIStrings.inc" -->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/AuthPreview/EntryProgrammingConstants.inc" -->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/AuthPreview/InternalProgrammingConstants.inc" -->


<!--#include virtual="/NR/System/WBC/Internals/ServerControls/StateControl/CNCStateControl.inc"-->

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

<!--#include virtual="/NR/System/WBC/Internals/ServerControls/GridControl/CNCGridControl.inc"-->
<!--#include file="CNCGridDecorator_AuthPreviewConnectedSelDlg.inc" -->

<!--#include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingControl.inc"-->
<!--#include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingRenderer_Common.inc"-->
<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/MLSDisplayConfig/ConnectedPagesDlgsConfig.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/AuthPreview/
'			AuthPreviewConnectedSel/CNCASPPageManager_AuthPreviewConnectedSelDlg.inc
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
' Purpose:	Encapsulate the ASP logic associated with AuthPreviewConnectedSelDlg.asp
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'
' Exposes the following properties:
'	- Property CurrentPageNode
'	- Property ConnectedPages
'	- Property GridStartItem
'	- Property GridEndItem
'	- Property GridPagingConfigControl
'	- Property GridControl
'	- Property GridPagingControl
'	- Property Error
'	- Property ASPUtilsObject
'	- Property Charset
'	- Property CodePage
'	- Property HasNotAccessablePosting
' ********************************************************************

Class CNCASPPageManager_AuthPreviewConnectedSelDlg

	' -- Flag that says whether we are creating simple / connected page
	Public CurrentPageNode

	' -- Objects needed for the "View"
	Public ConnectedPages
	Public GridStartItem
	Public GridEndItem
	Public GridPagingConfigControl
	Public GridControl
	Public GridPagingControl

	' -- Error Handling
	Public Error

	' -- MLS info
	Public ASPUtilsObject

	' -- CharSet
	Public Charset

	' -- CodePage
	Public CodePage

	' -- Has connected page that user has no rights to access
	Public HasNotAccessablePosting

	' -- Virtual Node
	Public IsVirtualNode

	' ---- [Private] Class standard initialization routine
	Private Sub Class_Initialize()
		Set ConnectedPages = Nothing
		Set GridStartItem = Nothing
		Set GridEndItem = Nothing
		Set GridPagingConfigControl = Nothing
		Set GridControl = Nothing
		Set GridPagingControl = Nothing
		Set CurrentPageNode = Nothing
		Error = ""
		HasNotAccessablePosting  = False
		IsVirtualNode = False
	End Sub

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

		' -- Set up Required Object so we know if we are missing any query string
		Call SetupRequiredObject()

		' -- Set up MLS for diff languate
		Call SetupMLSInfo()

		' -- Set up HasNotAccessablePosting warning flag
		Call SetupHasNotAccessablePosting()

		' -- Set up Connectepage collection
		Call SetupConnectedPagesCollection()

		' -- Set up flag to indicate virtual node
		Call SetupVirtualNodeIndicator()

		'Set up all the display control configuration
		Call SetupPagingConfigControl()
		Call SetupPagingControl()
		Call SetupDisplayIndices()
		Call SetupGridControl()

	End Sub


	' ---- [Private] Create all the objects that QPARAM carries
	'
	Private Sub SetUpRequiredObject()
		Set CurrentPageNode = AutoSession.This
	End Sub


	' ---- [Private] Sets up the Pages collection
	Private Sub SetupConnectedPagesCollection()
		Set ConnectedPages = CurrentPageNode.ConnectedPostings
	End Sub

	' ---- [Private] Sets up GridPagingConfigControl
	Private Sub SetupPagingConfigControl()
		Set GridPagingConfigControl = New CNCPagingConfigControl
		Call GridPagingConfigControl.InitPagingConfigControl( IDS_PAGINGCONFIG_ID_AUTHPREVIEW_CONNECTEDPAGESSELECTION, 5, True )
	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, ConnectedPages.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()
		If ConnectedPages.Count = 0 Then
			GridStartItem = 0
		Else
			GridStartItem = (GridPagingControl.CurrentPage - 1)*(GridPagingConfigControl.ItemsPerPage) + 1
		End If
		If (GridPagingConfigControl.ItemsPerPage < 0) Then
			' -- a minus one value from PagingConfigControl means "All" case
			GridEndItem = ConnectedPages.Count
		Else
			GridEndItem = GridPagingControl.CurrentPage * GridPagingConfigControl.ItemsPerPage
		End If
		GridEndItem = Min(ConnectedPages.Count, GridEndItem)
	End Sub

	' ----
	Private Sub SetupGridControl()
		Set GridControl = New CNCGridControl

		Dim pNCGridDecorator
		Set pNCGridDecorator = New CNCGridDecorator_AuthPreviewConnectedSelDlg

		Call GridControl.InitGridControl( IDS_GRIDID_AUTHPREVIEW_CONNECTEDPAGESPREVIEW, pNCGridDecorator, ConnectedPages, True )
		Call GridControl.SetDisplayRange( GridStartItem-1 , GridEndItem-1 )
		Call GridControl.AddColumn( IDS_GRIDINDEX_AUTHPREVIEW_DISPLAYNAME, True )
		Call GridControl.AddColumn( IDS_GRIDINDEX_AUTHPREVIEW_LOCATION, True )

		GridControl.ColumnHeadAnchorCSSClass = "WBC_styclsHeavyTextColor1"
		GridControl.ItemSpacing = 1
		GridControl.ItemPadding = 5

	End Sub

	' ---- [Private] Set up the MLS info this ASP page will be running under
	Private Sub SetupMLSInfo()
		Set ASPUtilsObject = GetInitializedASPUtils()

		CodePage = GetCodePageForConnectedPagesDlg(CurrentPageNode)
		CharSet = GetCharacterSetForConnectedPagesDlg(CurrentPageNode)

	End Sub

	' ---- [Private] Set up warning flag to tell user
	'                there are postings that he has no rights to see
	Private Sub SetupHasNotAccessablePosting()
		HasNotAccessablePosting = CurrentPageNode.HasInaccessibleConnectedPostings
	End Sub

	' ---- [Private]
	Private Sub SetupVirtualNodeIndicator()
		IsVirtualNode = True
		If IsExistingPosting( CurrentPageNode ) Then
			IsVirtualNode = False
		End If
	End Sub

End Class

%>
