PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Web/DesignTools/CacheTool.aspx.cs

#
C# | 151 lines | 101 code | 39 blank | 11 comment | 3 complexity | 0d6d91e3154e0e418f37e5f84a1f8915 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause, CPL-1.0, CC-BY-SA-3.0, GPL-2.0
  1. // Author: Joe Audette
  2. // Created: 2011-03-14
  3. // Last Modified: 2011-11-21
  4. //
  5. // The use and distribution terms for this software are covered by the
  6. // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
  7. // which can be found in the file CPL.TXT at the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by
  9. // the terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Configuration;
  16. using System.Data;
  17. using System.Globalization;
  18. using System.Web;
  19. using System.Web.Security;
  20. using System.Web.UI;
  21. using System.Web.UI.WebControls;
  22. using System.Web.UI.WebControls.WebParts;
  23. using System.Web.UI.HtmlControls;
  24. using mojoPortal.Web;
  25. using mojoPortal.Web.Framework;
  26. using mojoPortal.Web.UI;
  27. using log4net;
  28. using mojoPortal.Business;
  29. using mojoPortal.Business.WebHelpers;
  30. using Resources;
  31. namespace mojoPortal.Web.AdminUI
  32. {
  33. public partial class CacheToolPage : mojoBasePage
  34. {
  35. private string cssCacheCookieName = string.Empty;
  36. protected void Page_Load(object sender, EventArgs e)
  37. {
  38. if ((!WebUser.IsInRoles(siteSettings.RolesThatCanManageSkins)))
  39. {
  40. SiteUtils.RedirectToAccessDeniedPage(this);
  41. return;
  42. }
  43. LoadSettings();
  44. PopulateLabels();
  45. PopulateControls();
  46. }
  47. private void PopulateControls()
  48. {
  49. lblSkinGuid.Text = siteSettings.SkinVersion.ToString();
  50. if (CookieHelper.CookieExists(cssCacheCookieName))
  51. {
  52. btnCssCacheToggle.Text = DevTools.EnableCssCaching;
  53. }
  54. else
  55. {
  56. btnCssCacheToggle.Text = DevTools.DisableCssCaching;
  57. }
  58. }
  59. void btnCssCacheToggle_Click(object sender, EventArgs e)
  60. {
  61. if (CookieHelper.CookieExists(cssCacheCookieName))
  62. {
  63. HttpCookie cssCookie = new HttpCookie(cssCacheCookieName, string.Empty);
  64. cssCookie.Expires = DateTime.Now.AddMinutes(-10);
  65. cssCookie.Path = "/";
  66. Response.Cookies.Add(cssCookie);
  67. }
  68. else
  69. {
  70. CookieHelper.SetPersistentCookie(cssCacheCookieName, "true");
  71. }
  72. WebUtils.SetupRedirect(this, Request.RawUrl);
  73. }
  74. void btnResetSkinVersionGuid_Click(object sender, EventArgs e)
  75. {
  76. siteSettings.SkinVersion = Guid.NewGuid();
  77. siteSettings.Save();
  78. CacheHelper.ClearSiteSettingsCache(siteSettings.SiteId);
  79. WebUtils.SetupRedirect(this, Request.RawUrl);
  80. }
  81. private void PopulateLabels()
  82. {
  83. Title = SiteUtils.FormatPageTitle(siteSettings, DevTools.CacheTool);
  84. lnkAdminMenu.Text = Resource.AdminMenuLink;
  85. lnkAdminMenu.NavigateUrl = SiteRoot + "/Admin/AdminMenu.aspx";
  86. lnkAdvancedTools.Text = Resource.AdvancedToolsLink;
  87. lnkAdvancedTools.NavigateUrl = SiteRoot + "/Admin/AdvancedTools.aspx";
  88. lnkDesignerTools.Text = DevTools.DesignTools;
  89. lnkDesignerTools.NavigateUrl = SiteRoot + "/DesignTools/Default.aspx";
  90. lnkThisPage.Text = DevTools.CacheTool;
  91. lnkThisPage.NavigateUrl = SiteRoot + "/DesignTools/CacheTool.aspx";
  92. btnResetSkinVersionGuid.Text = Resource.ResetSkinVersionGuid;
  93. }
  94. private void LoadSettings()
  95. {
  96. cssCacheCookieName = SiteUtils.GetCssCacheCookieName(siteSettings);
  97. AddClassToBody("administration");
  98. AddClassToBody("designtools");
  99. }
  100. #region OnInit
  101. override protected void OnInit(EventArgs e)
  102. {
  103. base.OnInit(e);
  104. this.Load += new EventHandler(this.Page_Load);
  105. btnCssCacheToggle.Click += new EventHandler(btnCssCacheToggle_Click);
  106. btnResetSkinVersionGuid.Click += new EventHandler(btnResetSkinVersionGuid_Click);
  107. SuppressMenuSelection();
  108. SuppressPageMenu();
  109. }
  110. #endregion
  111. }
  112. }