mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 05:23:33 +08:00
Updating the Routeable slugify to use the item's path
--HG-- branch : dev
This commit is contained in:
@@ -44,21 +44,8 @@ namespace Orchard.Core.Containers.Drivers {
|
|||||||
if (updater != null) {
|
if (updater != null) {
|
||||||
var oldContainerId = model.ContainerId;
|
var oldContainerId = model.ContainerId;
|
||||||
updater.TryUpdateModel(model, "Containable", null, null);
|
updater.TryUpdateModel(model, "Containable", null, null);
|
||||||
if (oldContainerId != model.ContainerId) {
|
if (oldContainerId != model.ContainerId)
|
||||||
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
||||||
// reprocess slug
|
|
||||||
var routable = part.As<IRoutableAspect>();
|
|
||||||
_routableService.ProcessSlug(part.As<IRoutableAspect>());
|
|
||||||
if (!_routableService.ProcessSlug(routable)) {
|
|
||||||
var existingConflict = _services.Notifier.List().FirstOrDefault(n => n.Message.TextHint == "Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"");
|
|
||||||
if (existingConflict != null)
|
|
||||||
existingConflict.Message = T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
|
||||||
routable.Slug, routable.GetEffectiveSlug(), routable.ContentItem.ContentType);
|
|
||||||
else
|
|
||||||
_services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
|
||||||
routable.Slug, routable.GetEffectiveSlug(), routable.ContentItem.ContentType));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var containers = _contentManager.Query<ContainerPart, ContainerPartRecord>(VersionOptions.Latest).List();
|
var containers = _contentManager.Query<ContainerPart, ContainerPartRecord>(VersionOptions.Latest).List();
|
||||||
|
@@ -213,10 +213,7 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't create content")))
|
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't create content")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var isDraftable = contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable;
|
_contentManager.Create(contentItem, VersionOptions.Draft);
|
||||||
_contentManager.Create(
|
|
||||||
contentItem,
|
|
||||||
isDraftable ? VersionOptions.Draft : VersionOptions.Published);
|
|
||||||
|
|
||||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
|
@@ -4,6 +4,7 @@ using System.Web.Mvc;
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
|
using Orchard.Core.Routable.Services;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -62,7 +63,7 @@ namespace Orchard.Core.Routable.Controllers {
|
|||||||
contentItem = _contentManager.Get((int)id, VersionOptions.Latest);
|
contentItem = _contentManager.Get((int)id, VersionOptions.Latest);
|
||||||
|
|
||||||
if (contentItem == null) {
|
if (contentItem == null) {
|
||||||
contentItem = _contentManager.New(contentType);
|
contentItem = _contentManager.Create(contentType, VersionOptions.Draft);
|
||||||
|
|
||||||
if (containerId != null) {
|
if (containerId != null) {
|
||||||
var containerItem = _contentManager.Get((int)containerId);
|
var containerItem = _contentManager.Get((int)containerId);
|
||||||
@@ -71,9 +72,10 @@ namespace Orchard.Core.Routable.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_contentManager.UpdateEditor(contentItem, this);
|
_contentManager.UpdateEditor(contentItem, this);
|
||||||
|
_contentManager.Publish(contentItem);
|
||||||
_transactionManager.Cancel();
|
_transactionManager.Cancel();
|
||||||
|
|
||||||
return Json(contentItem.As<IRoutableAspect>().Slug ?? slug);
|
return Json(contentItem.As<IRoutableAspect>().GetEffectiveSlug() ?? slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -79,10 +79,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)."));
|
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 (!_routableService.ProcessSlug(part))
|
|
||||||
_services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
|
||||||
part.Slug, part.GetEffectiveSlug(), part.ContentItem.ContentType));
|
|
||||||
|
|
||||||
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)
|
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)
|
||||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ namespace Orchard.Core.Routable.Handlers {
|
|||||||
OnGetEditorShape<RoutePart>(SetModelProperties);
|
OnGetEditorShape<RoutePart>(SetModelProperties);
|
||||||
OnUpdateEditorShape<RoutePart>(SetModelProperties);
|
OnUpdateEditorShape<RoutePart>(SetModelProperties);
|
||||||
|
|
||||||
OnPublished<RoutePart>((context, routable) => {
|
OnPublishing<RoutePart>((context, routable) => {
|
||||||
if (context.PublishingItemVersionRecord != null)
|
if (context.PublishingItemVersionRecord != null)
|
||||||
processSlug(routable);
|
processSlug(routable);
|
||||||
if (!string.IsNullOrEmpty(routable.Path))
|
if (!string.IsNullOrEmpty(routable.Path))
|
||||||
|
Reference in New Issue
Block a user