Line 1: // ------------------------------------------------------------------------------------------
Line 2: // Copyright AspDotNetStorefront.com, 1995-2006. All Rights Reserved.
Line 3: // http://www.aspdotnetstorefront.com
Line 4: // For details on this license please visit the product homepage at the URL above.
Line 5: // THE ABOVE NOTICE MUST REMAIN INTACT.
Line 6: // $Header: /v6.2/Web/App_Code/SkinBase.cs 8 7/17/06 5:29p Abailey $
Line 7: // ------------------------------------------------------------------------------------------
Line 8: using System;
Line 9: using System.Collections;
Line 10: using System.IO;
Line 11: using System.Resources;
Line 12: using System.Globalization;
Line 13: using System.Reflection;
Line 14: using System.Text;
Line 15: using System.Text.RegularExpressions;
Line 16: using System.Web;
Line 17: using System.Data;
Line 18: using System.Xml;
Line 19: using System.Web.UI;
Line 20: using System.Web.UI.HtmlControls;
Line 21: using System.Web.UI.WebControls;
Line 22: using System.ComponentModel;
Line 23: using System.Threading;
Line 24: using AspDotNetStorefrontCommon;
Line 25:
Line 26: namespace AspDotNetStorefront
Line 27: {
Line 28: public class SkinBase : System.Web.UI.Page
Line 29: {
Line 30:
Line 31: private static readonly String ro_SkinCookieName = "SkinID";
Line 32:
Line 33: private String m_ErrorMsg = String.Empty;
Line 34: private bool m_Editing = false;
Line 35: private bool m_DataUpdated = false;
Line 36: //private Regex m_ReMatch = new Regex(@"\(!(.*?)!\)");
Line 37: private bool m_DesignMode = false;
Line 38: private Customer m_ThisCustomer;
Line 39: private String m_SectionTitle = String.Empty;
Line 40: private TemplateBase m_Template = null;
Line 41: private string m_TemplateName = "template.ascx";
Line 42: private int m_SkinID = 1;
Line 43: private String m_SETitle = String.Empty;
Line 44: private String m_SEDescription = String.Empty;
Line 45: private String m_SEKeywords = String.Empty;
Line 46: private String m_SENoScript = String.Empty;
Line 47: private String m_TemplateFN = String.Empty;
Line 48: private bool m_DisableContents = false;
Line 49: private int m_DefaultSkinID = 1;
Line 50: private String m_GraphicsColor = String.Empty;
Line 51: private String m_ContentsBGColor = String.Empty;
Line 52: private String m_PageBGColor = String.Empty;
Line 53: private String m_IGD = String.Empty; // impersonation customer guid for admin phone order entry display of product pages, etc...
Line 54:
Line 55: private System.Collections.Generic.Dictionary<string, EntityHelper> m_EntityHelpers = new System.Collections.Generic.Dictionary<string, EntityHelper>();
Line 56: private Parser m_Parser;
Line 57:
Line 58: public SkinBase(String TemplateName)
Line 59: {
Line 60: m_TemplateName = TemplateName;
Line 61: if (TemplateName.Length == 0)
Line 62: {
Line 63: m_TemplateName = "template.ascx";
Line 64: }
Line 65: m_DesignMode = (HttpContext.Current == null);
Line 66: m_DefaultSkinID = AppLogic.AppConfigUSInt("DefaultSkinID");
Line 67: if (!m_DesignMode)
Line 68: {
Line 69: m_EntityHelpers.Add("Category", new EntityHelper(EntityDefinitions.LookupSpecs("Category")));
Line 70: m_EntityHelpers.Add("Section", new EntityHelper(EntityDefinitions.LookupSpecs("Section")));
Line 71: m_EntityHelpers.Add("Manufacturer", new EntityHelper(EntityDefinitions.LookupSpecs("Manufacturer")));
Line 72: m_EntityHelpers.Add("Distributor", new EntityHelper(EntityDefinitions.LookupSpecs("Distributor")));
Line 73: #if PRO
Line 74: // not supported in PRO
Line 75: #else
Line 76: m_EntityHelpers.Add("Library", new EntityHelper(EntityDefinitions.LookupSpecs("Library")));
Line 77: #endif
Line 78: }
Line 79: }
Line 80:
Line 81: public SkinBase() : this(GetTemplateName()) {}
Line 82:
Line 83: private static string GetTemplateName()
Line 84: {
Line 85: string templateName = CommonLogic.QueryString("template");
Line 86: if (templateName.ToLowerInvariant().IndexOf("<script>") != -1)
Line 87: {
Line 88: throw new ArgumentException("SECURITY EXCEPTION");
Line 89: }
Line 90:
Line 91: if (templateName == null || templateName.Length == 0)
Line 92: {
Line 93: // undocumented feature:
Line 94: templateName = AppLogic.AppConfig("Template" + CommonLogic.GetThisPageName(false));
Line 95: }
Line 96: if (templateName == null || templateName.Length == 0)
Line 97: {
Line 98: templateName = "template";
Line 99: }
Line 100: if (templateName.Length > 0 && !templateName.EndsWith(".ascx"))
Line 101: {
Line 102: // undocumented feature:
Line 103: templateName += ".ascx";
Line 104: }
Line 105: return templateName;
Line 106: }
Line 107:
Line 108: private void FindLocaleStrings(Control c)
Line 109: {
Line 110: System.Web.UI.WebControls.Image i = c as System.Web.UI.WebControls.Image;
Line 111: if (i != null)
Line 112: {
Line 113: if (i.ImageUrl.IndexOf("(!") >= 0)
Line 114: {
Line 115: i.ImageUrl = AppLogic.LocateImageURL(i.ImageUrl.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", string.Empty).Replace("!)", string.Empty), ThisCustomer.LocaleSetting);
Line 116: }
Line 117: }
Line 118: else
Line 119: {
Line 120: System.Web.UI.WebControls.ImageButton b = c as System.Web.UI.WebControls.ImageButton;
Line 121: if (b != null)
Line 122: {
Line 123: if (b.ImageUrl.IndexOf("(!") >= 0)
Line 124: {
Line 125: b.ImageUrl = AppLogic.LocateImageURL(b.ImageUrl.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", string.Empty).Replace("!)", string.Empty), ThisCustomer.LocaleSetting);
Line 126: }
Line 127: }
Line 128: else
Line 129: {
Line 130: IEditableTextControl e = c as IEditableTextControl;
Line 131: if (e != null)
Line 132: {
Line 133: if (!(e is ListControl))
Line 134: {
Line 135: e.Text = AppLogic.GetString(e.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 136: }
Line 137: }
Line 138: else
Line 139: {
Line 140: IValidator v = c as IValidator;
Line 141: if (v != null)
Line 142: {
Line 143: v.ErrorMessage = AppLogic.GetString(v.ErrorMessage.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 144: }
Line 145: ITextControl t = c as ITextControl;
Line 146: if (t != null)
Line 147: {
Line 148: t.Text = AppLogic.GetString(t.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 149: }
Line 150: Button b2 = c as Button;
Line 151: if (b2 != null)
Line 152: {
Line 153: b2.Text = AppLogic.GetString(b2.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 154: }
Line 155: LinkButton l = c as LinkButton;
Line 156: if (l != null)
Line 157: {
Line 158: l.Text = AppLogic.GetString(l.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 159: }
Line 160: HyperLink h = c as HyperLink;
Line 161: if (h != null)
Line 162: {
Line 163: h.Text = AppLogic.GetString(h.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 164: }
Line 165: RadioButton r = c as RadioButton;
Line 166: if (r != null)
Line 167: {
Line 168: r.Text = AppLogic.GetString(r.Text.Replace("(!SKINID!)", SkinID.ToString()).Replace("(!", "").Replace("!)", ""), SkinID, ThisCustomer.LocaleSetting);
Line 169: }
Line 170: }
Line 171: }
Line 172: }
Line 173: if (c.HasControls())
Line 174: {
Line 175: foreach (Control cx in c.Controls)
Line 176: {
Line 177: FindLocaleStrings(cx);
Line 178: }
Line 179: }
Line 180: }
Line 181:
Line 182: protected override void OnInit(EventArgs e)
Line 183: {
Line 184: if (HttpContext.Current != null)
Line 185: {
Line 186: if (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.Cookie("SiteDisclaimerAccepted", true).Length == 0)
Line 187: {
Line 188: String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
Line 189: Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
Line 190: }
Line 191:
Line 192: bool IsAdminLoggedIn = Customer.StaticIsAdminUser(CommonLogic.SessionUSInt("CustomerID"));
Line 193: m_IGD = CommonLogic.QueryString("IGD");
Line 194: bool IsStartOfImpersonation = (CommonLogic.QueryString("IGD").Length != 0); // the url invocation starts the impersonation only!
Line 195: if (m_IGD.Length == 0 && IsAdminLoggedIn)
Line 196: {
Line 197: CustomerSession sess = new CustomerSession(CommonLogic.SessionUSInt("CustomerID"));
Line 198: m_IGD = sess.Session("IGD");
Line 199: sess = null;
Line 200: }
Line 201:
Line 202: if (m_IGD.Length == 0)
Line 203: {
Line 204: m_ThisCustomer = new Customer(); // build the current customer now that an asp.net session is available
Line 205: }
Line 206: else
Line 207: {
Line 208: int PhoneOrderCustomerID = 0;
Line 209: if (IsAdminLoggedIn)
Line 210: {
Line 211: IDataReader rs;
Line 212: try
Line 213: {
Line 214: rs = DB.GetRS("select CustomerID from Customer " + DB.GetNoLock() + " where CustomerGUID=" + DB.SQuote(m_IGD));
Line 215: if (rs.Read())
Line 216: {
Line 217: PhoneOrderCustomerID = DB.RSFieldInt(rs, "CustomerID");
Line 218: }
Line 219: rs.Close();
Line 220: }
Line 221: catch
Line 222: {
Line 223: m_IGD = String.Empty;
Line 224: IsStartOfImpersonation = false;
Line 225: PhoneOrderCustomerID = 0;
Line 226: }
Line 227: }
Line 228: if(PhoneOrderCustomerID != 0)
Line 229: {
Line 230: if (IsStartOfImpersonation)
Line 231: {
Line 232: CustomerSession sess = new CustomerSession(CommonLogic.SessionUSInt("CustomerID"));
Line 233: int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes");
Line 234: if (ImpersonationTimeoutInMinutes == 0)
Line 235: {
Line 236: ImpersonationTimeoutInMinutes = 20;
Line 237: }
Line 238: sess.SetVal("IGD", m_IGD, System.DateTime.Now.AddMinutes(ImpersonationTimeoutInMinutes));
Line 239: sess = null;
Line 240: }
Line 241: m_ThisCustomer = new Customer(PhoneOrderCustomerID, true); // build the impersonation customer the phone order customer
Line 242: }
Line 243: else
Line 244: {
Line 245: m_IGD = String.Empty;
Line 246: CustomerSession sess = new CustomerSession(CommonLogic.SessionUSInt("CustomerID"));
Line 247: sess.ClearVal("IGD");
Line 248: sess = null;
Line 249: m_ThisCustomer = new Customer(); // build the current regularly logged in customer
Line 250: }
Line 251: }
Line 252:
Line 253: Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Localization.GetWebConfigLocale());
Line 254: Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);
Line 255: LoadSkinTemplate();
Line 256: m_Parser = new Parser(m_EntityHelpers, m_SkinID, m_ThisCustomer);
Line 257:
Line 258: if (this.HasControls()) // probably a web form
Line 259: {
Line 260: foreach (Control c in this.Controls)
Line 261: {
Line 262: FindLocaleStrings(c);
Line 263: }
Line 264:
Line 265: Control ctl;
Line 266: int i = 1;
Line 267: int limitLoop = 1000;
Line 268: if (m_Template != null && m_Template.Content != null)
Line 269: {
Line 270: while (this.Controls.Count > 0 && i <= limitLoop)
Line 271: {
Line 272: bool FilterItOut = false;
Line 273: ctl = this.Controls[0];
Line 274: LiteralControl l = ctl as LiteralControl;
Line 275: if (l != null)
Line 276: {
Line 277: String txtVal = l.Text;
Line 278: String txtVallwr = txtVal.ToLowerInvariant();
Line 279: if (txtVallwr.IndexOf("<html") != -1 || txtVallwr.IndexOf("</html") != -1)
Line 280: {
Line 281: FilterItOut = true; // remove outer html/body crap, as we're going to be moving the page controls INSIDE The skin
Line 282: }
Line 283: }
Line 284: if (!FilterItOut)
Line 285: {
Line 286: // reparent the page control to be moved inside the skin template user control
Line 287: m_Template.Content.Controls.Add(ctl);
Line 288: }
Line 289: else
Line 290: {
Line 291: this.Controls.RemoveAt(0);
Line 292: }
Line 293: i++;
Line 294: }
Line 295: }
Line 296: // clear the controls (they were now all moved inside the template user control:
Line 297: this.Controls.Clear();
Line 298: // set the template user control to be owned by this page:
Line 299: this.Controls.Add(m_Template);
Line 300: // Now move the template child controls up to the page level so the ViewState will load
Line 301: while (m_Template.Controls.Count > 0)
Line 302: {
Line 303: this.Controls.Add(m_Template.Controls[0]);
Line 304: }
Line 305: }
Line 306: }
Line 307: base.OnInit(e);
Line 308: }
Line 309:
Line 310: protected override void OnPreRender(EventArgs e)
Line 311: {
Line 312: if (HttpContext.Current != null)
Line 313: {
Line 314: if (!this.HasControls()) //Probably a web form so use the control management technique
Line 315: {
Line 316: if (m_Template.Content != null)
Line 317: {
Line 318: //No controls so html must come from RenderContents. Create a literal to contain RenderContents
Line 319: m_Template.Content.Controls.Add(ParseControl(CreateContent()));
Line 320: }
Line 321: this.Controls.Clear();
Line 322: this.Controls.Add(m_Template);
Line 323: // Now move the template child controls up to the page level so the ViewState will load
Line 324: while (m_Template.Controls.Count > 0)
Line 325: {
Line 326: this.Controls.Add(m_Template.Controls[0]);
Line 327: }
Line 328: }
Line 329: }
Line 330: base.OnPreRender(e);
Line 331: }
Line 332:
Line 333: public string CreateContent()
Line 334: {
Line 335: StringBuilder tmpS = new StringBuilder(25000);
Line 336:
Line 337: //Create a literal to contain RenderContents
Line 338: StringWriter sw = new StringWriter();
Line 339: HtmlTextWriter htw = this.CreateHtmlTextWriter(sw);
Line 340: RenderContents(htw);
Line 341: htw.Flush();
Line 342: tmpS.Append(sw.ToString());
Line 343:
Line 344: htw.Close();
Line 345: sw.Close();
Line 346:
Line 347: return tmpS.ToString();
Line 348: }
Line 349:
Line 350: // replace any localization strings in the controls:
Line 351: private void IterateControls(ControlCollection controls)
Line 352: {
Line 353: for (int i = 0; i < controls.Count; i++)
Line 354: {
Line 355: Control c = controls[i];
Line 356: if (c.ID != "PageContent")
Line 357: {
Line 358: ProcessControl(c, true);
Line 359: }
Line 360: }
Line 361: }
Line 362:
Line 363: private void ProcessControl(Control ctl, bool includeChildren)
Line 364: {
Line 365: //PropertyDescriptorCollection PropDesc = TypeDescriptor.GetProperties(ctl.GetType());
Line 366: //for (int i = 0; i < PropDesc.Count; i++)
Line 367: //{
Line 368: // SetControlProperty(ctl, PropDesc[i]);
Line 369: //}
Line 370: IEditableTextControl e = ctl as IEditableTextControl;
Line 371: if (e != null) e.Text = ReplaceTokens(e.Text);
Line 372: else
Line 373: {
Line 374: ITextControl t = ctl as ITextControl;
Line 375: if (t != null) t.Text = ReplaceTokens(t.Text);
Line 376: }
Line 377: IValidator v = ctl as IValidator;
Line 378: if (v != null) v.ErrorMessage = ReplaceTokens(v.ErrorMessage);
Line 379: //
Line 380: // TODO: Add other controls which might have replaceable properties here
Line 381: //
Line 382: if (includeChildren && ctl.HasControls())
Line 383: {
Line 384: IterateControls(ctl.Controls);
Line 385: }
Line 386: }
Line 387:
Line 388: //private void SetControlProperty(Control ctl, PropertyDescriptor pd)
Line 389: //{
Line 390: // string s = String.Empty;
Line 391:
Line 392: // if (pd.PropertyType == s.GetType() && pd.IsBrowsable && !pd.IsReadOnly)
Line 393: // {
Line 394: // s = (String)pd.GetValue(ctl);
Line 395: // if (s != null && s.Length != 0)
Line 396: // {
Line 397: // if (s.IndexOf("(!") != -1)
Line 398: // {
Line 399: // s = ReplaceTokens(s);
Line 400: // }
Line 401: // pd.SetValue(ctl, s); //m_ReMatch.Replace(s, m_ResourceMatch));
Line 402: // }
Line 403: // }
Line 404: //}
Line 405:
Line 406:
Line 407: protected override void Render(System.Web.UI.HtmlTextWriter writer)
Line 408: {
Line 409: Response.CacheControl = "private";
Line 410: Response.Expires = 0;
Line 411: Response.AddHeader("pragma", "no-cache");
Line 412:
Line 413: if (m_SETitle.Length == 0)
Line 414: {
Line 415: m_SETitle = AppLogic.AppConfig("SE_MetaTitle");
Line 416: }
Line 417: if (m_SEDescription.Length == 0)
Line 418: {
Line 419: m_SEDescription = AppLogic.AppConfig("SE_MetaDescription");
Line 420: }
Line 421: if (m_SEKeywords.Length == 0)
Line 422: {
Line 423: m_SEKeywords = AppLogic.AppConfig("SE_MetaKeywords");
Line 424: }
Line 425: if (m_SENoScript.Length == 0)
Line 426: {
Line 427: m_SENoScript = AppLogic.AppConfig("SE_MetaNoScript");
Line 428: }
Line 429: IterateControls(Controls);
Line 430: base.Render(writer);
Line 431: }
Line 432:
Line 433: public void SetTemplate(String TemplateName)
Line 434: {
Line 435: if (TemplateName.Trim().Length != 0)
Line 436: {
Line 437: if (TemplateName.EndsWith(".ascx"))
Line 438: {
Line 439: m_TemplateName = TemplateName;
Line 440: }
Line 441: else
Line 442: {
Line 443: throw new ArgumentException("Skin template files (" + TemplateName + ") must end with .ascx for AspDotNetStorefront versions v5.x+!");
Line 444: }
Line 445: }
Line 446: }
Line 447:
Line 448: public void LoadSkinTemplate()
Line 449: {
Line 450:
Line 451: SkinID = 1;
Line 452: if (m_IGD.Length != 0)
Line 453: {
Line 454: m_TemplateName = "empty.ascx"; // force override for admin phone order pages
Line 455: }
Line 456: if (m_TemplateName.Length == 0)
Line 457: {
Line 458: m_TemplateName = "template.ascx";
Line 459: }
Line 460: m_TemplateFN = String.Empty;
Line 461: if (m_TemplateName.Length != 0)
Line 462: {
Line 463:
Line 464: SkinID = CommonLogic.QueryStringUSInt("SkinID");
Line 465:
Line 466: if (SkinID == 0)
Line 467: {
Line 468: SkinID = CommonLogic.QueryStringUSInt("SiteID"); // for backwards compatibility
Line 469: }
Line 470: if (SkinID == 0 && CommonLogic.QueryString("AffiliateID").Length != 0)
Line 471: {
Line 472: DataSet ds = DB.GetDS("Select DefaultSkinID from Affiliate " + DB.GetNoLock() + " where AffiliateID=" + CommonLogic.QueryStringUSInt("AffiliateID").ToString(), AppLogic.CachingOn, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()));
Line 473: if (ds.Tables[0].Rows.Count > 0)
Line 474: {
Line 475: SkinID = DB.RowFieldInt(ds.Tables[0].Rows[0], "DefaultSkinID");
Line 476: }
Line 477: ds.Dispose();
Line 478: }
Line 479: if (SkinID == 0)
Line 480: {
Line 481: SkinID = CommonLogic.CookieUSInt(ro_SkinCookieName);
Line 482: }
Line 483: if (SkinID == 0)
Line 484: {
Line 485: SkinID = m_DefaultSkinID;
Line 486: }
Line 487: if (SkinID == 0)
Line 488: {
Line 489: SkinID = 1;
Line 490: }
Line 491:
Line 492: AppLogic.SetCookie(ro_SkinCookieName, SkinID.ToString(), new TimeSpan(365, 0, 0, 0, 0));
Line 493: m_ThisCustomer.SkinID = SkinID;
Line 494:
Line 495: String Referrer = CommonLogic.PageReferrer();
Line 496: // store their referrer IF it is the first one, and it's not coming from internal:
Line 497: if (Referrer.Length != 0 && CommonLogic.Cookie("Referrer", true).Length == 0 && Referrer.IndexOf("localhost") == -1 && Referrer.IndexOf("192.") == -1 && Referrer.IndexOf("10.") == -1 && Referrer.IndexOf(AppLogic.AppConfig("LiveServer")) == -1)
Line 498: {
Line 499: AppLogic.SetCookie("Referrer", Referrer, new TimeSpan(365, 0, 0, 0, 0));
Line 500: }
Line 501:
Line 502: String _url = null;
Line 503: String LocaleTemplateURLCacheName = String.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), ThisCustomer.LocaleSetting);
Line 504: String WebLocaleTemplateURLCacheName = String.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), Localization.GetWebConfigLocale());
Line 505: String TemplateURLCacheName = String.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), "");
Line 506:
Line 507: if (_url == null)
Line 508: {
Line 509: // try customer locale:
Line 510: _url = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + ThisCustomer.LocaleSetting + ".ascx"));
Line 511:
Line 512: m_TemplateFN = CommonLogic.SafeMapPath(_url);
Line 513: if (!CommonLogic.FileExists(m_TemplateFN))
Line 514: {
Line 515: // try default store locale path:
Line 516: _url = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + Localization.GetWebConfigLocale() + ".ascx"));
Line 517: m_TemplateFN = CommonLogic.SafeMapPath(_url);
Line 518: }
Line 519: if (!CommonLogic.FileExists(m_TemplateFN))
Line 520: {
Line 521: // try base (NULL) locale path:
Line 522: _url = Path.Combine(SkinRoot, m_TemplateName);
Line 523: m_TemplateFN = CommonLogic.SafeMapPath(_url);
Line 524: }
Line 525: if (AppLogic.CachingOn)
Line 526: {
Line 527: HttpContext.Current.Cache.Insert(TemplateURLCacheName, _url, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
Line 528: }
Line 529: }
Line 530: m_Template = (TemplateBase)LoadControl(_url);
Line 531:
Line 532: }
Line 533: if (m_Template != null)
Line 534: {
Line 535: m_Template.AppRelativeTemplateSourceDirectory = "~/"; // move it from skins/skin_N to root relative, so all links/image refs are from root of site
Line 536: }
Line 537: }
Line 538:
Line 539: private string ReplaceTokens(String s)
Line 540: {
Line 541: if (s.IndexOf("(!") == -1)
Line 542: {
Line 543: return s;
Line 544: }
Line 545: String tmpS = String.Empty;
Line 546: // process SKIN specific tokens here only:
Line 547: s = s.Replace("(!SECTION_TITLE!)", SectionTitle);
Line 548: if (SectionTitle.Length != 0)
Line 549: {
Line 550: s = s.Replace("(!SUPERSECTIONTITLE!)", "<div align=\"left\"><span class=\"SectionTitleText\">" + SectionTitle + "</span><br/><small> </small></div>");
Line 551: }
Line 552: else
Line 553: {
Line 554: s = s.Replace("(!SUPERSECTIONTITLE!)", "");
Line 555: }
Line 556: //s = s.Replace("(!HOMEPAGE_ITEMS!)", functions.HarleyHomePageItems(75));
Line 557: s = s.Replace("(!HOMEPAGE_ITEMS!)", functions.HarleyHomePageItems(81));
Line 558: s = s.Replace("(!HOMEPAGE_ITEMS2!)", functions.HarleyHomePageItems(45));
Line 559: s = s.Replace("(!HOMEPAGE_ITEMS3!)", functions.HarleyHomePageItems(5));
Line 560: s = s.Replace("(!SEARCH_ITEMS!)", functions.SearchItemsHome(ThisCustomer.CustomerID, 0));
Line 561: s = s.Replace("(!METATITLE!)", HttpContext.Current.Server.HtmlEncode(m_SETitle));
Line 562: s = s.Replace("(!METADESCRIPTION!)", HttpContext.Current.Server.HtmlEncode(m_SEDescription));
Line 563: s = s.Replace("(!METAKEYWORDS!)", HttpContext.Current.Server.HtmlEncode(m_SEKeywords));
Line 564: s = s.Replace("(!SENOSCRIPT!)", m_SENoScript);
Line 565:
Line 566: if (m_GraphicsColor.Length == 0)
Line 567: {
Line 568: m_GraphicsColor = AppLogic.AppConfig("GraphicsColorDefault");
Line 569: if (m_GraphicsColor.Length == 0)
Line 570: {
Line 571: m_GraphicsColor = String.Empty;
Line 572: }
Line 573: }
Line 574: if (m_ContentsBGColor.Length == 0)
Line 575: {
Line 576: m_ContentsBGColor = AppLogic.AppConfig("ContentsBGColorDefault");
Line 577: if (m_ContentsBGColor.Length == 0)
Line 578: {
Line 579: m_ContentsBGColor = "#FFFFFF";
Line 580: }
Line 581: }
Line 582: if (m_PageBGColor.Length == 0)
Line 583: {
Line 584: m_PageBGColor = AppLogic.AppConfig("PageBGColorDefault");
Line 585: if (m_PageBGColor.Length == 0)
Line 586: {
Line 587: m_PageBGColor = "#FFFFFF";
Line 588: }
Line 589: }
Line 590: s = s.Replace("(!GRAPHICSCOLOR!)", m_GraphicsColor);
Line 591: s = s.Replace("(!CONTENTSBGCOLOR!)", m_ContentsBGColor);
Line 592: s = s.Replace("(!PAGEBGCOLOR!)", m_PageBGColor);
Line 593: s = GetParser.ReplaceTokens(s);
Line 594: return s;
Line 595: }
Line 596:
Line 597: protected virtual void RenderContents(System.Web.UI.HtmlTextWriter writer) { }
Line 598:
Line 599: public Customer ThisCustomer
Line 600: {
Line 601: get
Line 602: {
Line 603: return m_ThisCustomer;
Line 604: }
Line 605: }
Line 606:
Line 607: public Parser GetParser
Line 608: {
Line 609: get
Line 610: {
Line 611: return m_Parser;
Line 612: }
Line 613: }
Line 614:
Line 615: public String SectionTitle
Line 616: {
Line 617: get
Line 618: {
Line 619: return m_SectionTitle;
Line 620: }
Line 621: set
Line 622: {
Line 623: m_SectionTitle = value;
Line 624: }
Line 625: }
Line 626:
Line 627: public String ErrorMsg
Line 628: {
Line 629: get
Line 630: {
Line 631: return m_ErrorMsg;
Line 632: }
Line 633: set
Line 634: {
Line 635: m_ErrorMsg = value;
Line 636: }
Line 637: }
Line 638:
Line 639: public String SETitle
Line 640: {
Line 641: get
Line 642: {
Line 643: return m_SETitle;
Line 644: }
Line 645: set
Line 646: {
Line 647: m_SETitle = value;
Line 648: }
Line 649: }
Line 650:
Line 651: public String IGD
Line 652: {
Line 653: get
Line 654: {
Line 655: return m_IGD;
Line 656: }
Line 657: }
Line 658:
Line 659: public String SEKeywords
Line 660: {
Line 661: get
Line 662: {
Line 663: return m_SEKeywords;
Line 664: }
Line 665: set
Line 666: {
Line 667: m_SEKeywords = value;
Line 668: }
Line 669: }
Line 670:
Line 671: public String SEDescription
Line 672: {
Line 673: get
Line 674: {
Line 675: return m_SEDescription;
Line 676: }
Line 677: set
Line 678: {
Line 679: m_SEDescription = value;
Line 680: }
Line 681: }
Line 682:
Line 683: public String SENoScript
Line 684: {
Line 685: get
Line 686: {
Line 687: return m_SENoScript;
Line 688: }
Line 689: set
Line 690: {
Line 691: m_SENoScript = value;
Line 692: }
Line 693: }
Line 694:
Line 695: public String ContentsBGColor
Line 696: {
Line 697: get
Line 698: {
Line 699: return m_ContentsBGColor;
Line 700: }
Line 701: set
Line 702: {
Line 703: m_ContentsBGColor = value;
Line 704: }
Line 705: }
Line 706:
Line 707: public String PageBGColor
Line 708: {
Line 709: get
Line 710: {
Line 711: return m_PageBGColor;
Line 712: }
Line 713: set
Line 714: {
Line 715: m_PageBGColor = value;
Line 716: }
Line 717: }
Line 718:
Line 719: public String GraphicsColor
Line 720: {
Line 721: get
Line 722: {
Line 723: return m_GraphicsColor;
Line 724: }
Line 725: set
Line 726: {
Line 727: m_GraphicsColor = value;
Line 728: }
Line 729: }
Line 730:
Line 731: public bool Editing
Line 732: {
Line 733: get
Line 734: {
Line 735: return m_Editing;
Line 736: }
Line 737: set
Line 738: {
Line 739: m_Editing = value;
Line 740: }
Line 741: }
Line 742:
Line 743: public bool DisableContents
Line 744: {
Line 745: get
Line 746: {
Line 747: return m_DisableContents;
Line 748: }
Line 749: set
Line 750: {
Line 751: m_DisableContents = value;
Line 752: }
Line 753: }
Line 754:
Line 755: public bool DataUpdated
Line 756: {
Line 757: get
Line 758: {
Line 759: return m_DataUpdated;
Line 760: }
Line 761: set
Line 762: {
Line 763: m_DataUpdated = value;
Line 764: }
Line 765: }
Line 766:
Line 767: new public int SkinID
Line 768: {
Line 769: get
Line 770: {
Line 771: return m_SkinID;
Line 772: }
Line 773: set
Line 774: {
Line 775: m_SkinID = value;
Line 776: }
Line 777: }
Line 778:
Line 779: public string SkinRoot
Line 780: {
Line 781: get
Line 782: {
Line 783: return String.Format("skins/skin_{0}/", this.SkinID);
Line 784: }
Line 785: }
Line 786:
Line 787: public System.Collections.Generic.Dictionary<string, EntityHelper> EntityHelpers
Line 788: {
Line 789: get
Line 790: {
Line 791: return m_EntityHelpers;
Line 792: }
Line 793: }
Line 794:
Line 795: public string SkinImages
Line 796: {
Line 797: get
Line 798: {
Line 799: return String.Format("skins/skin_{0}/images/", this.SkinID);
Line 800: }
Line 801: }
Line 802:
Line 803: static public void RequireSecurePage()
Line 804: {
Line 805: if (AppLogic.AppConfigBool("UseSSL"))
Line 806: {
Line 807: if (AppLogic.OnLiveServer() && CommonLogic.ServerVariables("SERVER_PORT_SECURE") != "1")
Line 808: {
Line 809: HttpContext.Current.Response.Redirect(AppLogic.GetStoreHTTPLocation(true) + CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
Line 810: }
Line 811: }
Line 812: }
Line 813:
Line 814: static public void GoNonSecureAgain()
Line 815: {
Line 816: if (AppLogic.AppConfigBool("UseSSL"))
Line 817: {
Line 818: if (AppLogic.OnLiveServer() && CommonLogic.ServerVariables("SERVER_PORT_SECURE") == "1")
Line 819: {
Line 820: HttpContext.Current.Response.Redirect(AppLogic.GetStoreHTTPLocation(false) + CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
Line 821: }
Line 822: }
Line 823: }
Line 824:
Line 825: public void RequireCustomerRecord()
Line 826: {
Line 827: if (!m_ThisCustomer.HasCustomerRecord)
Line 828: {
Line 829: m_ThisCustomer.RequireCustomerRecord();
Line 830: }
Line 831: }
Line 832:
Line 833: public void RequiresLogin(String ReturnURL)
Line 834: {
Line 835: if (m_ThisCustomer.IsAnon)
Line 836: {
Line 837: Response.Redirect("signin.aspx?returnurl=" + Server.UrlEncode(ReturnURL));
Line 838: }
Line 839: }
Line 840:
Line 841: public void SetMetaTags(String SETitle, String SEKeywords, String SEDescription, String SENoScript)
Line 842: {
Line 843: m_SETitle = SETitle;
Line 844: m_SEDescription = SEKeywords;
Line 845: m_SEKeywords = SEDescription;
Line 846: m_SENoScript = SENoScript;
Line 847: }
Line 848: }
Line 849: }
Line 850:
|