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:
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
@@ -67,9 +66,11 @@ namespace Orchard.Core.Common.Handlers {
|
||||
bool ContentTypeWithACommonPart(string typeName) {
|
||||
//Note: What about content type handlers which activate "CommonPart" in code?
|
||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName);
|
||||
if (contentTypeDefinition == null)
|
||||
return false;
|
||||
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");
|
||||
|
||||
if (contentTypeDefinition != null)
|
||||
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AssignCreatingOwner(InitializingContentContext context, CommonPart part) {
|
||||
|
@@ -70,7 +70,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
var containerUrl = new UriBuilder(request.ToRootUrlString()) { Path = (request.ApplicationPath ?? "").TrimEnd('/') + "/" + (part.GetContainerPath() ?? "") };
|
||||
model.ContainerAbsoluteUrl = containerUrl.Uri.ToString().TrimEnd('/');
|
||||
|
||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
model.PromoteToHomePage = model.Id != 0 && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
return ContentShape("Parts_Routable_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
@@ -81,6 +81,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
|
||||
part.Title = model.Title;
|
||||
part.Slug = model.Slug;
|
||||
part.PromoteToHomePage = model.PromoteToHomePage;
|
||||
|
||||
if ( !_routableService.IsSlugValid(part.Slug) ) {
|
||||
var slug = (part.Slug ?? String.Empty);
|
||||
@@ -90,9 +91,6 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
|
||||
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
@@ -6,6 +8,7 @@ using Orchard.Core.Routable.Models;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Routable.Handlers {
|
||||
@@ -13,11 +16,18 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
private readonly IOrchardServices _services;
|
||||
private readonly IRoutablePathConstraint _routablePathConstraint;
|
||||
private readonly IRoutableService _routableService;
|
||||
private readonly IHomePageProvider _routableHomePageProvider;
|
||||
|
||||
public RoutePartHandler(IOrchardServices services, IRepository<RoutePartRecord> repository, IRoutablePathConstraint routablePathConstraint, IRoutableService routableService) {
|
||||
public RoutePartHandler(
|
||||
IOrchardServices services,
|
||||
IRepository<RoutePartRecord> repository,
|
||||
IRoutablePathConstraint routablePathConstraint,
|
||||
IRoutableService routableService,
|
||||
IEnumerable<IHomePageProvider> homePageProviders) {
|
||||
_services = services;
|
||||
_routablePathConstraint = routablePathConstraint;
|
||||
_routableService = routableService;
|
||||
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
|
||||
T = NullLocalizer.Instance;
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
@@ -34,21 +44,10 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
OnUpdateEditorShape<RoutePart>(SetModelProperties);
|
||||
|
||||
OnPublished<RoutePart>((context, route) => {
|
||||
var path = route.Path;
|
||||
route.Path = route.GetPathWithSlug(route.Slug);
|
||||
FinalizePath(route, context, processSlug);
|
||||
|
||||
if (context.PublishingItemVersionRecord != null)
|
||||
processSlug(route);
|
||||
|
||||
// if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict
|
||||
// then update and publish all contained items
|
||||
if (path != route.Path) {
|
||||
_routablePathConstraint.RemovePath(path);
|
||||
_routableService.FixContainedPaths(route);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(route.Path))
|
||||
_routablePathConstraint.AddPath(route.Path);
|
||||
if (route.ContentItem.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null)
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
|
||||
});
|
||||
|
||||
OnRemoved<RoutePart>((context, route) => {
|
||||
@@ -59,6 +58,24 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
||||
}
|
||||
|
||||
private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) {
|
||||
var path = route.Path;
|
||||
route.Path = route.GetPathWithSlug(route.Slug);
|
||||
|
||||
if (context.PublishingItemVersionRecord != null)
|
||||
processSlug(route);
|
||||
|
||||
// if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict
|
||||
// then update and publish all contained items
|
||||
if (path != route.Path) {
|
||||
_routablePathConstraint.RemovePath(path);
|
||||
_routableService.FixContainedPaths(route);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(route.Path))
|
||||
_routablePathConstraint.AddPath(route.Path);
|
||||
}
|
||||
|
||||
private static void SetModelProperties(BuildShapeContext context, RoutePart routable) {
|
||||
var item = context.Shape;
|
||||
item.Title = routable.Title;
|
||||
|
@@ -3,7 +3,6 @@ using Orchard.ContentManagement.Aspects;
|
||||
|
||||
namespace Orchard.Core.Routable.Models {
|
||||
public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect {
|
||||
|
||||
public string Title {
|
||||
get { return Record.Title; }
|
||||
set { Record.Title = value; }
|
||||
@@ -18,5 +17,7 @@ namespace Orchard.Core.Routable.Models {
|
||||
get { return Record.Path; }
|
||||
set { Record.Path = value; }
|
||||
}
|
||||
|
||||
public bool PromoteToHomePage { get; set; }
|
||||
}
|
||||
}
|
@@ -2,7 +2,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Services;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
@@ -10,24 +9,16 @@ namespace Orchard.Core.Routable.Services {
|
||||
[UsedImplicitly]
|
||||
public class RoutableHomePageProvider : IHomePageProvider {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
public const string Name = "RoutableHomePageProvider";
|
||||
|
||||
public RoutableHomePageProvider(
|
||||
IOrchardServices services,
|
||||
IContentManager contentManager,
|
||||
IShapeFactory shapeFactory,
|
||||
IWorkContextAccessor workContextAccessor) {
|
||||
IShapeFactory shapeFactory) {
|
||||
_contentManager = contentManager;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
Shape = shapeFactory;
|
||||
}
|
||||
|
||||
dynamic Shape { get; set; }
|
||||
public IOrchardServices Services { get; private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public string GetProviderName() {
|
||||
return Name;
|
||||
@@ -37,8 +28,8 @@ namespace Orchard.Core.Routable.Services {
|
||||
return GetProviderName() + ";" + id;
|
||||
}
|
||||
|
||||
public ActionResult GetHomePage(int itemId) {
|
||||
var contentItem = _contentManager.Get(itemId, VersionOptions.Published);
|
||||
public ActionResult GetHomePage(int id) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
||||
if (contentItem == null || !contentItem.Is<RoutePart>())
|
||||
return new HttpNotFoundResult();
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
@if (HasText(Model.Description)) {
|
||||
<div class="blog-description">
|
||||
<div class="content-description blog-description">
|
||||
<p>@Model.Description</p>
|
||||
</div>
|
||||
}
|
@@ -31,9 +31,6 @@
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.culture-selection div {
|
||||
font-size:1.4em;
|
||||
}
|
||||
.culture-selection dl {
|
||||
margin:.2em 0;
|
||||
}
|
||||
|
@@ -45,6 +45,8 @@ namespace Orchard.Setup {
|
||||
// standard services needed in setup mode
|
||||
builder.RegisterModule(new MvcModule());
|
||||
builder.RegisterModule(new CommandModule());
|
||||
builder.RegisterModule(new WorkContextModule());
|
||||
|
||||
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<WebFormViewEngineProvider>().As<IViewEngineProvider>().As<IShapeTemplateViewEngine>().InstancePerLifetimeScope();
|
||||
@@ -58,7 +60,7 @@ namespace Orchard.Setup {
|
||||
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<DefaultCommandManager>().As<ICommandManager>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<HelpCommand>().As<ICommandHandler>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<DefaultWorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
||||
builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
|
||||
builder.RegisterType<ResourceManifest>().As<IResourceManifestProvider>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<ResourceManager>().As<IResourceManager>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<ResourceFilter>().As<IFilterProvider>().InstancePerLifetimeScope();
|
||||
|
@@ -38,32 +38,30 @@ namespace Orchard.Users.Services {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public string VerifyUserUnicity(string userName, string email) {
|
||||
IEnumerable<UserPart> allUsers = _contentManager.Query<UserPart, UserPartRecord>().List();
|
||||
string normalizedUserName = userName.ToLower();
|
||||
|
||||
foreach (var user in allUsers) {
|
||||
if (String.Equals(userName.ToLower(), user.NormalizedUserName, StringComparison.OrdinalIgnoreCase)) {
|
||||
return "A user with that name already exists";
|
||||
}
|
||||
if (String.Equals(email, user.Email, StringComparison.OrdinalIgnoreCase)) {
|
||||
return "A user with that email already exists";
|
||||
}
|
||||
if (_contentManager.Query<UserPart, UserPartRecord>()
|
||||
.Where(user =>
|
||||
user.NormalizedUserName == normalizedUserName ||
|
||||
user.Email == email)
|
||||
.List().Any()) {
|
||||
return "User with that username and/or email already exists.";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string VerifyUserUnicity(int id, string userName, string email) {
|
||||
IEnumerable<UserPart> allUsers = _contentManager.Query<UserPart, UserPartRecord>().List();
|
||||
foreach (var user in allUsers) {
|
||||
if (user.Id == id)
|
||||
continue;
|
||||
if (String.Equals(userName.ToLower(), user.NormalizedUserName, StringComparison.OrdinalIgnoreCase)) {
|
||||
return "A user with that name already exists";
|
||||
}
|
||||
if (String.Equals(email, user.Email, StringComparison.OrdinalIgnoreCase)) {
|
||||
return "A user with that email already exists";
|
||||
}
|
||||
string normalizedUserName = userName.ToLower();
|
||||
|
||||
if (_contentManager.Query<UserPart, UserPartRecord>()
|
||||
.Where(user =>
|
||||
user.NormalizedUserName == normalizedUserName ||
|
||||
user.Email == email)
|
||||
.List().Any(user => user.Id != id)) {
|
||||
return "User with that username and/or email already exists.";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -854,7 +854,8 @@ table.items th, table.items td {
|
||||
}
|
||||
/* Core Contents and Orchard.PublishLater */
|
||||
|
||||
.orchard-blogs .edit-item-sidebar, .contents .edit-item-sidebar
|
||||
|
||||
.edit-item-sidebar
|
||||
{
|
||||
border:1px solid #d3d3d3;
|
||||
padding:8px;
|
||||
|
@@ -321,26 +321,25 @@ nav ul
|
||||
/* Main
|
||||
***************************************************************/
|
||||
|
||||
/* Blogs */
|
||||
.blog-description { font-size: 1.231em; }
|
||||
.blog-post .tags { margin-top: 12px; }
|
||||
.blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
||||
.blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; }
|
||||
.blog-posts { padding: 0; margin: 0; list-style: none; }
|
||||
.blog-posts li { padding: 0; margin: 0; }
|
||||
.blog-posts .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
||||
.blog-posts .blog-post header {}
|
||||
.blog-posts .blog-post header h1 { font-size: 1.308em; }
|
||||
.blog-posts .blog-post header h1 a { color: #434343; }
|
||||
.blog-posts .blog-post header h1 a:hover {}
|
||||
.blog-posts .blog-post .tags { margin-top: 12px; }
|
||||
.blog-posts .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
||||
.blog-posts .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
||||
.blog-posts .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
||||
.blog-posts .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
||||
.blog-posts .blog-post .metadata .commentcount { display: inline; }
|
||||
.blog-post {}
|
||||
.blog-post-title {}
|
||||
/* Content lists and details */
|
||||
.content-description { font-size: 1.154em; }
|
||||
.content-items { padding: 0; margin: 0; list-style: none; }
|
||||
.content-items li { padding: 0; margin: 0; }
|
||||
.content-items .content-item { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
||||
.content-items .content-item header {}
|
||||
.content-items .content-item header h1 { font-size: 1.308em; color:#ff0000; }
|
||||
.content-items .content-item header h1 a { color: #434343; }
|
||||
.content-items .content-item header h1 a:hover {}
|
||||
|
||||
/* Tags */
|
||||
.tags { margin-top: 12px; }
|
||||
.tags a { background-color: #dbdbdb; padding: 3px 6px; color: #434343; }
|
||||
.tags a:hover { background-color: #434343; padding: 3px; color: #fff; }
|
||||
|
||||
/* Metadata */
|
||||
.metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
||||
.metadata .published { display: inline; margin: 0 6px 0 0; }
|
||||
.metadata .commentcount { display: inline; }
|
||||
.meta {}
|
||||
|
||||
/* Comments */
|
||||
@@ -359,38 +358,6 @@ nav ul
|
||||
.comment-disabled {}
|
||||
.comment-count { font-size: 1.231em; }
|
||||
|
||||
/* Tag Search */
|
||||
.tagged-posts {}
|
||||
.tagged-posts { padding: 0; margin: 0; list-style: none; }
|
||||
.tagged-posts li { padding: 0; margin: 0; }
|
||||
.tagged-posts .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
||||
.tagged-posts .blog-post header {}
|
||||
.tagged-posts .blog-post header h1 { font-size: 1.308em; }
|
||||
.tagged-posts .blog-post header h1 a { color: #434343; }
|
||||
.tagged-posts .blog-post header h1 a:hover {}
|
||||
.tagged-posts .blog-post .tags { margin-top: 12px; }
|
||||
.tagged-posts .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
||||
.tagged-posts .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
||||
.tagged-posts .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 1.1em; }
|
||||
.tagged-posts .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
||||
.tagged-posts .blog-post .metadata .commentcount { display: inline; }
|
||||
|
||||
/* Search Results */
|
||||
.search-results {}
|
||||
.search-results { padding: 0; margin: 0; list-style: none; }
|
||||
.search-results li { padding: 0; margin: 0; }
|
||||
.search-results .blog-post { border-top: 1px solid #dbdbdb; padding: 6px 0 6px 0; }
|
||||
.search-results .blog-post header {}
|
||||
.search-results .blog-post header h1 { font-size: 1.308em; }
|
||||
.search-results .blog-post header h1 a { color: #434343; }
|
||||
.search-results .blog-post header h1 a:hover {}
|
||||
.search-results .blog-post .tags { margin-top: 12px; }
|
||||
.search-results .blog-post .tags a { background-color: #dbdbdb; padding: 3px; color: #434343; }
|
||||
.search-results .blog-post .tags a:hover { background-color: #434343; padding: 3px; color: #fff; text-decoration: none; }
|
||||
.search-results .blog-post .metadata { margin: 0 0 12px 0; color: #999; font-size: 0.846em; }
|
||||
.search-results .blog-post .metadata .published { display: inline; margin: 0 6px 0 0; }
|
||||
.search-results .blog-post .metadata .commentcount { display: inline; }
|
||||
|
||||
/* Confirmations */
|
||||
.message, .validation-summary-errors { margin:10px 0 4px 0; padding:4px; }
|
||||
.messages a { font-weight:bold; }
|
||||
@@ -455,18 +422,11 @@ nav ul
|
||||
/* Widgets
|
||||
***************************************************************/
|
||||
.widgets {}
|
||||
.widget h1 { font-size: 1.077em; }
|
||||
|
||||
/* Search */
|
||||
/* Search widget shuld go into the sidebar for proper styling */
|
||||
/* TODO: (mibach) Generic any zone compatible search widget */
|
||||
.widget-search-form
|
||||
{
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
right: 12px;
|
||||
}
|
||||
.widget-search-form h1 { font-size: 1.077em; }
|
||||
|
||||
.search-form {}
|
||||
.search-form input[type="text"] { float: left; }
|
||||
.search-form button[type="submit"] { float: left; margin: 0; margin-left: 6px; }
|
||||
@@ -477,12 +437,6 @@ nav ul
|
||||
.widget-control .manage-actions { position:absolute; top: 0px; right: 0px; }
|
||||
.widget-control .manage-actions a { display: block; background-color: #dbdbdb; color: #434343; padding: 3px 6px; }
|
||||
.widget-control .manage-actions a:hover { background-color: #434343; color: #fff; text-decoration: none; }
|
||||
.widget-control .widget-search-form /* TODO: (mibach) Remove special case for Search Widget */
|
||||
{
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 12px;
|
||||
}
|
||||
|
||||
/* Content Mode */
|
||||
.content-control { position: relative; border: 1px dotted #5f97af; }
|
||||
|
Reference in New Issue
Block a user