/// <summary> /// Determines from the querystring whic campaign is currently being invoked, if any. /// </summary> /// <returns></returns> public String GetActiveUserCampaign() { WebRequestContext context = new WebRequestContext(); String result = context.CurrentHttpContext.Request["utm_campaign"]; return result; }
/// <summary> /// Takes the markup and then starts to build up the HTML form /// </summary> /// <param name="markup"></param> /// <returns></returns> public StringBuilder Convert(StringBuilder html,String content) { this.markup = content.Trim(); WebRequestContext context = new WebRequestContext(); //CampaignManager campaignManager = new CampaignManager(); String culture = CurrentSite.Culture; String redirectTo = GetMetaValue(Redirect).Trim(); String submitButtonText = GetMetaValue(ButtonText).Trim(); String emailResultsTo = TextEncryption.Encode(GetMetaValue(EmailResults).Trim()); String currentResource = GetCurrentResource(); String campaigns = ""; //TODO campaignManager.GetInternalCampaignTrail("|"); String file = context.CurrentHttpContext.Request.QueryString["fget"]; if (file == null) file = ""; html.Append(String.Format(@"<input type=""text"" id=""{0}_{1}"" name=""{0}_{1}"" value="""" style=""display:none;"" />",this.id,"gooeykeycheck")); html.Append(HiddenField("culture", culture)).AppendLine(); html.Append(HiddenField("redirect", CmsUrl.ResolveUrl(redirectTo))).AppendLine(); html.Append(HiddenField("submit-email", emailResultsTo)).AppendLine(); html.Append(HiddenField("resource", currentResource)).AppendLine(); html.Append(HiddenField("campaign", campaigns.Trim())).AppendLine(); if (!String.IsNullOrEmpty(file)) html.Append(HiddenField("downloadfile", file.Trim())).AppendLine(); this.buttonText = submitButtonText; return html; }
public static Data.Model.Help.HelpPage GetCurrent() { WebRequestContext context = new WebRequestContext(); CmsUrl url = WebRequestContext.CurrentPage(); Data.Hash hash = TextHash.MD5(url.Path); HelpPageDao dao = new HelpPageDao(); HelpPage result = dao.FindByPageHash(hash); if (result != null) { String separator = "?"; String path = context.Request.Url.PathAndQuery; if (path.Contains("?")) separator = "&"; path = path + separator + "hide=1"; result.Text = result.Text.Replace("{action}", path); } return result; }
public override StringBuilder Convert(StringBuilder markup) { Match match = Form.Match(markup.ToString()); while (match.Success) { String content = match.Groups[1].Value; String id = System.Guid.NewGuid().ToString(); //Find the form and pull it out of the markup StringBuilder html = new StringBuilder(); FormMetaInfoParser metainfo = new FormMetaInfoParser(id); FormFieldParser fields = new FormFieldParser(id,base.FormatEngine); WebRequestContext context = new WebRequestContext(); CmsUrl url = new CmsUrl(context.Request.RawUrl); String pagename = url.PathWithoutExtension; String token = AntiXss.UrlEncode(TokenManager.Issue(pagename, TimeSpan.FromMinutes(2))); html.Append(@"<div class=""webscript-form"">").AppendLine(); html.Append(@"<form class=""gooeycms-form"" action=""/gooeyforms/formprocess.handler?token=" + token + @"&pagename=" + AntiXss.UrlEncode(pagename) + @""" method=""post"">").AppendLine(); html = metainfo.Convert(html, content); html = fields.Convert(html, content); html.AppendFormat(SubmitFormat, id, "submit", metainfo.SubmitButtonText).AppendLine(); html.Append(@"</form>").AppendLine(); html.Append(@"<span id=""form_error""></span>"); html.Append("</div>").AppendLine(); //Replace the form markup with the html markup = new StringBuilder(Form.Replace(markup.ToString(), html.ToString(), 1)); match = match.NextMatch(); } return markup; }
private String GetCurrentResource() { WebRequestContext context = new WebRequestContext(); return new CmsUrl(context.Request.RawUrl).RelativePath; }
private HashSet<String> GetViewedHelpPages() { HashSet<String> result = new HashSet<string>(); WebRequestContext context = new WebRequestContext(); HttpCookie cookie = context.CurrentHttpContext.Request.Cookies["help-system"]; if (cookie != null) { String[] temp = cookie.Value.Split(','); foreach (String item in temp) { result.Add(item.Trim()); } } return result; }
/// <summary> /// Hides the help page for the current user /// </summary> /// <param name="current"></param> public void Hide(Data.Model.Help.HelpPage current) { HashSet<String> pages = GetViewedHelpPages(); pages.Add(current.Hash); StringBuilder builder = new StringBuilder(); foreach (String value in pages) { builder.Append(value).Append(","); } builder.Remove(builder.Length - 1, 1); String values = builder.ToString(); HttpCookie cookie = new HttpCookie("help-system"); cookie.Value = values; cookie.Expires = UtcDateTime.Now.AddYears(25); WebRequestContext context = new WebRequestContext(); context.CurrentHttpContext.Response.Cookies.Add(cookie); }
private String FormEvaluator(Match match) { WebRequestContext context = new WebRequestContext(); CmsUrl url = new CmsUrl(context.Request.RawUrl); String currentUrl = url.RelativePath; String formMetaInfo = match.Groups[1].Value; String content = match.Groups[2].Value; StringBuilder metainfo = new StringBuilder(); String error = GetHiddenFields(currentUrl, formMetaInfo, metainfo); String pagename = url.PathWithoutExtension; if (error == null) { StringBuilder formhtml = new StringBuilder(); formhtml.Append(@"<form class=""gooeycms-form"" action=""/gooeyforms/formprocess.handler?&pagename=" + AntiXss.UrlEncode(pagename) + @""" method=""post"">").AppendLine(); formhtml.AppendLine(metainfo.ToString()); formhtml.Append(content); formhtml.Append(@"</form>").AppendLine(); formhtml.Append(@"<span id=""form_error""></span>"); return formhtml.Replace("{form_id}", System.Guid.NewGuid().ToString()).ToString(); } else return error; }