Merge pull request #5640 from jtkech/patch-4

#5552: ContentPicker Search Route issue

Fixes #5552
This commit is contained in:
Sébastien Ros 2015-08-20 12:26:09 -07:00
commit 73683ec057
3 changed files with 24 additions and 7 deletions

View File

@ -47,8 +47,6 @@ namespace Orchard.Search.Controllers {
public ActionResult Index(PagerParameters pagerParameters, string part, string field, string searchText = "") {
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var searchSettingsPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
var searchIndex = searchSettingsPart.SearchIndex;
var searchFields = searchSettingsPart.GetSearchFields(searchSettingsPart.SearchIndex);
var totalCount = 0;
var foundIds = new int[0];
@ -66,6 +64,11 @@ namespace Orchard.Search.Controllers {
return View("NoIndex");
}
var searchIndex = searchSettingsPart.SearchIndex;
if (settings != null && !String.IsNullOrEmpty(settings.SearchIndex))
searchIndex = settings.SearchIndex;
var searchFields = searchSettingsPart.GetSearchFields(searchIndex);
var builder = _indexManager.GetSearchIndexProvider().CreateSearchBuilder(searchIndex);
try {
@ -75,12 +78,12 @@ namespace Orchard.Search.Controllers {
var rawTypes = settings.DisplayedContentTypes.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
var contentTypes = _contentDefinitionManager
.ListTypeDefinitions()
.Where(x => x.Parts.Any(p => rawTypes.Contains(p.PartDefinition.Name)))
.Where(x => x.Parts.Any(p => rawTypes.Contains(p.PartDefinition.Name)) || rawTypes.Contains(x.Name))
.ToArray();
foreach (string type in contentTypes.Select(x => x.Name)) {
builder.WithField("type", type).AsFilter();
builder.WithField("type", type).NotAnalyzed().AsFilter();
}
}
@ -124,4 +127,4 @@ namespace Orchard.Search.Controllers {
return new ShapeResult(this, Services.New.ContentPicker().Tab(tab));
}
}
}
}

View File

@ -34,7 +34,7 @@ namespace Orchard.Search.Controllers {
}
if (!String.IsNullOrEmpty(mediaType)) {
builder.WithField("type", mediaType).Mandatory().AsFilter();
builder.WithField("type", mediaType).NotAnalyzed().AsFilter();
}
if (!String.IsNullOrEmpty(folderPath)) {

View File

@ -13,6 +13,20 @@ namespace Orchard.Search {
public IEnumerable<RouteDescriptor> GetRoutes() {
return new[] {
new RouteDescriptor {
Priority = 5,
Route = new Route("Search/ContentPicker",
new RouteValueDictionary {
{"area", "Orchard.Search"},
{"controller", "ContentPicker"},
{"action", "Index"}
},
null,
new RouteValueDictionary {
{"area", "Orchard.Search"}
},
new MvcRouteHandler())
},
new RouteDescriptor {
Priority = 5,
Route = new Route("Search/{searchIndex}",
@ -31,4 +45,4 @@ namespace Orchard.Search {
};
}
}
}
}