Comment -> CommentPart; HasComments -> CommentsPart; HasCommentsContainer -> CommentsContainerPart

- updating part names to conform to a <name>Part convention

--HG--
branch : dev
rename : src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentsContainerPartDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentsPartDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentPartHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentSettingsHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentSettingsPartHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentsPartHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasCommentsContainer.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPart.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/CommentRecord.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentPartRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettings.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsPart.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsRecord.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsPartRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasCommentsContainer.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsContainerPart.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasComments.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPart.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasCommentsRecord.cs => src/Orchard.Web/Modules/Orchard.Comments/Models/CommentsPartRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.HasComments.ascx => src/Orchard.Web/Modules/Orchard.Comments/Views/DisplayTemplates/Parts/Comments.Comments.ascx
rename : src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.HasComments.ascx => src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.Comments.ascx
rename : src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Comments.HasComments.ascx => src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Comments.Comments.ascx
rename : src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.HasComments.ascx => src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Comments.Comments.ascx
This commit is contained in:
Nathan Heskew
2010-07-22 14:08:31 -07:00
parent 0e63927f78
commit aa269fd49f
53 changed files with 180 additions and 180 deletions

View File

@@ -39,7 +39,7 @@ namespace Orchard.Comments.Controllers {
options = new CommentIndexOptions();
// Filtering
IEnumerable<Comment> comments;
IEnumerable<CommentPart> comments;
try {
switch (options.Filter) {
case CommentIndexFilter.All:
@@ -129,7 +129,7 @@ namespace Orchard.Comments.Controllers {
options = new CommentDetailsOptions();
// Filtering
IEnumerable<Comment> comments;
IEnumerable<CommentPart> comments;
try {
switch (options.Filter) {
case CommentDetailsFilter.All:
@@ -261,14 +261,14 @@ namespace Orchard.Comments.Controllers {
public ActionResult Edit(int id) {
try {
Comment comment = _commentService.GetComment(id);
CommentPart commentPart = _commentService.GetComment(id);
var viewModel = new CommentsEditViewModel {
CommentText = comment.Record.CommentText,
Email = comment.Record.Email,
Id = comment.Record.Id,
Name = comment.Record.Author,
SiteName = comment.Record.SiteName,
Status = comment.Record.Status,
CommentText = commentPart.Record.CommentText,
Email = commentPart.Record.Email,
Id = commentPart.Record.Id,
Name = commentPart.Record.Author,
SiteName = commentPart.Record.SiteName,
Status = commentPart.Record.Status,
};
return View(viewModel);
@@ -319,10 +319,10 @@ namespace Orchard.Comments.Controllers {
}
}
private CommentEntry CreateCommentEntry(CommentRecord comment) {
private CommentEntry CreateCommentEntry(CommentPartRecord commentPart) {
return new CommentEntry {
Comment = comment,
CommentedOn = _commentService.GetDisplayForCommentedContent(comment.CommentedOn).DisplayText,
Comment = commentPart,
CommentedOn = _commentService.GetDisplayForCommentedContent(commentPart.CommentedOn).DisplayText,
IsChecked = false,
};
}

View File

@@ -61,9 +61,9 @@ namespace Orchard.Comments.Controllers {
CommentedOn = viewModel.CommentedOn
};
Comment comment = _commentService.CreateComment(context, CurrentSite.As<CommentSettings>().Record.ModerateComments);
CommentPart commentPart = _commentService.CreateComment(context, CurrentSite.As<CommentSettingsPart>().Record.ModerateComments);
if (comment.Record.Status == CommentStatus.Pending)
if (commentPart.Record.Status == CommentStatus.Pending)
Services.Notifier.Information(T("Your comment will appear after the site administrator approves it."));
return !String.IsNullOrEmpty(returnUrl)

View File

@@ -16,8 +16,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<int>("ContentItemId")
);
//CREATE TABLE Orchard_Comments_CommentRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentRecord", table => table
//CREATE TABLE Orchard_Comments_CommentPartRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentPartRecord", table => table
.ContentPartRecord()
.Column<string>("Author")
.Column<string>("SiteName")
@@ -30,8 +30,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<int>("CommentedOnContainer")
);
//CREATE TABLE Orchard_Comments_CommentSettingsRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id));
SchemaBuilder.CreateTable("CommentSettingsRecord", table => table
//CREATE TABLE Orchard_Comments_CommentSettingsPartRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id));
SchemaBuilder.CreateTable("CommentSettingsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("ModerateComments")
.Column<bool>("EnableSpamProtection")
@@ -39,8 +39,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<string>("AkismetUrl")
);
//CREATE TABLE Orchard_Comments_HasCommentsRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id));
SchemaBuilder.CreateTable("HasCommentsRecord", table => table
//CREATE TABLE Orchard_Comments_CommentsPartRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("CommentsShown")
.Column<bool>("CommentsActive")
@@ -52,20 +52,20 @@ namespace Orchard.Comments.DataMigrations {
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Comment",
cfg => cfg
.WithPart("Comment")
.WithPart("CommentPart")
.WithPart("CommonPart")
);
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.WithPart("HasCommentsContainer")
.WithPart("CommentsContainerPart")
);
return 2;
}
public int UpdateFrom2() {
ContentDefinitionManager.AlterPartDefinition(typeof(HasComments).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(CommentsPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"Default", new ContentLocation { Zone = "primary", Position = "before.5" }},
{"Detail", new ContentLocation { Zone = "primary", Position = "after.5" }},
@@ -74,7 +74,7 @@ namespace Orchard.Comments.DataMigrations {
{"Editor", new ContentLocation { Zone = "primary", Position = "10" }},
}));
ContentDefinitionManager.AlterPartDefinition(typeof(HasCommentsContainer).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(CommentsContainerPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
{"Summary", new ContentLocation { Zone = "meta", Position = null }},

View File

@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Drivers;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class CommentDriver : ContentItemDriver<Comment> {
public class CommentPartDriver : ContentItemDriver<CommentPart> {
public readonly static ContentType ContentType = new ContentType {
Name = "Comment",
DisplayName = "Comment"

View File

@@ -9,8 +9,8 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> {
protected override DriverResult Display(HasCommentsContainer part, string displayType) {
public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> {
protected override DriverResult Display(CommentsContainerPart part, string displayType) {
if (displayType == "SummaryAdmin") {
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
}
@@ -27,8 +27,8 @@ namespace Orchard.Comments.Drivers {
.Where<CommonPartRecord>(rec => rec.Container == contentItem.Record).List();
// Count comments and create template
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().PendingComments.Count : 0));
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
return new CommentCountViewModel { Item = contentItem, CommentCount = count, PendingCount = pendingCount};
}

View File

@@ -7,8 +7,8 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsDriver : ContentPartDriver<HasComments> {
protected override DriverResult Display(HasComments part, string displayType) {
public class CommentsPartDriver : ContentPartDriver<CommentsPart> {
protected override DriverResult Display(CommentsPart part, string displayType) {
if (part.CommentsShown == false) {
return null;
}
@@ -16,7 +16,7 @@ namespace Orchard.Comments.Drivers {
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the...
// comment count go in any given skin or what if the skin builder doesn't want the count
if (displayType.StartsWith("Detail")) {
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Detail"));
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Detail"));
}
else if (displayType == "SummaryAdmin") {
var model = new CommentCountViewModel(part);
@@ -32,13 +32,13 @@ namespace Orchard.Comments.Drivers {
}
}
protected override DriverResult Editor(HasComments part) {
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
protected override DriverResult Editor(CommentsPart part) {
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
}
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
protected override DriverResult Editor(CommentsPart part, IUpdateModel updater) {
updater.TryUpdateModel(part, Prefix, null, null);
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Orchard.Comments.Feeds {
Localizer T { get; set; }
public void Populate(FeedContext context) {
foreach (var feedItem in context.Response.Items.OfType<FeedItem<Comment>>()) {
foreach (var feedItem in context.Response.Items.OfType<FeedItem<CommentPart>>()) {
var comment = feedItem.Item;
var commentedOn = _contentManager.Get(feedItem.Item.Record.CommentedOn);
var commentedOnInspector = new ItemInspector(

View File

@@ -30,7 +30,7 @@ namespace Orchard.Comments.Feeds {
limit = (int)limitValue.ConvertTo(typeof(int));
var comments = _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOnContainer == commentedOnContainer && x.Status == CommentStatus.Approved)
.OrderByDescending(x => x.CommentDateUtc)
.Slice(0, limit);

View File

@@ -30,7 +30,7 @@ namespace Orchard.Comments.Feeds {
limit = (int)limitValue.ConvertTo(typeof(int));
var comments = _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == commentedOn && x.Status == CommentStatus.Approved)
.OrderByDescending(x => x.CommentDateUtc)
.Slice(0, limit);

View File

@@ -7,8 +7,8 @@ using Orchard.Data;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentHandler : ContentHandler {
public CommentHandler(IRepository<CommentRecord> commentsRepository) {
public class CommentPartHandler : ContentHandler {
public CommentPartHandler(IRepository<CommentPartRecord> commentsRepository) {
Filters.Add(StorageFilter.For(commentsRepository));
}
}

View File

@@ -5,11 +5,11 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentSettingsHandler : ContentHandler {
public CommentSettingsHandler(IRepository<CommentSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<CommentSettings>("Site"));
public class CommentSettingsPartHandler : ContentHandler {
public CommentSettingsPartHandler(IRepository<CommentSettingsPartRecord> repository) {
Filters.Add(new ActivatingFilter<CommentSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings"));
Filters.Add(new TemplateFilterForRecord<CommentSettingsPartRecord>("CommentSettingsPart", "Parts/Comments.SiteSettings"));
}
}
}

View File

@@ -8,32 +8,32 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class HasCommentsHandler : ContentHandler {
public HasCommentsHandler(
public class CommentsPartHandler : ContentHandler {
public CommentsPartHandler(
IContentManager contentManager,
IRepository<HasCommentsRecord> hasCommentsRepository,
IRepository<CommentsPartRecord> commentsRepository,
ICommentService commentService) {
Filters.Add(StorageFilter.For(hasCommentsRepository));
Filters.Add(StorageFilter.For(commentsRepository));
OnInitializing<HasComments>((ctx, x) => {
OnInitializing<CommentsPart>((ctx, x) => {
x.CommentsActive = true;
x.CommentsShown = true;
});
OnLoading<HasComments>((context, comments) => {
OnLoading<CommentsPart>((context, comments) => {
comments._comments.Loader(list => contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
.List().ToList());
comments._pendingComments.Loader(list => contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
.List().ToList());
});
OnRemoved<HasComments>(
OnRemoved<CommentsPart>(
(context, c) => {
foreach (var comment in commentService.GetCommentsForCommentedContent(context.ContentItem.Id)) {
contentManager.Remove(comment.ContentItem);

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class Comment : ContentPart<CommentRecord> {
public class CommentPart : ContentPart<CommentPartRecord> {
}
}

View File

@@ -3,7 +3,7 @@ using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Comments.Models {
public class CommentRecord : ContentPartRecord {
public class CommentPartRecord : ContentPartRecord {
public virtual string Author { get; set; }
public virtual string SiteName { get; set; }
public virtual string UserName { get; set; }

View File

@@ -1,6 +0,0 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class CommentSettings : ContentPart<CommentSettingsRecord> {
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class CommentSettingsPart : ContentPart<CommentSettingsPartRecord> {
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Comments.Models {
public class CommentSettingsRecord : ContentPartRecord {
public class CommentSettingsPartRecord : ContentPartRecord {
public virtual bool ModerateComments { get; set; }
public virtual bool EnableSpamProtection { get; set; }
public virtual string AkismetKey { get; set; }

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class HasCommentsContainer : ContentPart {
public class CommentsContainerPart : ContentPart {
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Utilities;
namespace Orchard.Comments.Models {
public class CommentsPart : ContentPart<CommentsPartRecord> {
public CommentsPart() {
Comments = new List<CommentPart>();
PendingComments = new List<CommentPart>();
}
public readonly LazyField<IList<CommentPart>> _comments = new LazyField<IList<CommentPart>>();
public readonly LazyField<IList<CommentPart>> _pendingComments = new LazyField<IList<CommentPart>>();
public IList<CommentPart> Comments { get { return _comments.Value; } set { _comments.Value = value; } }
public IList<CommentPart> PendingComments { get { return _pendingComments.Value; } set { _pendingComments.Value = value; } }
public bool CommentsShown {
get { return Record.CommentsShown; }
set { Record.CommentsShown = value; }
}
public bool CommentsActive {
get { return Record.CommentsActive; }
set { Record.CommentsActive = value; }
}
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Comments.Models {
public class HasCommentsRecord : ContentPartRecord {
public class CommentsPartRecord : ContentPartRecord {
public virtual bool CommentsShown { get; set; }
public virtual bool CommentsActive { get; set; }
}

View File

@@ -1,28 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Utilities;
namespace Orchard.Comments.Models {
public class HasComments : ContentPart<HasCommentsRecord> {
public HasComments() {
Comments = new List<Comment>();
PendingComments = new List<Comment>();
}
public readonly LazyField<IList<Comment>> _comments = new LazyField<IList<Comment>>();
public readonly LazyField<IList<Comment>> _pendingComments = new LazyField<IList<Comment>>();
public IList<Comment> Comments { get { return _comments.Value; } set { _comments.Value = value; } }
public IList<Comment> PendingComments { get { return _pendingComments.Value; } set { _pendingComments.Value = value; } }
public bool CommentsShown {
get { return Record.CommentsShown; }
set { Record.CommentsShown = value; }
}
public bool CommentsActive {
get { return Record.CommentsActive; }
set { Record.CommentsActive = value; }
}
}
}

View File

@@ -73,28 +73,28 @@
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\CommentController.cs" />
<Compile Include="DataMigrations\CommentsDataMigration.cs" />
<Compile Include="Drivers\CommentDriver.cs" />
<Compile Include="Drivers\HasCommentsContainerDriver.cs" />
<Compile Include="Drivers\HasCommentsDriver.cs" />
<Compile Include="Drivers\CommentPartDriver.cs" />
<Compile Include="Drivers\CommentsContainerPartDriver.cs" />
<Compile Include="Drivers\CommentsPartDriver.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Models\ClosedCommentsRecord.cs" />
<Compile Include="Models\Comment.cs" />
<Compile Include="Handlers\CommentHandler.cs" />
<Compile Include="Models\CommentPart.cs" />
<Compile Include="Handlers\CommentPartHandler.cs" />
<Compile Include="Models\CommentStatus.cs" />
<Compile Include="Models\HasCommentsContainer.cs" />
<Compile Include="Models\CommentsContainerPart.cs" />
<Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" />
<Compile Include="Feeds\CommentedOnFeedQuery.cs" />
<Compile Include="Feeds\CommentFeedItemBuilder.cs" />
<Compile Include="Models\CommentRecord.cs" />
<Compile Include="Models\HasCommentsRecord.cs" />
<Compile Include="Models\CommentPartRecord.cs" />
<Compile Include="Models\CommentsPartRecord.cs" />
<Compile Include="Services\CreateCommentContext.cs" />
<Compile Include="Services\ICommentService.cs" />
<Compile Include="ViewModels\CommentCountViewModel.cs" />
<Compile Include="Models\CommentSettings.cs" />
<Compile Include="Handlers\CommentSettingsHandler.cs" />
<Compile Include="Models\CommentSettingsRecord.cs" />
<Compile Include="Handlers\HasCommentsHandler.cs" />
<Compile Include="Models\HasComments.cs" />
<Compile Include="Models\CommentSettingsPart.cs" />
<Compile Include="Handlers\CommentSettingsPartHandler.cs" />
<Compile Include="Models\CommentSettingsPartRecord.cs" />
<Compile Include="Handlers\CommentsPartHandler.cs" />
<Compile Include="Models\CommentsPart.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CommentService.cs" />
@@ -111,11 +111,11 @@
<Content Include="Views\Admin\Details.aspx" />
<Content Include="Views\Admin\Edit.aspx" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Count.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.CountAdmin.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Views\ListOfComments.ascx" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />

View File

@@ -32,36 +32,36 @@ namespace Orchard.Comments.Services {
public ILogger Logger { get; set; }
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
public IEnumerable<Comment> GetComments() {
public IEnumerable<CommentPart> GetComments() {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.List();
}
public IEnumerable<Comment> GetComments(CommentStatus status) {
public IEnumerable<CommentPart> GetComments(CommentStatus status) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.Status == status)
.List();
}
public IEnumerable<Comment> GetCommentsForCommentedContent(int id) {
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
.List();
}
public IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status) {
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id, CommentStatus status) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
.Where(ctx => ctx.Status == status)
.List();
}
public Comment GetComment(int id) {
return _contentManager.Get<Comment>(id);
public CommentPart GetComment(int id) {
return _contentManager.Get<CommentPart>(id);
}
public ContentItemMetadata GetDisplayForCommentedContent(int id) {
@@ -71,8 +71,8 @@ namespace Orchard.Comments.Services {
return _contentManager.GetItemMetadata(content);
}
public Comment CreateComment(CreateCommentContext context, bool moderateComments) {
var comment = _contentManager.Create<Comment>(CommentDriver.ContentType.Name);
public CommentPart CreateComment(CreateCommentContext context, bool moderateComments) {
var comment = _contentManager.Create<CommentPart>(CommentPartDriver.ContentType.Name);
comment.Record.Author = context.Author;
comment.Record.CommentDateUtc = _clock.UtcNow;
@@ -95,27 +95,27 @@ namespace Orchard.Comments.Services {
}
public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
Comment comment = GetComment(id);
comment.Record.Author = name;
comment.Record.Email = email;
comment.Record.SiteName = siteName;
comment.Record.CommentText = commentText;
comment.Record.Status = status;
CommentPart commentPart = GetComment(id);
commentPart.Record.Author = name;
commentPart.Record.Email = email;
commentPart.Record.SiteName = siteName;
commentPart.Record.CommentText = commentText;
commentPart.Record.Status = status;
}
public void ApproveComment(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Approved;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Approved;
}
public void PendComment(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Pending;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Pending;
}
public void MarkCommentAsSpam(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Spam;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Spam;
}
public void DeleteComment(int commentId) {

View File

@@ -25,11 +25,11 @@ namespace Orchard.Comments.Services {
public Localizer T { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
public bool ValidateComment(Comment comment) {
CommentSettingsRecord commentSettingsRecord = CurrentSite.As<CommentSettings>().Record;
string akismetKey = commentSettingsRecord.AkismetKey;
string akismetUrl = commentSettingsRecord.AkismetUrl;
bool enableSpamProtection = commentSettingsRecord.EnableSpamProtection;
public bool ValidateComment(CommentPart commentPart) {
CommentSettingsPartRecord commentSettingsPartRecord = CurrentSite.As<CommentSettingsPart>().Record;
string akismetKey = commentSettingsPartRecord.AkismetKey;
string akismetUrl = commentSettingsPartRecord.AkismetUrl;
bool enableSpamProtection = commentSettingsPartRecord.EnableSpamProtection;
if (enableSpamProtection == false) {
return true;
}
@@ -42,11 +42,11 @@ namespace Orchard.Comments.Services {
}
Akismet akismetApi = new Akismet(akismetKey, akismetUrl, null);
AkismetComment akismetComment = new AkismetComment {
CommentAuthor = comment.Record.Author,
CommentAuthorEmail = comment.Record.Email,
Blog = comment.Record.SiteName,
CommentAuthorUrl = comment.Record.SiteName,
CommentContent = comment.Record.CommentText,
CommentAuthor = commentPart.Record.Author,
CommentAuthorEmail = commentPart.Record.Email,
Blog = commentPart.Record.SiteName,
CommentAuthorUrl = commentPart.Record.SiteName,
CommentContent = commentPart.Record.CommentText,
UserAgent = HttpContext.Current.Request.UserAgent,
};

View File

@@ -4,13 +4,13 @@ using Orchard.ContentManagement;
namespace Orchard.Comments.Services {
public interface ICommentService : IDependency {
IEnumerable<Comment> GetComments();
IEnumerable<Comment> GetComments(CommentStatus status);
IEnumerable<Comment> GetCommentsForCommentedContent(int id);
IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status);
Comment GetComment(int id);
IEnumerable<CommentPart> GetComments();
IEnumerable<CommentPart> GetComments(CommentStatus status);
IEnumerable<CommentPart> GetCommentsForCommentedContent(int id);
IEnumerable<CommentPart> GetCommentsForCommentedContent(int id, CommentStatus status);
CommentPart GetComment(int id);
ContentItemMetadata GetDisplayForCommentedContent(int id);
Comment CreateComment(CreateCommentContext commentRecord, bool moderateComments);
CommentPart CreateComment(CreateCommentContext commentRecord, bool moderateComments);
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
void ApproveComment(int commentId);
void PendComment(int commentId);

View File

@@ -2,6 +2,6 @@ using Orchard.Comments.Models;
namespace Orchard.Comments.Services {
public interface ICommentValidator : IDependency {
bool ValidateComment(Comment comment);
bool ValidateComment(CommentPart commentPart);
}
}

View File

@@ -6,7 +6,7 @@ namespace Orchard.Comments.ViewModels {
public CommentCountViewModel() {
}
public CommentCountViewModel(HasComments part) {
public CommentCountViewModel(CommentsPart part) {
Item = part.ContentItem;
CommentCount = part.Comments.Count;
PendingCount = part.PendingComments.Count;

View File

@@ -9,7 +9,7 @@ namespace Orchard.Comments.ViewModels {
}
public class CommentEntry {
public CommentRecord Comment { get; set; }
public CommentPartRecord Comment { get; set; }
public string CommentedOn { get; set; }
public bool IsChecked { get; set; }
}

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments.Extensions"%>
<%@ Import Namespace="Orchard.Localization" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentSettingsRecord>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentSettingsPartRecord>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<fieldset>
<legend><%: T("Comments")%></legend>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -191,7 +191,7 @@ namespace Orchard.Setup.Services {
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
.DisplayedAs("Blog Post")
.WithPart("HasComments")
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Indexed());
@@ -201,7 +201,7 @@ namespace Orchard.Setup.Services {
.WithPart("PublishLaterPart")
.WithPart("IsRoutable")
.WithPart("BodyPart")
.WithPart("HasComments")
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Indexed());
@@ -215,8 +215,8 @@ namespace Orchard.Setup.Services {
page.As<IsRoutable>().Path = "home";
page.As<IsRoutable>().Title = T("Home").ToString();
page.As<CommonPart>().Owner = user;
if (page.Has<HasComments>()) {
page.As<HasComments>().CommentsShown = false;
if (page.Has<CommentsPart>()) {
page.As<CommentsPart>().CommentsShown = false;
}
contentManager.Publish(page);
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;

View File

@@ -195,7 +195,7 @@
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Blogs.BlogPost.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Blogs.BlogPost.ListByArchive.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Pages.Page.Metadata.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Tags.ShowTags.ascx" />
<Content Include="Themes\Contoso\Views\Header.ascx" />
@@ -239,7 +239,7 @@
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Blogs.BlogPost.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Blogs.BlogPost.ListByArchive.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Pages.Page.Metadata.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Tags.ShowTags.ascx" />
<Content Include="Themes\Corporate\Views\Footer.ascx" />

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,3 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,3 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -198,7 +198,7 @@
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Blogs.BlogPost.Summary.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Green\Views\Footer.ascx" />
<Content Include="Themes\Green\Views\Layout.ascx" />
<Content Include="Themes\Green\Views\ListOfComments.ascx" />