public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (FacetConfiguration == null) FacetConfiguration = (FacetConfiguration)ContextRegistry.GetContext().GetObject("facetConfiguration"); if(UrlOfuscator == null) UrlOfuscator = (UrlOfuscator)ContextRegistry.GetContext().GetObject("urlOfuscator"); var freeText = controllerContext.HttpContext.Request.Form["freetext"]; if(controllerContext.RouteData.Values["query"]!=null) { var query = controllerContext.RouteData.Values["query"].ToString(); if(query.Contains(UrlOfuscator.OfuscatedCharacters["="].ToString())) { var conditions = Conditions.From(query, UrlOfuscator); var selectedFiltersContext = QueryUrlParser.With(FacetConfiguration.FacetHierarchy, UrlOfuscator) .Parse(conditions) .GetSelectedFilters(); if (selectedFiltersContext.SelectedFilters.Count == 0) return new SearchParameters<Publication>(freeText, selectedFiltersContext.Page, selectedFiltersContext.SortField); return new SearchParameters<Publication>(freeText, selectedFiltersContext, FacetConfiguration.FacetHierarchy.ByName(selectedFiltersContext.SelectedFilters.Last().Name), GetFacetsWith(selectedFiltersContext.SelectedFilters)); } } return new SearchParameters<Publication> (freeText); }
public PageInfo(int number, string url, bool hasSelectedFilters, IUrlOfuscator urlOfuscator) { Number = number; if (!hasSelectedFilters) Url = url + "PG" + urlOfuscator.OfuscatedCharacters["="] + number; else Url = url + urlOfuscator.OfuscatedCharacters["&"] + "PG" + urlOfuscator.OfuscatedCharacters["="] + number; }
public static IEnumerable<Condition> From(string conditionsString, IUrlOfuscator urlOfuscator) { var conditionsArray = Regex.Split(conditionsString, urlOfuscator.OfuscatedCharacters["&"].ToString()); conditionsArray = conditionsArray.Where(x => x != string.Empty).ToArray(); //conditionsArray: //param=1 //param=2 var conditions = new List<Condition>(); conditionsArray.ToList().ForEach(x => conditions.Add(ConditionFactory.GetInstance(Regex.Split(x, urlOfuscator.OfuscatedCharacters["="].ToString())[0], Regex.Split(x, urlOfuscator.OfuscatedCharacters["="].ToString())[1]))); return conditions; }
public static QueryUrlParser With(IFacetHierarchy facetHierarchy, IUrlOfuscator urlOfuscator) { return new QueryUrlParser(facetHierarchy,urlOfuscator); }
public QueryUrlParser(IFacetHierarchy facetHierarchy, IUrlOfuscator urlOfuscator) { _facetHierarchy = facetHierarchy; _urlOfuscator = urlOfuscator; _filters = new List<SelectedFilter>(); }