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

<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/TasksAssistantUIStrings.inc" -->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/TasksAssistant/ProductionManager/ProductionManagerConstants.inc" -->

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

<!--#include virtual="/NR/System/WBC/Internals/ServerControls/PagingConfigControl/CNCPagingConfigControl.inc"-->
<!--#include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingControl.inc"-->
<!--#include virtual="/NR/System/WBC/Internals/ServerControls/PagingControl/CNCPagingRenderer_Common.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/
'				TasksAssistant/ProductionManager/
'				CNCASPPageManager_ProductionManager.inc
'
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
'
' Purpose:	Encapsulate the ASP logic associated with
'			ProductionManager.asp. This class takes care of maintaining
'			information about the various controls on the page and
'			taking care of initialization activities, such as setting
'			up URLs and creating new instances of server-side controls.
'
' Implements the INCASPPageManager interface:
'
'	- Sub InitManager()
'
' Exposes the following properties:
'
'	- Property ASPUtils [R]
'	- Property CodePage [R]
'	- Property Charset
'	- Property StartItem
'	- Property EndItem
'	- Property PagingConfigControl
'	- Property GridControl
'	- Property PagingControl
'	- Property PagesInProduction
'	- Property Error
'
' ********************************************************************

Class CNCASPPageManager_ProductionManager

	' see documentation below for property descriptions for an
	' explanation of what these member variables are used for
	Private m_pASPUtils
	Private m_strCodePage
	Private m_strCharset
	Private m_nStartItem
	Private m_nEndItem
	Private m_pPagingConfigControl
	Private m_pPagingControl
	Private m_pGridControl
	Private m_strError

	Private m_pPagesInProduction



	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the username
	' -------------------------------------------------------------------------
	Public Property Get UserShortName
		If Autosession.User Is Nothing Then
			UserShortName = ""
		Else
			UserShortName = Autosession.User.ShortName
		End If
	End Property
	
	
	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the ASP utility object for the page
	' -------------------------------------------------------------------------
	Public Property Get ASPUtils
		Set ASPUtils = m_pASPUtils
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the codepage for the page
	' -------------------------------------------------------------------------
	Public Property Get CodePage
		CodePage = m_strCodePage
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the charset for the page
	' -------------------------------------------------------------------------
	Public Property Get CharSet
		CharSet = m_strCharSet
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the start item for rendering the
	'  	page. The start item is an integer index that indicates the index into
	' 	the collection where rendering is to begin (based on the number of
	'	items per page).
	' -------------------------------------------------------------------------
	Public Property Get StartItem
		StartItem = m_nStartItem
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] Property that exposes the end item for rendering the
	'  	page. The end item is an integer index that indicates the index into
	' 	the collection where rendering is to end (based on the number of
	'	items per page).
	' -------------------------------------------------------------------------
	Public Property Get EndItem
		EndItem = m_nEndItem
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] The paging config control provides access to the server-
	'	side control that handles displaying the dropdown list that displays
	'	the number of items per page
	' -------------------------------------------------------------------------
	Public Property Get PagingConfigControl
		Set PagingConfigControl = m_pPagingConfigControl
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] This property exposes the paging control which is
	'	responsible for rendering different items depending on how many are
	'	to be shown per page.
	' -------------------------------------------------------------------------
	Public Property Get PagingControl
		Set PagingControl = m_pPagingControl
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] The Grid control provides the main functionality for
	'	rendering the sortable list of objects.
	' -------------------------------------------------------------------------
	Public Property Get GridControl
		Set GridControl = m_pGridControl
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] The pages in production property exposes a collection
	'	that contains all of the pages the current logged-in user has in
	'	production (i.e. being worked on; non-published; checked-out).
	' -------------------------------------------------------------------------
	Public Property Get PagesInProduction
		Set PagesInProduction = m_pPagesInproduction
	End Property


	' -------------------------------------------------------------------------
	'	[PUBLIC;READ] The error string is filled in when an error occurs in
	'	initialization of the page manager
	' -------------------------------------------------------------------------
	Public Property Get Error
		Error = m_strError
	End Property


	' -------------------------------------------------------------------------
	'	[PRIVATE] The Class_Initialize method acts as a constructor for the
	'	class and is called automatically by the scripting engine when the
	'	class is instantiated.
	' -------------------------------------------------------------------------
	Private Sub Class_Initialize()

		m_strCodePage = ""
		m_strCharSet = ""
		m_nStartItem = -1
		m_nEndItem = -1
		Set m_pASPUtils = Nothing
		Set m_pPagingConfigControl = Nothing
		Set m_pPagingControl = Nothing
		Set m_pGridControl = Nothing
		m_strError = ""

		Set m_pPagesInProduction = Nothing

	End Sub  'Class_Initialize


	' -------------------------------------------------------------------------
	'	[PUBLIC] This function should be the first one called by anyone
	'	creating a new instance of this page manager class. It is responsible
	'	for creating objects associated with all the member variables and
	'	thus, encapsulating initialization logic from the main ASP page.
	'
	'	@see CNCASPPageManager
	' -------------------------------------------------------------------------
	Public Sub InitManager()

		Call SetupBrowseContext()
		Call SetupASPUtils()
		Call SetupCodePage()
		Call SetupCharset()

		' Set up objects to control the view parameters
		Call SetupPagingConfigControl()
		Call SetupPagingControl()
		Call SetupDisplayIndices()
		Call SetupGridControl()

	End Sub  'InitManager


	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function to retrieve the information to be displayed
	'	(pages in production) from the ROM.
	' -------------------------------------------------------------------------
	Private Sub SetupBrowseContext

		Dim pPagesInProduction
		Set pPagesInProduction = AutoSession.Searches.UserPostingsInProduction

		If Not pPagesInProduction Is Nothing Then
			Set m_pPagesInProduction = pPagesInProduction
		End If  'if collection returned

	End Sub  'SetupBrowseContext


	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function to retrieve the ASP utility object
	' -------------------------------------------------------------------------
	Private Sub SetupASPUtils()

		Set m_pASPUtils = GetInitializedASPUtils()

	End Sub  'SetupASPUtils
	
	
	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function to setup the code page that the ASP page
	'	will be running under (for multi-language support).
	' -------------------------------------------------------------------------
	Private Sub SetupCodePage()

		m_strCodePage = GetCodePageForTasksAssistant( m_pASPUtils )

	End Sub  'SetupCodePage
	

	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function to setup the char page that the ASP page
	'	will be running under (for multi-language support).
	' -------------------------------------------------------------------------
	Private Sub SetupCharset()

		m_strCharSet = GetCharacterSetForTasksAssistant()

	End Sub  'SetupCharset


	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function to create a new instance of the page
	'	config control and set up its parameters, such as the default number
	'	of items per page.
	' -------------------------------------------------------------------------
	Private Sub SetupPagingConfigControl()

		' create an initialize the new paging config control. Note that the
		' last parameter on the call to InitPagingConfigControl indicates
		' whether the paging value should be persisted across sessions. In
		' this case, yes (True) -- it doesn't do any harm
		Set m_pPagingConfigControl = New CNCPagingConfigControl
		Call m_pPagingConfigControl.InitPagingConfigControl( IDS_PAGINGCONFIG_ID_PRODUCTIONMANAGER_ITEMSPERPAGE, _
														     IDS_PAGINGCONFIG_PRODUCTIONMANAGER_DEFAULTITEMSPERPAGE, _
														     True )
	End Sub  'SetupPagingConfigControl


	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function that configures the paging control with
	'	input from the paging config control. This is the spot where the
	'	paging renderer is attached to the paging control.
	' -------------------------------------------------------------------------
	Private Sub SetupPagingControl()

		Set m_pPagingControl = New CNCPagingControl

		' create a new instance of the paging render callback class. There is
		' nothing special that needs to be done here for rendering pages,
		' so use the common version.
		Dim pNCPagingRenderer
		Set pNCPagingRenderer = New CNCPagingRenderer_Common

		' init the paging control with the renderer, the total number of
		' items present in the collection to be paged, and the number
		' of items per page to display
		Call m_pPagingControl.InitPagingControl( pNCPagingRenderer, m_pPagesInProduction.Count, m_pPagingConfigControl.ItemsPerPage )

		' if a new value was set for items per page or the page was changed
		' (should be the case here since we initialized), then set the
		' current page to the beginning.
		If ( m_pPagingConfigControl.IsSetNewValue = True) Then

			' PagingConfigControl has just been set a new value, set PagingControl back to Page 1
			m_pPagingControl.CurrentPage = 1

		End If  'if paging control set to new value

	End Sub  'SetupPagingControl


	' -------------------------------------------------------------------------
	'	[PRIVATE] A helper function that configures the start and end item
	'	indexes into the collection of pages in production to determine exactly
	'	what items should be displayed on the screen given the current paging
	'	context.
	' -------------------------------------------------------------------------
	Private Sub SetupDisplayIndices()

		If ( m_pPagesInProduction Is Nothing ) Then
			m_nStartItem = 0
			m_nEndItem = 0

		Else

			' calculate the StartItem
			If ( m_pPagesInProduction.Count = 0 ) Then
				m_nStartItem = 0

			Else
				m_nStartItem = ( m_pPagingControl.CurrentPage - 1 ) * ( m_pPagingConfigControl.ItemsPerPage ) + 1

			End If  'calculate start/end indicies

			' calculate the EndItem
			If ( m_pPagingConfigControl.ItemsPerPage < 0 ) Then

				' -- a minus one value from PagingConfigControl means "All" case
				m_nEndItem = m_pPagesInProduction.Count

			Else

				m_nEndItem = m_pPagingControl.CurrentPage * m_pPagingConfigControl.ItemsPerPage

			End If  'if show all pages

			m_nEndItem = Min( m_pPagesInProduction.Count, EndItem )

		End If  'if no pages in production collection

	End Sub  'SetupDisplayIndicies


	' -------------------------------------------------------------------------
	'	[PRIVATE] This helper function takes care of creating the grid control
	'	and configuring it with the appopriate columns. All of the properties
	'	necessary for displaying postings in production are specified here,
	'	including what columns are sortable.
	' -------------------------------------------------------------------------
	Private Sub SetupGridControl()

		Set m_pGridControl = New CNCGridControl

		' create a new decorator control that is specific to the production
		' manager pages. This control will provide the base rendering
		' service and callback mechanism for displaying the list.
		Dim pGridDecorator
		Set pGridDecorator = New CNCGridDecorator_ProductionManager
		Call m_pGridControl.InitGridControl( IDS_GRIDID_PRODUCTIONMANAGER, pGridDecorator, m_pPagesInProduction, True )

		' set the display range for the control. Note that the indices are
		' zero-based, thus, the -1 on each of the ranges
		Call m_pGridControl.SetDisplayRange( m_nStartItem - 1, m_nEndItem - 1 )

		' add each of the columns to the grid. The boolean parameter
		' indicates whether the column is sortable or not
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_DISPLAYNAME, True )
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_GOTO, False )
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_PATH, True )
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_STATUS, False )
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_LASTMODIFIED, True )
		Call m_pGridControl.AddColumn( IDS_GRIDINDEX_DESCRIPTION, False )

		m_pGridControl.AscendingIndicatorHTML = "<img valign=bottom border=0 src='" & IDS_PATH_IMAGES_COMMON_ICONS & "iconArrowUp.gif'>"
		m_pGridControl.DescendingIndicatorHTML = "<img valign=bottom border=0 src='" & IDS_PATH_IMAGES_COMMON_ICONS & "iconArrowDown.gif'>"
		m_pGridControl.ColumnHeadAnchorCSSClass = IDS_CSS_PRODUCTIONMANAGER_HEAVYTEXT1
		m_pGridControl.ItemSpacing = 1
		m_pGridControl.ItemPadding = 5

	End Sub  'SetupGridControl

End Class  'CNCASPPageManager_ProductionManager

%>