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.

158 lines
4.9 KiB

  1. using System;
  2. using System.Globalization;
  3. using System.IO;
  4. using System.Security.Principal;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.HtmlControls;
  8. using System.Web.UI.WebControls;
  9. using UDDI;
  10. namespace UDDI.Web
  11. {
  12. public class HeaderControl : UserControl
  13. {
  14. protected PlaceHolder beta = null;
  15. protected PlaceHolder test = null;
  16. protected PlaceHolder edit = null;
  17. protected PlaceHolder coordinate = null;
  18. protected UddiLabel user = null;
  19. protected UddiLabel role = null;
  20. //protected string rootpath;
  21. protected string root;
  22. protected string roots;
  23. protected string isoLangCode;
  24. protected string[] links;
  25. protected HtmlSelect quickHelp;
  26. protected HtmlInputButton go;
  27. protected bool frames = false;
  28. public bool Frames
  29. {
  30. get { return frames; }
  31. set { frames = value; }
  32. }
  33. protected override void OnInit( EventArgs e )
  34. {
  35. Response.Expires = -1;
  36. Response.AddHeader( "Cache-Control", "no-cache" );
  37. Response.AddHeader( "Pragma", "no-cache" );
  38. root = HyperLinkManager.GetHyperLink( "" );
  39. roots = HyperLinkManager.GetSecureHyperLink( "" );
  40. if( null != beta && 1 == Config.GetInt( "Web.BetaSite", 0 ) )
  41. beta.Visible = true;
  42. if( null != test && 1 == Config.GetInt( "Web.TestSite", 0 ) )
  43. test.Visible = true;
  44. }
  45. protected override void OnLoad( EventArgs e )
  46. {
  47. if( !Page.IsPostBack && null != links )
  48. {
  49. for( int i = 0; i < links.Length; i += 2 )
  50. {
  51. string filename = links[ i + 1 ];
  52. //
  53. // 'cultureIDValue is expected to contain a neutral culture. ie,
  54. // 'en', or 'ko', or 'de'. All but a few neutral cultures have
  55. // a default specific culture. For example, the default specific
  56. // culture of 'en' is 'en-US'.
  57. //
  58. // Traditional & simplified Chinese (zh-CHT and zh-CHS respectively)
  59. // are examples of neutral cultures which have no default specific
  60. // culture!
  61. //
  62. // So what happens below is this: First we try to lookup the default
  63. // specific culture for the neutral culture that we were given. If that
  64. // fails (ie, if CreateSpecificCulture throws), we just get the lcid
  65. // of the neutral culture.
  66. //
  67. string defaultlang = Config.GetString( "Setup.WebServer.ProductLanguage","en" );
  68. int defaultlcid = 1033;
  69. int userlcid = Localization.GetCulture().LCID;
  70. try
  71. {
  72. defaultlcid = CultureInfo.CreateSpecificCulture( defaultlang ).LCID;
  73. }
  74. catch
  75. {
  76. CultureInfo ci = new CultureInfo( defaultlang );
  77. defaultlcid = ci.LCID;
  78. }
  79. string url = root + "/help/" + userlcid.ToString()+ "/" + filename;
  80. if( !File.Exists( Server.MapPath( url ) ) )
  81. {
  82. //
  83. // If the language the user wants isn't available user the defualt lang.
  84. //
  85. url = root +"/help/" + defaultlcid.ToString() + "/" + filename;
  86. }
  87. ListItem listItem = new ListItem(
  88. Localization.GetString( links[ i ] ),
  89. url );
  90. quickHelp.Items.Add( listItem );
  91. }
  92. go.Value = Localization.GetString( "BUTTON_GO" );
  93. go.Attributes.Add( "onclick", "ShowQuickHelp( '" + quickHelp.UniqueID + "' )" );
  94. quickHelp.Attributes.Add( "onchange", "ShowQuickHelp( '" + quickHelp.UniqueID + "' )" );
  95. }
  96. }
  97. protected override void Render( HtmlTextWriter output )
  98. {
  99. if( null != edit )
  100. edit.Visible = UDDI.Context.User.IsPublisher;
  101. if( null != coordinate )
  102. coordinate.Visible = UDDI.Context.User.IsCoordinator;
  103. if( null != user )
  104. {
  105. if( UDDI.Context.User.IsImpersonated )
  106. user.Text = String.Format( Localization.GetString( "TAG_IMPERSONATING_USER" ), UDDI.Context.User.ID );
  107. else
  108. user.Text = String.Format( Localization.GetString( "TAG_USER" ), UDDI.Context.User.ID );
  109. }
  110. if( null != role )
  111. {
  112. string roleName;
  113. if( UDDI.Context.User.IsAdministrator )
  114. roleName = Localization.GetString( "ROLE_ADMINISTRATOR" );
  115. else if( UDDI.Context.User.IsCoordinator )
  116. roleName = Localization.GetString( "ROLE_COORDINATOR" );
  117. else if( UDDI.Context.User.IsPublisher )
  118. roleName = Localization.GetString( "ROLE_PUBLISHER" );
  119. else if( UDDI.Context.User.IsUser )
  120. roleName = Localization.GetString( "ROLE_USER" );
  121. else
  122. roleName = Localization.GetString( "ROLE_ANONYMOUS" );
  123. role.Text = String.Format( Localization.GetString( "TAG_ROLE" ), roleName );
  124. }
  125. base.Render( output );
  126. }
  127. }
  128. }