mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : theming
This commit is contained in:
@@ -5,7 +5,7 @@ using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Email.Drivers {
|
||||
|
||||
// We define a specific driver instead of using a TemplateFilterForRecord, because we need the ;odel to be the part and not the record.
|
||||
// We define a specific driver instead of using a TemplateFilterForRecord, because we need the model to be the part and not the record.
|
||||
// Thus the encryption/decryption will be done when accessing the part's property
|
||||
|
||||
public class SmtpSettingsPartDriver : ContentPartDriver<SmtpSettingsPart> {
|
||||
@@ -17,13 +17,13 @@ namespace Orchard.Email.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "SmtpSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart termPart) {
|
||||
return ContentPartTemplate(termPart, "Parts/Smtp.SiteSettings");
|
||||
protected override DriverResult Editor(SmtpSettingsPart part) {
|
||||
return ContentPartTemplate(part, "Parts/Smtp.SiteSettings");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart termPart, IUpdateModel updater) {
|
||||
updater.TryUpdateModel(termPart, Prefix, null, null);
|
||||
return Editor(termPart);
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return Editor(part);
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ 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<SearchSettingsPart>().Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var searchFields = CurrentSite.As<SearchSettingsPart>().SearchedFields;
|
||||
|
||||
var searchHits = _searchService.Query(q, page, pageSize,
|
||||
CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
|
||||
|
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Indexing;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Search.Models;
|
||||
using Orchard.Search.ViewModels;
|
||||
|
||||
namespace Orchard.Search.Drivers {
|
||||
|
||||
public class SearchSettingsPartDriver : ContentPartDriver<SearchSettingsPart> {
|
||||
private const string SearchIndexName = "Search";
|
||||
private readonly IIndexManager _indexManager;
|
||||
|
||||
public SearchSettingsPartDriver(IIndexManager indexManager) {
|
||||
_indexManager = indexManager;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override string Prefix { get { return "SearchSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SearchSettingsPart part) {
|
||||
var model = new SearchSettingsViewModel();
|
||||
var searchedFields = part.SearchedFields;
|
||||
|
||||
if (_indexManager.HasIndexProvider()) {
|
||||
model.Entries = new List<SearchSettingsEntry>();
|
||||
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
|
||||
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });
|
||||
}
|
||||
}
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Search.SiteSettings");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater) {
|
||||
var model = new SearchSettingsViewModel();
|
||||
|
||||
if(updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
||||
}
|
||||
|
||||
return Editor(part);
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,7 +9,6 @@ namespace Orchard.Search.Handlers {
|
||||
public SearchSettingsPartHandler(IRepository<SearchSettingsPartRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<SearchSettingsPart>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
Filters.Add(new TemplateFilterForRecord<SearchSettingsPartRecord>("CommentSettings", "Parts/Search.SiteSettings"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,11 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Search.Models {
|
||||
public class SearchSettingsPart : ContentPart<SearchSettingsPartRecord> {
|
||||
public string[] SearchedFields {
|
||||
get { return Record.SearchedFields.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); }
|
||||
set { Record.SearchedFields = String.Join(", ", value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
128
src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj
Normal file
128
src/Orchard.Web/Modules/Orchard.Search/Orchard.Search.csproj
Normal file
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4BE4EB01-AC56-4048-924E-2CA77F509ABA}</ProjectGuid>
|
||||
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.Search</RootNamespace>
|
||||
<AssemblyName>Orchard.Search</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\SearchController.cs" />
|
||||
<Compile Include="DataMigrations\SearchDataMigration.cs" />
|
||||
<Compile Include="Drivers\SearchSettingsPartDriver.cs" />
|
||||
<Compile Include="Filters\SearchFilter.cs" />
|
||||
<Compile Include="Models\SearchSettingsPart.cs" />
|
||||
<Compile Include="Models\SearchSettingsPartRecord.cs" />
|
||||
<Compile Include="Routes.cs" />
|
||||
<Compile Include="Handlers\SearchSettingsPartHandler.cs" />
|
||||
<Compile Include="Services\ISearchService.cs" />
|
||||
<Compile Include="Services\SearchService.cs" />
|
||||
<Compile Include="ViewModels\SearchSettingsViewModel.cs" />
|
||||
<Compile Include="ViewModels\SearchResultViewModel.cs" />
|
||||
<Compile Include="ViewModels\SearchViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Styles\admin.css" />
|
||||
<Content Include="Styles\search.css" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Search.SiteSettings.ascx" />
|
||||
<Content Include="Views\SearchForm.ascx" />
|
||||
<Content Include="Views\Search\Index.ascx" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>47866</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
@@ -31,7 +31,7 @@ namespace Orchard.Search.Services {
|
||||
IPageOfItems<T> ISearchService.Query<T>(string query, int page, int? pageSize, bool filterCulture, string[] searchFields, Func<ISearchHit, T> shapeResult) {
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
return null;
|
||||
return new PageOfItems<T>(Enumerable.Empty<T>());
|
||||
|
||||
var searchBuilder = Search().Parse(searchFields, query);
|
||||
|
||||
|
@@ -0,0 +1,14 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Search.ViewModels {
|
||||
public class SearchSettingsViewModel : BaseViewModel {
|
||||
public IList<SearchSettingsEntry> Entries { get; set; }
|
||||
}
|
||||
|
||||
public class SearchSettingsEntry {
|
||||
public string Field { get; set; }
|
||||
public bool Selected { get; set; }
|
||||
public int Weight { get; set; }
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SearchSettingsPartRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Search.Models"%>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SearchSettingsViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Search.ViewModels"%>
|
||||
<fieldset>
|
||||
<legend><%: T("Search")%></legend>
|
||||
<%-- TODO: (sebros) Implementation details after Alpha
|
||||
@@ -10,8 +10,14 @@
|
||||
</div>
|
||||
--%>
|
||||
<div>
|
||||
<label for="SearchSettings_SearchedFields"><%: T("Searched fields")%></label>
|
||||
<%: Html.EditorFor(m => m.SearchedFields)%>
|
||||
<%: Html.ValidationMessage("SearchedFields", "*")%>
|
||||
<%
|
||||
for(var i=0; i<Model.Entries.Count; i++) {
|
||||
var j = i;%>
|
||||
<input type="checkbox" value="true" <% if(Model.Entries[j].Selected ) { %> checked="checked" <% } %>
|
||||
name="<%:Html.FieldNameFor(m => m.Entries[j].Selected)%>" id="<%:Html.FieldIdFor(m => m.Entries[j].Selected)%>"/>
|
||||
<%: Html.HiddenFor(m => m.Entries[j].Field)%>
|
||||
<label class="forcheckbox" for="<%:Html.FieldIdFor(m => m.Entries[j].Selected)%>"><%: Model.Entries[j].Field%></label>
|
||||
<%
|
||||
}%>
|
||||
</div>
|
||||
</fieldset>
|
Reference in New Issue
Block a user