mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Severing numerous ties to Routable
--HG-- branch : autoroute
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
72d4e648204d19d918c5eddec55c7be73d05a00d src/Orchard.Web/Modules/Orchard.Alias
|
||||
d78707da9c4ba311afb092f24bb463531bdc62e8 src/Orchard.Web/Modules/Orchard.Autoroute
|
||||
2324a4ee85573614dad9df657d383cf541d34d54 src/Orchard.Web/Modules/Orchard.Autoroute
|
||||
ec573e5476f7e8a5a61593d6393e9985e9484fcc src/Orchard.Web/Modules/Orchard.Forms
|
||||
0d1100754d594a2977eaab40630f1c46a9e8cf2c src/Orchard.Web/Modules/Orchard.Projections
|
||||
bf1f2857f36786c66013e0dee3c37e94cd26465e src/Orchard.Web/Modules/Orchard.Routable
|
||||
|
@@ -2,25 +2,29 @@
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Common.Settings;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Services;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Orchard.Core.Common.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class BodyPartDriver : ContentPartDriver<BodyPart> {
|
||||
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
|
||||
private readonly RequestContext _requestContext;
|
||||
|
||||
private const string TemplateName = "Parts.Common.Body";
|
||||
|
||||
public BodyPartDriver(IOrchardServices services, IEnumerable<IHtmlFilter> htmlFilters) {
|
||||
public BodyPartDriver(IOrchardServices services, IEnumerable<IHtmlFilter> htmlFilters, RequestContext requestContext) {
|
||||
_htmlFilters = htmlFilters;
|
||||
Services = services;
|
||||
_requestContext = requestContext;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
@@ -45,13 +49,13 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BodyPart part, dynamic shapeHelper) {
|
||||
var model = BuildEditorViewModel(part);
|
||||
var model = BuildEditorViewModel(part,_requestContext);
|
||||
return ContentShape("Parts_Common_Body_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BodyPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = BuildEditorViewModel(part);
|
||||
var model = BuildEditorViewModel(part, _requestContext);
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
|
||||
return ContentShape("Parts_Common_Body_Edit",
|
||||
@@ -69,11 +73,11 @@ namespace Orchard.Core.Common.Drivers {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Text", part.Text);
|
||||
}
|
||||
|
||||
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
|
||||
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part,RequestContext requestContext) {
|
||||
return new BodyEditorViewModel {
|
||||
BodyPart = part,
|
||||
EditorFlavor = GetFlavor(part),
|
||||
AddMediaPath = new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
|
||||
AddMediaPath = new PathBuilder(part,requestContext).AddContentType().AddContainerSlug().ToString()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,10 +91,12 @@ namespace Orchard.Core.Common.Drivers {
|
||||
class PathBuilder {
|
||||
private readonly IContent _content;
|
||||
private string _path;
|
||||
private readonly RequestContext _requestContext;
|
||||
|
||||
public PathBuilder(IContent content) {
|
||||
public PathBuilder(IContent content,RequestContext requestContext) {
|
||||
_content = content;
|
||||
_path = "";
|
||||
_requestContext = requestContext;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
@@ -104,23 +110,10 @@ namespace Orchard.Core.Common.Drivers {
|
||||
|
||||
public PathBuilder AddContainerSlug() {
|
||||
var common = _content.As<ICommonPart>();
|
||||
if (common == null)
|
||||
if (common == null || common.Container==null)
|
||||
return this;
|
||||
|
||||
var routable = common.Container.As<RoutePart>();
|
||||
if (routable == null)
|
||||
return this;
|
||||
|
||||
Add(routable.Slug);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PathBuilder AddSlug() {
|
||||
var routable = _content.As<RoutePart>();
|
||||
if (routable == null)
|
||||
return this;
|
||||
|
||||
Add(routable.Slug);
|
||||
var helper = new UrlHelper(_requestContext);
|
||||
Add(helper.ItemDisplayUrl(common.Container));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Containers.Extensions;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Themes;
|
||||
|
@@ -12,7 +12,6 @@ using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Core.Containers.Extensions;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Core.Feeds;
|
||||
|
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Core.Containers.Extensions {
|
||||
@@ -21,16 +20,6 @@ namespace Orchard.Core.Containers.Extensions {
|
||||
? query.OrderByDescending<TitlePartRecord, string>(record => record.Title)
|
||||
: query.OrderBy<TitlePartRecord, string>(record => record.Title);
|
||||
break;
|
||||
case "RoutePart.Title":
|
||||
query = descendingOrder
|
||||
? query.OrderByDescending<RoutePartRecord, string>(record => record.Title)
|
||||
: query.OrderBy<RoutePartRecord, string>(record => record.Title);
|
||||
break;
|
||||
case "RoutePart.Slug":
|
||||
query = descendingOrder
|
||||
? query.OrderByDescending<RoutePartRecord, string>(record => record.Slug)
|
||||
: query.OrderBy<RoutePartRecord, string>(record => record.Slug);
|
||||
break;
|
||||
case "CustomPropertiesPart.CustomOne":
|
||||
query = descendingOrder
|
||||
? query.OrderByDescending<CustomPropertiesPartRecord, string>(record => record.CustomOne)
|
||||
@@ -75,14 +64,6 @@ namespace Orchard.Core.Containers.Extensions {
|
||||
{"TitlePart.Title|>", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<TitlePartRecord>(r => true /* CompareTo is not implemented - r.Title.CompareTo(s) == 1*/))},
|
||||
{"TitlePart.Title|=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<TitlePartRecord>(r => r.Title.Equals(s, StringComparison.OrdinalIgnoreCase)))},
|
||||
{"TitlePart.Title|^=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<TitlePartRecord>(r => r.Title.StartsWith(s, StringComparison.OrdinalIgnoreCase)))},
|
||||
{"RoutePart.Title|<", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => true /* CompareTo is not implemented - r.Title.CompareTo(s) == -1*/))},
|
||||
{"RoutePart.Title|>", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => true /* CompareTo is not implemented - r.Title.CompareTo(s) == 1*/))},
|
||||
{"RoutePart.Title|=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => r.Title.Equals(s, StringComparison.OrdinalIgnoreCase)))},
|
||||
{"RoutePart.Title|^=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => r.Title.StartsWith(s, StringComparison.OrdinalIgnoreCase)))},
|
||||
{"RoutePart.Slug|<", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => true /* CompareTo is not implemented - r.Slug.CompareTo(s) == -1*/))},
|
||||
{"RoutePart.Slug|>", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => true /* CompareTo is not implemented - r.Slug.CompareTo(s) == 1*/))},
|
||||
{"RoutePart.Slug|=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => r.Slug.Equals(s.Trim(), StringComparison.OrdinalIgnoreCase)))},
|
||||
{"RoutePart.Slug|^=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<RoutePartRecord>(r => r.Slug.StartsWith(s, StringComparison.OrdinalIgnoreCase)))},
|
||||
{"CommonPart.PublishedUtc|<", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<CommonPartRecord>(r => r.PublishedUtc < DateTime.Parse(s)))},
|
||||
{"CommonPart.PublishedUtc|>", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<CommonPartRecord>(r => r.PublishedUtc > DateTime.Parse(s)))},
|
||||
{"CommonPart.PublishedUtc|=", new Func<IContentQuery<ContentItem>, string, IContentQuery<ContentItem>>((q, s) => q.Where<CommonPartRecord>(r => r.PublishedUtc == DateTime.Parse(s)))}, // todo: (heskew) not practical as is. needs some sense of precision....
|
||||
|
@@ -12,7 +12,6 @@ using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Containers.Models;
|
||||
using Orchard.Core.Contents.Settings;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
@@ -293,6 +292,8 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
// store the previous route in case a back redirection is requested
|
||||
// TODO: (PH:Autoroute) This won't be needed if automatic redirect aliases are implemented; otherwise, needs fixing
|
||||
/*
|
||||
string previousRoute = null;
|
||||
if(contentItem.Has<RoutePart>()
|
||||
&&!string.IsNullOrWhiteSpace(returnUrl)
|
||||
@@ -301,7 +302,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
&& String.Equals(returnUrl, Url.ItemDisplayUrl(contentItem), StringComparison.OrdinalIgnoreCase)
|
||||
) {
|
||||
previousRoute = contentItem.As<RoutePart>().Path;
|
||||
}
|
||||
}*/
|
||||
|
||||
dynamic model = _contentManager.UpdateEditor(contentItem, this);
|
||||
if (!ModelState.IsValid) {
|
||||
@@ -313,12 +314,14 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
conditionallyPublish(contentItem);
|
||||
|
||||
// did the route change ?
|
||||
// TODO: (PH:Autoroute) This won't be needed if automatic redirect aliases are implemented; otherwise, needs fixing
|
||||
/*
|
||||
if (!string.IsNullOrWhiteSpace(returnUrl)
|
||||
&& previousRoute != null
|
||||
&& !String.Equals(contentItem.As<RoutePart>().Path, previousRoute, StringComparison.OrdinalIgnoreCase)) {
|
||||
returnUrl = Url.ItemDisplayUrl(contentItem);
|
||||
}
|
||||
|
||||
*/
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName)
|
||||
? T("Your content has been saved.")
|
||||
: T("Your {0} has been saved.", contentItem.TypeDefinition.DisplayName));
|
||||
|
@@ -6,7 +6,6 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Common.Settings;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Core.Feeds.StandardBuilders {
|
||||
@@ -15,7 +14,7 @@ namespace Orchard.Core.Feeds.StandardBuilders {
|
||||
private readonly ContentItemMetadata _metadata;
|
||||
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
|
||||
private readonly ICommonPart _common;
|
||||
private readonly RoutePart _routable;
|
||||
private readonly ITitleAspect _titleAspect;
|
||||
private readonly BodyPart _body;
|
||||
|
||||
public ItemInspector(IContent item, ContentItemMetadata metadata) : this(item, metadata, Enumerable.Empty<IHtmlFilter>()) {}
|
||||
@@ -25,7 +24,7 @@ namespace Orchard.Core.Feeds.StandardBuilders {
|
||||
_metadata = metadata;
|
||||
_htmlFilters = htmlFilters;
|
||||
_common = item.Get<ICommonPart>();
|
||||
_routable = item.Get<RoutePart>();
|
||||
_titleAspect = item.Get<ITitleAspect>();
|
||||
_body = item.Get<BodyPart>();
|
||||
}
|
||||
|
||||
@@ -33,8 +32,8 @@ namespace Orchard.Core.Feeds.StandardBuilders {
|
||||
get {
|
||||
if (_metadata != null && !string.IsNullOrEmpty(_metadata.DisplayText))
|
||||
return _metadata.DisplayText;
|
||||
if (_routable != null && !string.IsNullOrEmpty(_routable.Title))
|
||||
return _routable.Title;
|
||||
if (_titleAspect != null && !string.IsNullOrEmpty(_titleAspect.Title))
|
||||
return _titleAspect.Title;
|
||||
return _item.ContentItem.ContentType + " #" + _item.ContentItem.Id;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ using Orchard.Blogs.Routing;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
|
@@ -8,7 +8,6 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Routable.Models;
|
||||
|
||||
namespace Orchard.Blogs.Drivers {
|
||||
public class RecentBlogPostsPartDriver : ContentPartDriver<RecentBlogPostsPart> {
|
||||
@@ -23,7 +22,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Display(RecentBlogPostsPart part, string displayType, dynamic shapeHelper) {
|
||||
BlogPart blog = GetBlogFromSlug(part.ForBlog);
|
||||
BlogPart blog = _blogService.Get(part.ForBlog,VersionOptions.Published).As<BlogPart>();
|
||||
|
||||
if (blog == null) {
|
||||
return null;
|
||||
@@ -46,7 +45,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
protected override DriverResult Editor(RecentBlogPostsPart part, dynamic shapeHelper) {
|
||||
var viewModel = new RecentBlogPostsViewModel {
|
||||
Count = part.Count,
|
||||
Slug = part.ForBlog,
|
||||
BlogId = part.ForBlog,
|
||||
Blogs = _blogService.Get().ToList().OrderBy(b => b.Name)
|
||||
};
|
||||
|
||||
@@ -57,7 +56,7 @@ namespace Orchard.Blogs.Drivers {
|
||||
protected override DriverResult Editor(RecentBlogPostsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var viewModel = new RecentBlogPostsViewModel();
|
||||
if (updater.TryUpdateModel(viewModel, Prefix, null, null)) {
|
||||
part.ForBlog = viewModel.Slug;
|
||||
part.ForBlog = viewModel.BlogId;
|
||||
part.Count = viewModel.Count;
|
||||
}
|
||||
|
||||
@@ -65,9 +64,9 @@ namespace Orchard.Blogs.Drivers {
|
||||
}
|
||||
|
||||
protected override void Importing(RecentBlogPostsPart part, ImportContentContext context) {
|
||||
var blogSlug = context.Attribute(part.PartDefinition.Name, "BlogSlug");
|
||||
if (blogSlug != null) {
|
||||
part.ForBlog = blogSlug;
|
||||
var blogId = context.Attribute(part.PartDefinition.Name, "BlogId");
|
||||
if (blogId != null) {
|
||||
part.ForBlog = Convert.ToInt32(blogId);
|
||||
}
|
||||
|
||||
var count = context.Attribute(part.PartDefinition.Name, "Count");
|
||||
@@ -77,14 +76,9 @@ namespace Orchard.Blogs.Drivers {
|
||||
}
|
||||
|
||||
protected override void Exporting(RecentBlogPostsPart part, ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("BlogSlug", part.ForBlog);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("BlogId", part.ForBlog);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Count", part.Count);
|
||||
}
|
||||
|
||||
private BlogPart GetBlogFromSlug(string slug) {
|
||||
return _contentManager.Query<BlogPart, BlogPartRecord>()
|
||||
.Join<RoutePartRecord>().Where(rr => rr.Slug == slug)
|
||||
.List().FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,6 @@ using System.Web.Mvc;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
|
@@ -107,8 +107,26 @@ namespace Orchard.Blogs {
|
||||
.WithPart("AutoroutePart")
|
||||
);
|
||||
return 5;
|
||||
}
|
||||
public int UpdateFrom5() {
|
||||
SchemaBuilder.AlterTable("RecentBlogPostsPartRecord",
|
||||
table => table.AddColumn<int>("BlogId")
|
||||
);
|
||||
|
||||
SchemaBuilder.AlterTable("BlogArchivesPartRecord",
|
||||
table => table.AddColumn<int>("BlogId")
|
||||
);
|
||||
|
||||
// TODO: (PH:Autoroute) Convert BlogSlug to BlogId
|
||||
SchemaBuilder.AlterTable("RecentBlogPostsPartRecord",
|
||||
table => table.DropColumn("BlogSlug")
|
||||
);
|
||||
|
||||
SchemaBuilder.AlterTable("BlogArchivesPartRecord",
|
||||
table => table.DropColumn("BlogSlug")
|
||||
);
|
||||
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
@@ -7,7 +6,6 @@ namespace Orchard.Blogs.Models {
|
||||
|
||||
// TODO: (PH) This isn't referenced in many places but should use ContentItemMetadata instead?
|
||||
public string Name {
|
||||
|
||||
get { return this.As<ITitleAspect>().Title; }
|
||||
}
|
||||
|
||||
|
@@ -4,9 +4,9 @@ using Orchard.ContentManagement;
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class RecentBlogPostsPart : ContentPart<RecentBlogPostsPartRecord> {
|
||||
|
||||
public string ForBlog {
|
||||
get { return Record.BlogSlug; }
|
||||
set { Record.BlogSlug = value; }
|
||||
public int ForBlog {
|
||||
get { return Record.BlogId; }
|
||||
set { Record.BlogId = value; }
|
||||
}
|
||||
|
||||
[Required]
|
||||
|
@@ -5,8 +5,7 @@ namespace Orchard.Blogs.Models {
|
||||
public RecentBlogPostsPartRecord() {
|
||||
Count = 5;
|
||||
}
|
||||
|
||||
public virtual string BlogSlug { get; set; }
|
||||
public virtual int BlogId { get; set; }
|
||||
public virtual int Count { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,6 @@ using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.Tasks.Scheduling;
|
||||
|
||||
@@ -24,18 +22,6 @@ namespace Orchard.Blogs.Services {
|
||||
_publishingTaskManager = publishingTaskManager;
|
||||
}
|
||||
|
||||
public BlogPostPart Get(BlogPart blogPart, string slug) {
|
||||
return Get(blogPart, slug, VersionOptions.Published);
|
||||
}
|
||||
|
||||
public BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions) {
|
||||
var postPath = blogPart.As<IRoutableAspect>().GetChildPath(slug);
|
||||
return
|
||||
_contentManager.Query(versionOptions, "BlogPost").Join<RoutePartRecord>().Where(rr => rr.Path == postPath).
|
||||
Join<CommonPartRecord>().Where(cr => cr.Container == blogPart.Record.ContentItemRecord).List().
|
||||
SingleOrDefault().As<BlogPostPart>();
|
||||
}
|
||||
|
||||
public BlogPostPart Get(int id) {
|
||||
return Get(id, VersionOptions.Published);
|
||||
}
|
||||
|
@@ -5,8 +5,6 @@ using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Blogs.Services {
|
||||
public interface IBlogPostService : IDependency {
|
||||
BlogPostPart Get(BlogPart blogPart, string slug);
|
||||
BlogPostPart Get(BlogPart blogPart, string slug, VersionOptions versionOptions);
|
||||
BlogPostPart Get(int id);
|
||||
BlogPostPart Get(int id, VersionOptions versionOptions);
|
||||
IEnumerable<BlogPostPart> Get(BlogPart blogPart);
|
||||
|
@@ -9,8 +9,6 @@ using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Core.Routable.Services;
|
||||
using Orchard.Core.XmlRpc;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
@@ -20,6 +18,7 @@ using Orchard.Mvc.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Blogs.Services {
|
||||
[UsedImplicitly]
|
||||
@@ -288,8 +287,8 @@ namespace Orchard.Blogs.Services {
|
||||
}
|
||||
|
||||
//RoutePart
|
||||
if (blogPost.Is<RoutePart>()) {
|
||||
blogPost.As<RoutePart>().Title = HttpUtility.HtmlDecode(title);
|
||||
if (blogPost.Is<TitlePart>()) {
|
||||
blogPost.As<TitlePart>().Title = HttpUtility.HtmlDecode(title);
|
||||
blogPost.As<RoutePart>().Slug = slug;
|
||||
_routableService.FillSlugFromTitle(blogPost.As<RoutePart>());
|
||||
blogPost.As<RoutePart>().Path = blogPost.As<RoutePart>().GetPathWithSlug(blogPost.As<RoutePart>().Slug);
|
||||
|
@@ -4,7 +4,8 @@ using Orchard.Blogs.Models;
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class RecentBlogPostsViewModel {
|
||||
public int Count { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public int BlogId { get; set; }
|
||||
public IEnumerable<BlogPart> Blogs { get; set; }
|
||||
|
||||
}
|
||||
}
|
@@ -1,15 +1,14 @@
|
||||
@model Orchard.Blogs.ViewModels.RecentBlogPostsViewModel
|
||||
|
||||
@using Orchard.Blogs.Models;
|
||||
@using Orchard.Core.Routable.Models;
|
||||
@using Orchard.ContentManagement;
|
||||
|
||||
<fieldset>
|
||||
<div>
|
||||
@Html.LabelFor(m => m.Slug, T("For Blog"))
|
||||
<select id="@Html.FieldIdFor(m => m.Slug)" name="@Html.FieldNameFor(m => m.Slug)">
|
||||
@Html.LabelFor(m => m.BlogId, T("For Blog"))
|
||||
<select id="@Html.FieldIdFor(m => m.BlogId)" name="@Html.FieldNameFor(m => m.BlogId)">
|
||||
@foreach(BlogPart blog in Model.Blogs) {
|
||||
@Html.SelectOption(Model.Slug, blog.As<RoutePart>().Slug, blog.Name)
|
||||
@Html.SelectOption(Model.BlogId, blog.ContentItem.Id, blog.Name)
|
||||
}
|
||||
</select>
|
||||
<span class="hint">@T("Select which blog you want to display the recent posts for")</span>
|
||||
|
Reference in New Issue
Block a user