mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Commented out everything that changes the alias of a content item.
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Orchard.Autoroute.Drivers {
|
||||
|
||||
var settings = part.TypePartDefinition.Settings.GetModel<AutorouteSettings>();
|
||||
|
||||
// if the content type has no pattern for autoroute, then use a default one
|
||||
// If the content type has no pattern for autoroute, then use a default one.
|
||||
if(!settings.Patterns.Any()) {
|
||||
settings.AllowCustomPattern = true;
|
||||
settings.AutomaticAdjustmentOnEdit = false;
|
||||
@@ -63,16 +63,15 @@ namespace Orchard.Autoroute.Drivers {
|
||||
Settings = settings
|
||||
};
|
||||
|
||||
// retrieve home page
|
||||
var homepage = _aliasService.Get(string.Empty);
|
||||
// Retrieve home page.
|
||||
//var homepage = _aliasService.Get(string.Empty);
|
||||
var displayRouteValues = _contentManager.GetItemMetadata(part).DisplayRouteValues;
|
||||
|
||||
viewModel.IsHomePage = homepage.Match(displayRouteValues);
|
||||
viewModel.PromoteToHomePage = viewModel.IsHomePage || part.DisplayAlias == "/";
|
||||
//viewModel.IsHomePage = homepage.Match(displayRouteValues);
|
||||
//viewModel.PromoteToHomePage = viewModel.IsHomePage || part.DisplayAlias == "/";
|
||||
|
||||
if (settings.PerItemConfiguration) {
|
||||
// if enabled, the list of all available patterns is displayed, and the user can
|
||||
// select which one to use
|
||||
// If enabled, the list of all available patterns is displayed, and the user can select which one to use.
|
||||
|
||||
// todo: later
|
||||
}
|
||||
@@ -80,14 +79,14 @@ namespace Orchard.Autoroute.Drivers {
|
||||
var previous = part.DisplayAlias;
|
||||
if (updater != null && updater.TryUpdateModel(viewModel, Prefix, null, null)) {
|
||||
|
||||
// remove any leading slash in the permalink
|
||||
// Remove any leading slash in the permalink.
|
||||
if (viewModel.CurrentUrl != null) {
|
||||
viewModel.CurrentUrl = viewModel.CurrentUrl.TrimStart('/');
|
||||
}
|
||||
|
||||
part.DisplayAlias = viewModel.CurrentUrl;
|
||||
|
||||
// reset the alias if we need to force regeneration, and the user didn't provide a custom one
|
||||
// Reset the alias if we need to force regeneration, and the user didn't provide a custom one.
|
||||
if(settings.AutomaticAdjustmentOnEdit && previous == part.DisplayAlias) {
|
||||
part.DisplayAlias = string.Empty;
|
||||
}
|
||||
@@ -96,13 +95,12 @@ namespace Orchard.Autoroute.Drivers {
|
||||
updater.AddModelError("CurrentUrl", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\", \"|\", \"%\", \".\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
|
||||
// if CurrentUrl is set, the handler won't try to create an alias for it
|
||||
// but instead keep the value
|
||||
// If CurrentUrl is set, the handler won't try to create an alias for it but instead keep the value.
|
||||
|
||||
// if home page is requested, use "/" to have the handler create a homepage alias
|
||||
if(viewModel.PromoteToHomePage) {
|
||||
part.DisplayAlias = "/";
|
||||
}
|
||||
//// If home page is requested, use "/" to have the handler create a homepage alias.
|
||||
//if(viewModel.PromoteToHomePage) {
|
||||
// part.DisplayAlias = "/";
|
||||
//}
|
||||
}
|
||||
|
||||
return ContentShape("Parts_Autoroute_Edit",
|
||||
@@ -127,7 +125,7 @@ namespace Orchard.Autoroute.Drivers {
|
||||
}
|
||||
|
||||
protected override void Exporting(AutoroutePart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Alias", String.IsNullOrEmpty(part.Record.DisplayAlias) ? "/" : part.Record.DisplayAlias);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Alias", part.Record.DisplayAlias);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("CustomPattern", part.Record.CustomPattern);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("UseCustomPattern", part.Record.UseCustomPattern);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
@@ -56,24 +54,24 @@ namespace Orchard.Autoroute.Handlers {
|
||||
private void PublishAlias(AutoroutePart part) {
|
||||
ProcessAlias(part);
|
||||
|
||||
// should it become the home page ?
|
||||
if (part.DisplayAlias == "/") {
|
||||
part.DisplayAlias = String.Empty;
|
||||
//// should it become the home page ?
|
||||
//if (part.DisplayAlias == "/") {
|
||||
// part.DisplayAlias = String.Empty;
|
||||
|
||||
// regenerate the alias for the previous home page
|
||||
var currentHomePages = _orchardServices.ContentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias == "").List();
|
||||
foreach (var current in currentHomePages.Where(x => x.Id != part.Id)) {
|
||||
if (current != null) {
|
||||
current.CustomPattern = String.Empty; // force the regeneration
|
||||
current.DisplayAlias = _autorouteService.Value.GenerateAlias(current);
|
||||
// // regenerate the alias for the previous home page
|
||||
// var currentHomePages = _orchardServices.ContentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias == "").List();
|
||||
// foreach (var current in currentHomePages.Where(x => x.Id != part.Id)) {
|
||||
// if (current != null) {
|
||||
// current.CustomPattern = String.Empty; // force the regeneration
|
||||
// current.DisplayAlias = _autorouteService.Value.GenerateAlias(current);
|
||||
|
||||
// we changed the alias of the previous homepage, so publish this change if the content item was published.
|
||||
if(current.IsPublished())
|
||||
_orchardServices.ContentManager.Publish(current.ContentItem);
|
||||
}
|
||||
_autorouteService.Value.PublishAlias(current);
|
||||
}
|
||||
}
|
||||
// // we changed the alias of the previous homepage, so publish this change if the content item was published.
|
||||
// if(current.IsPublished())
|
||||
// _orchardServices.ContentManager.Publish(current.ContentItem);
|
||||
// }
|
||||
// _autorouteService.Value.PublishAlias(current);
|
||||
// }
|
||||
//}
|
||||
|
||||
_autorouteService.Value.PublishAlias(part);
|
||||
}
|
||||
@@ -95,8 +93,9 @@ namespace Orchard.Autoroute.Handlers {
|
||||
if (part.DisplayAlias != "/") {
|
||||
var previous = part.Path;
|
||||
if (!_autorouteService.Value.ProcessPath(part))
|
||||
_orchardServices.Notifier.Warning(T("Permalinks in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
||||
previous, part.Path, part.ContentItem.ContentType));
|
||||
_orchardServices.Notifier.Warning(
|
||||
T("Permalinks in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
||||
previous, part.Path, part.ContentItem.ContentType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,23 +117,23 @@ namespace Orchard.Autoroute.Services {
|
||||
}
|
||||
|
||||
public void RemoveAliases(AutoroutePart part) {
|
||||
// https://github.com/OrchardCMS/Orchard/issues/5137
|
||||
// If the alias of the specified part is empty while not being the homepage,
|
||||
// we need to make sure we are not removing all empty aliases in order to prevent losing the homepage content item being the homepage.
|
||||
if (String.IsNullOrWhiteSpace(part.Path)) {
|
||||
if (!IsHomePage(part)) {
|
||||
// The item being removed is NOT the homepage, so we need to make sure we're not removing the alias for the homepage.
|
||||
var aliasRecordId = GetHomePageAliasRecordId();
|
||||
//// https://github.com/OrchardCMS/Orchard/issues/5137
|
||||
//// If the alias of the specified part is empty while not being the homepage,
|
||||
//// we need to make sure we are not removing all empty aliases in order to prevent losing the homepage content item being the homepage.
|
||||
//if (String.IsNullOrWhiteSpace(part.Path)) {
|
||||
// if (!IsHomePage(part)) {
|
||||
// // The item being removed is NOT the homepage, so we need to make sure we're not removing the alias for the homepage.
|
||||
// var aliasRecordId = GetHomePageAliasRecordId();
|
||||
|
||||
// Remove all aliases EXCEPT for the alias of the homepage.
|
||||
_aliasStorage.Remove(x => x.Path == part.Path && x.Source == AliasSource && x.Id != aliasRecordId);
|
||||
// // Remove all aliases EXCEPT for the alias of the homepage.
|
||||
// _aliasStorage.Remove(x => x.Path == part.Path && x.Source == AliasSource && x.Id != aliasRecordId);
|
||||
|
||||
// Done.
|
||||
return;
|
||||
}
|
||||
}
|
||||
// // Done.
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
// Safe to delete all aliases for the specified part since it is definitely not the homepage.
|
||||
//// Safe to delete all aliases for the specified part since it is definitely not the homepage.
|
||||
_aliasService.Delete(part.Path, AliasSource);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Orchard.Autoroute.Services {
|
||||
if (existingPaths == null || !existingPaths.Contains(part.Path))
|
||||
return part.Path;
|
||||
|
||||
int? version = existingPaths.Select(s => GetSlugVersion(part.Path, s)).OrderBy(i => i).LastOrDefault();
|
||||
var version = existingPaths.Select(s => GetSlugVersion(part.Path, s)).OrderBy(i => i).LastOrDefault();
|
||||
|
||||
return version != null
|
||||
? String.Format("{0}-{1}", part.Path, version)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Text.RegularExpressions;
|
||||
using Orchard.Utility.Extensions;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Autoroute.Services {
|
||||
|
||||
@@ -86,6 +84,5 @@ namespace Orchard.Autoroute.Services {
|
||||
public string Slugify(string text) {
|
||||
return Slugify(new FillSlugContext(null, text));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,15 +94,15 @@ namespace Orchard.Pages.Commands {
|
||||
}
|
||||
}
|
||||
|
||||
// (PH:Autoroute) Hackish way to leave Slug and Homepage switches intact without requiring a dependency on Autoroute. This may throw an Exception with
|
||||
// no AutoroutePart. But it means that normal setup recipes will still be able to give you a homepage without issue.
|
||||
if (Homepage || !String.IsNullOrWhiteSpace(Slug)) {
|
||||
dynamic dpage = page;
|
||||
if (dpage.AutoroutePart != null) {
|
||||
dpage.AutoroutePart.UseCustomPattern = true;
|
||||
dpage.AutoroutePart.CustomPattern = Homepage ? "/" : Slug;
|
||||
}
|
||||
}
|
||||
//// (PH:Autoroute) Hackish way to leave Slug and Homepage switches intact without requiring a dependency on Autoroute. This may throw an Exception with
|
||||
//// no AutoroutePart. But it means that normal setup recipes will still be able to give you a homepage without issue.
|
||||
//if (Homepage || !String.IsNullOrWhiteSpace(Slug)) {
|
||||
// dynamic dpage = page;
|
||||
// if (dpage.AutoroutePart != null) {
|
||||
// dpage.AutoroutePart.UseCustomPattern = true;
|
||||
// dpage.AutoroutePart.CustomPattern = Homepage ? "/" : Slug;
|
||||
// }
|
||||
//}
|
||||
|
||||
var layout = default(string);
|
||||
if (UseWelcomeText) {
|
||||
|
||||
Reference in New Issue
Block a user