<%@CODEPAGE=65001%>
<!--#include virtual="/NR/System/WBC/Internals/Main/WBCApp.inc"-->
<!--#include file="Dependency.inc"-->

<%
	Response.CharSet = "UTF-8"
	'--- Get parameters out of URL
	Dim strNodeGuid
	strNodeGuid = Request.QueryString("NRNODEGUID")

	'--- Set the token cookie if it is in the QueryString
	SetAuthTokenCookie

	'--- Get Session and Server Object
	Set g_pAESession = AutoSession.Session
	Set g_pAEServer = AutoSession.Server

	'-- Retrieve the main object
	Dim pAENode
	Set pAENode=g_pAEServer.GetNodeByGuid(strNodeGuid, True)

%>

<HTML>
	<HEAD>
	<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
	<title><%= IDS_UI_BROWSER_TITLE %></title>

	<link rel="stylesheet" TYPE="text/css" href="/NR/System/WBC/Customizable/WBC.css">

	</HEAD>

<BODY <%= IDS_BODYSETTING %> class="WBC_styclsTextColor0">

<table height="90%" width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr valign=top >
		<td>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<!-- Show the Main Header -->
				<tr class="WBC_styclsBackground1">
					<td align=right><img border=0 src="/NR/System/WBC/Internals/WBCFuncPages/CommonImages/Logos/LogoMSCMS-WBC.gif"></td>
					<td width=100% valign="middle"  class="WBC_styclsHeaderText">
						Dependent Report
					</td>
					<td><img src="<%=IDS_TRANSPARENT_GIF%>"
								width="<%= C_INT_MAIN_MARGIN %>" height="<%=C_INT_HEADER_HEIGHT%>" border="0"></td>
				</tr>

				<!-- Show the Sub Header -->
				<tr class="WBC_styclsBackground2">
					<td><img src="<%=IDS_TRANSPARENT_GIF%>"
						width="15" height="<%=C_INT_SUBHEAD_HEIGHT%>" border="0"></td>
					<td height="25" class="WBC_styclsSubheadText">
						Objects Using This Template
					</td>
					<td><img src="<%=IDS_TRANSPARENT_GIF%>"
						width="15" height="<%=C_INT_SUBHEAD_HEIGHT%>" border="0"></td>
				</tr>
				<tr>
					<td colspan=3><img src="<%=IDS_TRANSPARENT_GIF%>"
						width="15" height="<%=C_INT_MAIN_SPACING%>" border="0"></td>
				</tr>

				<!-- Set the margin width for the rest of the page -->
				<tr>
					<td rowspan="999"><img src="<%=IDS_TRANSPARENT_GIF%>"
								width="<%= C_INT_MAIN_MARGIN %>" height="1" border="0"></td>
					<td><img src="<%=IDS_TRANSPARENT_GIF%>"
								width="100%" height="1" border="0"></td>
					<td rowspan="999"><img src="<%=IDS_TRANSPARENT_GIF%>"
								width="<%= C_INT_MAIN_MARGIN %>" height="1" border="0"></td>
				</tr>


				<!-- Write the status box -->
				<tr>
					<td class="WBC_styclsBackground1">
						<table width="100%" border="0" cellspacing="<%= C_INT_THICK_BORDER %>" cellpadding="5">
							<tr class="WBC_styclsBackground3">
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">

										<!-- we show the status box -->
										<tr>
											<td align='left' valign='top' width='1%' NOWRAP><span class="WBC_styclsHeavyTextColor1">Template:</span>&nbsp;&nbsp;</td>
											<td align='left' valign='top' ><span class="WBC_styclsTextColor1">
											<%= Server.HTMLEncode(pAENode.Name) %>
											</span></td>
										</tr>
										<tr>
											<td align='left' valign='top' width='1%' NOWRAP><span class="WBC_styclsHeavyTextColor1">Template Gallery:</span>&nbsp;&nbsp;</td>
											<td align='left' valign='top' ><span class="WBC_styclsTextColor1"><%= GetPath(pAENode.Parent) %></span></td>
										</tr>
										<tr>
											<td align='left' valign='top' width='1%' NOWRAP><span class="WBC_styclsHeavyTextColor1">Owner:</span>&nbsp;&nbsp;</td>
											<td align='left' valign='top' ><span class="WBC_styclsTextColor1"><%= Server.HTMLEncode(ShortUserName(pAENode.Owner)) %></span></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td><img src="<%=IDS_TRANSPARENT_GIF%>"
							width="15" height="<%=C_INT_XSMALL_SPACING%>" border="0"></td>
				</tr>


				<!-- Show the details in List -->
				<tr>
					<td>
						<%
							' -------------------------------------------------
							'
							'	Show list of Descktop Client Pages
							'
							' -------------------------------------------------

							'--- Execute Template Dependancy Search
							Dim pAEServerSearchResult
							g_pAEServer.ClearSearch "DependantsOnTemplate"
							g_pAEServer.SetSearchOption "TemplateGuid", strNodeGuid, true
							g_pAEServer.SetSearchOption "FilterByVersion", "Both", true
							Set pAEServerSearchResult = g_pAEServer.ExecuteSearch

							'--- Get title and table flags depending on whether results are Pages or Channels

							Dim bWriteStatus
							Dim bWriteOwner
							Dim bWriteLayoutPreview
							Dim bItemsFound
							Const bWriteRevisedPreview=false

							If (pAEServerSearchResult.Count > 0) then
								bItemsFound = True
							Else
								bItemsFound = False
							End if

							If (bItemsFound = True) then

								'-- Set parameter base on the node type
								Select Case pAEServerSearchResult.Type(0)
									Case AE_NODE_PAGE

										bWriteStatus=true
										bWriteOwner=true
										bWriteLayoutPreview=true

									Case AE_NODE_CHANNEL

										bWriteStatus=false
										bWriteOwner=false
										bWriteLayoutPreview=false

									Case Else
										' do nothing
								End Select

							End If


							'-- Write the result title
							Response.Write "<br><br><div class='WBC_styclsSubheadText'>" + "Desktop Client Pages" + "</div><br>"

							'-- Begin the table
							Response.Write GetTableBegin()

							'-- Write the table headers
							Response.Write GetResultTableHeader(bWriteStatus, bWriteOwner, bWriteLayoutPreview, bWriteRevisedPreview)



							'-- Write the table
							if (pAEServerSearchResult.Count > 0) then
								Response.Write GetResultTable(pAEServerSearchResult, bWriteStatus, bWriteOwner, bWriteLayoutPreview, bWriteRevisedPreview)
							Else
								' Check to see if there are any archived pages dependent on this template
								g_pAEServer.ClearSearch "DependantsOnTemplate"
								g_pAEServer.SetSearchOption "TemplateGuid", strNodeGuid, true
								g_pAEServer.SetSearchOption "MaxNodestoReturn", "1", true
								g_pAEServer.SetSearchOption "FilterByVersion", "Both", true
								g_pAEServer.SetSearchOption "IncludeArchivedNodes", "T", true
								Set pAEServerSearchResult = g_pAEServer.ExecuteSearch

								Response.Write "<TR NOWRAP ALIGN='CENTER' class='WBC_styclsAlternateRowBg1'><TD COLSPAN='6' class='WBC_styclsTextColor0'>" + vbCrLf

								if (pAEServerSearchResult.Count > 0) then
									Response.Write "The only dependents found are versions in the Page Archive" + vbCrLf
								Else
									Response.Write "No Desktop Client Pages are using this Template" + vbCrLf
								end if

								Response.Write "</TD></TR>" + vbCrLf
							end if


							'-- End the table
							Response.Write GetTableEnd()
						%>
					</td>
				</tr>
			</table>
		</td>
	</tr>

</table>

</BODY>
</HTML>
