mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +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; }
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
|
||||||
public ActionResult Index(string q, int page = 1, int pageSize = 10) {
|
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 {
|
var searchViewModel = new SearchViewModel {
|
||||||
Query = q,
|
Query = q,
|
||||||
DefaultPageSize = 10, // <- yeah, I know :|
|
DefaultPageSize = 10, // <- yeah, I know :|
|
||||||
PageOfResults = _searchService.Query(q, page, pageSize,
|
PageOfResults = _searchService.Query(q, page, pageSize,
|
||||||
CurrentSite.As<SearchSettings>().Record.FilterCulture,
|
CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
|
||||||
searchFields,
|
searchFields,
|
||||||
searchHit => new SearchResultViewModel {
|
searchHit => new SearchResultViewModel {
|
||||||
Content = _contentManager.BuildDisplayModel(_contentManager.Get(searchHit.ContentItemId), "SummaryForSearch"),
|
Content = _contentManager.BuildDisplayModel(_contentManager.Get(searchHit.ContentItemId), "SummaryForSearch"),
|
||||||
|
@@ -5,7 +5,7 @@ namespace Orchard.Search.DataMigrations {
|
|||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
|
|
||||||
SchemaBuilder.CreateTable("SearchSettingsRecord", table => table
|
SchemaBuilder.CreateTable("SearchSettingsPartRecord", table => table
|
||||||
.ContentPartRecord()
|
.ContentPartRecord()
|
||||||
.Column<bool>("FilterCulture")
|
.Column<bool>("FilterCulture")
|
||||||
.Column<string>("SearchedFields")
|
.Column<string>("SearchedFields")
|
||||||
|
@@ -5,11 +5,11 @@ using Orchard.ContentManagement.Handlers;
|
|||||||
|
|
||||||
namespace Orchard.Search.Handlers {
|
namespace Orchard.Search.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class SearchSettingsHandler : ContentHandler {
|
public class SearchSettingsPartHandler : ContentHandler {
|
||||||
public SearchSettingsHandler(IRepository<SearchSettingsRecord> repository) {
|
public SearchSettingsPartHandler(IRepository<SearchSettingsPartRecord> repository) {
|
||||||
Filters.Add(new ActivatingFilter<SearchSettings>("Site"));
|
Filters.Add(new ActivatingFilter<SearchSettingsPart>("Site"));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
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;
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Search.Models {
|
namespace Orchard.Search.Models {
|
||||||
public class SearchSettingsRecord : ContentPartRecord {
|
public class SearchSettingsPartRecord : ContentPartRecord {
|
||||||
public virtual bool FilterCulture { get; set; }
|
public virtual bool FilterCulture { get; set; }
|
||||||
public virtual string SearchedFields { get; set; }
|
public virtual string SearchedFields { get; set; }
|
||||||
|
|
||||||
public SearchSettingsRecord() {
|
public SearchSettingsPartRecord() {
|
||||||
FilterCulture = false;
|
FilterCulture = false;
|
||||||
SearchedFields = "body, title";
|
SearchedFields = "body, title";
|
||||||
}
|
}
|
@@ -68,10 +68,10 @@
|
|||||||
<Compile Include="Controllers\SearchController.cs" />
|
<Compile Include="Controllers\SearchController.cs" />
|
||||||
<Compile Include="DataMigrations\SearchDataMigration.cs" />
|
<Compile Include="DataMigrations\SearchDataMigration.cs" />
|
||||||
<Compile Include="Filters\SearchFilter.cs" />
|
<Compile Include="Filters\SearchFilter.cs" />
|
||||||
<Compile Include="Models\SearchSettings.cs" />
|
<Compile Include="Models\SearchSettingsPart.cs" />
|
||||||
<Compile Include="Models\SearchSettingsRecord.cs" />
|
<Compile Include="Models\SearchSettingsPartRecord.cs" />
|
||||||
<Compile Include="Routes.cs" />
|
<Compile Include="Routes.cs" />
|
||||||
<Compile Include="Handlers\SearchSettingsHandler.cs" />
|
<Compile Include="Handlers\SearchSettingsPartHandler.cs" />
|
||||||
<Compile Include="Services\ISearchService.cs" />
|
<Compile Include="Services\ISearchService.cs" />
|
||||||
<Compile Include="Services\SearchService.cs" />
|
<Compile Include="Services\SearchService.cs" />
|
||||||
<Compile Include="ViewModels\SearchResultViewModel.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"%>
|
<%@ Import Namespace="Orchard.Search.Models"%>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><%: T("Search")%></legend>
|
<legend><%: T("Search")%></legend>
|
||||||
|
Reference in New Issue
Block a user