Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

639 lines
18 KiB

  1. <% '==================================================
  2. ' Microsoft Server Appliance
  3. '
  4. ' Copyright (c) Microsoft Corporation. All rights reserved.
  5. '================================================== %>
  6. <%
  7. '
  8. ' The tab container
  9. '
  10. Public Const TAB_CONTAINER = "TABS"
  11. Dim strSourceNameLoc
  12. Dim g_iNextTabId
  13. g_iNextTabId = 0
  14. strSourceNameLoc = "sakitmsg.dll"
  15. Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
  16. if Err.number <> 0 then
  17. Response.Write "Error in localizing the web content "
  18. Response.End
  19. end if
  20. '-----------------------------------------------------
  21. 'START of localization content
  22. dim L_HELPTOOLTIP_TEXT
  23. dim L_ABOUTLABEL_TEXT
  24. L_HELPTOOLTIP_TEXT = objLocMgr.GetString(strSourceNameLoc,"&H40010023", varReplacementStrings)
  25. L_ABOUTLABEL_TEXT = objLocMgr.GetString(strSourceNameLoc,"&H40010025", varReplacementStrings)
  26. 'End of localization content
  27. '-----------------------------------------------------
  28. Set ObjLocMgr = nothing
  29. '
  30. ' Outputs the tab bar
  31. '
  32. Public Function ServeTabBar()
  33. SA_ServeTabBar(TAB_CONTAINER)
  34. End Function
  35. ' --------------------------------------------------------------
  36. '
  37. ' Function: SA_ServeEmptyTabBar
  38. '
  39. ' Synopsis: Serve an empty tab bar
  40. '
  41. ' Arguments: None
  42. '
  43. ' Returns: Nothing
  44. '
  45. ' --------------------------------------------------------------
  46. Public Function SA_ServeEmptyTabBar()
  47. SA_ClearError()
  48. Call EmitTabPageHeader()
  49. '
  50. ' First level tabs
  51. '
  52. rw "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
  53. rw "<tr>"
  54. ' This sets the height of the table
  55. rw "<td height=20 width=""100%"" class=""InActiveTab"" valign=middle align=right>"
  56. rw "</tr></table>"
  57. '
  58. ' Second level tabs
  59. rw "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
  60. rw "<tr>"
  61. ' this sets the height of the second-level tabs
  62. rw "<td height=20 width=""100%"" class=""InActiveTab2"" valign=middle align=right>&nbsp;"
  63. ' close table
  64. rw "</tr></table>"
  65. Call SA_SetLastError(gc_ERR_SUCCESS, "TABS.SA_ServeEmptyTabBar")
  66. SA_ServeEmptyTabBar = gc_ERR_SUCCESS
  67. End Function
  68. Public Function SA_ServeTabBar(ByVal strTabContainer)
  69. Dim colTabs
  70. Call EmitTabPageHeader()
  71. Set colTabs = GetElements(strTabContainer)
  72. Call Assert(colTabs.Count > 0, "No tabs found in container " + strTabContainer)
  73. ' the selected tab of interest
  74. Dim sSelectedID
  75. sSelectedID = GetTab1()
  76. ' the element we're currently at
  77. Dim sElementID
  78. ' the IWebElement object
  79. Dim objElement
  80. ' the secondLevelContainer
  81. Dim sSecondLevelContainer
  82. sSecondLevelContainer = ""
  83. '
  84. ' First level tabs
  85. '
  86. rw "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
  87. rw "<tr>"
  88. For Each objElement In colTabs
  89. sElementID = objElement.GetProperty("ElementID")
  90. rw GetTabLink(objElement, sElementID, IsSameElementID(sElementID, sSelectedID))
  91. If IsSameElementID(sElementID, sSelectedID) Then
  92. sSecondLevelContainer = GetLinksContainer(objElement)
  93. End If
  94. Next ' objElement
  95. Set colTabs = Nothing
  96. ' This sets the height of the table
  97. rw "<td height=20 width=""100%"" class=""InActiveTab"" valign=middle align=right>"
  98. ' this is the help link (or menu)
  99. Call ServeContextHelp()
  100. rw "</td>"
  101. rw "</tr></table>"
  102. If sSecondLevelContainer = "" Then
  103. ' nothing was selected and we can't display the next menu
  104. ' set up the table
  105. rw "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
  106. rw "<tr>"
  107. ' this sets the height of the second-level tabs
  108. rw "<td height=20 width=""100%"" class=""InActiveTab2"" valign=middle align=right>&nbsp;"
  109. ' close table
  110. rw "</tr></table>"
  111. Exit Function
  112. End If
  113. ' now look in this collection
  114. Set colTabs = GetElements(sSecondLevelContainer)
  115. ' get the selected tab
  116. sSelectedID = GetTab2()
  117. ' set up the table
  118. rw "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
  119. rw "<tr>"
  120. ' go through the collection, output as a TaskLink
  121. For Each objElement In colTabs
  122. sElementID = objElement.GetProperty("ElementID")
  123. rw GetTaskLink(objElement, sElementID, IsSameElementID(sElementID, sSelectedID))
  124. ' don't check to see if it's selected because we don't care (only 2 levels deep)
  125. Next 'objElement
  126. Set colTabs = Nothing
  127. ' this sets the height of the second-level tabs
  128. rw "<td height=20 width=""100%"" class=""InActiveTab2"" valign=middle align=right>&nbsp;</td>"
  129. ' close table
  130. rw "</tr></table>"
  131. Call EmitTabPageFooter()
  132. End Function
  133. Private Function ServeContextHelp()
  134. Dim objContextHelp
  135. Dim objElement
  136. Set objContextHelp = GetElements("ContextHelpLink")
  137. For each objElement in objContextHelp
  138. Dim strCaption
  139. Dim strDescription
  140. Dim strLongDescription
  141. Dim strURL
  142. Dim strResourceDLL
  143. strResourceDLL = objElement.GetProperty("Source")
  144. strCaption = GetLocalized(strResourceDLL, objElement.GetProperty("CaptionRID"))
  145. If ( Len( objElement.GetProperty("DescriptionRID") ) > 0 ) Then
  146. strDescription = GetLocalized(strResourceDLL, objElement.GetProperty("DescriptionRID"))
  147. Else
  148. strDescription = ""
  149. End If
  150. If ( Len( objElement.GetProperty("LongDescriptionRID") ) > 0 ) Then
  151. 'strLongDescription = SA_EncodeQuotes(GetLocalized(strResourceDLL, objElement.GetProperty("LongDescriptionRID")))
  152. strLongDescription = GetLocalized(strResourceDLL, objElement.GetProperty("LongDescriptionRID"))
  153. Else
  154. strLongDescription = ""
  155. End If
  156. strURL = objElement.GetProperty("URL")
  157. strURL = strURL & "?" & SAI_FLD_PAGEKEY & "=" & SAI_GetPageKey() & _
  158. "&URL=" & Server.URLEncode(Request.ServerVariables("URL") & _
  159. "?" & Request.ServerVariables("QUERY_STRING"))
  160. Response.Write("&nbsp;<a id='ContextHelp' ")
  161. Response.Write(" onclick=""javascript: var objWnd ; objWnd = window.open('" + m_VirtualRoot + strURL +"' , '_spawnHelp', 'toolbar=no, status=no, menubar=no, height=350,width=500, top=65, left=125 location=no, scrollbars=yes, resizable=yes'); objWnd.focus() ;"" return false; ")
  162. 'Response.Write(" onclick=""javascript: var objWnd ; objWnd = window.open('" + m_VirtualRoot + strURL +"' , '_spawnHelp', 'toolbar=no, status=no, menubar=no, height=350,width=500, top=65, left=125 location=no, scrollbars=yes, resizable=yes'); objWnd.focus(); objWnd.setActive() ; return false; "" ")
  163. Response.Write("class=""InActiveTabNoBorder"" onmouseover=""window.status=''; this.className='InActiveTabNoBorderHover'; return true;"" onmouseout=""window.status=''; this.className='InActiveTabNoBorder'; return true;"" ")
  164. Response.Write(" title="""+Server.HTMLEncode(strLongDescription)+""" ")
  165. Response.Write(" >")
  166. Response.Write("<b>?</b>")
  167. Response.Write("</a>&nbsp;")
  168. Exit For
  169. Next
  170. End Function
  171. Function GetElements(container)
  172. 'Return collection of IWebElement objects based on the Container parm.
  173. Dim objRetriever
  174. Dim objElements
  175. Set objRetriever = Server.CreateObject("Elementmgr.ElementRetriever")
  176. Set objElements = objRetriever.GetElements(1, container)
  177. Set GetElements = objElements
  178. Set objElements = Nothing
  179. Set objRetriever = Nothing
  180. End Function
  181. Function IsRawURLPage(ByVal pageType)
  182. On Error Resume Next
  183. IsRawURLPage = FALSE
  184. If ( UCase(pageType) = "RAW" ) Then
  185. IsRawURLPage = TRUE
  186. End If
  187. Err.Clear
  188. End Function
  189. '
  190. '' Wrapper for Response.Write
  191. '
  192. Function rw(v)
  193. Response.Write v
  194. Response.Write vbCrLf
  195. End Function
  196. '
  197. '' Gets the first level tab, always a string
  198. '
  199. Function GetTab1()
  200. Dim strTab
  201. strTab = Request.QueryString("tab1")
  202. if strTab = "" then
  203. strTab = Request.Form("tab1")
  204. end if
  205. GetTab1 = strTab
  206. End Function
  207. '
  208. '' Gets the second level tab, always a string
  209. '
  210. Function GetTab2()
  211. Dim strTab
  212. strTab = Request.QueryString("tab2")
  213. if strTab = "" then
  214. strTab = Request.Form("tab2")
  215. end if
  216. GetTab2 = strTab
  217. End Function
  218. '
  219. ''Get the URL for the current Primary Tab
  220. '
  221. Private Function SAI_GetCurrentPrimaryTabURL(ByVal bIncludeVirtualRoot)
  222. Dim strLink
  223. Dim colTabs
  224. Set colTabs = GetElements(TAB_CONTAINER)
  225. ' the selected tab of interest
  226. Dim sSelectedID
  227. sSelectedID = GetTab1()
  228. ' the element we're currently at
  229. Dim sElementID
  230. ' the IWebElement object
  231. Dim objElement
  232. ' go through each element and find the current one
  233. For Each objElement In colTabs
  234. sElementID = objElement.GetProperty("ElementID")
  235. If IsSameElementID(sElementID, sSelectedID) Then
  236. strLink = objElement.GetProperty("URL")
  237. If InStr(strLink, "?") = 0 Then
  238. strLink = strLink & "?tab1=" & sElementID
  239. else
  240. strLink = strLink & "&tab1=" & sElementID
  241. end if
  242. Exit For
  243. End If
  244. Next ' objElement
  245. Set colTabs = Nothing
  246. If ( TRUE = bIncludeVirtualRoot ) Then
  247. strLink = GetVirtualDirectory() & strLink
  248. End If
  249. If (0 = InStr(1, strLink, ":")) Then
  250. Call SA_MungeURL(strLink, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  251. End If
  252. SAI_GetCurrentPrimaryTabURL = strLink
  253. End Function
  254. Public Function GetCurrentPrimaryTabURL()
  255. GetCurrentPrimaryTabURL = SAI_GetCurrentPrimaryTabURL(TRUE)
  256. End Function
  257. '
  258. '' Asserts that bCondition is true
  259. '
  260. Function Assert(ByVal bCondition, ByVal sText)
  261. If Not bCondition Then
  262. Err.Raise 1, sText
  263. Response.End
  264. End If
  265. End Function
  266. '
  267. '' Returns the Container that should be used to find children elements
  268. '' (was the Source and CaptionRID, now it's the ElementID)
  269. '
  270. Function GetLinksContainer(objElement)
  271. Dim s
  272. ' s = objElement.GetProperty("Source")
  273. ' s = s & objElement.GetProperty("CaptionRID")
  274. s = objElement.GetProperty("ElementID")
  275. GetLinksContainer = s
  276. End Function
  277. '
  278. '' Returns the title and onmouseover encoding for inside any html element.
  279. '
  280. Function GetHoverText(ByVal sText, ByVal sClassName)
  281. on error goto 0
  282. Dim s
  283. Dim sStatusText
  284. sStatusText = sText
  285. sStatusText = SA_EncodeQuotes(sStatusText)
  286. s = " title=""" + Server.HTMLEncode(sText) + """ "
  287. s = s & " onmouseout=""window.status=''; this.className='" & sClassName & "NoBorder';return true;"" "
  288. s = s & " onmouseover=""window.status='" + sStatusText + "'; this.className='" + sClassName + "NoBorderHover" + "'; return true;"" "
  289. GetHoverText = s
  290. End Function
  291. '
  292. '' Returns the localized string (should use LocMan)
  293. '
  294. Function GetLocalized(sSourceDLL, sHex)
  295. dim varReplacementStrings
  296. ' GetLocalized = sSourceDLL & sHex
  297. GetLocalized = getLocString(sSourceDLL, sHex, varReplacementStrings)
  298. If GetLocalized = "" then
  299. GetLocalized = sSourceDLL & sHex
  300. End If
  301. End Function
  302. Function GetLink(objElement, sHref, sClassName, sClassName2, bAddReturnURL)
  303. on error resume next
  304. Dim s
  305. Dim strURL
  306. Dim strTitle
  307. Dim strTaskTitle
  308. Dim strPageType
  309. Dim strWindowFeatures
  310. Dim sReturnURL
  311. Dim sOpenPageURL
  312. strTitle = GetLocalized(objElement.GetProperty("Source"), objElement.GetProperty("CaptionRID"))
  313. strTaskTitle = strTitle
  314. strPageType = objElement.GetProperty("PageType")
  315. strWindowFeatures = objElement.GetProperty("WindowFeatures")
  316. 'make the href
  317. s = "<td nowrap class=""" & sClassName & """>&nbsp;"
  318. if objElement.GetProperty("IsEmbedded") = 1 then
  319. s = s & "<a onclick=""" + "OpenPage('" & m_VirtualRoot & "', '" & sHref & "', '"+GetCurrentPrimaryTabURL()+"', '" & SA_EncodeQuotes(strTaskTitle) & "'); "" "
  320. Elseif (Len(Trim(strPageType)) > 0) Then
  321. Select Case UCase(Trim(strPageType))
  322. Case "NORMAL"
  323. sOpenPageURL = sHref
  324. If ( TRUE = bAddReturnURL ) Then
  325. sReturnURL = SAI_GetCurrentPrimaryTabURL(FALSE)
  326. Call SA_MungeURL(sOpenPageURL, "ReturnURL", sReturnURL)
  327. End If
  328. strURL = "javascript:OpenNormalPage('" & m_VirtualRoot & "', '" & sOpenPageURL & "');"
  329. Case "FRAMESET"
  330. strURL = "javascript:OpenPage('" & m_VirtualRoot & "', '" & sHref & "', '"+GetCurrentPrimaryTabURL()+"', '" & SA_EncodeQuotes(strTaskTitle) & "');"
  331. Case "NEW"
  332. strURL = "javascript:OpenNewPage('" & m_VirtualRoot & "', '" & sHref & "', '" & strWindowFeatures & "');"
  333. Case "RAW"
  334. strURL = "javascript:OpenRawPageEx('" & sHref & "', '" & strWindowFeatures & "');"
  335. Case Else
  336. SA_TraceOut "TABS", "Invalid Task PageType: " + strPageType
  337. sOpenPageURL = sHref
  338. If ( TRUE = bAddReturnURL ) Then
  339. sReturnURL = SAI_GetCurrentPrimaryTabURL(FALSE)
  340. Call SA_MungeURL(sOpenPageURL, "ReturnURL", sReturnURL)
  341. End If
  342. strURL = "javascript:OpenNormalPage('" & m_VirtualRoot & "', '" & sOpenPageURL & "');"
  343. End Select
  344. s = s + "<a onclick=""" + strURL + """ "
  345. else
  346. sOpenPageURL = sHref
  347. If ( TRUE = bAddReturnURL ) Then
  348. sReturnURL = SAI_GetCurrentPrimaryTabURL(FALSE)
  349. Call SA_MungeURL(sOpenPageURL, "ReturnURL", sReturnURL)
  350. End If
  351. s = s + "<a onclick=""" + "OpenNormalPage('" + m_VirtualRoot + "', '" + sOpenPageURL + "');"" "
  352. end if
  353. 'get the id attribute, needed by TEST folks
  354. s = s & " id='MenuItem_" & CStr(GetNextTabId()) + "' "
  355. 'get the class
  356. s = s & "class=""" & sClassName & "NoBorder"" "
  357. 'add the event handler for the IsOkayToChangeTabs(); function
  358. 's = s & "onclick=""return IsOkayToChangeTabs();"" "
  359. 'make hovertext from the DescriptionRID
  360. If ( Len( objElement.GetProperty("DescriptionRID") ) > 0 ) Then
  361. s = s & GetHoverText(GetLocString(objElement.GetProperty("Source"), objElement.GetProperty("DescriptionRID"), ""), sClassName)
  362. Else
  363. s = s & GetHoverText("", sClassName)
  364. End If
  365. 'build link content from the CaptionRID
  366. s = s & ">" & strTitle
  367. 'close link
  368. s = s & "</a>&nbsp;</td>"
  369. s = s & "<td width=2 class=""" & sClassName2 & """>"
  370. s = s & "<IMG SRC='" + m_VirtualRoot + "images/TabSeparator.gif' WIDTH='2' HEIGHT='15' ALIGN='ABSMIDDLE' BORDER='0'>"
  371. s = s & "</td>"
  372. GetLink = s
  373. End Function
  374. '
  375. '' Adds i &nbsp;s to both sides of v
  376. '
  377. Function GetPadded(v, i)
  378. Dim s
  379. s = Replace(String(i, " "), " ", "&nbsp;")
  380. GetPadded = s & v & s
  381. End Function
  382. '
  383. '' This is an equivalent of VB's IIf function. Both vIfTrue and vIfFalse are evaluated,
  384. '' unlike the ternary ? : operator (watch for side effects [div 0, etc.]).
  385. '
  386. Function IIf(bCondition, vIfTrue, vIfFalse)
  387. If bCondition Then
  388. IIf = vIfTrue
  389. Else
  390. IIf = vIfFalse
  391. End If
  392. End Function
  393. '
  394. '' Formats the tab link, differently if bIsSelected
  395. '
  396. Function GetTabLink(objElement, sElementID, bIsSelected)
  397. on error resume next
  398. Dim strLink
  399. Dim pageType
  400. pageType = objElement.GetProperty("PageType")
  401. '
  402. ' We do not alter RAW URL's
  403. If ( IsRawURLPage(pageType) ) Then
  404. strLink = objElement.GetProperty("URL")
  405. '
  406. ' All other PageTypes have the current tab selections appended to the URL
  407. Else
  408. strLink = objElement.GetProperty("URL")
  409. If InStr(strLink, "?") = 0 Then
  410. strLink = strLink & "?tab1=" & objElement.GetProperty("ElementID") 'Server.URLEncode(GetTab1())
  411. else
  412. strLink = strLink & "&tab1=" & objElement.GetProperty("ElementID") 'Server.URLEncode(GetTab1())
  413. end if
  414. End If
  415. If (0 = InStr(1, strLink, ":")) Then
  416. Call SA_MungeURL(strLink, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  417. End If
  418. 'response.write "URL is " & strLink & "<P>"
  419. GetTabLink = GetLink(objElement, strLink, IIf(bIsSelected, "ActiveTab", "InActiveTab"), "InActiveTab", FALSE)
  420. End Function
  421. '
  422. '' Formats the task link, differently if bIsSelected
  423. '
  424. Function GetTaskLink(objElement, sElementID, bIsSelected)
  425. on error resume next
  426. Dim strLink
  427. Dim pageType
  428. pageType = objElement.GetProperty("PageType")
  429. '
  430. ' We do not alter RAW URL's
  431. If ( IsRawURLPage(pageType) ) Then
  432. strLink = objElement.GetProperty("URL")
  433. '
  434. ' All other PageTypes have the current tab selections appended to the URL
  435. Else
  436. strLink = objElement.GetProperty("URL")
  437. If InStr(strLink, "?") = 0 Then
  438. strLink = strLink & "?tab1=" & Server.URLEncode(GetTab1())
  439. else
  440. strLink = strLink & "&tab1=" & Server.URLEncode(GetTab1())
  441. end if
  442. strLink = strLink & "&tab2=" & Server.URLEncode(sElementID)
  443. End If
  444. If (0 = InStr(1, strLink, ":")) Then
  445. Call SA_MungeURL(strLink, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  446. End If
  447. GetTaskLink = GetLink(objElement, strLink, IIf(bIsSelected, "ActiveTab2", "InActiveTab2"), "InActiveTab2", TRUE)
  448. End Function
  449. '
  450. '' Returns true if these are the same element ID. Mainly for capitalization
  451. '' and or/charset issues. Uses case-insensitive, space-trimmed comparison.
  452. '' Has issues with unicode registry keys.
  453. '
  454. Function IsSameElementID(ByVal sElementID1, ByVal sElementID2)
  455. Dim s1, s2
  456. s1 = LCase(Trim(sElementID1))
  457. s2 = LCase(Trim(sElementID2))
  458. IsSameElementID = CBool(s1 = s2)
  459. End Function
  460. Private Function GetNextTabId()
  461. GetNextTabId = g_iNextTabId
  462. g_iNextTabId = g_iNextTabId + 1
  463. End Function
  464. Private Function EmitTabPageHeader()
  465. %>
  466. <html>
  467. <head>
  468. <!-- Microsoft(R) Server Appliance Platform - Web Framework Tabs
  469. Copyright (c) Microsoft Corporation. All rights reserved. -->
  470. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  471. <%
  472. Call SA_EmitAdditionalStyleSheetReferences("")
  473. %>
  474. <script LANGUAGE=javascript>
  475. function IsOkayToChangeTabs()
  476. {
  477. return true;
  478. }
  479. function GetVirtualRoot()
  480. {
  481. return "<%=m_VirtualRoot%>";
  482. }
  483. function GetUnsavedChangesMessage()
  484. {
  485. return '<%=SA_EscapeQuotes(GetLocString("sacoremsg.dll", "402003E8", ""))%>';
  486. }
  487. function GetIsDebugEnabled()
  488. {
  489. //return false;
  490. return <%=SA_IsDebugEnabled%>
  491. }
  492. function SA_GetVersion()
  493. {
  494. return <%=SA_GetVersion()%>;
  495. }
  496. </script>
  497. </head>
  498. <BODY>
  499. <%
  500. End Function
  501. Private Function EmitTabPageFooter()
  502. %>
  503. </BODY>
  504. </html>
  505. <%
  506. End Function
  507. %>