--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-06-09 09:55:50 -07:00
6 changed files with 27 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ using Orchard.Localization;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Localization.Services; using Orchard.Localization.Services;
using Orchard.Settings;
namespace Orchard.Core.Localization.Handlers { namespace Orchard.Core.Localization.Handlers {
[UsedImplicitly] [UsedImplicitly]
@@ -22,6 +23,8 @@ namespace Orchard.Core.Localization.Handlers {
OnActivated<Localized>(InitializePart); OnActivated<Localized>(InitializePart);
OnLoaded<Localized>(LazyLoadHandlers); OnLoaded<Localized>(LazyLoadHandlers);
OnIndexed<Localized>((context, localized) => context.IndexDocument.Add("culture", localized.Culture != null ? localized.Culture.Culture : _cultureManager.GetSiteCulture()).Store(false).Analyze(false));
} }
public Localizer T { get; set; } public Localizer T { get; set; }

View File

@@ -4,7 +4,9 @@ using System.Linq;
using Orchard.Collections; using Orchard.Collections;
using Orchard.Indexing; using Orchard.Indexing;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Localization.Services;
using Orchard.UI.Notify; using Orchard.UI.Notify;
using System.Web;
namespace Orchard.Search.Services namespace Orchard.Search.Services
{ {
@@ -13,11 +15,13 @@ namespace Orchard.Search.Services
private const string SearchIndexName = "Search"; private const string SearchIndexName = "Search";
private readonly IIndexManager _indexManager; private readonly IIndexManager _indexManager;
private readonly IEnumerable<IIndexNotifierHandler> _indexNotifierHandlers; private readonly IEnumerable<IIndexNotifierHandler> _indexNotifierHandlers;
private readonly ICultureManager _cultureManager;
public SearchService(IOrchardServices services, IIndexManager indexManager, IEnumerable<IIndexNotifierHandler> indexNotifierHandlers) { public SearchService(IOrchardServices services, IIndexManager indexManager, IEnumerable<IIndexNotifierHandler> indexNotifierHandlers, ICultureManager cultureManager) {
Services = services; Services = services;
_indexManager = indexManager; _indexManager = indexManager;
_indexNotifierHandlers = indexNotifierHandlers; _indexNotifierHandlers = indexNotifierHandlers;
_cultureManager = cultureManager;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }
@@ -36,6 +40,10 @@ namespace Orchard.Search.Services
.WithField("title", query) .WithField("title", query)
.WithField("body", query); .WithField("body", query);
if(HttpContext.Current != null) {
searchBuilder.WithField("culture", _cultureManager.GetCurrentCulture(HttpContext.Current));
}
var totalCount = searchBuilder.Count(); var totalCount = searchBuilder.Count();
if (pageSize != null) if (pageSize != null)
searchBuilder = searchBuilder searchBuilder = searchBuilder

View File

@@ -148,6 +148,11 @@ namespace Orchard.Setup.Services {
//var hackInstallationGenerator = environment.Resolve<IHackInstallationGenerator>(); //var hackInstallationGenerator = environment.Resolve<IHackInstallationGenerator>();
//hackInstallationGenerator.GenerateInstallEvents(); //hackInstallationGenerator.GenerateInstallEvents();
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
contentDefinitionManager.AlterTypeDefinition("blogpost", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
contentDefinitionManager.AlterTypeDefinition("page", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
contentDefinitionManager.AlterTypeDefinition("sandboxpage", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
// create home page as a CMS page // create home page as a CMS page
var page = contentManager.Create("page", VersionOptions.Draft); var page = contentManager.Create("page", VersionOptions.Draft);
page.As<BodyAspect>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>"; page.As<BodyAspect>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
@@ -172,11 +177,6 @@ namespace Orchard.Setup.Services {
var authenticationService = environment.Resolve<IAuthenticationService>(); var authenticationService = environment.Resolve<IAuthenticationService>();
authenticationService.SignIn(user, true); authenticationService.SignIn(user, true);
} }
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
contentDefinitionManager.AlterTypeDefinition("blogpost", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
contentDefinitionManager.AlterTypeDefinition("page", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
contentDefinitionManager.AlterTypeDefinition("sandboxpage", cfg => cfg.WithPart("HasComments").WithPart("HasTags").WithPart("Localized"));
} }
catch { catch {
environment.Resolve<ITransactionManager>().Cancel(); environment.Resolve<ITransactionManager>().Cancel();

View File

@@ -1,8 +1,4 @@
using System; using Orchard.ContentManagement.MetaData.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.ContentManagement { namespace Orchard.ContentManagement {
public class ContentField { public class ContentField {

View File

@@ -1,11 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web; using System.Web;
using JetBrains.Annotations;
using Orchard.Data; using Orchard.Data;
using Orchard.Localization.Records; using Orchard.Localization.Records;
using Orchard.Settings;
namespace Orchard.Localization.Services { namespace Orchard.Localization.Services {
public class DefaultCultureManager : ICultureManager { public class DefaultCultureManager : ICultureManager {
@@ -17,6 +18,8 @@ namespace Orchard.Localization.Services {
_cultureSelectors = cultureSelectors; _cultureSelectors = cultureSelectors;
} }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
public IEnumerable<string> ListCultures() { public IEnumerable<string> ListCultures() {
var query = from culture in _cultureRepository.Table select culture.Culture; var query = from culture in _cultureRepository.Table select culture.Culture;
return query.ToList(); return query.ToList();
@@ -51,6 +54,10 @@ namespace Orchard.Localization.Services {
return _cultureRepository.Get(id); return _cultureRepository.Get(id);
} }
public string GetSiteCulture() {
return CurrentSite == null ? null : CurrentSite.SiteCulture;
}
// "<languagecode2>" or // "<languagecode2>" or
// "<languagecode2>-<country/regioncode2>" or // "<languagecode2>-<country/regioncode2>" or
// "<languagecode2>-<scripttag>-<country/regioncode2>" // "<languagecode2>-<scripttag>-<country/regioncode2>"

View File

@@ -8,5 +8,6 @@ namespace Orchard.Localization.Services {
void AddCulture(string cultureName); void AddCulture(string cultureName);
string GetCurrentCulture(HttpContext requestContext); string GetCurrentCulture(HttpContext requestContext);
CultureRecord GetCultureById(int id); CultureRecord GetCultureById(int id);
string GetSiteCulture();
} }
} }