mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -21,13 +21,13 @@ namespace Orchard.Search.Controllers {
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ActionResult Index(string q, int page = 1, int pageSize = 10) {
|
||||
var searchFields = CurrentSite.As<SearchSettings>().Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var searchFields = CurrentSite.As<SearchSettingsPart>().Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
var searchViewModel = new SearchViewModel {
|
||||
Query = q,
|
||||
DefaultPageSize = 10, // <- yeah, I know :|
|
||||
PageOfResults = _searchService.Query(q, page, pageSize,
|
||||
CurrentSite.As<SearchSettings>().Record.FilterCulture,
|
||||
CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
|
||||
searchFields,
|
||||
searchHit => new SearchResultViewModel {
|
||||
Content = _contentManager.BuildDisplayModel(_contentManager.Get(searchHit.ContentItemId), "SummaryForSearch"),
|
||||
|
@@ -5,7 +5,7 @@ namespace Orchard.Search.DataMigrations {
|
||||
|
||||
public int Create() {
|
||||
|
||||
SchemaBuilder.CreateTable("SearchSettingsRecord", table => table
|
||||
SchemaBuilder.CreateTable("SearchSettingsPartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
.Column<bool>("FilterCulture")
|
||||
.Column<string>("SearchedFields")
|
||||
|
@@ -5,11 +5,11 @@ using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Search.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class SearchSettingsHandler : ContentHandler {
|
||||
public SearchSettingsHandler(IRepository<SearchSettingsRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<SearchSettings>("Site"));
|
||||
public class SearchSettingsPartHandler : ContentHandler {
|
||||
public SearchSettingsPartHandler(IRepository<SearchSettingsPartRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<SearchSettingsPart>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
Filters.Add(new TemplateFilterForRecord<SearchSettingsRecord>("CommentSettings", "Parts/Search.SiteSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<SearchSettingsPartRecord>("CommentSettings", "Parts/Search.SiteSettings"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Search.Models {
|
||||
public class SearchSettings : ContentPart<SearchSettingsRecord> {
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Search.Models {
|
||||
public class SearchSettingsPart : ContentPart<SearchSettingsPartRecord> {
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Search.Models {
|
||||
public class SearchSettingsRecord : ContentPartRecord {
|
||||
public class SearchSettingsPartRecord : ContentPartRecord {
|
||||
public virtual bool FilterCulture { get; set; }
|
||||
public virtual string SearchedFields { get; set; }
|
||||
|
||||
public SearchSettingsRecord() {
|
||||
public SearchSettingsPartRecord() {
|
||||
FilterCulture = false;
|
||||
SearchedFields = "body, title";
|
||||
}
|
@@ -68,10 +68,10 @@
|
||||
<Compile Include="Controllers\SearchController.cs" />
|
||||
<Compile Include="DataMigrations\SearchDataMigration.cs" />
|
||||
<Compile Include="Filters\SearchFilter.cs" />
|
||||
<Compile Include="Models\SearchSettings.cs" />
|
||||
<Compile Include="Models\SearchSettingsRecord.cs" />
|
||||
<Compile Include="Models\SearchSettingsPart.cs" />
|
||||
<Compile Include="Models\SearchSettingsPartRecord.cs" />
|
||||
<Compile Include="Routes.cs" />
|
||||
<Compile Include="Handlers\SearchSettingsHandler.cs" />
|
||||
<Compile Include="Handlers\SearchSettingsPartHandler.cs" />
|
||||
<Compile Include="Services\ISearchService.cs" />
|
||||
<Compile Include="Services\SearchService.cs" />
|
||||
<Compile Include="ViewModels\SearchResultViewModel.cs" />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SearchSettingsRecord>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SearchSettingsPartRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Search.Models"%>
|
||||
<fieldset>
|
||||
<legend><%: T("Search")%></legend>
|
||||
|
Reference in New Issue
Block a user