<!-- #include virtual="/NR/System/WBC/Internals/Integration/InternalHooks/URLGenerationHooks/CommonURLHooks.inc" -->
<!-- #include virtual="/NR/System/WBC/Customizable/Hooks/URLGenerationHooks/CommonURLHooks.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."
'
'	This file exposes functions that are used to construct common site URL's
'	under different WBC modes. The set of Functions exposed are:
'	- Function GetWBCLiveSiteModeURL()
'	- Function GetWBCEditSiteModeURL( pThis )
'	- Function GetWBCAuthoringModeURL( pPosting )
'	- Function GetWBCPreviewModeURL( pThis )
'
'	The following functions are supported for backwards compatibility
'	with version 3.x :
'	- Function GetWBCBasicEditURL( pThis )
'	- Function GetWBCAuthoringURL( pThis )
'	- Function GetPreviewURL( pThis )
' *****************************************************************************


' -----------------------------------------------------------------------------
'
'	[Public] This function returns the link to WBC Live Site Mode view.
'
'	@return - the WBC Live Site Mode URL given the current Channel or Posting
'			context. Note that even if the current object is a Posting, its
'			parent Channel URL may be returned if the Posting does not have a
'			Live version.
'
' -----------------------------------------------------------------------------
Function GetWBCLiveSiteModeURL()
	GetWBCLiveSiteModeURL = "#"

	If Not IsStagedOrCrawled Then
		Dim strWBCPurpose
		strWBCPurpose = Request.QueryString(IDS_QPARAM_WBCPURPOSE)

		If (strWBCPurpose = IDS_WBCPURPOSE_BASIC) Or _
			(strWBCPurpose = IDS_WBCPURPOSE_AUTHORING) Then
			' -- Disable WBC mode propagation policy because we want to
			'		generate all the query string parameters ourselves
			Call DisableROMPropagationPolicyForWBCMode()

			' -- brace for the case that we are viewing an Unpublished Posting and
			' 	 there is no Published version of the Posting
			Dim pThis
			If GetCurrentObject.IsPosting Then
				' only direct user to Posting if Published Posting exists;
				' otherwise, direct user to the parent Channel
				If AutoSession.ThisPosting.StateApprovedVersion = "Published" Then
					Set pThis = AutoSession.ThisPosting
				Else
					Set pThis = AutoSession.ThisChannel
				End If
			Else
				' viewing a Channel, so just stay on the Channel
				Set pThis = AutoSession.ThisChannel
			End If
			GetWBCLiveSiteModeURL = pThis.URLModePublished

			' -- call Internal Hook
			Call OnInternalCustomizeWBCLiveSiteModeURL( pThis, GetWBCLiveSiteModeURL )

			' -- call External Customizable Hook
			Call OnCustomizeWBCLiveSiteModeURL( pThis, GetWBCLiveSiteModeURL )

			' -- restore WBC mode propagation policy
			Call SetROMPropagationPolicyForWBCMode()
		End If
	End If
End Function


' -----------------------------------------------------------------------------
'
'	[Public] This function returns the link to WBC Edit Site Mode of the
'			passed in Channel or Posting
'
'	@pThis [in] - the Channel or Posting whose WBC Edit Site Mode URL is to be
'					returned.
'
'	@return - the WBC Edit Site Mode URL of the Channel or Posting
'
' -----------------------------------------------------------------------------
Function GetWBCEditSiteModeURL( pThis )
	GetWBCEditSiteModeURL = "#"

	If Not IsStagedOrCrawled Then
		' -- Disable WBC mode propagation policy because we want to
		'		generate all the query string parameters ourselves
		Call DisableROMPropagationPolicyForWBCMode()

		GetWBCEditSiteModeURL = AppendQueryString( pThis.URLModeUnpublished, _
									IDS_QPARAM_WBCPURPOSE & "=" & IDS_WBCPURPOSE_BASIC )

		' -- call hook function to allow custom modification of the URL
		Call OnInternalCustomizeWBCEditSiteModeURL( pThis, GetWBCEditSiteModeURL )

		' -- call hook function to allow custom modification of the URL
		Call OnCustomizeWBCEditSiteModeURL( pThis, GetWBCEditSiteModeURL )

		' -- restore WBC mode propagation policy
		Call SetROMPropagationPolicyForWBCMode()
	End If
End Function

' ---- [Public] For backwards compatibility with version 3.x
Function GetWBCBasicEditURL( pThis )
	GetWBCBasicEditURL = GetWBCEditSiteModeURL( pThis )
End Function


' -----------------------------------------------------------------------------
'
'	[Public] This function returns the link to WBC Authoring Mode of the
'			passed in Channel or Posting
'
'	@pPosting [in] - the Posting whose WBC Authoring Mode URL is to be returned.
'
'	@return - the WBC Authoring Mode URL of a Posting
'
' -----------------------------------------------------------------------------
Function GetWBCAuthoringModeURL( pPosting )
	GetWBCAuthoringModeURL = "#"

	If Not IsStagedOrCrawled Then
		' -- Disable WBC mode propagation policy because we want to
		'		generate all the query string parameters ourselves
		Call DisableROMPropagationPolicyForWBCMode()

		GetWBCAuthoringModeURL = AppendQueryString(pPosting.URLModeUnpublished, _
							IDS_QPARAM_NREMIT & "=" & IDS_EMIT_THINEDIT & "&" & _
							IDS_QPARAM_WBCPURPOSE & "=" & IDS_WBCPURPOSE_AUTHORING )

		' -- call Internal Hook
		Call OnInternalCustomizeWBCAuthoringModeURL( pPosting, GetWBCAuthoringModeURL )

		' -- call External Customizable Hook
		Call OnCustomizeWBCAuthoringModeURL( pPosting, GetWBCAuthoringModeURL )

		' -- restore WBC mode propagation policy
		Call SetROMPropagationPolicyForWBCMode()
	End If
End Function

' ---- [Public] For backwards compatibility with version 3.x
Function GetWBCAuthoringURL( pThis )
	GetWBCAuthoringURL = GetWBCAuthoringModeURL( pThis )
End Function


' -----------------------------------------------------------------------------
'
'	[Public] This function returns the link to preview the passed in Channel
'				or Posting without any WBC UI (as though in Live Site Mode).
'
'	@pThis [in] - the Channel or Posting whose WBC Preview Mode URL is to be
'					returned.
'
'	@return - the WBC Preview Mode URL of the Channel or Posting
'
' -----------------------------------------------------------------------------
Function GetWBCPreviewModeURL( pThis )
	GetWBCPreviewModeURL = "#"

	If Not IsStagedOrCrawled Then
		' -- Disable WBC mode propagation policy because we want to
		'		generate all the query string parameters ourselves
		Call DisableROMPropagationPolicyForWBCMode()

		' WBCMODE=PresentationUnpublishedPreview is for WBC.NET
		GetWBCPreviewModeURL = AppendQueryString( pThis.URLModeUnpublished, _
								IDS_QPARAM_NREMIT & "=" & IDS_EMIT_VIEW & _
								"&WBCMODE=PresentationUnpublishedPreview" )

		' -- call Internal Hook
		Call OnInternalCustomizeWBCPreviewModeURL( pThis, GetWBCPreviewModeURL )

		' -- call External Hook
		Call OnCustomizeWBCPreviewModeURL( pThis, GetWBCPreviewModeURL )

		' -- restore WBC mode propagation policy
		Call SetROMPropagationPolicyForWBCMode()
	End If
End Function


' ---- [Public] For backwards compatibility with version 3.x
Function GetPreviewURL( pThis )
	GetPreviewURL = GetWBCPreviewModeURL( pThis )
End Function

%>