mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-08 10:35:01 +08:00
Updating to MVC 2 RC. Adjusting for some differences. Adding record for HasComments part.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044540
This commit is contained in:
Binary file not shown.
@@ -91,11 +91,11 @@ namespace Orchard.Tests.Packages.Users.Controllers {
|
|||||||
_obj = obj;
|
_obj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsPrefix(ControllerContext controllerContext, string prefix) {
|
public bool ContainsPrefix( string prefix) {
|
||||||
return typeof(T).GetProperties().Any(x => x.Name.StartsWith(prefix));
|
return typeof(T).GetProperties().Any(x => x.Name.StartsWith(prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueProviderResult GetValue(ControllerContext controllerContext, string key) {
|
public ValueProviderResult GetValue( string key) {
|
||||||
var property = typeof(T).GetProperty(key);
|
var property = typeof(T).GetProperty(key);
|
||||||
if (property == null)
|
if (property == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Orchard.Web {
|
|||||||
protected void Application_Start() {
|
protected void Application_Start() {
|
||||||
// This is temporary until MVC2 is officially released.
|
// This is temporary until MVC2 is officially released.
|
||||||
// We want to avoid running against an outdated preview installed in the GAC
|
// We want to avoid running against an outdated preview installed in the GAC
|
||||||
CheckMvcVersion(new Version("2.0.41116.0")/*MVC2 Beta file version #*/);
|
CheckMvcVersion(new Version("2.0.41211.0")/*MVC2 RC file version #*/);
|
||||||
RegisterRoutes(RouteTable.Routes);
|
RegisterRoutes(RouteTable.Routes);
|
||||||
|
|
||||||
_host = OrchardStarter.CreateHost(MvcSingletons);
|
_host = OrchardStarter.CreateHost(MvcSingletons);
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
private readonly IBlogPostService _blogPostService;
|
private readonly IBlogPostService _blogPostService;
|
||||||
|
|
||||||
public BlogPostController(
|
public BlogPostController(
|
||||||
|
IOrchardServices services,
|
||||||
ISessionLocator sessionLocator, IContentManager contentManager,
|
ISessionLocator sessionLocator, IContentManager contentManager,
|
||||||
IAuthorizer authorizer,
|
IAuthorizer authorizer,
|
||||||
INotifier notifier,
|
INotifier notifier,
|
||||||
IBlogService blogService,
|
IBlogService blogService,
|
||||||
IBlogPostService blogPostService) {
|
IBlogPostService blogPostService) {
|
||||||
|
Services = services;
|
||||||
_sessionLocator = sessionLocator;
|
_sessionLocator = sessionLocator;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_authorizer = authorizer;
|
_authorizer = authorizer;
|
||||||
@@ -37,6 +39,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
private Localizer T { get; set; }
|
private Localizer T { get; set; }
|
||||||
|
|
||||||
//TODO: (erikpo) Should think about moving the slug parameters and get calls and null checks up into a model binder or action filter
|
//TODO: (erikpo) Should think about moving the slug parameters and get calls and null checks up into a model binder or action filter
|
||||||
@@ -151,8 +154,8 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost, ActionName("Edit")]
|
||||||
public ActionResult Edit(string blogSlug, string postSlug, FormCollection input) {
|
public ActionResult EditPOST(string blogSlug, string postSlug) {
|
||||||
if (!_authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
|
if (!_authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
@@ -171,13 +174,15 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
BlogPost = _contentManager.UpdateEditorModel(post, this)
|
BlogPost = _contentManager.UpdateEditorModel(post, this)
|
||||||
};
|
};
|
||||||
|
|
||||||
IValueProvider values = input.ToValueProvider();
|
TryUpdateModel(model);
|
||||||
TryUpdateModel(model, values);
|
|
||||||
|
if (ModelState.IsValid==false) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
_notifier.Information(T("Blog post information updated."));
|
_notifier.Information(T("Blog post information updated."));
|
||||||
|
return Redirect(Url.BlogPostEdit(blog.Slug, post.Slug));
|
||||||
//TODO: (erikpo) Since the model isn't actually updated yet and it's possible the slug changed I'm getting the slug from input. Lame?!?!
|
|
||||||
return Redirect(Url.BlogPostEdit(blog.Slug, values.GetValue(ControllerContext, "Slug").AttemptedValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@@ -111,10 +111,10 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[AcceptVerbs(HttpVerbs.Post)]
|
[AcceptVerbs(HttpVerbs.Post)]
|
||||||
public ActionResult Create(FormCollection input, string returnUrl) {
|
public ActionResult Create(string returnUrl) {
|
||||||
var viewModel = new CommentsCreateViewModel();
|
var viewModel = new CommentsCreateViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel, input.ToValueProvider());
|
UpdateModel(viewModel);
|
||||||
if (CurrentSite.As<CommentSettings>().Record.RequireLoginToAddComment) {
|
if (CurrentSite.As<CommentSettings>().Record.RequireLoginToAddComment) {
|
||||||
if (!_authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment")))
|
if (!_authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using Orchard.Comments.Models;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
|
||||||
|
namespace Orchard.Comments.Controllers {
|
||||||
|
public class HasCommentsDriver : PartDriver<HasComments> {
|
||||||
|
protected override DriverResult Display(HasComments part, string displayType) {
|
||||||
|
if (part.CommentsShown == false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (displayType.StartsWith("Detail")) {
|
||||||
|
return Combined(
|
||||||
|
PartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"),
|
||||||
|
PartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.5"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return PartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.5");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DriverResult Editor(HasComments part) {
|
||||||
|
return PartTemplate(part, "Parts/Comments.HasComments");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
|
||||||
|
updater.TryUpdateModel(part, Prefix, null, null);
|
||||||
|
return PartTemplate(part, "Parts/Comments.HasComments");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,73 +1,28 @@
|
|||||||
using System;
|
using JetBrains.Annotations;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.ContentManagement;
|
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.ContentManagement.ViewModels;
|
|
||||||
using Orchard.Comments.Services;
|
|
||||||
|
|
||||||
namespace Orchard.Comments.Models {
|
namespace Orchard.Comments.Models {
|
||||||
|
[UsedImplicitly]
|
||||||
public class HasCommentsHandler : ContentHandler {
|
public class HasCommentsHandler : ContentHandler {
|
||||||
private readonly IRepository<Comment> _commentsRepository;
|
public HasCommentsHandler(
|
||||||
private readonly IRepository<ClosedComments> _closedCommentsRepository;
|
IRepository<Comment> commentsRepository,
|
||||||
private readonly ICommentService _commentService;
|
IRepository<HasCommentsRecord> hasCommentsRepository) {
|
||||||
|
|
||||||
public HasCommentsHandler(IRepository<Comment> commentsRepository, IRepository<ClosedComments> closedCommentsRepository, ICommentService commentService) {
|
|
||||||
_commentsRepository = commentsRepository;
|
|
||||||
_closedCommentsRepository = closedCommentsRepository;
|
|
||||||
_commentService = commentService;
|
|
||||||
Filters.Add(new ActivatingFilter<HasComments>("sandboxpage"));
|
Filters.Add(new ActivatingFilter<HasComments>("sandboxpage"));
|
||||||
Filters.Add(new ActivatingFilter<HasComments>("blogpost"));
|
Filters.Add(new ActivatingFilter<HasComments>("blogpost"));
|
||||||
|
Filters.Add(new StorageFilter<HasCommentsRecord>(hasCommentsRepository) { AutomaticallyCreateMissingRecord = true });
|
||||||
|
|
||||||
|
OnActivated<HasComments>((ctx, x) => {
|
||||||
|
x.CommentsActive = true;
|
||||||
|
x.CommentsShown = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
OnLoading<HasComments>((context, comments) => {
|
||||||
|
comments.Comments = commentsRepository.Fetch(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void BuildDisplayModel(BuildDisplayModelContext context) {
|
|
||||||
if (context.ContentItem.Has<HasComments>() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.Count", ZoneName="body", Position = "above" });
|
|
||||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments", Position = "999" });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
|
||||||
if (context.ContentItem.Has<HasComments>() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments" });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
|
||||||
if (context.ContentItem.Has<HasComments>() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CommentsViewModel viewModel = new CommentsViewModel();
|
|
||||||
context.Updater.TryUpdateModel(viewModel, String.Empty, null, null);
|
|
||||||
bool closed = viewModel.Closed == null ? false : true;
|
|
||||||
bool currentStatus = _commentService.CommentsClosedForCommentedContent(context.ContentItem.Id);
|
|
||||||
if (currentStatus != closed) {
|
|
||||||
if (closed) {
|
|
||||||
_commentService.CloseCommentsForCommentedContent(context.ContentItem.Id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_commentService.EnableCommentsForCommentedContent(context.ContentItem.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments" });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Loading(LoadContentContext context) {
|
|
||||||
if (context.ContentItem.Has<HasComments>() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HasComments comments = context.ContentItem.Get<HasComments>();
|
|
||||||
comments.Comments = _commentsRepository.Fetch(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved);
|
|
||||||
if (_closedCommentsRepository.Get(x => x.ContentItemId == context.ContentItem.Id) != null) {
|
|
||||||
comments.Closed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CommentsViewModel {
|
|
||||||
public String Closed { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,29 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Comments.Models {
|
namespace Orchard.Comments.Models {
|
||||||
public class HasComments : ContentPart {
|
public class HasComments : ContentPart<HasCommentsRecord> {
|
||||||
public HasComments() {
|
|
||||||
Comments = Enumerable.Empty<Comment>();
|
public int CommentCount { get { return Comments.Count(); } }
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Comment> Comments { get; set; }
|
public IEnumerable<Comment> Comments { get; set; }
|
||||||
public bool Closed { get; set; }
|
|
||||||
|
public bool CommentsShown {
|
||||||
|
get { return Record.CommentsShown; }
|
||||||
|
set { Record.CommentsShown = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CommentsActive {
|
||||||
|
get { return Record.CommentsActive; }
|
||||||
|
set { Record.CommentsActive = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HasCommentsRecord : ContentPartRecord {
|
||||||
|
public virtual bool CommentsShown { get; set; }
|
||||||
|
public virtual bool CommentsActive { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,6 +67,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
|
<Compile Include="Controllers\HasCommentsDriver.cs" />
|
||||||
<Compile Include="Models\Comment.cs" />
|
<Compile Include="Models\Comment.cs" />
|
||||||
<Compile Include="Models\CommentSettings.cs" />
|
<Compile Include="Models\CommentSettings.cs" />
|
||||||
<Compile Include="Models\CommentSettingsHandler.cs" />
|
<Compile Include="Models\CommentSettingsHandler.cs" />
|
||||||
@@ -82,6 +83,7 @@
|
|||||||
<Compile Include="ViewModels\CommentsDetailsViewModel.cs" />
|
<Compile Include="ViewModels\CommentsDetailsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\CommentsEditViewModel.cs" />
|
<Compile Include="ViewModels\CommentsEditViewModel.cs" />
|
||||||
<Compile Include="ViewModels\CommentsIndexViewModel.cs" />
|
<Compile Include="ViewModels\CommentsIndexViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\EditCommentsViewModel.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Package.txt" />
|
<Content Include="Package.txt" />
|
||||||
|
|||||||
@@ -29,19 +29,22 @@ namespace Orchard.Comments.Services {
|
|||||||
public class CommentService : ICommentService {
|
public class CommentService : ICommentService {
|
||||||
private readonly IRepository<Comment> _commentRepository;
|
private readonly IRepository<Comment> _commentRepository;
|
||||||
private readonly IRepository<ClosedComments> _closedCommentsRepository;
|
private readonly IRepository<ClosedComments> _closedCommentsRepository;
|
||||||
|
private readonly IRepository<HasCommentsRecord> _hasCommentsRepository;
|
||||||
private readonly ICommentValidator _commentValidator;
|
private readonly ICommentValidator _commentValidator;
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IAuthorizer _authorizer;
|
private readonly IAuthorizer _authorizer;
|
||||||
private readonly INotifier _notifier;
|
private readonly INotifier _notifier;
|
||||||
|
|
||||||
public CommentService(IRepository<Comment> commentRepository,
|
public CommentService(IRepository<Comment> commentRepository,
|
||||||
IRepository<ClosedComments> closedCommentsRepository,
|
IRepository<ClosedComments> closedCommentsRepository,
|
||||||
|
IRepository<HasCommentsRecord> hasCommentsRepository,
|
||||||
ICommentValidator commentValidator,
|
ICommentValidator commentValidator,
|
||||||
IContentManager contentManager,
|
IContentManager contentManager,
|
||||||
IAuthorizer authorizer,
|
IAuthorizer authorizer,
|
||||||
INotifier notifier) {
|
INotifier notifier) {
|
||||||
_commentRepository = commentRepository;
|
_commentRepository = commentRepository;
|
||||||
_closedCommentsRepository = closedCommentsRepository;
|
_closedCommentsRepository = closedCommentsRepository;
|
||||||
|
_hasCommentsRepository = hasCommentsRepository;
|
||||||
_commentValidator = commentValidator;
|
_commentValidator = commentValidator;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_authorizer = authorizer;
|
_authorizer = authorizer;
|
||||||
@@ -51,7 +54,7 @@ namespace Orchard.Comments.Services {
|
|||||||
|
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
|
||||||
|
|
||||||
#region Implementation of ICommentService
|
#region Implementation of ICommentService
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Orchard.Comments.ViewModels {
|
||||||
|
public class EditCommentsViewModel {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||||
<span class="commentcount"><a href="#comments"><%=Model.Comments.Count() %> Comment<%=Model.Comments.Count() == 1 ? "" : "s" %></a></span>
|
<span class="commentcount"><a href="#comments"><%=Model.CommentCount %> Comment<%=Model.CommentCount == 1 ? "" : "s" %></a></span>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||||
<h3 id="comments"><a name="comments"><%=Model.Comments.Count() %> Comment<%=Model.Comments.Count() == 1 ? "" : "s" %></a></h3><%
|
<h3 id="comments"><a name="comments"><%=Model.CommentCount %> Comment<%=Model.CommentCount == 1 ? "" : "s" %></a></h3><%
|
||||||
foreach (var comment in Model.Comments) { %>
|
foreach (var comment in Model.Comments) { %>
|
||||||
<div>
|
<div>
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div><%
|
</div><%
|
||||||
}
|
}
|
||||||
if (Model.Closed) { %>
|
if (Model.CommentsActive == false) { %>
|
||||||
<p>Comments have been disabled for this content.</p><%
|
<p>Comments have been disabled for this content.</p><%
|
||||||
} else { %>
|
} else { %>
|
||||||
<% using(Html.BeginForm("Create", "Admin", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comments" })) { %>
|
<% using(Html.BeginForm("Create", "Admin", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comments" })) { %>
|
||||||
@@ -35,4 +35,6 @@ if (Model.Closed) { %>
|
|||||||
<%=Html.AntiForgeryTokenOrchard() %>
|
<%=Html.AntiForgeryTokenOrchard() %>
|
||||||
</fieldset><%
|
</fieldset><%
|
||||||
}
|
}
|
||||||
} %>
|
} %>
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +1,21 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
<%@ Import Namespace="Orchard.Comments.Models" %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Comments<% if (Model.ContentItem.Id != 0) { %>: <% var commentCount = Model.Comments.Count(); %>
|
<legend>Comments<% if (Model.ContentItem.Id != 0) { %>:
|
||||||
<%=Html.ActionLink(
|
<%
|
||||||
|
var commentCount = Model.CommentCount; %>
|
||||||
|
<%=Html.ActionLink(
|
||||||
string.Format("{0} comment{1}", commentCount, commentCount == 1 ? "" : "s"),
|
string.Format("{0} comment{1}", commentCount, commentCount == 1 ? "" : "s"),
|
||||||
"Details",
|
"Details",
|
||||||
new { Area = "Orchard.Comments", Controller = "Admin", id = Model.ContentItem.Id, returnUrl = Context.Request.Url }
|
new { Area = "Orchard.Comments", Controller = "Admin", id = Model.ContentItem.Id, returnUrl = Context.Request.Url }
|
||||||
) %>
|
) %>
|
||||||
- <a href="#">0 pending</a><% } %></legend>
|
- <a href="#">0 pending</a><% } %></legend>
|
||||||
<label for="Closed">
|
<label for="CommentsShown">
|
||||||
<% if (Model.Closed) {%>
|
<%=Html.EditorFor(x=>x.CommentsShown) %>
|
||||||
<input id="Closed" name="Closed" type="checkbox" checked="checked" />
|
<%= T("Comments are shown. Existing comments are displayed.")%>
|
||||||
<% } else { %>
|
</label>
|
||||||
<input id="Closed" name="Closed" type="checkbox" />
|
<label for="CommentsActive">
|
||||||
<% } %>
|
<%=Html.EditorFor(x=>x.CommentsActive) %>
|
||||||
Comments are disabled
|
<%= T("Comments active. Users may add comments.")%>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Orchard.DevTools.Controllers {
|
|||||||
.Select(x => x.GetType())
|
.Select(x => x.GetType())
|
||||||
.SelectMany(x => AllTypes(x))
|
.SelectMany(x => AllTypes(x))
|
||||||
.Distinct();
|
.Distinct();
|
||||||
model.DisplayModel = _contentManager.BuildDisplayModel(model.Item, null);
|
model.DisplayModel = _contentManager.BuildDisplayModel(model.Item, "Detail");
|
||||||
model.EditorModel = _contentManager.BuildEditorModel(model.Item);
|
model.EditorModel = _contentManager.BuildEditorModel(model.Item);
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AdminViewModel>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AdminViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%><%
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
|
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||||
|
<%
|
||||||
Html.RegisterStyle("site.css"); %>
|
Html.RegisterStyle("site.css"); %>
|
||||||
<div id="header" role="banner">
|
<div id="header" role="banner">
|
||||||
<h1><%=Html.ActionLink("Project Orchard", "Index", new { Area = "", Controller = "Home" })%></h1>
|
<h1><%=Html.ActionLink("Project Orchard", "Index", new { Area = "", Controller = "Home" })%></h1>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Drivers {
|
namespace Orchard.ContentManagement.Drivers {
|
||||||
public class CombinedResult : DriverResult {
|
public class CombinedResult : DriverResult {
|
||||||
private readonly DriverResult[] _results;
|
private readonly IEnumerable<DriverResult> _results;
|
||||||
|
|
||||||
public CombinedResult(DriverResult[] results) {
|
public CombinedResult(IEnumerable<DriverResult> results) {
|
||||||
_results = results;
|
_results = results.Where(x => x != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(BuildDisplayModelContext context) {
|
public override void Apply(BuildDisplayModelContext context) {
|
||||||
@@ -15,9 +17,9 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(BuildEditorModelContext context) {
|
public override void Apply(BuildEditorModelContext context) {
|
||||||
foreach(var result in _results) {
|
foreach (var result in _results) {
|
||||||
result.Apply(context);
|
result.Apply(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ namespace Orchard.ContentManagement.Handlers {
|
|||||||
instance.Record = record;
|
instance.Record = record;
|
||||||
}
|
}
|
||||||
else if (AutomaticallyCreateMissingRecord) {
|
else if (AutomaticallyCreateMissingRecord) {
|
||||||
instance.Record = new TRecord {ContentItemRecord = context.ContentItemRecord};
|
instance.Record.ContentItemRecord = context.ContentItemRecord;
|
||||||
_repository.Create(instance.Record);
|
_repository.Create(instance.Record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Orchard.Mvc.Html {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
return html.ActionLink(
|
return html.ActionLink(
|
||||||
linkText ?? metadata.DisplayText,
|
linkText ?? metadata.DisplayText ?? "view",
|
||||||
Convert.ToString(metadata.DisplayRouteValues["action"]),
|
Convert.ToString(metadata.DisplayRouteValues["action"]),
|
||||||
metadata.DisplayRouteValues);
|
metadata.DisplayRouteValues);
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ namespace Orchard.Mvc.Html {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
return html.ActionLink(
|
return html.ActionLink(
|
||||||
linkText ?? metadata.DisplayText,
|
linkText ?? metadata.DisplayText ?? "edit",
|
||||||
Convert.ToString(metadata.EditorRouteValues["action"]),
|
Convert.ToString(metadata.EditorRouteValues["action"]),
|
||||||
metadata.EditorRouteValues);
|
metadata.EditorRouteValues);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,14 @@ namespace Orchard.Mvc.ViewEngines {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//TEMP: to be replaced with an efficient spooling writer
|
//TEMP: to be replaced with an efficient spooling writer
|
||||||
var childWriter = new StringWriter();
|
var childContext = new ViewContext(
|
||||||
viewEngineResult.View.Render(viewContext, childWriter);
|
viewContext,
|
||||||
layoutViewContext.BodyContent = childWriter.ToString();
|
viewEngineResult.View,
|
||||||
|
viewContext.ViewData,
|
||||||
|
viewContext.TempData,
|
||||||
|
new StringWriter());
|
||||||
|
viewEngineResult.View.Render(childContext, childContext.Writer);
|
||||||
|
layoutViewContext.BodyContent = childContext.Writer.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,12 +119,12 @@ namespace Orchard.Mvc.ViewEngines {
|
|||||||
|
|
||||||
|
|
||||||
private static void Monitor(ViewEngineResult result, string viewName) {
|
private static void Monitor(ViewEngineResult result, string viewName) {
|
||||||
if (result.View == null) {
|
//if (result.View == null) {
|
||||||
Trace.WriteLine("Unable to find " + viewName);
|
// Trace.WriteLine("Unable to find " + viewName);
|
||||||
foreach (var search in result.SearchedLocations) {
|
// foreach (var search in result.SearchedLocations) {
|
||||||
Trace.WriteLine(" location " + search);
|
// Trace.WriteLine(" location " + search);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReleaseView(ControllerContext controllerContext, IView view) {
|
public void ReleaseView(ControllerContext controllerContext, IView view) {
|
||||||
|
|||||||
@@ -25,4 +25,28 @@ namespace Orchard.Mvc {
|
|||||||
return MvcHtmlString.Create(Html.Encode(T(textHint, formatTokens)));
|
return MvcHtmlString.Create(Html.Encode(T(textHint, formatTokens)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ViewUserControl<TModel> : System.Web.Mvc.ViewUserControl<TModel> {
|
||||||
|
public ViewUserControl() {
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RenderView(ViewContext viewContext) {
|
||||||
|
T = LocalizationUtilities.Resolve(viewContext, AppRelativeVirtualPath);
|
||||||
|
base.RenderView(viewContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
|
public MvcHtmlString H(string value) {
|
||||||
|
return MvcHtmlString.Create(Html.Encode(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MvcHtmlString _Encoded(string textHint) {
|
||||||
|
return MvcHtmlString.Create(Html.Encode(T(textHint)));
|
||||||
|
}
|
||||||
|
public MvcHtmlString _Encoded(string textHint, params string[] formatTokens) {
|
||||||
|
return MvcHtmlString.Create(Html.Encode(T(textHint, formatTokens)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ namespace Orchard.UI.Notify {
|
|||||||
foreach (var entry in _notifier.List()) {
|
foreach (var entry in _notifier.List()) {
|
||||||
sb.Append(Convert.ToString(entry.Type))
|
sb.Append(Convert.ToString(entry.Type))
|
||||||
.Append(':')
|
.Append(':')
|
||||||
.AppendLine(entry.Message.ToString());
|
.AppendLine(entry.Message.ToString())
|
||||||
|
.AppendLine("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign values into temp data
|
// assign values into temp data
|
||||||
@@ -62,7 +63,7 @@ namespace Orchard.UI.Notify {
|
|||||||
return;// nothing to do, really
|
return;// nothing to do, really
|
||||||
|
|
||||||
var messageEntries = new List<NotifyEntry>();
|
var messageEntries = new List<NotifyEntry>();
|
||||||
foreach (var line in messages.Split(new[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) {
|
foreach (var line in messages.Split(new[] { System.Environment.NewLine + "-" + System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) {
|
||||||
var delimiterIndex = line.IndexOf(':');
|
var delimiterIndex = line.IndexOf(':');
|
||||||
if (delimiterIndex != -1) {
|
if (delimiterIndex != -1) {
|
||||||
var type = (NotifyType)Enum.Parse(typeof(NotifyType), line.Substring(0, delimiterIndex));
|
var type = (NotifyType)Enum.Parse(typeof(NotifyType), line.Substring(0, delimiterIndex));
|
||||||
|
|||||||
Reference in New Issue
Block a user