<!--#include virtual="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/EmitterThinEdit.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."
' ********************************************************************


Class CPlaceholderEmitter
    Public Name
    Public Width
    Public Height
    Public Rows 
    Public Columns 
    Public Style
    Public HtmlSrcCodeEditable
    Public pPlaceholder
    
    Private Sub Class_Initialize()
        call SetDefaultValues
    End Sub
    
    Public Sub SetDefaultValues()
        Name = ""
        Width = 150
        Height = 150
        Style = ""
        Rows = 25 
        Columns = 40
        HtmlSrcCodeEditable = false
    End Sub
    
    Public Sub Emit(phName)
        Name = phName
        InternalEmitPlaceholder(me)
        call SetDefaultValues
    End Sub
End Class

Dim PlaceholderEmitter
set PlaceholderEmitter = new CPlaceholderEmitter

Sub EmitPlaceholder(strPhName)
	PlaceholderEmitter.Emit(strPhName)
End Sub


' ---- [Public] This subroutine retrieves the placeholder object and writes its contents.
Sub InternalEmitPlaceholder(PlaceholderEmitter)
	Dim pThis

	Set pThis = AutoSession.This
	Set PlaceholderEmitter.pPlaceholder = pThis.Placeholders(PlaceholderEmitter.Name)
	If PlaceholderEmitter.pPlaceholder is Nothing Then
		Exit Sub
	End If

	Dim strEmit
	strEmit = Request.QueryString(IDS_QPARAM_NREMIT)

	' Call hook function to invoke customzied script before the operation
	If OnInternalBeforeEmit( pThis, PlaceholderEmitter.Name, strEmit ) And _
		OnBeforeEmit( pThis, PlaceholderEmitter.Name, strEmit ) Then

		If strEmit = IDS_EMIT_THINEDIT Then
			' only emit for Posting placeholders under ThinEdit mode
			If (PlaceholderEmitter.pPlaceholder.IsEditable And Not pThis.IsChannel) Then
				Call EmitPh4ThinEdit( pThis, PlaceholderEmitter )
			Else
				' no need to filter illegal content
				Call EmitPh4View( PlaceholderEmitter, False )
			End If
		ElseIf strEmit = IDS_EMIT_WIN32EDIT Then
			Call EmitPh4Win32Edit( PlaceholderEmitter )
		Else
			' no need to filter illegal content
			Call EmitPh4View( PlaceholderEmitter, False )
		End If

		' Call Internal Hook
		Call OnInternalAfterEmit( pThis, PlaceholderEmitter.Name, strEmit )

		' Call External Customizable Hook
		Call OnAfterEmit( pThis, PlaceholderEmitter.Name, strEmit )
		
	End If
End Sub

' ---- [Private] This subroutine writes placeholder contents for Win32 Client editing.
Sub EmitPh4Win32Edit(PlaceholderEmitter)
	Dim strPhName
	strPhName = PlaceholderEmitter.pPlaceholder.Name
%>
	<object	id="<%= Server.HTMLEncode(strPhName) %>" name="<%= Server.HTMLEncode(strPhName) %>"
		classid="clsid:57CC8933-4975-11D1-888F-006097B58A00"
		width="<%= Server.HTMLEncode(PlaceholderEmitter.Width) %>"
		height="<%= Server.HTMLEncode(PlaceholderEmitter.Height)%>" >
		<param name="ControlName" value="<%= Server.HTMLEncode(strPhName) %>">
	</object>
<%
End Sub


' ---- [Private] This subroutine writes placeholder contents in placeholder html.
Sub EmitPh4View( PlaceholderEmitter, bFilter )
	Dim strHTML

	' filter illegal content based on bFilter value passed in
	strHTML = PlaceholderEmitter.pPlaceholder.GetHTML( bFilter )

	' 1 special case: placeholder content is empty and it's a template and
	'			we are not doing content-switching preview for a new posting
	If (AutoSession.IsUsingTemplate) And (strHTML = "") And _
		(Request.QueryString(IDS_QPARAM_WBCACCEPT) = "" ) Then
		strHTML = "<table border=1><tr><th>Placeholder " & Server.HTMLEncode(PlaceholderEmitter.pPlaceholder.Name) & " is inserted here</th></tr></table>"
	End If
	Response.Write(strHTML)
End Sub
%>