diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs
index ca95f3cad1c..e47038cde80 100644
--- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs
+++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs
@@ -352,6 +352,32 @@ public ActionResult EditAndPublishPOST(int id, string returnUrl) {
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem));
}
+ ///
+ /// This action is specific to the submit button of the edit form.
+ /// Unpublish logic is the same of the Unpublish action, which is called by the content list.
+ ///
+ ///
+ ///
+ ///
+ [HttpPost, ActionName("Edit")]
+ [Mvc.FormValueRequired("submit.Unpublish")]
+ public ActionResult EditUnpublishPOST(int id, string returnUrl) {
+ return Unpublish(id, returnUrl);
+ }
+
+ ///
+ /// This action is specific to the submit button of the edit form.
+ /// Delete logic is the same of the Remove action, which is called by the content list.
+ ///
+ ///
+ ///
+ ///
+ [HttpPost, ActionName("Edit")]
+ [Mvc.FormValueRequired("submit.Delete")]
+ public ActionResult EditDeletePOST(int id, string returnUrl) {
+ return Remove(id, returnUrl);
+ }
+
private ActionResult EditPOST(int id, string returnUrl, Action conditionallyPublish) {
var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);
diff --git a/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs b/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs
index cb49524f646..c722caf8e2e 100644
--- a/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs
+++ b/src/Orchard.Web/Core/Contents/Drivers/ContentsDriver.cs
@@ -21,8 +21,16 @@ protected override DriverResult Display(ContentPart part, string displayType, dy
protected override DriverResult Editor(ContentPart part, dynamic shapeHelper) {
var results = new List { ContentShape("Content_SaveButton", saveButton => saveButton) };
- if (part.TypeDefinition.Settings.GetModel().Draftable)
+ if (part.TypeDefinition.Settings.GetModel().Draftable) {
results.Add(ContentShape("Content_PublishButton", publishButton => publishButton));
+ if (part.ContentItem.IsPublished()) {
+ results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton));
+ }
+ }
+
+ if (part.Id > 0) {
+ results.Add(ContentShape("Content_DeleteButton", deleteButton => deleteButton));
+ }
return Combined(results.ToArray());
}
diff --git a/src/Orchard.Web/Core/Contents/Placement.info b/src/Orchard.Web/Core/Contents/Placement.info
index cab2f6d7a77..4c409c86001 100644
--- a/src/Orchard.Web/Core/Contents/Placement.info
+++ b/src/Orchard.Web/Core/Contents/Placement.info
@@ -6,8 +6,10 @@
Parts_Contents_Publish_SummaryAdmin
-->
+
+
diff --git a/src/Orchard.Web/Core/Contents/Views/Content.DeleteButton.cshtml b/src/Orchard.Web/Core/Contents/Views/Content.DeleteButton.cshtml
new file mode 100644
index 00000000000..106a5d37b1c
--- /dev/null
+++ b/src/Orchard.Web/Core/Contents/Views/Content.DeleteButton.cshtml
@@ -0,0 +1,9 @@
+@using Orchard.ContentManagement;
+@using Orchard.Core.Contents;
+@using Orchard.Utility.Extensions
+
+@if (Authorizer.Authorize(Permissions.DeleteContent, (IContent)Model.ContentItem)) {
+
+}
diff --git a/src/Orchard.Web/Core/Contents/Views/Content.UnpublishButton.cshtml b/src/Orchard.Web/Core/Contents/Views/Content.UnpublishButton.cshtml
new file mode 100644
index 00000000000..c9d3e09455a
--- /dev/null
+++ b/src/Orchard.Web/Core/Contents/Views/Content.UnpublishButton.cshtml
@@ -0,0 +1,11 @@
+@using Orchard.ContentManagement;
+@using Orchard.Core.Contents;
+@using Orchard.Utility.Extensions;
+@{
+ var contentItem = Model.ContentItem as IContent;
+}
+@if (Authorizer.Authorize(Permissions.PublishContent, contentItem) && contentItem.IsPublished()) {
+
+}
diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj
index 67072601b4f..77d33482c25 100644
--- a/src/Orchard.Web/Core/Orchard.Core.csproj
+++ b/src/Orchard.Web/Core/Orchard.Core.csproj
@@ -610,6 +610,8 @@
+
+
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
index 0155c4ea858..742c2644084 100644
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
@@ -138,6 +138,12 @@ public ActionResult EditPOST(int blogId, int postId, string returnUrl) {
});
}
+ [HttpPost, ActionName("Edit")]
+ [Mvc.FormValueRequired("submit.Delete")]
+ public ActionResult EditDeletePOST(int blogId, int postId, string returnUrl) {
+ return Delete(blogId, postId);
+ }
+
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Publish")]
public ActionResult EditAndPublishPOST(int blogId, int postId, string returnUrl) {
@@ -156,6 +162,12 @@ public ActionResult EditAndPublishPOST(int blogId, int postId, string returnUrl)
return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
}
+ [HttpPost, ActionName("Edit")]
+ [Mvc.FormValueRequired("submit.Unpublish")]
+ public ActionResult EditUnpublishPOST(int blogId, int postId, string returnUrl) {
+ return Unpublish(blogId, postId);
+ }
+
public ActionResult EditPOST(int blogId, int postId, string returnUrl, Action conditionallyPublish) {
var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null)
diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Styles/admin-dialog.css b/src/Orchard.Web/Modules/Orchard.Layouts/Styles/admin-dialog.css
index a622ef3b09d..7d7cea519d8 100644
--- a/src/Orchard.Web/Modules/Orchard.Layouts/Styles/admin-dialog.css
+++ b/src/Orchard.Web/Modules/Orchard.Layouts/Styles/admin-dialog.css
@@ -1101,17 +1101,17 @@ html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; }
padding:0;
}
-fieldset.publish-button, fieldset.delete-button, fieldset.save-button {
+fieldset.publish-button, fieldset.delete-button, fieldset.save-button, fieldset.unpublish-button {
clear:none;
float:left;
}
fieldset.save-button {
clear:left;
}
-fieldset.publish-button {
+fieldset.publish-button, fieldset.unpublish-button {
margin: 0 12px 0 0;
padding: 0 12px;
- border-right:1px solid #ccc;
+ border-right: 1px solid #ccc;
}
fieldset.delete-button {
margin: 0 0 0 12px;
diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs
index 7c686031e89..cbdedcf7d6d 100644
--- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs
+++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs
@@ -33,10 +33,6 @@ protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper)
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.LayerPart", Model: layerPart, Prefix: Prefix))
};
- if (layerPart.Id > 0)
- results.Add(ContentShape("Widget_DeleteButton",
- deleteButton => deleteButton));
-
return Combined(results.ToArray());
}
diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs
index 7d474bb1617..c20af20b8af 100644
--- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs
+++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
+using Orchard.Core.Contents.Settings;
using Orchard.Localization;
using Orchard.Utility.Extensions;
using Orchard.Widgets.Models;
@@ -35,9 +36,10 @@ protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelpe
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix))
};
- if (widgetPart.Id > 0)
- results.Add(ContentShape("Widget_DeleteButton",
- deleteButton => deleteButton));
+ if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel().Draftable) {
+ results.Add(ContentShape("Content_UnpublishButton",
+ unpublishButton => unpublishButton));
+ }
return Combined(results.ToArray());
}
@@ -45,16 +47,16 @@ protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelpe
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(widgetPart, Prefix, null, null);
- if(string.IsNullOrWhiteSpace(widgetPart.Title)) {
+ if (string.IsNullOrWhiteSpace(widgetPart.Title)) {
updater.AddModelError("Title", T("Title can't be empty."));
}
-
+
// if there is a name, ensure it's unique
- if(!string.IsNullOrWhiteSpace(widgetPart.Name)) {
+ if (!string.IsNullOrWhiteSpace(widgetPart.Name)) {
widgetPart.Name = widgetPart.Name.ToHtmlName();
var widgets = _contentManager.Query().Where(x => x.Name == widgetPart.Name && x.Id != widgetPart.Id).Count();
- if(widgets > 0) {
+ if (widgets > 0) {
updater.AddModelError("Name", T("A Widget with the same Name already exists."));
}
}
diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj
index bbf0c15d046..508576b18c7 100644
--- a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj
@@ -207,9 +207,6 @@
-
-
-
diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info b/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info
index 344e199fa21..69b4ef7aafb 100644
--- a/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info
+++ b/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info
@@ -1,5 +1,4 @@
-
diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Widget.DeleteButton.cshtml b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Widget.DeleteButton.cshtml
deleted file mode 100644
index 0a28fdec52c..00000000000
--- a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Widget.DeleteButton.cshtml
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css
index 23f7758901b..15fe5789939 100644
--- a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css
+++ b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css
@@ -1130,14 +1130,14 @@ html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; }
padding:0;
}
-fieldset.publish-button, fieldset.delete-button, fieldset.save-button {
+fieldset.publish-button, fieldset.delete-button, fieldset.save-button, fieldset.unpublish-button {
clear:none;
float:left;
}
fieldset.save-button {
clear:left;
}
-fieldset.publish-button {
+fieldset.publish-button, fieldset.unpublish-button {
margin: 0 12px 0 0;
padding: 0 12px;
border-right:1px solid #ccc;
@@ -1495,13 +1495,13 @@ html.dir-rtl {
margin-left:inherit;
margin-right:10px;
}
-.dir-rtl fieldset.publish-button, fieldset.delete-button, .dir-rtl fieldset.save-button {
+.dir-rtl fieldset.publish-button, fieldset.delete-button, .dir-rtl fieldset.save-button, .dir-rtl fieldset.unpublish-button {
float:right;
}
.dir-rtl fieldset.save-button {
clear:right;
}
-.dir-rtl fieldset.publish-button {
+.dir-rtl fieldset.publish-button, .dir-rtl fieldset.unpublish-button {
margin: 0 0 0 12px ;
}
.dir-rtl fieldset.delete-button {