mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Removing the IContentDisplayInfo interface in favor of new manager method GetItemMetadata
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042888
This commit is contained in:
@@ -5,7 +5,7 @@ using Orchard.Models;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPost : ContentPart<BlogPostRecord>, IContentDisplayInfo {
|
||||
public class BlogPost : ContentPart<BlogPostRecord> {
|
||||
public readonly static ContentType ContentType = new ContentType { Name = "blogpost", DisplayName = "Blog Post" };
|
||||
|
||||
public Blog Blog { get; set; }
|
||||
@@ -16,20 +16,5 @@ namespace Orchard.Blogs.Models {
|
||||
public IUser Creator { get { return this.As<CommonAspect>().OwnerField.Value; } }
|
||||
public DateTime? Published { get { return Record.Published; } }
|
||||
|
||||
#region IContentDisplayInfo Members
|
||||
|
||||
public string DisplayText {
|
||||
get { return Title; }
|
||||
}
|
||||
|
||||
public RouteValueDictionary DisplayRouteValues() {
|
||||
return new RouteValueDictionary(new { area = "Orchard.Blogs", controller = "BlogPost", action = "Item", blogSlug = Blog.Slug, postSlug = Slug });
|
||||
}
|
||||
|
||||
public RouteValueDictionary EditRouteValues() {
|
||||
return new RouteValueDictionary(new { area = "Orchard.Blogs", controller = "BlogPost", action = "Edit", blogSlug = Blog.Slug, postSlug = Slug });
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
@@ -17,6 +18,28 @@ namespace Orchard.Blogs.Models {
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>("blogpost"));
|
||||
Filters.Add(new StorageFilter<BlogPostRecord>(repository));
|
||||
OnLoaded<BlogPost>((context, bp) => bp.Blog = contentManager.Get<Blog>(bp.Record.Blog.Id));
|
||||
|
||||
OnGetItemMetadata<BlogPost>((context, bp) => {
|
||||
context.Metadata.DisplayText = bp.Title;
|
||||
context.Metadata.DisplayRouteValues =
|
||||
new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Blogs",
|
||||
controller = "BlogPost",
|
||||
action = "Item",
|
||||
blogSlug = bp.Blog.Slug,
|
||||
postSlug = bp.Slug
|
||||
});
|
||||
context.Metadata.EditorRouteValues =
|
||||
new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Blogs",
|
||||
controller = "BlogPost",
|
||||
action = "Edit",
|
||||
blogSlug = bp.Blog.Slug,
|
||||
postSlug = bp.Slug
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@ namespace Orchard.Comments.Services {
|
||||
IEnumerable<Comment> GetCommentsForCommentedContent(int id);
|
||||
IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status);
|
||||
Comment GetComment(int id);
|
||||
IContentDisplayInfo GetDisplayForCommentedContent(int id);
|
||||
ContentItemMetadata GetDisplayForCommentedContent(int id);
|
||||
void CreateComment(Comment comment);
|
||||
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
|
||||
void MarkCommentAsSpam(int commentId);
|
||||
@@ -73,8 +73,11 @@ namespace Orchard.Comments.Services {
|
||||
return _commentRepository.Get(id);
|
||||
}
|
||||
|
||||
public IContentDisplayInfo GetDisplayForCommentedContent(int id) {
|
||||
return _contentManager.Get(id).As<IContentDisplayInfo>();
|
||||
public ContentItemMetadata GetDisplayForCommentedContent(int id) {
|
||||
var content = _contentManager.Get(id);
|
||||
if (content == null)
|
||||
return null;
|
||||
return _contentManager.GetItemMetadata(content);
|
||||
}
|
||||
|
||||
public void CreateComment(Comment comment) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
@@ -8,11 +9,11 @@ namespace Orchard.Sandbox.Models {
|
||||
public class SandboxContentProvider : ContentProvider {
|
||||
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] {SandboxPage.ContentType};
|
||||
return new[] { SandboxPage.ContentType };
|
||||
}
|
||||
|
||||
public SandboxContentProvider(
|
||||
IRepository<SandboxPageRecord> pageRepository,
|
||||
IRepository<SandboxPageRecord> pageRepository,
|
||||
IRepository<SandboxSettingsRecord> settingsRepository) {
|
||||
|
||||
// define the "sandboxpage" content type
|
||||
@@ -22,6 +23,26 @@ namespace Orchard.Sandbox.Models {
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new StorageFilter<SandboxPageRecord>(pageRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
|
||||
OnGetItemMetadata<SandboxPage>((context, page) => {
|
||||
context.Metadata.DisplayText = page.Record.Name;
|
||||
context.Metadata.DisplayRouteValues =
|
||||
new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Sandbox",
|
||||
controller = "Page",
|
||||
action = "Show",
|
||||
id = context.ContentItem.Id,
|
||||
});
|
||||
context.Metadata.EditorRouteValues =
|
||||
new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Sandbox",
|
||||
controller = "Page",
|
||||
action = "Edit",
|
||||
id = context.ContentItem.Id,
|
||||
});
|
||||
});
|
||||
|
||||
// add settings to site, and simple record-template gui
|
||||
Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsRecord>>("site"));
|
||||
Filters.Add(new StorageFilter<SandboxSettingsRecord>(settingsRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
|
@@ -2,21 +2,9 @@ using System.Web.Routing;
|
||||
using Orchard.Models;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxPage : ContentPart<SandboxPageRecord>, IContentDisplayInfo {
|
||||
public class SandboxPage : ContentPart<SandboxPageRecord> {
|
||||
|
||||
public readonly static ContentType ContentType = new ContentType {Name = "sandboxpage", DisplayName = "Sandbox Page"};
|
||||
|
||||
string IContentDisplayInfo.DisplayText {
|
||||
get { return Record.Name; }
|
||||
}
|
||||
|
||||
RouteValueDictionary IContentDisplayInfo.DisplayRouteValues() {
|
||||
return new RouteValueDictionary(new { area = "Orchard.Sandbox", controller = "Page", action = "Show", id = ContentItem.Id });
|
||||
}
|
||||
|
||||
RouteValueDictionary IContentDisplayInfo.EditRouteValues() {
|
||||
return new RouteValueDictionary(new { area = "Orchard.Sandbox", controller = "Page", action = "Edit", id = ContentItem.Id });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@ namespace Orchard.Tags.Models {
|
||||
Filters.Add(new ActivatingFilter<HasTags>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<HasTags>("blogpost"));
|
||||
|
||||
OnGetDisplays<HasTags>((context, part) => {
|
||||
context.Displays.Add(new ModelTemplate(context.ContentItem.Get<HasTags>()) { Position = "2", TemplateName = "HasTagsList" });
|
||||
context.Displays.Add(new ModelTemplate(context.ContentItem.Get<HasTags>()) { Position = "5" });
|
||||
OnGetDisplays<HasTags>((context, hasTags) => {
|
||||
context.Displays.Add(new ModelTemplate(hasTags) { Position = "2", TemplateName = "HasTagsList" });
|
||||
context.Displays.Add(new ModelTemplate(hasTags) { Position = "5" });
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,10 @@
|
||||
<% foreach (var contentItem in Model.Contents) { %>
|
||||
<tr>
|
||||
<td>
|
||||
<%=contentItem.As<IContentDisplayInfo>().DisplayText%>
|
||||
<%=Html.ItemDisplayText(contentItem)%>
|
||||
</td>
|
||||
<td>
|
||||
<%=Html.ItemDisplayLink(contentItem)%>
|
||||
<%=Html.ItemDisplayLink(contentItem)%>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
Reference in New Issue
Block a user