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

<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/AuthResourceUIStrings.inc" -->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/ResourceBrowser/Authoring/AuthResourceConstants.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/ResourceBrowser/
'			Authoring/ImageProperties/CNCASPPageManager_ImageProperties.inc
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
' Purpose:	Encapsulate the ASP logic associated with ImagePropertiesBrowse.asp
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'	- Property Error
'
' Exposes the following properties:
'	- Property ASPUtils
'	- Property Charset
'	- Property CodePage
'	- Property PlaceholderParameters
'	- Property CurrentPosting
'	- Property Resources
'	- Property URLSelectImage
'	- Property URLResourceGalleries
'	- Property URLResources
'	- Property PlaceholderName
'	- Property PlaceholderType
'	- Property CanHyperlinks
'	- Property Error
' ********************************************************************

Class CNCASPPageManager_ImageProperties
	' -- The ASP Utility
	Public ASPUtils

	' -- The Charset ASP page will be running under
	Public Charset

	' -- The CodePage ASP page will be running under
	Public CodePage

	' -- Object of the current Posting
	Public CurrentPosting

	' -- the links to go back select image
	Public URLSelectImage

	' -- the links to go back resource galleries in the ASP page
	Public URLResourceGallery

	' -- the links to go back resource item in the ASP page
	Public URLResources

	' -- allow Hyperlink of the placeholder
	Public CanHyperlinks

	' -- the ResourceGallery and Resource item Object
	Public ResourceGallery
	Public Resource

	' -- the error
	Public Error

	' internal variable
	Private m_strResourceGUID

	' -- Placeholder information
	Private m_strPlaceholderName
	Private m_strPlaceholderType
	Private m_bAllowDeskTopRes
	Private m_strPlaceholderParameters

	' ---- [Private] Standard Class_Initialize
	Private Sub Class_Initialize()
		Set CurrentPosting = Nothing
		Set ResourceGallery = Nothing
		Set Resource = Nothing
		Set ASPUtils = Nothing
		URLSelectImage = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_SELECT_URL
		URLResourceGallery = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_GALLERIES_URL
		URLResources = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_RESOURCES_URL
		CanHyperlinks = False
		Error = ""

		m_strPlaceholderName = ""
		m_strPlaceholderType = ""
		m_bAllowDeskTopRes = False
		m_strPlaceholderParameters = ""
	End Sub

	' ---- [Public] InitManaer will take care of all programming logic in the ASP page
	Public Sub InitManager()
		Call SetupBrowseContext()
		' -- Set up URL needed for links in the ASP page
		If (Resource Is Nothing) Then
			Error = IDS_ERR_RESOURCE_NOT_FOUND
			Exit Sub
		End If

		' -- Set up the ASP Utility
		Call SetupASPUtils()

		' -- Set up the Charset base on the Resource configuration function
		Call SetupCharset()

		' -- Set up the CodePage base on the Resource configuration function
		Call SetupCodePage()

		' -- Set up information of the current placeholder
		Call SetupPlaceholderInfo()

		' -- Set up the current Posting object
		Call SetupCurrentPosting()

		' -- Set up the CanHyperLinks properties
		Call SetupCanHyperLinks

		' -- Set up all links URL
		Call SetupLinksURL()
	End Sub

	' ---- [Public] get the placeholder information parameter
	Public Property Get PlaceholderParameters()
		PlaceholderParameters = m_strPlacholderParameters
	End Property

	' ---- [Public] get the placeholder name
	Public Property Get PlaceholderName()
		PlaceholderName = m_strPlaceholderName
	End Property

	' ---- [Public] get the placeholder type
	Public Property Get PlaceholderType()
		PlaceholderType = m_strPlaceholderType
	End Property

	' ---- [Private] Retrieve Placeholder name from Querystring in a XSS safe fashion
	Private Function GetPlaceholderName()
		On Error Resume Next
		Dim pPlaceholder

		Set pPlaceholder = AutoSession.ThisPosting.Placeholders( CStr(Request.QueryString(IDS_QPARAM_PHNAME)) )
		If (pPlaceholder Is Nothing) Then
			GetPlaceholderName = ""
		Else
			GetPlaceholderName = CStr(Request.QueryString(IDS_QPARAM_PHNAME))
		End If
	End Function

	' ---- [Private] Set up information of the current placeholder
	Private Sub SetupPlaceholderInfo()
		m_strPlaceholderName = GetPlaceholderName()
		' restrict value of m_strPlaceholderType to guard against XSS attack
		Select Case Request.QueryString( IDS_QPARAM_PHTYPE )
			Case IDS_PHTYPE_MULTIPURPOSE
				m_strPlaceholderType = IDS_PHTYPE_MULTIPURPOSE
			Case IDS_PHTYPE_SINGLEIMAGE
				m_strPlaceholderType = IDS_PHTYPE_SINGLEIMAGE
			Case IDS_PHTYPE_THINEDITIE
				m_strPlaceholderType = IDS_PHTYPE_THINEDITIE
			Case Else
				m_strPlaceholderType = ""
		End Select
		m_bAllowDeskTopRes = CBool(Request.QueryString( IDS_QPARAM_DESKRES ))
		m_strPlaceholderParameters = IDS_QPARAM_PHNAME & "=" & Server.URLEncode( m_strPlaceholderName ) & _
									"&" & IDS_QPARAM_PHTYPE & "=" & m_strPlaceholderType & _
									"&" & IDS_QPARAM_DESKRES & "=" & m_bAllowDeskTopRes
	End Sub

	' ---- [Private] Sets up the browsing context (Gallery)
	Private Sub SetupBrowseContext()
		Dim strResourceGUID

		If (Request.QueryString(IDS_QPARAM_RESOURCE) = "")  Then
			Set Resources = Nothing
		Else
			strResourceGUID = CStr( Request.QueryString( IDS_QPARAM_RESOURCE ) )
			Set Resource = AutoSession.Searches.GetByGUID( strResourceGUID )

			If (Resource is Nothing) then
				Set ResourceGallery = Nothing
			Else
				Set ResourceGallery = Resource.Parent
			End If
		End If
	End Sub

	' ---- [Private] Set up the Charset this ASP page will be running under
	Private Sub SetupASPUtils()
		Set ASPUtils = GetInitializedASPUtils()
	End Sub

	' ---- [Private] Set up the Charset this ASP page will be running under
	Private Sub SetupCharset()
		Charset = GetCharacterSetForResource( ResourceGallery )
	End Sub

	' ---- [Private] Set up the CodePage this ASP page will be running under
	Private Sub SetupCodePage()
		Dim pASPUtils
		Set pASPUtils = GetInitializedASPUtils()
		CodePage = GetCodePageForResource( ResourceGallery, pASPUtils )
	End Sub

	' ---- [Private] Sets up the current Posting object
	Private Sub SetupCurrentPosting()
		Set CurrentPosting = AutoSession.ThisPosting
	End Sub

	' ---- [Private] Sets up the current Posting object
	Private Sub SetupCanHyperLinks()
		CanHyperLinks = CurrentPosting.Placeholders( m_strPlaceholderName ).AllowsHyperlinks
	End Sub

	' ---- [Private] Set up URL needed for links in the ASP page
	Private Sub SetupLinksURL
		URLSelectImage = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_SELECT_URL & "?" & CurrentPosting.QueryString & _
							"&" & m_strPlaceholderParameters
		URLResourceGallery = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_GALLERIES_URL & "?" & CurrentPosting.QueryString & _
							"&" & m_strPlaceholderParameters

		URLResources = IDS_PATH_INSERT_IMAGE_URL & IDS_PATH_IMAGE_RESOURCES_URL & "?" & CurrentPosting.QueryString & _
							"&" & IDS_QPARAM_GALLERY & "=" & ResourceGallery.Guid & _
							"&" & m_strPlaceholderParameters
	End Sub

	' ----- [Public] Write resource display name of resource name depend on the codepage
	Public Sub ResourceName()
		' Show Display Name
		Call ASPUtils.MBCSWrite( ASPUtils.HTMLEncode( Resource.DisplayName ), CurrentPosting.CodePage )
	End Sub

End Class

%>