using System; using System.Collections; using System.Data; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Text; using System.ComponentModel; public class WebBlockPage : Page { private DatabaseClass _Database = null; public DatabaseClass Database { get { if (_Database == null) _Database = DatabaseClass.Current; // this will auto-create our connection return _Database; } } public bool HideOverlayMenu = false; private string _RelativePath; public string RelativePath { get { if (_RelativePath == null) _RelativePath = (Page.Request.ApplicationPath.Length == 1 ? "" : Page.Request.ApplicationPath); return _RelativePath; } } public string SitePath { get { return System.Configuration.ConfigurationManager.AppSettings["SitePath"]; } } public string SecureSitePath { get { return System.Configuration.ConfigurationManager.AppSettings["SecureSitePath"]; } } private bool _SecurePage = false; public bool SecurePage { get { return _SecurePage; } set { _SecurePage = value; } } protected override void OnInit(EventArgs e) { if (!Request.IsLocal && Configuration.Get("UseSSL") == "On") { // make sure we're on the right site (secure or not) if (SecurePage && !Request.IsSecureConnection) Response.Redirect(SecureSitePath + Request.Url.PathAndQuery.Remove(0, RelativePath.Length)); else if (!SecurePage && Request.IsSecureConnection) Response.Redirect(SitePath + Request.Url.PathAndQuery.Remove(0, RelativePath.Length)); } // if this is a regular web blocks page, we also want to add in our administrative menu // we'll use page.registerstartupscript if (Session["WebBlocksEditFlag"] != null && !HideOverlayMenu) { System.Text.StringBuilder wbWindow = new System.Text.StringBuilder(); wbWindow.Append(""); wbWindow.Append("
"); wbWindow.Append("Web Blocks Control Panel

"); wbWindow.Append("Home
"); wbWindow.Append("Log Out

"); // Check if user wants to toggle the preview flag if (Request.QueryString["preview"] != null && Int32.Parse(Request.QueryString["preview"]) == 1) Session["WebBlocksPreviewFlag"] = true; else if (Request.QueryString["preview"] != null && Int32.Parse(Request.QueryString["preview"]) == 0) Session["WebBlocksPreviewFlag"] = null; // Create the preview link (exclude preview querystring if there is one) string link = Request.Path + "?"; for (int i = 0; i < Request.QueryString.Count; i = i + 1) if(Request.QueryString.Keys[i] != "preview") link = link + Request.QueryString.Keys[i] + "=" + Request.QueryString[i] + "&"; if (Session["WebBlocksPreviewFlag"] != null) { wbWindow.Append("View Live Blocks
"); wbWindow.Append("
Approve changes"); wbWindow.Append("
Deny changes"); } else { wbWindow.Append("View Draft"); } wbWindow.Append("
"); ClientScript.RegisterStartupScript(typeof(string), "webBlocksWindow", wbWindow.ToString()); } base.OnInit (e); } protected override void OnUnload(EventArgs e) { if (_Database != null) _Database.Dispose(); base.OnUnload(e); } #region WebMarketPro specific stuff public ShoppingCart ShoppingCart { get { if (Session["ShoppingCart"] == null) Session["ShoppingCart"] = ShoppingCart.CreateShoppingCart(); return (ShoppingCart)Session["ShoppingCart"]; } } public CustomerInfo CustomerInfo { get { return (CustomerInfo)Session["CustomerInfo"]; } set { Session["CustomerInfo"] = value; } } #endregion }