mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +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;
|
||||
@@ -146,9 +145,9 @@ namespace Orchard.Alias.Controllers {
|
||||
}
|
||||
|
||||
try {
|
||||
_aliasService.Set(aliasPath, routePath, "Custom",false);
|
||||
_aliasService.Set(aliasPath, routePath, "Custom", false);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
catch (Exception ex) {
|
||||
Services.TransactionManager.Cancel();
|
||||
Services.Notifier.Error(T("An error occured while creating 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);
|
||||
@@ -210,10 +209,9 @@ namespace Orchard.Alias.Controllers {
|
||||
}
|
||||
|
||||
try {
|
||||
_aliasService.Set(aliasPath, routePath, "Custom",false);
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -148,21 +147,20 @@ namespace Orchard.Alias.Implementation {
|
||||
private IEnumerable<RouteDescriptor> GetRouteDescriptors() {
|
||||
return _routeProviders
|
||||
.SelectMany(routeProvider => {
|
||||
var routes = new List<RouteDescriptor>();
|
||||
routeProvider.GetRoutes(routes);
|
||||
return routes;
|
||||
})
|
||||
var routes = new List<RouteDescriptor>();
|
||||
routeProvider.GetRoutes(routes);
|
||||
return routes;
|
||||
})
|
||||
.Where(routeDescriptor => !(routeDescriptor.Route is AliasRoute))
|
||||
.OrderByDescending(routeDescriptor => routeDescriptor.Priority);
|
||||
}
|
||||
|
||||
private class StubHttpContext : HttpContextBase {
|
||||
public override HttpRequestBase Request
|
||||
{
|
||||
get{return new StubHttpRequest();}
|
||||
public override HttpRequestBase Request {
|
||||
get { return new StubHttpRequest(); }
|
||||
}
|
||||
|
||||
private class StubHttpRequest : HttpRequestBase {}
|
||||
private class StubHttpRequest : HttpRequestBase { }
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
@@ -36,7 +35,7 @@ namespace Orchard.Alias.Implementation.Map {
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="AliasInfo"/> intance to add</param>
|
||||
public void Insert(AliasInfo info) {
|
||||
if(info == null) {
|
||||
if (info == null) {
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
_aliases[info.Path] = info;
|
||||
@@ -73,18 +72,18 @@ namespace Orchard.Alias.Implementation.Map {
|
||||
}
|
||||
// Set the path at the end of the tree
|
||||
object takenPath;
|
||||
focus.Paths.TryRemove(path,out takenPath);
|
||||
focus.Paths.TryRemove(path, out takenPath);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ExpandTree(Node root, string path, IDictionary<string, string> routeValues) {
|
||||
foreach(var expanded in Expand(routeValues)) {
|
||||
foreach (var expanded in Expand(routeValues)) {
|
||||
var focus = root;
|
||||
foreach (var routeValue in expanded.OrderBy(kv => kv.Key, StringComparer.InvariantCultureIgnoreCase)) {
|
||||
// See if we already have a stem for this route key (i.e. "controller") and create if not
|
||||
var stem = focus.Stems.GetOrAdd(routeValue.Key,key=>new ConcurrentDictionary<string, Node>(StringComparer.InvariantCultureIgnoreCase));
|
||||
var stem = focus.Stems.GetOrAdd(routeValue.Key, key => new ConcurrentDictionary<string, Node>(StringComparer.InvariantCultureIgnoreCase));
|
||||
// See if the stem has a node for this value (i.e. "Item") and create if not
|
||||
var node = stem.GetOrAdd(routeValue.Value, key=>new Node());
|
||||
var node = stem.GetOrAdd(routeValue.Value, key => new Node());
|
||||
// Keep switching to new node until we reach deepest match
|
||||
// TODO: (PH) Thread safety: at this point something could techincally traverse and find an empty node with a blank path ... not fatal
|
||||
// since it will simply not match and therefore return a default-looking route instead of the aliased one. And the changes of that route
|
||||
@@ -111,16 +110,16 @@ namespace Orchard.Alias.Implementation.Map {
|
||||
|
||||
// For each key/value pair, we want a list containing a single list with either the term, or the term and the "default" value
|
||||
var termSets = ordered.Select(term => {
|
||||
if (term.Key.EndsWith("-")) {
|
||||
var termKey = term.Key.Substring(0, term.Key.Length - 1);
|
||||
return new[] {
|
||||
if (term.Key.EndsWith("-")) {
|
||||
var termKey = term.Key.Substring(0, term.Key.Length - 1);
|
||||
return new[] {
|
||||
// This entry will auto-match in some cases because it was omitted from the route values
|
||||
new [] { new KeyValuePair<string, string>(termKey, "\u0000") },
|
||||
new [] { new KeyValuePair<string, string>(termKey, term.Value) }
|
||||
};
|
||||
}
|
||||
return new[] {new[] {term}};
|
||||
});
|
||||
}
|
||||
return new[] { new[] { term } };
|
||||
});
|
||||
|
||||
// Run each of those lists through an aggregation function, by taking the product of each set, so producting a tree of possibilities
|
||||
var produced = termSets.Aggregate(new[] { empty }.AsEnumerable(), (coords, termSet) => Product(coords, termSet, (coord, term) => coord.Concat(term)));
|
||||
@@ -191,7 +190,7 @@ namespace Orchard.Alias.Implementation.Map {
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<string, ConcurrentDictionary<string, Node>> Stems { get; set; }
|
||||
public ConcurrentDictionary<string,object> Paths { get; set; }
|
||||
public ConcurrentDictionary<string, object> Paths { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -110,12 +110,11 @@ namespace Orchard.Alias.Implementation.Storage {
|
||||
// Bulk updates might go wrong if we don't flush.
|
||||
_aliasRepository.Flush();
|
||||
var dict = ToDictionary(aliasRecord);
|
||||
_aliasHolder.RemoveAlias(new AliasInfo() { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6});
|
||||
_aliasHolder.RemoveAlias(new AliasInfo() { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6 });
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -30,7 +29,7 @@ namespace Orchard.Roles.Recipes.Builders {
|
||||
}
|
||||
|
||||
public override void Build(BuildContext context) {
|
||||
var aliases = _aliasHolder.GetMaps().SelectMany(m => m.GetAliases()).Where(m => m.IsManaged== false).ToList();
|
||||
var aliases = _aliasHolder.GetMaps().SelectMany(m => m.GetAliases()).Where(m => m.IsManaged == false).ToList();
|
||||
|
||||
if (!aliases.Any())
|
||||
return;
|
||||
@@ -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,17 +41,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
_aliasService.Set(aliasPath, rvd, "Custom", false);
|
||||
}
|
||||
_aliasService.Set(aliasPath, rvd, "Custom", false);
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex, "Error while processing alias '{0}'.", aliasPath);
|
||||
@@ -61,5 +58,5 @@ namespace Orchard.Alias.Recipes.Executors {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -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; }
|
||||
|
@@ -4,25 +4,25 @@
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<legend>@T("Create Alias")</legend>
|
||||
<div>
|
||||
<label for="aliasPath">@T("Alias Path")</label>
|
||||
@Html.TextBox("aliasPath", (object)ViewBag.Path, new { @class = "text large" })
|
||||
@Html.ValidationMessage("aliasPath")
|
||||
<span class="hint">@T("The path of the alias e.g., my-blog/my-post")</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="routePath">@T("Route Path")</label>
|
||||
@Html.TextBox("routePath", (object)ViewBag.Route, new { @class = "text medium" })
|
||||
@Html.ValidationMessage("routePath")
|
||||
<span class="hint">@T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
@Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" })
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
<fieldset>
|
||||
<legend>@T("Create Alias")</legend>
|
||||
<div>
|
||||
<label for="aliasPath">@T("Alias Path")</label>
|
||||
@Html.TextBox("aliasPath", (object)ViewBag.Path, new { @class = "text large" })
|
||||
@Html.ValidationMessage("aliasPath")
|
||||
<span class="hint">@T("The path of the alias e.g., my-blog/my-post")</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="routePath">@T("Route Path")</label>
|
||||
@Html.TextBox("routePath", (object)ViewBag.Route, new { @class = "text medium" })
|
||||
@Html.ValidationMessage("routePath")
|
||||
<span class="hint">@T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
@Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" })
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
@@ -3,11 +3,11 @@
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
<legend>@T("Delete alias")</legend>
|
||||
<p>@T("Removing alias '{0}'. Are you sure?", ViewBag.Path)</p>
|
||||
@Html.Hidden("path")
|
||||
@Html.Hidden("confirmed", true)
|
||||
<button class="primaryAction" type="submit">@T("Yes")</button>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>@T("Delete alias")</legend>
|
||||
<p>@T("Removing alias '{0}'. Are you sure?", ViewBag.Path)</p>
|
||||
@Html.Hidden("path")
|
||||
@Html.Hidden("confirmed", true)
|
||||
<button class="primaryAction" type="submit">@T("Yes")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
@@ -4,25 +4,25 @@
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<legend>@T("Edit alias")</legend>
|
||||
<div>
|
||||
<label for="aliasPath">@T("Alias Path")</label>
|
||||
@Html.TextBox("aliasPath", null, new { @class = "text large" })
|
||||
@Html.ValidationMessage("aliasPath")
|
||||
<span class="hint">@T("The path of the alias e.g., my-blog/my-post")</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="routePath">@T("Route Path")</label>
|
||||
@Html.TextBox("routePath", null, new { @class = "text medium" })
|
||||
@Html.ValidationMessage("routePath")
|
||||
<span class="hint">@T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
@Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" })
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
<fieldset>
|
||||
<legend>@T("Edit alias")</legend>
|
||||
<div>
|
||||
<label for="aliasPath">@T("Alias Path")</label>
|
||||
@Html.TextBox("aliasPath", null, new { @class = "text large" })
|
||||
@Html.ValidationMessage("aliasPath")
|
||||
<span class="hint">@T("The path of the alias e.g., my-blog/my-post")</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="routePath">@T("Route Path")</label>
|
||||
@Html.TextBox("routePath", null, new { @class = "text medium" })
|
||||
@Html.ValidationMessage("routePath")
|
||||
<span class="hint">@T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
@Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" })
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@
|
||||
<button type="submit" name="submit.BulkEdit" value="@T("Apply")">@T("Apply")</button>
|
||||
</fieldset>
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="filterResults">@T("Sort by:")</label>
|
||||
<label for="filterResults">@T("Sort by:")</label>
|
||||
<select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
|
||||
@Html.SelectOption(options.Order, AliasOrder.Path, T("Path").ToString())
|
||||
</select>
|
||||
@@ -43,60 +43,60 @@
|
||||
@Html.SelectOption(Model.Options.Filter, AliasFilter.Managed, T("Managed").ToString())
|
||||
@Html.SelectOption(Model.Options.Filter, AliasFilter.Custom, T("Custom").ToString())
|
||||
</select>
|
||||
<input type="hidden" name="Page" value="1" />
|
||||
<label for="pageSize">@T("Show:")</label>
|
||||
<select id="pageSize" name="PageSize">
|
||||
@Html.SelectOption((int)Model.Pager.PageSize, 0, T("All").ToString())
|
||||
@foreach(int size in pageSizes.OrderBy(p => p)) {
|
||||
@Html.SelectOption((int)Model.Pager.PageSize, size, size.ToString())
|
||||
}
|
||||
</select>
|
||||
<input type="hidden" name="Page" value="1" />
|
||||
<label for="pageSize">@T("Show:")</label>
|
||||
<select id="pageSize" name="PageSize">
|
||||
@Html.SelectOption((int)Model.Pager.PageSize, 0, T("All").ToString())
|
||||
@foreach (int size in pageSizes.OrderBy(p => p)) {
|
||||
@Html.SelectOption((int)Model.Pager.PageSize, size, size.ToString())
|
||||
}
|
||||
</select>
|
||||
<button type="submit" name="submit.Filter" value="@T("Filter")">@T("Filter")</button>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<table class="items">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="checkbox"><input type="checkbox" class="check-all"/></th>
|
||||
<th scope="col">@T("Alias")</th>
|
||||
<th scope="col">@T("Route")</th>
|
||||
<th scope="col">@T("IsManaged")</th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var aliasEntry in Model.AliasEntries) {
|
||||
var alias = aliasEntry.Alias;
|
||||
index++;
|
||||
var virtualPathData = aliasService.LookupVirtualPaths(alias.RouteValues.ToRouteValueDictionary(), ViewContext.HttpContext).FirstOrDefault();
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="checkbox"><input type="checkbox" class="check-all" /></th>
|
||||
<th scope="col">@T("Alias")</th>
|
||||
<th scope="col">@T("Route")</th>
|
||||
<th scope="col">@T("IsManaged")</th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var aliasEntry in Model.AliasEntries) {
|
||||
var alias = aliasEntry.Alias;
|
||||
index++;
|
||||
var virtualPathData = aliasService.LookupVirtualPaths(alias.RouteValues.ToRouteValueDictionary(), ViewContext.HttpContext).FirstOrDefault();
|
||||
|
||||
if (virtualPathData == null) {
|
||||
continue;
|
||||
if (virtualPathData == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var url = virtualPathData.VirtualPath;
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" value="@alias.Path" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.Path)" />
|
||||
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].IsChecked)" />
|
||||
</td>
|
||||
<td>
|
||||
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path))
|
||||
</td>
|
||||
<td>
|
||||
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" checked="@alias.IsManaged" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.IsManaged)" disabled="disabled" />
|
||||
</td>
|
||||
<td>
|
||||
@if (!alias.IsManaged) {
|
||||
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })
|
||||
<text>|</text>
|
||||
@Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" })
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
var url = virtualPathData.VirtualPath;
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" value="@alias.Path" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.Path)"/>
|
||||
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].IsChecked)"/>
|
||||
</td>
|
||||
<td>
|
||||
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path))
|
||||
</td>
|
||||
<td>
|
||||
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" checked="@alias.IsManaged" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.IsManaged)" disabled="disabled" />
|
||||
</td>
|
||||
<td>
|
||||
@if (!alias.IsManaged) {
|
||||
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })
|
||||
<text>|</text>
|
||||
@Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" })
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@Display(Model.Pager)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ namespace Orchard.Blogs.Routing {
|
||||
}
|
||||
|
||||
// archive for blog as homepage ?
|
||||
if(path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) {
|
||||
if (path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) {
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user