Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public static QueryUrlParser With(IFacetHierarchy facetHierarchy, IUrlOfuscator urlOfuscator)
 {
     return new QueryUrlParser(facetHierarchy,urlOfuscator);
 }
Ejemplo n.º 5
0
 public QueryUrlParser(IFacetHierarchy facetHierarchy, IUrlOfuscator urlOfuscator)
 {
     _facetHierarchy = facetHierarchy;
     _urlOfuscator = urlOfuscator;
     _filters = new List<SelectedFilter>();
 }