Fixed format settings. Made IsManaged optional with default value false in IAliasService.

This commit is contained in:
mahsaro
2015-08-03 12:28:16 +01:00
parent 057a2a32ad
commit bb143d7236
21 changed files with 189 additions and 209 deletions

View File

@@ -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));
}

View File

@@ -45,7 +45,7 @@ namespace Orchard.Alias.Controllers {
if (options == null)
options = new AdminIndexOptions();
var aliases = _aliasHolder.GetMaps().SelectMany(x => x.GetAliases());
if (!String.IsNullOrWhiteSpace(options.Search)) {
@@ -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;
@@ -111,7 +110,7 @@ namespace Orchard.Alias.Controllers {
break;
default:
throw new ArgumentOutOfRangeException();
}
}
return RedirectToAction("Index");
}
@@ -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;
@@ -273,8 +269,8 @@ namespace Orchard.Alias.Controllers {
var changeLink = T("<a href=\"{0}\">change</a>", editUrl);
var deleteLink = T("<a href=\"{0}\" itemprop=\"UnsafeUrl RemoveUrl\">delete</a>", deleteUrl);
Services.Notifier.Error(T("Cannot save alias <i>{0}</i>. It conflicts with existing one pointing to {1}. Please {2} or {3} the existing alias first.",
aliasPath,
Services.Notifier.Error(T("Cannot save alias <i>{0}</i>. It conflicts with existing one pointing to {1}. Please {2} or {3} the existing alias first.",
aliasPath,
routePathLink,
changeLink,
deleteLink));

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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);
}
@@ -92,7 +91,7 @@ namespace Orchard.Alias.Implementation {
// the route has an area, lookup in the specific alias map
var map = _aliasHolder.GetMap(area.ToString());
if (map == null) {
return Enumerable.Empty<string>();
}
@@ -105,7 +104,7 @@ namespace Orchard.Alias.Implementation {
return new[] { locate.Item2 };
}
// no specific area, lookup in all alias maps
var result = new List<string>();
foreach (var map in _aliasHolder.GetMaps()) {
@@ -118,7 +117,7 @@ namespace Orchard.Alias.Implementation {
return result;
}
public IEnumerable<Tuple<string, RouteValueDictionary>> List() {
return _aliasStorage.List().Select(item => Tuple.Create(item.Item1, item.Item3.ToRouteValueDictionary()));
}
@@ -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 { }
}
}
}

View File

@@ -26,7 +26,7 @@ namespace Orchard.Alias.Implementation.Holder {
/// Adds or updates a set of aliases in the tree
/// </summary>
void SetAliases(IEnumerable<AliasInfo> aliases);
/// <summary>
/// Removes an alias from the tree based on its path
/// </summary>

View File

@@ -8,12 +8,12 @@ using System.Collections.Concurrent;
namespace Orchard.Alias.Implementation.Map {
public class AliasMap {
private readonly string _area;
private readonly string _area;
private readonly ConcurrentDictionary<string, AliasInfo> _aliases;
private readonly Node _root;
private readonly Node _root;
public AliasMap(string area) {
_area = area;
_area = area;
_aliases = new ConcurrentDictionary<string, AliasInfo>(StringComparer.OrdinalIgnoreCase);
_root = new Node();
}
@@ -21,9 +21,8 @@ namespace Orchard.Alias.Implementation.Map {
public IEnumerable<AliasInfo> GetAliases() {
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; }
}
}

View File

@@ -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);

View File

@@ -44,13 +44,13 @@ namespace Orchard.Alias.Implementation.Updater {
}
public class AliasUpdaterEvent : IOrchardShellEvents {
private readonly IAliasHolderUpdater _aliasHolderUpdater;
public AliasUpdaterEvent(IAliasHolderUpdater aliasHolderUpdater) {
_aliasHolderUpdater = aliasHolderUpdater;
}
void IOrchardShellEvents.Activated() {
_aliasHolderUpdater.Refresh();
}

View File

@@ -1,5 +1,5 @@
namespace Orchard.Alias.Implementation.Updater {
public interface IAliasUpdateCursor : ISingletonDependency {
int Cursor { get; set; }
int Cursor { get; set; }
}
}

View File

@@ -20,11 +20,10 @@ namespace Orchard.Alias {
return 1;
}
public int UpdateFrom1()
{
public int UpdateFrom1() {
SchemaBuilder.AlterTable("AliasRecord",
table => table
.AddColumn<bool>("IsManaged", column => column.WithDefault(false))
.AddColumn<bool>("IsManaged", column => column.WithDefault(false))
);
return 2;
}

View File

@@ -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)));
}
@@ -52,6 +49,6 @@ namespace Orchard.Roles.Recipes.Builders {
root.Add(aliasElement);
}
}
}
}

View File

@@ -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;
}
@@ -31,7 +30,7 @@ namespace Orchard.Alias.Recipes.Executors {
</RouteValues>
</Alias>
*/
public override void Execute(RecipeExecutionContext context) {
public override void Execute(RecipeExecutionContext context) {
foreach (var aliasElement in context.RecipeStep.Step.Elements()) {
var aliasPath = aliasElement.Attribute("Path").Value;
@@ -42,24 +41,22 @@ 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);
throw;
}
}
}
}
}
}
}

View File

@@ -10,7 +10,7 @@ namespace Orchard.Alias {
public class Routes : IRouteProvider {
private readonly ShellBlueprint _blueprint;
private readonly IAliasHolder _aliasHolder;
public Routes(ShellBlueprint blueprint, IAliasHolder aliasHolder) {
_blueprint = blueprint;
_aliasHolder = aliasHolder;

View File

@@ -11,8 +11,9 @@ namespace Orchard.Alias.ViewModels {
public class AliasEntry {
public AliasInfo Alias { get; set; }
public bool IsChecked { get; set; }
public bool IsChecked { get; set; }
}
public class AdminIndexOptions {
public string Search { get; set; }
public AliasOrder Order { get; set; }

View File

@@ -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>
}

View File

@@ -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>
}

View File

@@ -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>
}

View File

@@ -1,5 +1,5 @@
@model AdminIndexViewModel
@using Orchard.Alias
@using Orchard.Alias.ViewModels
@using Orchard.Environment.Configuration
@@ -7,12 +7,12 @@
@{
var urlPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix;
Layout.Title = T("Manage Aliases").Text;
var aliasService = WorkContext.Resolve<IAliasService>();
AdminIndexOptions options = Model.Options;
int index = -1;
var pageSizes = new List<int?>() { 10, 50, 100 };
var defaultPageSize = WorkContext.CurrentSite.PageSize;
if (!pageSizes.Contains(defaultPageSize)) {
@@ -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,62 +43,62 @@
@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>
<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">&nbsp;</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;
<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">&nbsp;</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;
}
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)
</fieldset>
}

View File

@@ -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 };
}

View File

@@ -39,18 +39,17 @@ 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;
}
var isBlog =
var isBlog =
//routeValues.ContainsKey("area") &&
//routeValues["area"] == "Orchard.Blogs" &&
aliasInfo.RouteValues.ContainsKey("controller") &&
aliasInfo.RouteValues["controller"] == "Blog" &&
aliasInfo.RouteValues.ContainsKey("action") &&
aliasInfo.RouteValues["action"] == "Item"
aliasInfo.RouteValues["action"] == "Item"
;
return isBlog;
@@ -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;
}