<!-- #include virtual="/NR/System/WBC/Internals/Integration/InternalHooks/URLGenerationHooks/AuthoringModeHooks.inc" -->
<!-- #include virtual="/NR/System/WBC/Customizable/Hooks/URLGenerationHooks/AuthoringModeHooks.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."
' ********************************************************************

' ---- [Private] Global count of all placeholders emitted for thin edit in the WBC.
Dim g_nPhCount
g_nPhCount = 0

' -----------------------------------------------------------------------------
'
'	[Public] Registers the placeholder name and increments the count of
'				placeholders in the WBC form
'
' -----------------------------------------------------------------------------
Sub RegisterPlaceholderInThinEditForm( pPlaceholder )
	If pPlaceholder.IsEditable Then
		' Increment placeholder count
		g_nPhCount = g_nPhCount + 1

		' Output the placholder name into a known hidden form element
		Response.Write("<input type=""hidden"" name=""NCPHName_" & g_nPhCount & _
						""" value=""" & pPlaceholder.Name & """>")
	End If
End Sub

' -----------------------------------------------------------------------------
'
'	[Public] Generates the <form> tag and the necessary hidden elemets for the
'			authoring form
'
' -----------------------------------------------------------------------------
Sub EmbedWBCAuthFormBegin()
	If IsAuthoringMode Then
%>
		<!-- form onsubmit is set to false to prevent form from submitting by hitting enter key -->
		<form name="NC_EditForm"
		      method="post"
		      target=""
		      action=""
		      enctype="multipart/form-data"
		      onsubmit="return false;">

			<input type="hidden" name="NC_SavePageURL" value="<%= GetAuthFormSaveURL()%>">
			<input type="hidden" name="NC_SavePageAndExitURL" value="<%= GetAuthFormSaveAndExitURL()%>">
			<input type="hidden" name="NC_PreviewURL" value="<%= GetAuthFormPreviewURL(AutoSession.ThisPosting) %>">
			<input type="hidden" name="NC_SaveNewPageAndContinue" value="<%= GetAuthSaveNewPageAndContinue() %>">
			<input type="hidden" name="NC_SaveNewPageAndExit" value="<%= GetAuthSaveNewPageAndExit() %>">
<%
	End If
End Sub

' -----------------------------------------------------------------------------
'
'[Public] Generates the </form> tag and the necessary hidden elemets for the
'			authoring form
'
' -----------------------------------------------------------------------------
Sub EmbedWBCAuthFormEnd()
	If IsAuthoringMode Then
        Dim pASPUtils
        Set pASPUtils = GetInitializedASPUtils()
%>
			<input type="hidden" name="NC_Name"
					value="<%= Server.HTMLEncode(AutoSession.ThisPosting.Name) %>">
			<input type="hidden" name="NC_DisplayName"
					value="<%= Server.HTMLEncode(AutoSession.ThisPosting.DisplayName) %>">

			<!-- count of all placeholders emitted for thin editing -->
			<input type="hidden" name="NCPHCount" value="<%= g_nPhCount %>">
		</form>
		<script language="JavaScript"
				src="<%=IDS_FRAMEWORK_VIRTUAL_PATH%>/Internals/PageTemplate/Authoring/AuthFormClient.js"
				type="text/javascript"></script>
<%
	End If
End Sub





' -----------------------------------------------------------------------------
'
'	[Private] Returns the URL to save the authoring form
'
' -----------------------------------------------------------------------------
Function GetAuthFormSaveURL()
	' -- Disable WBC mode propagation policy because we want to
	'		generate all the query string parameters ourselves
	Call DisableROMPropagationPolicyForWBCMode()

	GetAuthFormSaveURL = IDS_FRAMEWORK_VIRTUAL_PATH & IDS_PAGEOPERATIONAUTHORING_PAGESAVEOLD_PATH & "/ExistingPageSave.asp?" & _
					AutoSession.ThisPosting.QueryStringModeUpdate & "&" & _
					IDS_QSTR_PAGEOPERATIONAUTHORING_LASTMODIFIEDDATE & "=" & CDbl(CDate(AutoSession.ThisPosting.LastModifiedDate)) & "&" & _
					IDS_QSTR_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING & "=" & IDS_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING_TRUE

	' -- call Internal hook function to allow custom modification of the URL
	Call OnInternalCustomizeAuthSaveURL( AutoSession.ThisPosting, GetAuthFormSaveURL )

	' -- call hook function to allow custom modification of the URL
	Call OnCustomizeAuthSaveURL( AutoSession.ThisPosting, GetAuthFormSaveURL )

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



' ---- [Private] Returns the URL to save the authoring form and exit back to edit mode
Function GetAuthFormSaveAndExitURL()
	' -- Disable WBC mode propagation policy because we want to
	'		generate all the query string parameters ourselves
	Call DisableROMPropagationPolicyForWBCMode()

	GetAuthFormSaveAndExitURL = IDS_FRAMEWORK_VIRTUAL_PATH & IDS_PAGEOPERATIONAUTHORING_PAGESAVEOLD_PATH & "/ExistingPageSave.asp?" & _
					AutoSession.ThisPosting.QueryStringModeUpdate & "&" & _
					IDS_QSTR_PAGEOPERATIONAUTHORING_LASTMODIFIEDDATE & "=" & CDbl(CDate(AutoSession.ThisPosting.LastModifiedDate)) & "&" & _
					IDS_QSTR_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING & "=" & IDS_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING_FALSE

	' -- call Internal hook function to allow custom modification of the URL
	Call OnInternalCustomizeAuthSaveURL( AutoSession.ThisPosting, GetAuthFormSaveAndExitURL )

	' -- call hook function to allow custom modification of the URL
	Call OnCustomizeAuthSaveURL( AutoSession.ThisPosting, GetAuthFormSaveAndExitURL )

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


' -----------------------------------------------------------------------------
'
'	[Private] Returns URL that provides a preview of the content being authored
'
' -----------------------------------------------------------------------------
Function GetAuthFormPreviewURL( pPosting )
	' -- Disable WBC mode propagation policy because we want to
	'		generate all the query string parameters ourselves
	Call DisableROMPropagationPolicyForWBCMode()

	If pPosting.IsFramed Then
		GetAuthFormPreviewURL = AppendQueryString( pPosting.URLPostingFrame(False), _
									IDS_QPARAM_WBCACCEPT & "=" & IDS_ACCEPTCONTENT_PHS )
	Else
		GetAuthFormPreviewURL = AppendQueryString( pPosting.URL, _
									IDS_QPARAM_WBCACCEPT & "=" & IDS_ACCEPTCONTENT_PHS )
	End If

	' -- call Internal Hook function to allow custom modification of the URL
	Call OnInternalCustomizeAuthPreviewURL( pPosting, GetAuthFormPreviewURL )

	' -- call Customizable Hook function to allow custom modification of the URL
	Call OnCustomizeAuthPreviewURL( pPosting, GetAuthFormPreviewURL )

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


' -----------------------------------------------------------------------------
'
'	[Private] Set up URL to submit to NewPageSave.asp
'
' -----------------------------------------------------------------------------
Function GetAuthSaveNewPageAndContinue()
	' -- Disable WBC mode propagation policy because we want to
	'		generate all the query string parameters ourselves
	Call DisableROMPropagationPolicyForWBCMode()

	GetAuthSaveNewPageAndContinue = IDS_FRAMEWORK_VIRTUAL_PATH & IDS_PAGEOPERATIONAUTHORING_PAGESAVE_PATH & _
			"/NewPageSave/NewPageSave.asp?" & Autosession.This.QueryStringModeUpdate & "&" & _
			IDS_QSTR_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING & "=" & IDS_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING_TRUE

	' -- call Internal hook function to allow custom modification of the URL
	Call OnInternalCustomizeAuthSaveURL( AutoSession.This, GetAuthSaveNewPageAndContinue )

	' -- call hook function to allow custom modification of the URL
	Call OnCustomizeAuthSaveURL( AutoSession.This, GetAuthSaveNewPageAndContinue )

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


' -----------------------------------------------------------------------------
'
'	[Private] Set up URL to sumbit to NewPageSave.asp This is not used in
'				version 4.0 but was written in case site designer wants this
'				fearure
'
' -----------------------------------------------------------------------------
Function GetAuthSaveNewPageAndExit()
	' -- Disable WBC mode propagation policy because we want to
	'		generate all the query string parameters ourselves
	Call DisableROMPropagationPolicyForWBCMode()

	GetAuthSaveNewPageAndExit = IDS_FRAMEWORK_VIRTUAL_PATH & IDS_PAGEOPERATIONAUTHORING_PAGESAVE_PATH & _
			"/NewPageSave/NewPageSave.asp?" & Autosession.This.QueryStringModeUpdate & "&" & _
			IDS_QSTR_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING & "=" & IDS_PAGEOPERATIONAUTHORING_CONTINUEAUTHORING_FALSE

	' -- call Internal hook function to allow custom modification of the URL
	Call OnInternalCustomizeAuthSaveURL( AutoSession.This, GetAuthSaveNewPageAndExit )

	' -- call hook function to allow custom modification of the URL
	Call OnCustomizeAuthSaveURL( AutoSession.This, GetAuthSaveNewPageAndExit )

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



%>
