mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge pull request #5567 from OrchardCMS/issue/homepage-alias
Issue/homepage alias
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Orchard.Alias {
|
||||
|
||||
IEnumerable<Tuple<string, RouteValueDictionary>> List();
|
||||
IEnumerable<Tuple<string, RouteValueDictionary, string>> List(string sourceStartsWith);
|
||||
IEnumerable<VirtualPathData> LookupVirtualPaths(RouteValueDictionary routeValues, System.Web.HttpContextBase HttpContext);
|
||||
IEnumerable<VirtualPathData> LookupVirtualPaths(RouteValueDictionary routeValues, System.Web.HttpContextBase httpContext);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -4,11 +4,15 @@ using System.Linq;
|
||||
using Orchard.Alias;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Autoroute.ViewModels;
|
||||
using Orchard.Autoroute.Settings;
|
||||
using Orchard.Autoroute.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Utility.Extensions;
|
||||
@@ -20,27 +24,29 @@ using Orchard.ContentManagement.Aspects;
|
||||
|
||||
namespace Orchard.Autoroute.Drivers {
|
||||
public class AutoroutePartDriver : ContentPartDriver<AutoroutePart> {
|
||||
private readonly IAliasService _aliasService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IAutorouteService _autorouteService;
|
||||
private readonly IAuthorizer _authorizer;
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
private readonly IAliasService _aliasService;
|
||||
private readonly ICultureManager _cultureManager;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public AutoroutePartDriver(
|
||||
IAliasService aliasService,
|
||||
IContentManager contentManager,
|
||||
IAutorouteService autorouteService,
|
||||
INotifier notifier,
|
||||
IHomeAliasService homeAliasService,
|
||||
IAliasService aliasService,
|
||||
IAuthorizer authorizer,
|
||||
INotifier notifier,
|
||||
ICultureManager cultureManager,
|
||||
IContentManager contentManager,
|
||||
IHttpContextAccessor httpContextAccessor) {
|
||||
|
||||
_aliasService = aliasService;
|
||||
_contentManager = contentManager;
|
||||
_autorouteService = autorouteService;
|
||||
_authorizer = authorizer;
|
||||
_notifier = notifier;
|
||||
_homeAliasService = homeAliasService;
|
||||
_cultureManager = cultureManager;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
||||
@@ -56,43 +62,43 @@ namespace Orchard.Autoroute.Drivers {
|
||||
protected override DriverResult Editor(AutoroutePart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var settings = part.TypePartDefinition.Settings.GetModel<AutorouteSettings>();
|
||||
var itemCulture = _cultureManager.GetSiteCulture();
|
||||
|
||||
//if we are editing an existing content item
|
||||
|
||||
// If we are editing an existing content item, check to see if we are an ILocalizableAspect so we can use its culture for alias generation.
|
||||
if (part.Record.Id != 0) {
|
||||
ContentItem contentItem = _contentManager.Get(part.Record.ContentItemRecord.Id);
|
||||
var aspect = contentItem.As<ILocalizableAspect>();
|
||||
var localizableAspect = part.As<ILocalizableAspect>();
|
||||
|
||||
if (aspect != null) {
|
||||
itemCulture = aspect.Culture;
|
||||
if (localizableAspect != null) {
|
||||
itemCulture = localizableAspect.Culture;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.UseCulturePattern) {
|
||||
//if we are creating from a form post we use the form value for culture
|
||||
HttpContextBase context = _httpContextAccessor.Current();
|
||||
// Hack: if the LocalizedPart is attached to the content item, it will submit the following form value,
|
||||
// which we use to determine what culture to use for alias generation.
|
||||
var context = _httpContextAccessor.Current();
|
||||
if (!String.IsNullOrEmpty(context.Request.Form["Localization.SelectedCulture"])) {
|
||||
itemCulture = context.Request.Form["Localization.SelectedCulture"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//we update the settings assuming that when
|
||||
//pattern culture = null or "" it means culture = default website culture
|
||||
//for patterns that we migrated
|
||||
foreach (RoutePattern pattern in settings.Patterns.Where(x => String.IsNullOrWhiteSpace(x.Culture))) {
|
||||
// We update the settings assuming that when
|
||||
// pattern culture = null or "" it means culture = default website culture
|
||||
// for patterns that we migrated.
|
||||
foreach (var pattern in settings.Patterns.Where(x => String.IsNullOrWhiteSpace(x.Culture))) {
|
||||
pattern.Culture = _cultureManager.GetSiteCulture(); ;
|
||||
}
|
||||
|
||||
//we do the same for default patterns
|
||||
foreach (DefaultPattern pattern in settings.DefaultPatterns.Where(x => String.IsNullOrWhiteSpace(x.Culture))) {
|
||||
// We do the same for default patterns.
|
||||
foreach (var pattern in settings.DefaultPatterns.Where(x => String.IsNullOrWhiteSpace(x.Culture))) {
|
||||
pattern.Culture = _cultureManager.GetSiteCulture();
|
||||
}
|
||||
|
||||
// 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(x => String.Equals(x.Culture, itemCulture, StringComparison.OrdinalIgnoreCase))) {
|
||||
settings.Patterns = new List<RoutePattern> { new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = itemCulture } };
|
||||
}
|
||||
|
||||
// if the content type has no defaultPattern for autoroute, then use a default one
|
||||
// If the content type has no defaultPattern for autoroute, then use a default one.
|
||||
if (!settings.DefaultPatterns.Any(x => String.Equals(x.Culture, itemCulture, StringComparison.OrdinalIgnoreCase))) {
|
||||
// If we are in the default culture, check the old setting.
|
||||
if (String.Equals(itemCulture, _cultureManager.GetSiteCulture(), StringComparison.OrdinalIgnoreCase)) {
|
||||
@@ -113,79 +119,59 @@ namespace Orchard.Autoroute.Drivers {
|
||||
CurrentCulture = itemCulture
|
||||
};
|
||||
|
||||
// retrieve home page
|
||||
var homepage = _aliasService.Get(string.Empty);
|
||||
var displayRouteValues = _contentManager.GetItemMetadata(part).DisplayRouteValues;
|
||||
// Retrieve home page.
|
||||
var homePageId = _homeAliasService.GetHomePageId();
|
||||
var isHomePage = part.Id == homePageId;
|
||||
|
||||
viewModel.IsHomePage = homepage.Match(displayRouteValues);
|
||||
viewModel.PromoteToHomePage = viewModel.IsHomePage || part.DisplayAlias == "/";
|
||||
viewModel.IsHomePage = isHomePage;
|
||||
viewModel.PromoteToHomePage = part.PromoteToHomePage;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
if (settings.AutomaticAdjustmentOnEdit && previous == part.DisplayAlias) {
|
||||
part.DisplayAlias = string.Empty;
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (!_autorouteService.IsPathValid(part.DisplayAlias)) {
|
||||
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 home page is requested, use "/" to have the handler create a homepage alias
|
||||
if (viewModel.PromoteToHomePage) {
|
||||
part.DisplayAlias = "/";
|
||||
}
|
||||
// Mark the content item to be the homepage. Once this content isp ublished, the home alias will be updated to point to this content item.
|
||||
part.PromoteToHomePage = viewModel.PromoteToHomePage;
|
||||
}
|
||||
|
||||
return ContentShape("Parts_Autoroute_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Autoroute.Edit", Model: viewModel, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override void Importing(AutoroutePart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||
var displayAlias = context.Attribute(part.PartDefinition.Name, "Alias");
|
||||
if (displayAlias != null) {
|
||||
part.DisplayAlias = displayAlias;
|
||||
}
|
||||
|
||||
var customPattern = context.Attribute(part.PartDefinition.Name, "CustomPattern");
|
||||
if (customPattern != null) {
|
||||
part.CustomPattern = customPattern;
|
||||
}
|
||||
|
||||
var useCustomPattern = context.Attribute(part.PartDefinition.Name, "UseCustomPattern");
|
||||
if (useCustomPattern != null) {
|
||||
part.UseCustomPattern = bool.Parse(useCustomPattern);
|
||||
}
|
||||
|
||||
var useCulturePattern = context.Attribute(part.PartDefinition.Name, "UseCulturePattern");
|
||||
if (useCulturePattern != null) {
|
||||
part.UseCulturePattern = bool.Parse(useCulturePattern);
|
||||
}
|
||||
protected override void Importing(AutoroutePart part, ImportContentContext context) {
|
||||
context.ImportAttribute(part.PartDefinition.Name, "Alias", s => part.DisplayAlias = s);
|
||||
context.ImportAttribute(part.PartDefinition.Name, "CustomPattern", s => part.CustomPattern = s);
|
||||
context.ImportAttribute(part.PartDefinition.Name, "UseCustomPattern", s => part.UseCustomPattern = XmlHelper.Parse<bool>(s));
|
||||
context.ImportAttribute(part.PartDefinition.Name, "UseCulturePattern", s => part.UseCulturePattern = XmlHelper.Parse<bool>(s));
|
||||
context.ImportAttribute(part.PartDefinition.Name, "PromoteToHomePage", s => part.PromoteToHomePage = XmlHelper.Parse<bool>(s));
|
||||
}
|
||||
|
||||
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);
|
||||
protected override void Exporting(AutoroutePart part, ExportContentContext context) {
|
||||
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);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("UseCulturePattern", part.Record.UseCulturePattern);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("PromoteToHomePage", part.UseCustomPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,33 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Alias;
|
||||
|
||||
namespace Orchard.Autoroute.Handlers {
|
||||
public class AutoroutePartHandler : ContentHandler {
|
||||
|
||||
private readonly Lazy<IAutorouteService> _autorouteService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IAliasService _aliasService;
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public AutoroutePartHandler(
|
||||
IRepository<AutoroutePartRecord> autoroutePartRepository,
|
||||
Lazy<IAutorouteService> autorouteService,
|
||||
IOrchardServices orchardServices,
|
||||
IAliasService aliasService) {
|
||||
IOrchardServices orchardServices,
|
||||
IHomeAliasService homeAliasService) {
|
||||
|
||||
Filters.Add(StorageFilter.For(autoroutePartRepository));
|
||||
_autorouteService = autorouteService;
|
||||
_orchardServices = orchardServices;
|
||||
_aliasService = aliasService;
|
||||
_homeAliasService = homeAliasService;
|
||||
|
||||
OnUpdated<AutoroutePart>((ctx, part) => CreateAlias(part));
|
||||
|
||||
@@ -38,8 +36,6 @@ namespace Orchard.Autoroute.Handlers {
|
||||
}
|
||||
});
|
||||
|
||||
// OnVersioned<AutoroutePart>((ctx, part1, part2) => CreateAlias(part1));
|
||||
|
||||
OnPublished<AutoroutePart>((ctx, part) => PublishAlias(part));
|
||||
|
||||
// Remove alias if removed or unpublished
|
||||
@@ -60,55 +56,52 @@ 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.PromoteToHomePage) {
|
||||
// Get the current homepage an unmark it as the homepage.
|
||||
var currentHomePage = _homeAliasService.GetHomePage(VersionOptions.Latest);
|
||||
if(currentHomePage != null && currentHomePage.Id != part.Id) {
|
||||
var autoroutePart = currentHomePage.As<AutoroutePart>();
|
||||
|
||||
// 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);
|
||||
if (autoroutePart != null) {
|
||||
autoroutePart.PromoteToHomePage = false;
|
||||
if(autoroutePart.IsPublished())
|
||||
_orchardServices.ContentManager.Publish(autoroutePart.ContentItem);
|
||||
}
|
||||
_autorouteService.Value.PublishAlias(current);
|
||||
}
|
||||
|
||||
// Update the home alias to point to this item being published.
|
||||
_homeAliasService.PublishHomeAlias(part);
|
||||
}
|
||||
|
||||
_autorouteService.Value.PublishAlias(part);
|
||||
}
|
||||
|
||||
private void ProcessAlias(AutoroutePart part) {
|
||||
// generate an alias if one as not already been entered
|
||||
// Generate an alias if one as not already been entered.
|
||||
if (String.IsNullOrWhiteSpace(part.DisplayAlias)) {
|
||||
part.DisplayAlias = _autorouteService.Value.GenerateAlias(part);
|
||||
}
|
||||
|
||||
// if the generated alias is empty, compute a new one
|
||||
// If the generated alias is empty, compute a new one.
|
||||
if (String.IsNullOrWhiteSpace(part.DisplayAlias)) {
|
||||
_autorouteService.Value.ProcessPath(part);
|
||||
_orchardServices.Notifier.Warning(T("The permalink could not be generated, a new slug has been defined: \"{0}\"", part.Path));
|
||||
return;
|
||||
}
|
||||
|
||||
// check for permalink conflict, unless we are trying to set the home page
|
||||
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));
|
||||
}
|
||||
// Check for permalink conflict, unless we are trying to set the home page.
|
||||
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));
|
||||
}
|
||||
|
||||
void RemoveAlias(AutoroutePart part) {
|
||||
// Is this the current home page?
|
||||
var homePageRoute = _aliasService.Get("");
|
||||
var homePageId = homePageRoute.ContainsKey("id") ? int.Parse(homePageRoute["id"].ToString()) : default(int);
|
||||
var homePageId = _homeAliasService.GetHomePageId();
|
||||
|
||||
// Is this the current home page?
|
||||
if (part.ContentItem.Id == homePageId) {
|
||||
_orchardServices.Notifier.Warning(T("You removed the content item that served as the site\'s home page. \nMost possibly this means that instead of the home page a \"404 Not Found\" error page will be displayed without a link to log in or access the dashboard. \n\nTo prevent this you can e.g. publish a content item that has the \"Set as home page\" checkbox ticked."));
|
||||
}
|
||||
|
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Autoroute.ImportExport {
|
||||
public interface IExportEventHandler : IEventHandler {
|
||||
void Exporting(dynamic context);
|
||||
void Exported(dynamic context);
|
||||
}
|
||||
|
||||
public class HomeAliasHandler : IExportEventHandler {
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public HomeAliasHandler(IHomeAliasService homeAliasService, IContentManager contentManager) {
|
||||
_homeAliasService = homeAliasService;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public void Exporting(dynamic context) {
|
||||
}
|
||||
|
||||
public void Exported(dynamic context) {
|
||||
|
||||
if (!((IEnumerable<string>)context.ExportOptions.CustomSteps).Contains("HomeAlias")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var homeAliasRoute = _homeAliasService.GetHomeRoute() ?? new RouteValueDictionary();
|
||||
var root = new XElement("HomeAlias", homeAliasRoute.Select(x => new XElement(Capitalize(x.Key), x.Value)));
|
||||
var homePage = _homeAliasService.GetHomePage(VersionOptions.Latest);
|
||||
|
||||
// If the home alias points to a content item, store its identifier in addition to the routevalues,
|
||||
// so we can publish the home page alias during import where the ID primary key value of the home page might have changed,
|
||||
// so we can't rely on the route values in that case.
|
||||
if (homePage != null) {
|
||||
var homePageIdentifier = _contentManager.GetItemMetadata(homePage).Identity.ToString();
|
||||
root.Attr("Identifier", homePageIdentifier);
|
||||
}
|
||||
|
||||
context.Document.Element("Orchard").Add(root);
|
||||
}
|
||||
|
||||
private string Capitalize(string value) {
|
||||
if (String.IsNullOrEmpty(value))
|
||||
return value;
|
||||
|
||||
return Char.ToUpper(value[0]) + value.Substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Autoroute.ImportExport {
|
||||
public interface ICustomExportStep : IEventHandler {
|
||||
void Register(IList<string> steps);
|
||||
}
|
||||
|
||||
public class HomeAliasExportStep : ICustomExportStep {
|
||||
public void Register(IList<string> steps) {
|
||||
steps.Add("HomeAlias");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
|
||||
namespace Orchard.Autoroute.ImportExport {
|
||||
public class HomeAliasImportHandler : Component, IRecipeHandler {
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public HomeAliasImportHandler(IHomeAliasService homeAliasService, IContentManager contentManager) {
|
||||
_homeAliasService = homeAliasService;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public void ExecuteRecipeStep(RecipeContext recipeContext) {
|
||||
if (!String.Equals(recipeContext.RecipeStep.Name, "HomeAlias", StringComparison.OrdinalIgnoreCase)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var root = recipeContext.RecipeStep.Step;
|
||||
var routeValueDictionary = root.Elements().ToDictionary(x => x.Name.LocalName.ToLower(), x => (object)x.Value);
|
||||
var homePageIdentifier = root.Attr("Identifier");
|
||||
var homePageIdentity = new ContentIdentity(homePageIdentifier);
|
||||
var homePage = !String.IsNullOrEmpty(homePageIdentifier) ? _contentManager.ResolveIdentity(homePageIdentity) : default(ContentItem);
|
||||
|
||||
if(homePage != null)
|
||||
_homeAliasService.PublishHomeAlias(homePage);
|
||||
else
|
||||
_homeAliasService.PublishHomeAlias(new RouteValueDictionary(routeValueDictionary));
|
||||
|
||||
recipeContext.Executed = true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,6 +21,11 @@ namespace Orchard.Autoroute.Models {
|
||||
set { Store(x => x.DisplayAlias, value); }
|
||||
}
|
||||
|
||||
public bool PromoteToHomePage {
|
||||
get { return this.Retrieve(x => x.PromoteToHomePage); }
|
||||
set { this.Store(x => x.PromoteToHomePage, value); }
|
||||
}
|
||||
|
||||
public string Path {
|
||||
get { return DisplayAlias; }
|
||||
}
|
||||
|
@@ -81,6 +81,9 @@
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="ImportExport\HomeAliasExportStep.cs" />
|
||||
<Compile Include="ImportExport\HomeAliasExportHandler.cs" />
|
||||
<Compile Include="ImportExport\HomeAliasImportHandler.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="Module.txt" />
|
||||
@@ -114,6 +117,8 @@
|
||||
<Compile Include="Providers\ContentDefinition\ContentDefinitionEventHandler.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Services\AliasResolverSelector.cs" />
|
||||
<Compile Include="Services\HomeAliasService.cs" />
|
||||
<Compile Include="Services\IHomeAliasService.cs" />
|
||||
<Compile Include="Services\PathResolutionService.cs" />
|
||||
<Compile Include="Services\IPathResolutionService.cs" />
|
||||
<Compile Include="Services\IRouteEvents.cs" />
|
||||
@@ -151,20 +156,20 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
|
||||
<PropertyGroup>
|
||||
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
|
||||
</PropertyGroup>
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
-->
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
-->
|
||||
</Target>
|
||||
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
|
||||
|
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Orchard.Alias;
|
||||
using Orchard.Alias.Implementation.Storage;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Autoroute.Settings;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -14,6 +13,7 @@ using Orchard.Localization.Services;
|
||||
using Orchard.Mvc;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Alias.Implementation.Storage;
|
||||
|
||||
namespace Orchard.Autoroute.Services {
|
||||
public class AutorouteService : Component, IAutorouteService {
|
||||
@@ -56,7 +56,7 @@ namespace Orchard.Autoroute.Services {
|
||||
var settings = part.TypePartDefinition.Settings.GetModel<AutorouteSettings>();
|
||||
var itemCulture = _cultureManager.GetSiteCulture();
|
||||
|
||||
//if we are editing an existing content item
|
||||
// If we are editing an existing content item.
|
||||
if (part.Record.Id != 0) {
|
||||
ContentItem contentItem = _contentManager.Get(part.Record.ContentItemRecord.Id);
|
||||
var aspect = contentItem.As<ILocalizableAspect>();
|
||||
@@ -77,9 +77,8 @@ namespace Orchard.Autoroute.Services {
|
||||
|
||||
string pattern = GetDefaultPattern(part.ContentItem.ContentType, itemCulture).Pattern;
|
||||
|
||||
// String.Empty forces pattern based generation. "/" forces homepage.
|
||||
if (part.UseCustomPattern
|
||||
&& (!String.IsNullOrWhiteSpace(part.CustomPattern) || String.Equals(part.CustomPattern, "/"))) {
|
||||
// String.Empty forces pattern based generation.
|
||||
if (part.UseCustomPattern && (!String.IsNullOrWhiteSpace(part.CustomPattern))) {
|
||||
pattern = part.CustomPattern;
|
||||
}
|
||||
|
||||
@@ -150,8 +149,8 @@ namespace Orchard.Autoroute.Services {
|
||||
else {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = culture });
|
||||
return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return a default pattern if set
|
||||
var patternCultureSearch = settings.Patterns.Any(x => String.Equals(x.Culture, culture, StringComparison.OrdinalIgnoreCase)) ? culture : null;
|
||||
@@ -161,30 +160,13 @@ namespace Orchard.Autoroute.Services {
|
||||
if (settings.Patterns.Where(x => x.Culture == patternCultureSearch).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == defaultPatternCultureSearch).FirstOrDefault().PatternIndex)) != null) {
|
||||
return settings.Patterns.Where(x => x.Culture == patternCultureSearch).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == defaultPatternCultureSearch).FirstOrDefault().PatternIndex));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// return a default pattern if none is defined
|
||||
return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture };
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Safe to delete all aliases for the specified part since it is definitely not the homepage.
|
||||
public void RemoveAliases(AutoroutePart part) {
|
||||
_aliasService.Delete(part.Path, AliasSource);
|
||||
}
|
||||
|
||||
@@ -192,7 +174,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)
|
||||
@@ -229,16 +211,6 @@ namespace Orchard.Autoroute.Services {
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsHomePage(IContent content) {
|
||||
var homePageRoute = _aliasService.Get("");
|
||||
var homePageId = homePageRoute.ContainsKey("id") ? XmlHelper.Parse<int>((string)homePageRoute["id"]) : default(int?);
|
||||
return content.Id == homePageId;
|
||||
}
|
||||
|
||||
private int GetHomePageAliasRecordId() {
|
||||
return _aliasStorage.List(x => x.Path == "").First().Item5;
|
||||
}
|
||||
|
||||
private SettingsDictionary GetTypePartSettings(string contentType) {
|
||||
var contentDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
using System.Web.Routing;
|
||||
using Orchard.Alias;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Autoroute.Services {
|
||||
public class HomeAliasService : IHomeAliasService {
|
||||
private readonly IAliasService _aliasService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private const string AliasSource = "Autoroute:Home";
|
||||
private const string HomeAlias = "";
|
||||
|
||||
public HomeAliasService(IAliasService aliasService, IContentManager contentManager) {
|
||||
_aliasService = aliasService;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public RouteValueDictionary GetHomeRoute() {
|
||||
return _aliasService.Get(HomeAlias);
|
||||
}
|
||||
|
||||
public int? GetHomePageId() {
|
||||
var homePageRoute = GetHomeRoute();
|
||||
var homePageId =
|
||||
homePageRoute != null
|
||||
? homePageRoute.ContainsKey("id")
|
||||
? XmlHelper.Parse<int>((string)homePageRoute["id"])
|
||||
: default(int?)
|
||||
: default(int?);
|
||||
|
||||
return homePageId;
|
||||
}
|
||||
|
||||
public IContent GetHomePage(VersionOptions version = null) {
|
||||
var homePageId = GetHomePageId();
|
||||
var homePage = homePageId != null ? _contentManager.Get(homePageId.Value, version ?? VersionOptions.Published) : default(IContent);
|
||||
|
||||
return homePage;
|
||||
}
|
||||
|
||||
public void PublishHomeAlias(IContent content) {
|
||||
var routeValues = _contentManager.GetItemMetadata(content).DisplayRouteValues;
|
||||
PublishHomeAlias(routeValues);
|
||||
}
|
||||
|
||||
public void PublishHomeAlias(string route) {
|
||||
_aliasService.DeleteBySource(AliasSource);
|
||||
_aliasService.Set(HomeAlias, route, AliasSource);
|
||||
}
|
||||
|
||||
public void PublishHomeAlias(RouteValueDictionary route) {
|
||||
_aliasService.DeleteBySource(AliasSource);
|
||||
_aliasService.Set(HomeAlias, route, AliasSource);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Autoroute.Services {
|
||||
|
||||
public interface IHomeAliasService : IDependency {
|
||||
RouteValueDictionary GetHomeRoute();
|
||||
int? GetHomePageId();
|
||||
IContent GetHomePage(VersionOptions version = null);
|
||||
void PublishHomeAlias(IContent content);
|
||||
void PublishHomeAlias(string route);
|
||||
void PublishHomeAlias(RouteValueDictionary route);
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ using Orchard.Data;
|
||||
namespace Orchard.Autoroute.Services {
|
||||
public class PathResolutionService : IPathResolutionService {
|
||||
private readonly IContentManager _contentManager;
|
||||
IRepository<AutoroutePartRecord> _autorouteRepository;
|
||||
private readonly IRepository<AutoroutePartRecord> _autorouteRepository;
|
||||
|
||||
public PathResolutionService(
|
||||
IRepository<AutoroutePartRecord> autorouteRepository,
|
||||
@@ -17,8 +17,7 @@ namespace Orchard.Autoroute.Services {
|
||||
|
||||
public AutoroutePart GetPath(string path) {
|
||||
var autorouteRecord = _autorouteRepository.Table
|
||||
.Where(part => part.DisplayAlias == path && part.ContentItemVersionRecord.Published)
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefault(part => part.DisplayAlias == path && part.ContentItemVersionRecord.Published);
|
||||
|
||||
if (autorouteRecord == null) {
|
||||
return null;
|
||||
|
@@ -18,45 +18,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
@if (!Model.PromoteToHomePage) {
|
||||
<fieldset class="permalink">
|
||||
<label>@T("Permalink")</label>
|
||||
@if (Model.Settings.AllowCustomPattern) {
|
||||
<span class="permalink-definition" dir="ltr">
|
||||
<span>@Url.MakeAbsolute("/")@urlPrefix</span>
|
||||
<span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text is-url" })</span>
|
||||
</span>
|
||||
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}", pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Name, pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Description)</span>
|
||||
}
|
||||
else {
|
||||
var hintClass = string.Empty;
|
||||
if (!string.IsNullOrEmpty(Model.CurrentUrl)) {
|
||||
hintClass = "hint";
|
||||
<span>@Url.MakeAbsolute("/")@urlPrefix@Model.CurrentUrl</span>
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Model.CurrentUrl)
|
||||
|| (!string.IsNullOrEmpty(Model.CurrentUrl) && Model.Settings.AutomaticAdjustmentOnEdit)) {
|
||||
<span class="@hintClass">@T("Save the current item and the url will be generated using the pattern {0} e.g., {1}", pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Name, pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Description)</span>
|
||||
}
|
||||
}
|
||||
@if (!String.IsNullOrEmpty(Model.CurrentUrl)) {
|
||||
<span>
|
||||
@Html.Link(
|
||||
T("View").Text,
|
||||
Url.MakeAbsolute("/") + urlPrefix + Model.CurrentUrl.TrimStart('/'),
|
||||
new { target = "_blank" })
|
||||
</span>
|
||||
<fieldset class="permalink">
|
||||
<label>@T("Permalink")</label>
|
||||
@if (Model.Settings.AllowCustomPattern) {
|
||||
<span class="permalink-definition" dir="ltr">
|
||||
<span>@Url.MakeAbsolute("/")@urlPrefix</span>
|
||||
<span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text is-url" })</span>
|
||||
</span>
|
||||
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}.", pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Name, pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Description)</span>
|
||||
}
|
||||
else {
|
||||
var hintClass = string.Empty;
|
||||
if (!string.IsNullOrEmpty(Model.CurrentUrl)) {
|
||||
hintClass = "hint";
|
||||
<span>@Url.MakeAbsolute("/")@urlPrefix@Model.CurrentUrl</span>
|
||||
}
|
||||
|
||||
</fieldset>
|
||||
if (string.IsNullOrEmpty(Model.CurrentUrl)
|
||||
|| (!string.IsNullOrEmpty(Model.CurrentUrl) && Model.Settings.AutomaticAdjustmentOnEdit)) {
|
||||
<span class="@hintClass">@T("Save the current item and the url will be generated using the pattern {0} e.g., {1}.", pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Name, pattern.ElementAtOrDefault(Convert.ToInt32(defaultPattern.PatternIndex)).Description)</span>
|
||||
}
|
||||
}
|
||||
@if (!String.IsNullOrEmpty(Model.CurrentUrl)) {
|
||||
<span>
|
||||
@Html.Link(
|
||||
T("View").Text,
|
||||
Url.MakeAbsolute("/") + urlPrefix + Model.CurrentUrl.TrimStart('/'),
|
||||
new { target = "_blank" })
|
||||
</span>
|
||||
}
|
||||
|
||||
</fieldset>
|
||||
@if (!Model.IsHomePage) {
|
||||
if (AuthorizedFor(Permissions.SetHomePage)) {
|
||||
<fieldset>
|
||||
<span class="checkbox-and-label">
|
||||
@Html.EditorFor(m => m.PromoteToHomePage)
|
||||
@Html.CheckBoxFor(m => m.PromoteToHomePage)
|
||||
<label for="@Html.FieldIdFor(m => m.PromoteToHomePage)" class="forcheckbox">@T("Set as home page")</label>
|
||||
</span>
|
||||
<span class="hint">@T("Check to promote this content as the home page")</span>
|
||||
<span class="hint">@T("Check to promote this content as the home page.")</span>
|
||||
</fieldset>
|
||||
}
|
||||
}
|
||||
|
6
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/dash.all.min.js
vendored
Normal file
6
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/dash.all.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/jquery.blockUI.min.js
vendored
Normal file
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/jquery.blockUI.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./jquery.fileupload"],e):e(window.jQuery)}(function(e){"use strict";var s=e.blueimp.fileupload.prototype.options.add;e.widget("blueimp.fileupload",e.blueimp.fileupload,{options:{processQueue:[],add:function(r,i){var o=e(this);i.process(function(){return o.fileupload("process",i)}),s.call(this,r,i)}},processActions:{},_processFile:function(s,r){var i=this,o=e.Deferred().resolveWith(i,[s]),t=o.promise();return this._trigger("process",null,s),e.each(s.processQueue,function(s,o){var n=function(s){return r.errorThrown?e.Deferred().rejectWith(i,[r]).promise():i.processActions[o.action].call(i,s,o)};t=t.pipe(n,o.always&&n)}),t.done(function(){i._trigger("processdone",null,s),i._trigger("processalways",null,s)}).fail(function(){i._trigger("processfail",null,s),i._trigger("processalways",null,s)}),t},_transformProcessQueue:function(s){var r=[];e.each(s.processQueue,function(){var i={},o=this.action,t=this.prefix===!0?o:this.prefix;e.each(this,function(r,o){i[r]="string"===e.type(o)&&"@"===o.charAt(0)?s[o.slice(1)||(t?t+r.charAt(0).toUpperCase()+r.slice(1):r)]:o}),r.push(i)}),s.processQueue=r},processing:function(){return this._processing},process:function(s){var r=this,i=e.extend({},this.options,s);return i.processQueue&&i.processQueue.length&&(this._transformProcessQueue(i),0===this._processing&&this._trigger("processstart"),e.each(s.files,function(o){var t=o?e.extend({},i):i,n=function(){return s.errorThrown?e.Deferred().rejectWith(r,[s]).promise():r._processFile(t,s)};t.index=o,r._processing+=1,r._processingQueue=r._processingQueue.pipe(n,n).always(function(){r._processing-=1,0===r._processing&&r._trigger("processstop")})})),this._processingQueue},_create:function(){this._super(),this._processing=0,this._processingQueue=e.Deferred().resolveWith(this).promise()}})});
|
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./jquery.fileupload-process"],e):e(window.jQuery)}(function(e){"use strict";e.blueimp.fileupload.prototype.options.processQueue.push({action:"validate",always:!0,acceptFileTypes:"@",maxFileSize:"@",minFileSize:"@",maxNumberOfFiles:"@",disabled:"@disableValidation"}),e.widget("blueimp.fileupload",e.blueimp.fileupload,{options:{getNumberOfFiles:e.noop,messages:{maxNumberOfFiles:"Maximum number of files exceeded",acceptFileTypes:"File type not allowed",maxFileSize:"File is too large",minFileSize:"File is too small"}},processActions:{validate:function(i,l){if(l.disabled)return i;var r,s=e.Deferred(),t=this.options,o=i.files[i.index];return(l.minFileSize||l.maxFileSize)&&(r=o.size),"number"===e.type(l.maxNumberOfFiles)&&(t.getNumberOfFiles()||0)+i.files.length>l.maxNumberOfFiles?o.error=t.i18n("maxNumberOfFiles"):!l.acceptFileTypes||l.acceptFileTypes.test(o.type)||l.acceptFileTypes.test(o.name)?r>l.maxFileSize?o.error=t.i18n("maxFileSize"):"number"===e.type(r)&&r<l.minFileSize?o.error=t.i18n("minFileSize"):delete o.error:o.error=t.i18n("acceptFileTypes"),o.error||i.files.error?(i.files.error=!0,s.rejectWith(this,[i])):s.resolveWith(this,[i]),s.promise()}}})});
|
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/jquery.fileupload.min.js
vendored
Normal file
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/jquery.fileupload.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/swfobject.min.js
vendored
Normal file
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/swfobject.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/uri.min.js
vendored
Normal file
1
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/lib/uri.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,38 +1,38 @@
|
||||
@model Orchard.ImportExport.ViewModels.ImportResultViewModel
|
||||
@{
|
||||
Layout.Title = T("Import Result").ToString();
|
||||
}
|
||||
@if (Model.Result.IsSuccessful) {
|
||||
<div class="message message-Information">
|
||||
@T("The recipe file was successfully imported.")
|
||||
</div>
|
||||
}
|
||||
else {
|
||||
<div class="message message-Error">
|
||||
@T("The recipe file import failed. Check the logs (recipe execution ID <strong>{0}</strong>) for more information.", Model.Result.ExecutionId)
|
||||
</div>
|
||||
}
|
||||
<h2>@T("Recipe steps")</h2>
|
||||
<table class="items" style="width: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@T("Recipe")</th>
|
||||
<th>@T("Step")</th>
|
||||
<th>@T("Executed")</th>
|
||||
<th>@T("Result")</th>
|
||||
<th>@T("Message")</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var step in Model.Result.Steps) {
|
||||
<tr>
|
||||
<td>@(!String.IsNullOrWhiteSpace(step.RecipeName) ? step.RecipeName : T("Untitled").ToString())</td>
|
||||
<td>@step.StepName</td>
|
||||
<td>@step.IsCompleted</td>
|
||||
<td>@if (step.IsSuccessful) { @T("Successful") } else if (step.IsCompleted) { <strong>@T("Failed")</strong> }</td>
|
||||
<td><strong>@step.ErrorMessage</strong></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@model Orchard.ImportExport.ViewModels.ImportResultViewModel
|
||||
@{
|
||||
Layout.Title = T("Import Result").ToString();
|
||||
}
|
||||
@if (Model.Result.IsSuccessful) {
|
||||
<div class="message message-Information">
|
||||
@T("The recipe file was successfully imported.")
|
||||
</div>
|
||||
}
|
||||
else {
|
||||
<div class="message message-Error">
|
||||
@T("The recipe file import failed. Check the logs (recipe execution ID <strong>{0}</strong>) for more information.", Model.Result.ExecutionId)
|
||||
</div>
|
||||
}
|
||||
<h2>@T("Recipe steps")</h2>
|
||||
<table class="items" style="width: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@T("Recipe")</th>
|
||||
<th>@T("Step")</th>
|
||||
<th>@T("Executed")</th>
|
||||
<th>@T("Result")</th>
|
||||
<th>@T("Message")</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var step in Model.Result.Steps) {
|
||||
<tr>
|
||||
<td>@(!String.IsNullOrWhiteSpace(step.RecipeName) ? step.RecipeName : T("Untitled").ToString())</td>
|
||||
<td>@step.StepName</td>
|
||||
<td>@step.IsCompleted</td>
|
||||
<td>@if (step.IsSuccessful) { @T("Successful") } else if (step.IsCompleted) { <strong>@T("Failed")</strong> }</td>
|
||||
<td><strong>@step.ErrorMessage</strong></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -172,36 +172,36 @@ namespace Orchard.Localization.Providers {
|
||||
|
||||
return new string[] { "AM", "PM" };
|
||||
}
|
||||
}
|
||||
|
||||
public string GetEraName(int era) {
|
||||
var t = T("A.D.;A.D.").Text;
|
||||
var parts = t.Split(';');
|
||||
if (parts.Length >= era + 1) {
|
||||
return parts[era];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetShortEraName(int era) {
|
||||
var t = T("AD;AD").Text;
|
||||
var parts = t.Split(';');
|
||||
if (parts.Length >= era + 1) {
|
||||
return parts[era];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetEra(string eraName) {
|
||||
var t = T("AD;AD").Text;
|
||||
var parts = t.ToLowerInvariant().Split(';');
|
||||
if (parts.Contains(eraName.ToLowerInvariant())) {
|
||||
return parts.ToList().IndexOf(eraName.ToLowerInvariant());
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException("eraName");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetEraName(int era) {
|
||||
var t = T("A.D.;A.D.").Text;
|
||||
var parts = t.Split(';');
|
||||
if (parts.Length >= era + 1) {
|
||||
return parts[era];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetShortEraName(int era) {
|
||||
var t = T("AD;AD").Text;
|
||||
var parts = t.Split(';');
|
||||
if (parts.Length >= era + 1) {
|
||||
return parts[era];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetEra(string eraName) {
|
||||
var t = T("AD;AD").Text;
|
||||
var parts = t.ToLowerInvariant().Split(';');
|
||||
if (parts.Contains(eraName.ToLowerInvariant())) {
|
||||
return parts.ToList().IndexOf(eraName.ToLowerInvariant());
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException("eraName");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +1,15 @@
|
||||
@using System.Globalization
|
||||
@using Orchard.Alias
|
||||
@using Orchard.Autoroute.Services
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.ContentManagement.Aspects
|
||||
@using Orchard.Localization.Services
|
||||
@{
|
||||
var localizableAspects = Enumerable.Empty<ILocalizableAspect>();
|
||||
|
||||
var homePage = GetByPath(string.Empty);
|
||||
var homePage = WorkContext.Resolve<IHomeAliasService>().GetHomePage();
|
||||
|
||||
if (homePage != null) {
|
||||
var localizationService = WorkContext.Resolve<ILocalizationService>();
|
||||
localizableAspects = localizationService.GetLocalizations(homePage).Concat<ILocalizableAspect>(new[] { homePage.As<ILocalizableAspect>() });
|
||||
localizableAspects = localizationService.GetLocalizations(homePage).Concat(new[] { homePage.As<ILocalizableAspect>() });
|
||||
}
|
||||
}
|
||||
@if (localizableAspects.Any()) {
|
||||
@@ -30,22 +29,4 @@
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
@functions{
|
||||
public IContent GetByPath(string aliasPath) {
|
||||
var contentRouting = WorkContext.Resolve<IAliasService>().Get(aliasPath);
|
||||
|
||||
if (contentRouting == null)
|
||||
return null;
|
||||
|
||||
object id;
|
||||
if (contentRouting.TryGetValue("id", out id)) {
|
||||
int contentId;
|
||||
if (int.TryParse(id as string, out contentId)) {
|
||||
return WorkContext.Resolve<IContentManager>().Get(contentId);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.Commands;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
@@ -21,6 +22,7 @@ namespace Orchard.Pages.Commands {
|
||||
private readonly IMenuService _menuService;
|
||||
private readonly INavigationManager _navigationManager;
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
|
||||
public PageCommands(
|
||||
IContentManager contentManager,
|
||||
@@ -28,12 +30,15 @@ namespace Orchard.Pages.Commands {
|
||||
IAuthenticationService authenticationService,
|
||||
ISiteService siteService,
|
||||
IMenuService menuService,
|
||||
INavigationManager navigationManager) {
|
||||
INavigationManager navigationManager,
|
||||
IHomeAliasService homeAliasService) {
|
||||
|
||||
_contentManager = contentManager;
|
||||
_membershipService = membershipService;
|
||||
_siteService = siteService;
|
||||
_menuService = menuService;
|
||||
_navigationManager = navigationManager;
|
||||
_homeAliasService = homeAliasService;
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
@@ -94,14 +99,8 @@ 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;
|
||||
}
|
||||
if (Homepage) {
|
||||
_homeAliasService.PublishHomeAlias(page);
|
||||
}
|
||||
|
||||
var layout = default(string);
|
||||
|
@@ -6,5 +6,5 @@ Version: 1.9.1
|
||||
OrchardVersion: 1.9
|
||||
Description: Introduces a preconfigured page content type.
|
||||
FeatureDescription: A basic page content type.
|
||||
Dependencies: Contents, Orchard.ContentPicker
|
||||
Dependencies: Contents, Orchard.ContentPicker, Orchard.Autoroute
|
||||
Category: Content
|
||||
|
@@ -78,6 +78,11 @@
|
||||
<Name>Orchard.Core</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Autoroute\Orchard.Autoroute.csproj">
|
||||
<Project>{66fccd76-2761-47e3-8d11-b45d0001ddaa}</Project>
|
||||
<Name>Orchard.Autoroute</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.ContentPicker\Orchard.ContentPicker.csproj">
|
||||
<Project>{f301ef7d-f19c-4d83-aa94-cb64f29c037d}</Project>
|
||||
<Name>Orchard.ContentPicker</Name>
|
||||
@@ -116,11 +121,11 @@
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -177,17 +177,17 @@ namespace Orchard.Localization.Services {
|
||||
return new[] { DateTimeFormat.AMDesignator, DateTimeFormat.PMDesignator };
|
||||
}
|
||||
}
|
||||
|
||||
public string GetEraName(int era) {
|
||||
return DateTimeFormat.GetEraName(era);
|
||||
}
|
||||
|
||||
public string GetShortEraName(int era) {
|
||||
return DateTimeFormat.GetAbbreviatedEraName(era);
|
||||
}
|
||||
|
||||
public int GetEra(string eraName) {
|
||||
return DateTimeFormat.GetEra(eraName);
|
||||
|
||||
public string GetEraName(int era) {
|
||||
return DateTimeFormat.GetEraName(era);
|
||||
}
|
||||
|
||||
public string GetShortEraName(int era) {
|
||||
return DateTimeFormat.GetAbbreviatedEraName(era);
|
||||
}
|
||||
|
||||
public int GetEra(string eraName) {
|
||||
return DateTimeFormat.GetEra(eraName);
|
||||
}
|
||||
|
||||
protected virtual DateTimeFormatInfo DateTimeFormat {
|
||||
@@ -242,6 +242,6 @@ namespace Orchard.Localization.Services {
|
||||
return _calendarManager.GetCalendarByName(workContext.CurrentCalendar);
|
||||
return CurrentCulture.Calendar;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -298,9 +298,9 @@ namespace Orchard.Localization.Services {
|
||||
monthNameGenitive = parts.Month > 0 ? _dateTimeFormatProvider.MonthNamesGenitive[parts.Month - 1] : null;
|
||||
monthNameShortGenitive = parts.Month > 0 ? _dateTimeFormatProvider.MonthNamesShortGenitive[parts.Month - 1] : null;
|
||||
dayName = parts.Day > 0 ? _dateTimeFormatProvider.DayNames[(int)calendar.GetDayOfWeek(parts.ToDateTime(calendar))] : null;
|
||||
dayNameShort = parts.Day > 0 ? _dateTimeFormatProvider.DayNamesShort[(int)calendar.GetDayOfWeek(parts.ToDateTime(calendar))] : null;
|
||||
dayNameShort = parts.Day > 0 ? _dateTimeFormatProvider.DayNamesShort[(int)calendar.GetDayOfWeek(parts.ToDateTime(calendar))] : null;
|
||||
eraName = parts.Day > 0 ? _dateTimeFormatProvider.GetEraName((int)calendar.GetEra(parts.ToDateTime(calendar))) : null;
|
||||
eraNameShort = parts.Day > 0 ? _dateTimeFormatProvider.GetShortEraName((int)calendar.GetEra(parts.ToDateTime(calendar))) : null;
|
||||
eraNameShort = parts.Day > 0 ? _dateTimeFormatProvider.GetShortEraName((int)calendar.GetEra(parts.ToDateTime(calendar))) : null;
|
||||
}
|
||||
|
||||
protected virtual void GetTimeFormatValues(TimeParts parts, out bool isPm, out int hour12, out string amPm, out string amPmShort, out string timeZone, out string offsetSign, out int offsetHours, out int offsetMinutes, out string fraction1Zero, out string fraction2Zero, out string fraction3Zero, out string fraction1Digit, out string fraction2Digit, out string fraction3Digit) {
|
||||
@@ -409,7 +409,7 @@ namespace Orchard.Localization.Services {
|
||||
{"yyy", "{0:000}"},
|
||||
{"yy", "{1:00}"},
|
||||
{"y", "{1:0}"},
|
||||
{"gg", "{10}"},
|
||||
{"gg", "{10}"},
|
||||
{"g", "{10}"}
|
||||
};
|
||||
}
|
||||
|
@@ -161,20 +161,20 @@ namespace Orchard.Localization.Services {
|
||||
/// </summary>
|
||||
string[] AmPmDesignators {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string containing the name of the specified era.
|
||||
/// </summary>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string containing the name of the specified era.
|
||||
/// </summary>
|
||||
string GetEraName(int era);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string containing the abbreviated name of the specified era, if an abbreviation exists.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Returns a string containing the abbreviated name of the specified era, if an abbreviation exists.
|
||||
/// </summary>
|
||||
string GetShortEraName(int era);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the integer representing the specified era.
|
||||
/// <summary>
|
||||
/// Returns the integer representing the specified era.
|
||||
/// </summary>
|
||||
int GetEra(string eraName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user