Exposing FilterCulture option in search settings

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-15 09:15:08 -08:00
parent 4893f884d0
commit e74766d9e2
4 changed files with 18 additions and 8 deletions

View File

@@ -38,10 +38,12 @@ namespace Orchard.Search.Drivers {
if (updater.TryUpdateModel(model, Prefix, null, null)) {
// update part if successful
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
part.FilterCulture = model.FilterCulture;
}
}
else if (_indexManager.HasIndexProvider()) {
// viewing editor: build model from part
model.FilterCulture = part.FilterCulture;
model.Entries = new List<SearchSettingsEntry>();
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });

View File

@@ -7,5 +7,10 @@ namespace Orchard.Search.Models {
get { return Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); }
set { Record.SearchedFields = String.Join(", ", value); }
}
public bool FilterCulture {
get { return Record.FilterCulture; }
set { Record.FilterCulture = value; }
}
}
}

View File

@@ -3,6 +3,7 @@
namespace Orchard.Search.ViewModels {
public class SearchSettingsViewModel {
public IList<SearchSettingsEntry> Entries { get; set; }
public bool FilterCulture { get; set; }
}
public class SearchSettingsEntry {

View File

@@ -4,20 +4,15 @@
<fieldset>
<legend>@T("Search")</legend>
<div>
<label>@T("Searched fields")</label>
<span class="hint">@T("Check any property which should be used for search queries.")</span>
@{var entryIndex = 0;}
@if (Model.Entries != null && Model.Entries.Any()) {
<ul>
@foreach(var modelEntry in Model.Entries) {
<li>
@if(Model.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.EditorFor(m => m.Entries[entryIndex].Selected)
@Html.HiddenFor(m => m.Entries[entryIndex].Field)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Entries[entryIndex].Selected)">@Model.Entries[entryIndex].Field</label>
</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>
}
</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>