コード例 #1
0
        private Facet CreateFromContentTag(ISearchContext searchContext, ContentTag tag)
        {
            var queryString = searchContext.AsNameValueCollection();
            var f           = new Facet(tag, "", IsSelected(tag.Value));

            // recursively set children
            f.SetChildren(GetChildren(searchContext, queryString, tag.Children));
            return(f);
        }
コード例 #2
0
        public string ClearAllFiltersUrl(ISearchContext searchContext)
        {
            var result =
                searchContext.AsNameValueCollection()
                .RemoveKey(Constants.SearchContext.Keys.Facets)
                .RemoveKey(Constants.SearchContext.Keys.PageNumber);

            // remove keyword if we are treating it as a facet
            if (searchContext.CollectionSettings.ShowKeywordFacet)
            {
                result = result.RemoveKey(Constants.SearchContext.Keys.Query);
            }

            return(result.ToQueryString(true));
        }
コード例 #3
0
        public IEnumerable <Facet> CreateSelectedFacets(ISearchContext searchContext)
        {
            foreach (var selectedFacetViewModelProvider in selectedFilterProviders)
            {
                if (!selectedFacetViewModelProvider.AnyFacetsActive(searchContext))
                {
                    continue;
                }

                var selected = selectedFacetViewModelProvider.Get(searchContext, searchContext.AsNameValueCollection());

                foreach (var facetViewModel in selected)
                {
                    yield return(facetViewModel);
                }
            }
        }
コード例 #4
0
        private Facet CreateFromAutomatedTag(ISearchContext searchContext, AutomatedTag tag)
        {
            var f = new Facet(tag, "", IsSelected(tag.Value));
            // TODO this logic needs to be pushed into the automated tag implementation to be more flexible, e.g. sorting might be different per tag (year -> desc)

            var children =
                resultSetFacets.Where(facet => facet.Item.Id.Equals(tag.Id))
                .Select(
                    facet =>
                    new Facet(
                        facet.Item,
                        GetChildQueryString(searchContext, searchContext.AsNameValueCollection(), facet.Item),
                        IsSelected(facet.Item.Value),
                        facet.Count,
                        null))
                .OrderBy(facet => facet.Title);

            f.SetChildren(children);
            return(f);
        }