mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Exposing FilterCulture option in search settings
--HG-- branch : 1.x
This commit is contained in:
@@ -38,10 +38,12 @@ namespace Orchard.Search.Drivers {
|
|||||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||||
// update part if successful
|
// update part if successful
|
||||||
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
||||||
|
part.FilterCulture = model.FilterCulture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_indexManager.HasIndexProvider()) {
|
else if (_indexManager.HasIndexProvider()) {
|
||||||
// viewing editor: build model from part
|
// viewing editor: build model from part
|
||||||
|
model.FilterCulture = part.FilterCulture;
|
||||||
model.Entries = new List<SearchSettingsEntry>();
|
model.Entries = new List<SearchSettingsEntry>();
|
||||||
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
|
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
|
||||||
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });
|
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });
|
||||||
|
|||||||
@@ -7,5 +7,10 @@ namespace Orchard.Search.Models {
|
|||||||
get { return Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); }
|
get { return Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); }
|
||||||
set { Record.SearchedFields = String.Join(", ", value); }
|
set { Record.SearchedFields = String.Join(", ", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FilterCulture {
|
||||||
|
get { return Record.FilterCulture; }
|
||||||
|
set { Record.FilterCulture = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Orchard.Search.ViewModels {
|
namespace Orchard.Search.ViewModels {
|
||||||
public class SearchSettingsViewModel {
|
public class SearchSettingsViewModel {
|
||||||
public IList<SearchSettingsEntry> Entries { get; set; }
|
public IList<SearchSettingsEntry> Entries { get; set; }
|
||||||
|
public bool FilterCulture { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SearchSettingsEntry {
|
public class SearchSettingsEntry {
|
||||||
|
|||||||
+10
-8
@@ -4,20 +4,15 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>@T("Search")</legend>
|
<legend>@T("Search")</legend>
|
||||||
<div>
|
<div>
|
||||||
|
<label>@T("Searched fields")</label>
|
||||||
|
<span class="hint">@T("Check any property which should be used for search queries.")</span>
|
||||||
@{var entryIndex = 0;}
|
@{var entryIndex = 0;}
|
||||||
|
|
||||||
@if (Model.Entries != null && Model.Entries.Any()) {
|
@if (Model.Entries != null && Model.Entries.Any()) {
|
||||||
<ul>
|
<ul>
|
||||||
@foreach(var modelEntry in Model.Entries) {
|
@foreach(var modelEntry in Model.Entries) {
|
||||||
<li>
|
<li>
|
||||||
@if(Model.Entries[entryIndex].Selected) {
|
@Html.EditorFor(m => m.Entries[entryIndex].Selected)
|
||||||
|
|
||||||
<input type="checkbox" value="true" checked="checked" name="@Html.FieldNameFor(m => m.Entries[entryIndex].Selected)" id="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)"/>
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => m.Entries[entryIndex].Selected)" id="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)"/>
|
|
||||||
}
|
|
||||||
@Html.HiddenFor(m => m.Entries[entryIndex].Field)
|
@Html.HiddenFor(m => m.Entries[entryIndex].Field)
|
||||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)">@Model.Entries[entryIndex].Field</label>
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)">@Model.Entries[entryIndex].Field</label>
|
||||||
</li>
|
</li>
|
||||||
@@ -30,4 +25,11 @@
|
|||||||
<span class="hint">@T("There are currently no fields to search from. Please update you index, and check some indexable content exists.")</span>
|
<span class="hint">@T("There are currently no fields to search from. Please update you index, and check some indexable content exists.")</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>@T("Localization")</label>
|
||||||
|
@Html.EditorFor(m => m.FilterCulture)
|
||||||
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.FilterCulture)">@T("Narrow search to current culture only")</label>
|
||||||
|
<span class="hint">@T("Is checked, search results will only include content items localized in the current culture of the request.")</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user