mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding some content create/edit/remove/etc. action notifications to fill the void of notifications being removed from the PublishLater part.
--HG-- branch : dev
This commit is contained in:
@@ -21,19 +21,16 @@ using Orchard.UI.Notify;
|
||||
namespace Orchard.Core.Contents.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class AdminController : Controller, IUpdateModel {
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
|
||||
public AdminController(
|
||||
IOrchardServices orchardServices,
|
||||
INotifier notifier,
|
||||
IContentManager contentManager,
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
ITransactionManager transactionManager) {
|
||||
Services = orchardServices;
|
||||
_notifier = notifier;
|
||||
_contentManager = contentManager;
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_transactionManager = transactionManager;
|
||||
@@ -251,11 +248,10 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return View("Create", model);
|
||||
}
|
||||
|
||||
if (!contentItem.Has<IPublishingControlAspect>()) {
|
||||
if (!contentItem.Has<IPublishingControlAspect>())
|
||||
_contentManager.Publish(contentItem);
|
||||
_notifier.Information(T("Created content item"));
|
||||
}
|
||||
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(model.Content.Item.TypeDefinition.DisplayName) ? T("Your content has been created.") : T("Your {0} has been created.", model.Content.Item.TypeDefinition.DisplayName));
|
||||
return RedirectToAction("Edit", new RouteValueDictionary { { "Id", contentItem.Id } });
|
||||
}
|
||||
|
||||
@@ -299,6 +295,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
if (!contentItem.Has<IPublishingControlAspect>())
|
||||
_contentManager.Publish(contentItem);
|
||||
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(model.Content.Item.TypeDefinition.DisplayName) ? T("Your content has been saved.") : T("Your {0} has been saved.", model.Content.Item.TypeDefinition.DisplayName));
|
||||
return RedirectToAction("Edit", new RouteValueDictionary { { "Id", contentItem.Id } });
|
||||
}
|
||||
|
||||
@@ -309,8 +306,10 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.DeleteOthersContent, contentItem, T("Couldn't remove content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (contentItem != null)
|
||||
if (contentItem != null) {
|
||||
_contentManager.Remove(contentItem);
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName) ? T("That content has been removed.") : T("That {0} has been removed.", contentItem.TypeDefinition.DisplayName));
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(returnUrl))
|
||||
return Redirect(returnUrl);
|
||||
@@ -329,7 +328,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
|
||||
_contentManager.Publish(contentItem);
|
||||
Services.ContentManager.Flush();
|
||||
Services.Notifier.Information(T("{0} successfully published.", contentItem.TypeDefinition.DisplayName));
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName) ? T("That content has been published.") : T("That {0} has been published.", contentItem.TypeDefinition.DisplayName));
|
||||
|
||||
if (!String.IsNullOrEmpty(returnUrl))
|
||||
return Redirect(returnUrl);
|
||||
@@ -348,7 +347,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
|
||||
_contentManager.Unpublish(contentItem);
|
||||
Services.ContentManager.Flush();
|
||||
Services.Notifier.Information(T("{0} successfully unpublished.", contentItem.TypeDefinition.DisplayName));
|
||||
Services.Notifier.Information(string.IsNullOrWhiteSpace(contentItem.TypeDefinition.DisplayName) ? T("That content has been unpublished.") : T("That {0} has been unpublished.", contentItem.TypeDefinition.DisplayName));
|
||||
|
||||
if (!String.IsNullOrEmpty(returnUrl))
|
||||
return Redirect(returnUrl);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CreateItemViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<h1><%:Html.TitleForPage((string.IsNullOrEmpty(Model.Content.Item.TypeDefinition.DisplayName) ? T("Create Content") : T("Create {0}", Model.Content.Item.TypeDefinition.DisplayName)).ToString()) %></h1>
|
||||
<h1><%:Html.TitleForPage((string.IsNullOrWhiteSpace(Model.Content.Item.TypeDefinition.DisplayName) ? T("Create Content") : T("Create {0}", Model.Content.Item.TypeDefinition.DisplayName)).ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%:Html.ValidationSummary() %>
|
||||
<%:Html.EditorForItem(m=>m.Content) %>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditItemViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<h1><%:Html.TitleForPage((string.IsNullOrEmpty(Model.Content.Item.TypeDefinition.DisplayName) ? T("Edit Content") : T("Edit {0}", Model.Content.Item.TypeDefinition.DisplayName)).ToString()) %></h1>
|
||||
<h1><%:Html.TitleForPage((string.IsNullOrWhiteSpace(Model.Content.Item.TypeDefinition.DisplayName) ? T("Edit Content") : T("Edit {0}", Model.Content.Item.TypeDefinition.DisplayName)).ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%:Html.ValidationSummary() %>
|
||||
<%:Html.EditorForItem(m=>m.Content) %>
|
||||
|
@@ -61,6 +61,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return View(model);
|
||||
}
|
||||
|
||||
Services.Notifier.Information(T("Your {0} has been created.", blogPost.TypeDefinition.DisplayName));
|
||||
return Redirect(Url.BlogPostEdit(model.BlogPost.Item));
|
||||
}
|
||||
|
||||
@@ -93,13 +94,13 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
// Get draft (create a new version if needed)
|
||||
var post = _blogPostService.Get(postId, VersionOptions.DraftRequired);
|
||||
if (post == null)
|
||||
var blogPost = _blogPostService.Get(postId, VersionOptions.DraftRequired);
|
||||
if (blogPost == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
// Validate form input
|
||||
var model = new BlogPostEditViewModel {
|
||||
BlogPost = Services.ContentManager.UpdateEditorModel(post, this)
|
||||
BlogPost = Services.ContentManager.UpdateEditorModel(blogPost, this)
|
||||
};
|
||||
|
||||
TryUpdateModel(model);
|
||||
@@ -109,6 +110,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return View(model);
|
||||
}
|
||||
|
||||
Services.Notifier.Information(T("Your {0} has been saved.", blogPost.TypeDefinition.DisplayName));
|
||||
return Redirect(Url.BlogPostEdit(model.BlogPost.Item));
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CreateBlogViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<h1><%: Html.TitleForPage(T("Create Blog").ToString()) %></h1>
|
||||
<h1><%: Html.TitleForPage(T("Create New Blog").ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%: Html.ValidationSummary() %>
|
||||
<%: Html.EditorForItem(vm => vm.Blog) %><%
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CreateBlogPostViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<h1><%: Html.TitleForPage(T("Add Post").ToString()) %></h1>
|
||||
<h1><%: Html.TitleForPage(T("Create New Blog Post").ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%: Html.ValidationSummary() %>
|
||||
<%: Html.EditorForItem(m => m.BlogPost) %><%
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPostEditViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<h1><%: Html.TitleForPage(T("Edit Post").ToString()) %></h1>
|
||||
<h1><%: Html.TitleForPage(T("Edit Blog Post").ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%: Html.ValidationSummary() %>
|
||||
<%: Html.EditorForItem(m => m.BlogPost) %><%
|
||||
|
Reference in New Issue
Block a user