menu.asp
<%@ Language=VBScript%>
<% Option Explicit %>
<%
' to force authentication for connection to SQL Server
If Request.ServerVariables("AUTH_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If
%>
<% Response.Buffer = True %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK href="../forms.css" rel="stylesheet" type="text/css"/>
</HEAD>
<BODY>
<% Dim item,oXML,oXSL,rootResult,perr,errXML,errXSL
Dim language,personAlias,personType,posDelimiter
Dim oRs
Set oXML= Server.CreateObject("Microsoft.XMLDOM")
Set oXSL= Server.CreateObject("Microsoft.XMLDOM")
oXML.async = False
oXSL.async = False
language = Request.QueryString("lang")
If (IsEmpty(language) Or language="") Then language = "en-us"
'DEBUG CODE: hardcoded personType just for checking
personType = "E"
' Response.Write "PATH: " & "../" & language & "/menu/" & personType & "menu.xml" & "<BR>"
oXML.load(Server.MapPath("../" & language & "/menu/" & personType & "menu.xml"))
oXSL.load(Server.MapPath("menu.xsl"))
Set errXML = oXML.parseError
If errXML.errorCode <> 0 Then reportError(errXML)
Set errXSL = oXSL.parseError
If errXSL.errorCode <> 0 Then reportError(errXSL)
call makeMenuXML()
Sub reportError(perr)
Dim serr
serr = "CODE: " & perr.errorCode & "<br>"
serr = serr & "URL: " & perr.url & "<br>"
serr = serr & "LINE: " & perr.line & "<br>"
serr = serr & "SRCTEXT:" & perr.srcText & "<br>"
serr = serr & "REASON: " & perr.reason
Response.Write serr
End Sub
Sub makeMenuXML()
Dim currNode,strNode,toRemoveNode,newNode,childNode
Dim menuArray,oLoadMenu,srcPath,item,sURL
'Adds the servername as an attribute to topmenu node
Set currNode = oXML.selectSingleNode("//topmenu")
sURL = Request.ServerVariables("URL")
currNode.setAttribute "rooturl","http://" & _
Request.ServerVariables("HTTP_HOST") & _
Left(sURL,InStr(2,sURL,"/")-1)
srcPath = server.MapPath("..")
Set oLoadMenu = Server.CreateObject("Litware.Lingo")
If IsEmpty(oLoadMenu) or oLoadMenu Is Nothing Then
Response.Write "Object failed:"
Response.End
End If
Set menuArray = oLoadMenu.LoadMenuOptions(srcPath,"lingo.xml")
strNode = "//menu[@name='Build']"
Set currNode = oXML.selectSingleNode(strNode)
For each item in menuArray
Set newNode = oXML.createElement("menuitem")
Set childNode = currNode.appendChild(newNode)
childNode.setAttribute "itemname",item
childNode.setAttribute "url","/menu/build.asp"
Next
Response.Write oXML.transformNode(oXSL)
Set oLoadMenu = Nothing
End Sub
%>
</BODY>
</HTML>