mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed format settings. Made IsManaged optional with default value false in IAliasService.
This commit is contained in:
@@ -3,17 +3,14 @@ using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.Alias
|
||||
{
|
||||
namespace Orchard.Alias {
|
||||
[OrchardFeature("Orchard.Alias.UI")]
|
||||
public class AdminMenu : INavigationProvider
|
||||
{
|
||||
public class AdminMenu : INavigationProvider {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder)
|
||||
{
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder
|
||||
.Add(T("Aliases"), "4", item => item.Action("Index", "Admin", new { area = "Orchard.Alias" }).Permission(StandardPermissions.SiteOwner));
|
||||
}
|
||||
|
@@ -55,8 +55,7 @@ namespace Orchard.Alias.Controllers {
|
||||
|
||||
aliases = aliases.ToList();
|
||||
|
||||
switch (options.Filter)
|
||||
{
|
||||
switch (options.Filter) {
|
||||
case AliasFilter.Managed:
|
||||
aliases = aliases.Where(x => x.IsManaged);
|
||||
break;
|
||||
@@ -212,8 +211,7 @@ namespace Orchard.Alias.Controllers {
|
||||
try {
|
||||
_aliasService.Set(aliasPath, routePath, "Custom", false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
Services.TransactionManager.Cancel();
|
||||
Services.Notifier.Error(T("An error occured while editing the alias '{0}': {1}. Please check the values are correct.", aliasPath, ex.Message));
|
||||
Logger.Error(ex, T("An error occured while creating the alias '{0}'", aliasPath).Text);
|
||||
@@ -251,8 +249,7 @@ namespace Orchard.Alias.Controllers {
|
||||
return this.RedirectLocal(returnUrl, Url.Action("Index"));
|
||||
}
|
||||
|
||||
private string GetExistingPathForAlias(string aliasPath)
|
||||
{
|
||||
private string GetExistingPathForAlias(string aliasPath) {
|
||||
var routeValues = _aliasService.Get(aliasPath.TrimStart('/', '\\'));
|
||||
if (routeValues == null) return null;
|
||||
|
||||
@@ -261,8 +258,7 @@ namespace Orchard.Alias.Controllers {
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
private bool CheckAndWarnIfAliasExists(string aliasPath)
|
||||
{
|
||||
private bool CheckAndWarnIfAliasExists(string aliasPath) {
|
||||
var routePath = GetExistingPathForAlias(aliasPath);
|
||||
if (routePath == null) return false;
|
||||
|
||||
|
@@ -5,8 +5,8 @@ using System.Web.Routing;
|
||||
namespace Orchard.Alias {
|
||||
public interface IAliasService : IDependency {
|
||||
RouteValueDictionary Get(string aliasPath);
|
||||
void Set(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged);
|
||||
void Set(string aliasPath, string routePath, string aliasSource, bool isManaged);
|
||||
void Set(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged = false);
|
||||
void Set(string aliasPath, string routePath, string aliasSource, bool isManaged = false);
|
||||
void Delete(string aliasPath);
|
||||
void Delete(string aliasPath, string aliasSource);
|
||||
/// <summary>
|
||||
@@ -18,8 +18,8 @@ namespace Orchard.Alias {
|
||||
IEnumerable<string> Lookup(RouteValueDictionary routeValues);
|
||||
IEnumerable<string> Lookup(string routePath);
|
||||
|
||||
void Replace(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged);
|
||||
void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged);
|
||||
void Replace(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged = false);
|
||||
void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged = false);
|
||||
|
||||
IEnumerable<Tuple<string, RouteValueDictionary>> List();
|
||||
IEnumerable<Tuple<string, RouteValueDictionary, string>> List(string sourceStartsWith);
|
||||
|
@@ -32,8 +32,7 @@ namespace Orchard.Alias.Implementation {
|
||||
//IDictionary<string, string> routeValues;
|
||||
AliasInfo aliasInfo;
|
||||
// TODO: Might as well have the lookup in AliasHolder...
|
||||
if (_aliasMap.TryGetAlias(virtualPath, out aliasInfo))
|
||||
{
|
||||
if (_aliasMap.TryGetAlias(virtualPath, out aliasInfo)) {
|
||||
// Construct RouteData from the route values
|
||||
var data = new RouteData(this, _routeHandler);
|
||||
foreach (var routeValue in aliasInfo.RouteValues) {
|
||||
|
@@ -80,8 +80,7 @@ namespace Orchard.Alias.Implementation {
|
||||
Set(aliasPath, routeValues, aliasSource, isManaged);
|
||||
}
|
||||
|
||||
public void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged)
|
||||
{
|
||||
public void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged) {
|
||||
Replace(aliasPath, ToDictionary(routePath).ToRouteValueDictionary(), aliasSource, isManaged);
|
||||
}
|
||||
|
||||
@@ -157,8 +156,7 @@ namespace Orchard.Alias.Implementation {
|
||||
}
|
||||
|
||||
private class StubHttpContext : HttpContextBase {
|
||||
public override HttpRequestBase Request
|
||||
{
|
||||
public override HttpRequestBase Request {
|
||||
get { return new StubHttpRequest(); }
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,7 @@ namespace Orchard.Alias.Implementation.Map {
|
||||
return _aliases.Select(x => new AliasInfo { Area = _area, Path = x.Key, RouteValues = x.Value.RouteValues, IsManaged = x.Value.IsManaged });
|
||||
}
|
||||
|
||||
public bool TryGetAlias(string virtualPath, out AliasInfo aliasInfo)
|
||||
{
|
||||
public bool TryGetAlias(string virtualPath, out AliasInfo aliasInfo) {
|
||||
return _aliases.TryGetValue(virtualPath, out aliasInfo);
|
||||
}
|
||||
|
||||
|
@@ -114,8 +114,7 @@ namespace Orchard.Alias.Implementation.Storage {
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Tuple<string, string, IDictionary<string, string>, string, int, bool>> List()
|
||||
{
|
||||
public IEnumerable<Tuple<string, string, IDictionary<string, string>, string, int, bool>> List() {
|
||||
return List((Expression<Func<AliasRecord, bool>>)null);
|
||||
}
|
||||
|
||||
@@ -129,13 +128,11 @@ namespace Orchard.Alias.Implementation.Storage {
|
||||
return table.OrderBy(a => a.Id).Select(ToDictionary).ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Tuple<string, string, IDictionary<string, string>, string, int, bool>> List(string sourceStartsWith)
|
||||
{
|
||||
public IEnumerable<Tuple<string, string, IDictionary<string, string>, string, int, bool>> List(string sourceStartsWith) {
|
||||
return List(a => a.Source.StartsWith(sourceStartsWith));
|
||||
}
|
||||
|
||||
private static Tuple<string, string, IDictionary<string, string>, string, int, bool> ToDictionary(AliasRecord aliasRecord)
|
||||
{
|
||||
private static Tuple<string, string, IDictionary<string, string>, string, int, bool> ToDictionary(AliasRecord aliasRecord) {
|
||||
IDictionary<string, string> routeValues = new Dictionary<string, string>();
|
||||
if (aliasRecord.Action.Area != null) {
|
||||
routeValues.Add("area", aliasRecord.Action.Area);
|
||||
|
@@ -20,8 +20,7 @@ namespace Orchard.Alias {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int UpdateFrom1()
|
||||
{
|
||||
public int UpdateFrom1() {
|
||||
SchemaBuilder.AlterTable("AliasRecord",
|
||||
table => table
|
||||
.AddColumn<bool>("IsManaged", column => column.WithDefault(false))
|
||||
|
@@ -7,12 +7,11 @@ using Orchard.Alias.Records;
|
||||
using Orchard.Alias.Implementation.Holder;
|
||||
|
||||
namespace Orchard.Roles.Recipes.Builders {
|
||||
public class RolesStep : RecipeBuilderStep {
|
||||
public class AliasStep : RecipeBuilderStep {
|
||||
private readonly IRepository<AliasRecord> _aliasRecordepository;
|
||||
private readonly IAliasHolder _aliasHolder;
|
||||
|
||||
public RolesStep(IRepository<AliasRecord> aliasRecordRepository, IAliasHolder aliasHolder)
|
||||
{
|
||||
public AliasStep(IRepository<AliasRecord> aliasRecordRepository, IAliasHolder aliasHolder) {
|
||||
_aliasRecordepository = aliasRecordRepository;
|
||||
_aliasHolder = aliasHolder;
|
||||
}
|
||||
@@ -38,13 +37,11 @@ namespace Orchard.Roles.Recipes.Builders {
|
||||
var root = new XElement("Aliases");
|
||||
context.RecipeDocument.Element("Orchard").Add(root);
|
||||
|
||||
foreach (var alias in aliases.OrderBy(x => x.Path))
|
||||
{
|
||||
foreach (var alias in aliases.OrderBy(x => x.Path)) {
|
||||
var aliasElement = new XElement("Alias", new XAttribute("Path", alias.Path));
|
||||
|
||||
var routeValuesElement = new XElement("RouteValues");
|
||||
foreach (var routeValue in alias.RouteValues)
|
||||
{
|
||||
foreach (var routeValue in alias.RouteValues) {
|
||||
routeValuesElement.Add(new XElement("Add", new XAttribute("Key", routeValue.Key), new XAttribute("Value", routeValue.Value)));
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,7 @@ namespace Orchard.Alias.Recipes.Executors {
|
||||
public class AliasStep : RecipeExecutionStep {
|
||||
private readonly IAliasService _aliasService;
|
||||
|
||||
public AliasStep(IAliasService aliasService)
|
||||
{
|
||||
public AliasStep(IAliasService aliasService) {
|
||||
_aliasService = aliasService;
|
||||
}
|
||||
|
||||
@@ -42,10 +41,8 @@ namespace Orchard.Alias.Recipes.Executors {
|
||||
|
||||
var routeValuesElement = aliasElement.Descendants("RouteValues").FirstOrDefault();
|
||||
|
||||
if (routeValuesElement != null)
|
||||
{
|
||||
foreach (var routeValue in routeValuesElement.Descendants("Add"))
|
||||
{
|
||||
if (routeValuesElement != null) {
|
||||
foreach (var routeValue in routeValuesElement.Descendants("Add")) {
|
||||
rvd.Add(routeValue.Attribute("Key").Value, routeValue.Attribute("Value").Value);
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Orchard.Alias.ViewModels {
|
||||
public AliasInfo Alias { get; set; }
|
||||
public bool IsChecked { get; set; }
|
||||
}
|
||||
|
||||
public class AdminIndexOptions {
|
||||
public string Search { get; set; }
|
||||
public AliasOrder Order { get; set; }
|
||||
|
@@ -146,7 +146,8 @@ namespace Orchard.Autoroute.Services {
|
||||
if (String.Equals(culture, _cultureManager.GetSiteCulture(), StringComparison.OrdinalIgnoreCase) && !String.IsNullOrWhiteSpace(patternIndex)) {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = patternIndex, Culture = culture });
|
||||
return settings.Patterns.Where(x => x.Culture == null).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == culture).FirstOrDefault().PatternIndex));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = culture });
|
||||
return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture };
|
||||
}
|
||||
|
@@ -39,8 +39,7 @@ namespace Orchard.Blogs.Routing {
|
||||
|
||||
//IDictionary<string, string> routeValues;
|
||||
AliasInfo aliasInfo;
|
||||
if (!_aliasHolder.GetMap("Orchard.Blogs").TryGetAlias(path, out aliasInfo))
|
||||
{
|
||||
if (!_aliasHolder.GetMap("Orchard.Blogs").TryGetAlias(path, out aliasInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user