public static MvcHtmlString CloseLink(this HtmlHelper helper) { TagBuilder builder = new TagBuilder("a"); string absolutePath = helper.ViewContext.HttpContext.Request.Url.AbsolutePath; builder.MergeAttribute("class", "icon close"); builder.SetInnerText(helper.GetResource("RemoveFilter")); string facet = helper.ViewContext.RouteData.Values.GetLevel1BrandFacet(); string facetValue = helper.ViewContext.RouteData.Values.GetLevel1BrandFacetValueDelimeted(); if (!string.IsNullOrEmpty(helper.ViewContext.HttpContext.Request["fh_params"])) { Query query = new Query(); query.ParseQuery(helper.ViewContext.HttpContext.Request["fh_params"]); Location location = new Location(FredHopperExtensions.RemoveFacetValues(query.getLocation().toString(), facet, facetValue)); query.setLocation(location); absolutePath = absolutePath + query.ToFhParams(); } else { absolutePath = absolutePath + "?clear=true"; } UrlHelper helper2 = new UrlHelper(helper.ViewContext.RequestContext); builder.MergeAttribute("href", helper2.Content(absolutePath.AddApplicationRoot())); return MvcHtmlString.Create(builder.ToString()); }
public void SetHrefLinks(Query query) { Location location = new Location(query.getLocation()); int offset = query.getListStartIndex(); query.removeListStartIndex(); int num2 = this.Facets.Count<FacetItem>(f => f.Selected); string ticked = HttpContext.Current.Request["fh_ticked"] ?? ""; foreach (FacetItem item in this.Facets) { Location location2 = new Location(location); MultiValuedCriterion mvc = location2.getCriterion("schematitle") as MultiValuedCriterion; if (mvc != null) { (from f in this.Facets where !f.Enabled select f).ToList<FacetItem>().ForEach(f => mvc.getGreaterThan().remove(f.Value)); if (string.IsNullOrEmpty(ticked)) { if (num2 == mvc.getGreaterThan().valueSet().size()) { item.Selected = false; mvc.getGreaterThan().clear().add(item.Value); } } else { if (ticked.Split(new char[] { ',' }).Contains<string>(item.Value)) { mvc.getGreaterThan().remove(item.Value); } else { mvc.getGreaterThan().add(item.Value); } if (mvc.getGreaterThan().isEmpty()) { location2.removeCriteria("schematitle"); } } query.setLocation(location2); item.Href = query.ToFhParams(); if (string.IsNullOrEmpty(ticked)) { item.Href = item.Href + "&fh_ticked=" + item.Value; } else { List<string> items = ticked.Split(new char[] { ',' }).ToList<string>(); (from f in this.Facets where !f.Enabled select f).ToList<FacetItem>().ForEach(f => items.Remove(f.Value)); if (items.Contains(item.Value)) { items.Remove(item.Value); } else { items.Add(item.Value); } item.Href = Regex.Replace(item.Href, @"&fh_ticked=[\w|,]+", ""); if (items.Count > 0) { item.Href = item.Href + "&fh_ticked=" + string.Join(",", items); } } } } query.setLocation(location); query.setListStartIndex(offset); this.Facets.ToList<FacetItem>().ForEach(delegate (FacetItem f) { if (f.Enabled) { f.Selected = false; } List<string> list = ticked.Split(new char[] { ',' }).ToList<string>(); if (f.Enabled && list.Contains(f.Value)) { f.Selected = true; } }); }
public static FacetItem getFacetItem(filtersection fs, string fh_location, filter f) { FacetItem item = new FacetItem { FHId = fs.value.Value, NumItems = fs.nr, Selected = fs.selected }; link link = fs.link; item.Text = link.name; Query query = new Query(); query.ParseQuery(link.urlparams); query.removeListStartIndex(); string urlParams = string.Empty; if (fs.selected) { string str2 = query.getLocation().getLastCriterion().toString(); string facetValue = str2.Substring(str2.IndexOf('{') + 1).Replace("}", ""); urlParams = RemoveFacetValues(fh_location, query.getLocation().getLastCriterion().getAttributeName(), facetValue); } else { Location location = new Location(fh_location); location.addCriterion(query.getLocation().getLastCriterion()); urlParams = location.toString(); if ((f.customfields != null) && (f.customfields.SingleOrDefault<customfield>(c => (c.name == "RefineMethod")).Value == "CombineFacets")) { urlParams = CreateOrCondition(urlParams); } } Location location2 = new Location(urlParams); query.setLocation(location2); item.Value = query.ToFhParams(); return item; }