mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding Publish/Unpublish buttons to Media Actions view.
The Publish/Unpublish buttons appear only when the content type of the media item is set to Draftable.
This commit is contained in:
@@ -1,20 +1,34 @@
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.Core.Contents;
|
||||
@using Orchard.Core.Contents.Settings
|
||||
@{
|
||||
ContentItem contentItem = Model.ContentItem;
|
||||
var draftable = contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable;
|
||||
}
|
||||
|
||||
@if (Authorizer.Authorize(Permissions.EditContent, contentItem)) {
|
||||
@Html.Link(T("Edit").Text, Url.ItemEditUrl(contentItem), new {@class = "button", id="edit-media-link"})
|
||||
}
|
||||
<div id="media-actions">
|
||||
@if (Authorizer.Authorize(Permissions.EditContent, contentItem)) {
|
||||
@Html.Link(T("Edit").Text, Url.ItemEditUrl(contentItem), new { @class = "button", id = "edit-media-link" })
|
||||
}
|
||||
@if (Authorizer.Authorize(Permissions.PublishContent, contentItem) && draftable) {
|
||||
if (contentItem.HasPublished()) {
|
||||
@Html.AntiForgeryTokenValueOrchardLink(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new { Area = "Contents", contentItem.Id }), new { @class = "button", itemprop = "UnsafeUrl" })
|
||||
}
|
||||
else {
|
||||
@Html.AntiForgeryTokenValueOrchardLink(T("Publish").Text, Url.Action("Publish", "Admin", new { Area = "Contents", contentItem.Id }), new { @class = "button", itemprop = "UnsafeUrl" })
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
// update the returnUrl from javascript to get the main window's location
|
||||
$('#edit-media-link').each(function() {
|
||||
$('#media-actions .button').each(function () {
|
||||
var self = $(this);
|
||||
var returnUrl = self.attr('href') + '?returnUrl=' + encodeURIComponent(window.location);
|
||||
var href = self.attr('href');
|
||||
var containsQueryString = href.indexOf("?") >= 0;
|
||||
var returnUrl = href + (containsQueryString ? "&" : "?") + "returnUrl=" + encodeURIComponent(window.location);
|
||||
self.attr('href', returnUrl);
|
||||
});
|
||||
//]]>
|
||||
//]]>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user