mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 19:44:02 +08:00
Changed page management to match functionality with blog post management
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.Blogs.Models;
|
using Orchard.Blogs.Models;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.Mvc.Html;
|
using Orchard.Mvc.Html;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Extensions {
|
namespace Orchard.Blogs.Extensions {
|
||||||
@@ -9,7 +11,7 @@ namespace Orchard.Blogs.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string PublishedState(this HtmlHelper htmlHelper, BlogPost blogPost) {
|
public static string PublishedState(this HtmlHelper htmlHelper, BlogPost blogPost) {
|
||||||
return htmlHelper.DateTime(blogPost.PublishedUtc, "Draft");
|
return htmlHelper.DateTime(blogPost.As<ICommonAspect>().VersionPublishedUtc, "Draft");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string PublishedWhen(this HtmlHelper<BlogPost> htmlHelper) {
|
public static string PublishedWhen(this HtmlHelper<BlogPost> htmlHelper) {
|
||||||
@@ -17,7 +19,7 @@ namespace Orchard.Blogs.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string PublishedWhen(this HtmlHelper htmlHelper, BlogPost blogPost) {
|
public static string PublishedWhen(this HtmlHelper htmlHelper, BlogPost blogPost) {
|
||||||
return htmlHelper.DateTimeRelative(blogPost.PublishedUtc, "as a Draft");
|
return htmlHelper.DateTimeRelative(blogPost.As<ICommonAspect>().VersionPublishedUtc, "as a Draft");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,6 @@ namespace Orchard.Blogs.Models {
|
|||||||
get { return this.As<ICommonAspect>().CreatedUtc; }
|
get { return this.As<ICommonAspect>().CreatedUtc; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? PublishedUtc {
|
|
||||||
get { return this.As<ICommonAspect>().VersionPublishedUtc; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime? ScheduledPublishUtc { get; set; }
|
public DateTime? ScheduledPublishUtc { get; set; }
|
||||||
|
|
||||||
private string _scheduledPublishUtcDate;
|
private string _scheduledPublishUtcDate;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
||||||
|
<%@ Import Namespace="Orchard.ContentManagement.Aspects"%>
|
||||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
@@ -30,20 +31,20 @@
|
|||||||
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||||
}
|
}
|
||||||
else if (Model.Item.IsPublished) { %>
|
else if (Model.Item.IsPublished) { %>
|
||||||
<%=_Encoded("Published: ") + Html.PublishedWhen(Model.Item) %><%
|
<%=_Encoded("Published: ") + Html.DateTimeRelative(Model.Item.As<ICommonAspect>().VersionPublishedUtc.Value)%><%
|
||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%=_Encoded("Last modified: ") + Html.DateTimeRelative(Model.Item.As<CommonAspect>().ModifiedUtc.Value) %><%
|
<%=_Encoded("Last modified: ") + Html.DateTimeRelative(Model.Item.As<ICommonAspect>().ModifiedUtc.Value) %><%
|
||||||
} %> |
|
} %> |
|
||||||
</li>
|
</li>
|
||||||
<li><%=_Encoded("By {0}", Model.Item.Creator == null ? String.Empty : Model.Item.Creator.UserName)%></li>
|
<li><%=_Encoded("By {0}", Model.Item.Creator.UserName)%></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="related"><%
|
<div class="related"><%
|
||||||
if (Model.Item.HasPublished){ %>
|
if (Model.Item.HasPublished){ %>
|
||||||
<a href="<%=Url.BlogPost(Model.Item) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%><%
|
<a href="<%=Url.BlogPost(Model.Item) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%><%
|
||||||
if (Model.Item.HasDraft) { %>
|
if (Model.Item.HasDraft) { %>
|
||||||
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostPublish(Model.Item)) %>" title="<%=_Encoded("Publish Draft")%>"><%=_Encoded("Publish Draft")%></a><%=_Encoded(" | ")%><%
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostPublish(Model.Item)) %>" title="<%=_Encoded("Publish Draft")%>"><%=_Encoded("Publish Draft")%></a><%=_Encoded(" | ")%><%
|
||||||
} %>
|
} %>
|
||||||
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostUnpublish(Model.Item)) %>" title="<%=_Encoded("Unpublish Post")%>"><%=_Encoded("Unpublish")%></a><%=_Encoded(" | ")%><%
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostUnpublish(Model.Item)) %>" title="<%=_Encoded("Unpublish Post")%>"><%=_Encoded("Unpublish")%></a><%=_Encoded(" | ")%><%
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,7 @@
|
|||||||
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostPublish(Model.Item)) %>" title="<%=_Encoded("Publish Post")%>"><%=_Encoded("Publish")%></a><%=_Encoded(" | ")%><%
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostPublish(Model.Item)) %>" title="<%=_Encoded("Publish Post")%>"><%=_Encoded("Publish")%></a><%=_Encoded(" | ")%><%
|
||||||
} %>
|
} %>
|
||||||
<a href="<%=Url.BlogPostEdit(Model.Item) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%>
|
<a href="<%=Url.BlogPostEdit(Model.Item) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%>
|
||||||
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostDelete(Model.Item)) %>" title="<%=_Encoded("Delete")%>"><%=_Encoded("Delete")%></a>
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.BlogPostDelete(Model.Item)) %>" title="<%=_Encoded("Delete Post")%>"><%=_Encoded("Delete")%></a>
|
||||||
<br /><%Html.Zone("meta");%>
|
<br /><%Html.Zone("meta");%>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Web.Mvc;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.Mvc.AntiForgery;
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.Pages.Models;
|
using Orchard.Pages.Models;
|
||||||
using Orchard.Pages.Services;
|
using Orchard.Pages.Services;
|
||||||
@@ -210,7 +211,6 @@ namespace Orchard.Pages.Controllers {
|
|||||||
return RedirectToAction("Edit", "Admin", new { id = model.Page.Item.ContentItem.Id });
|
return RedirectToAction("Edit", "Admin", new { id = model.Page.Item.ContentItem.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ActionResult DiscardDraft(int id) {
|
public ActionResult DiscardDraft(int id) {
|
||||||
// get the current draft version
|
// get the current draft version
|
||||||
var draft = Services.ContentManager.Get(id, VersionOptions.Draft);
|
var draft = Services.ContentManager.Get(id, VersionOptions.Draft);
|
||||||
@@ -239,9 +239,41 @@ namespace Orchard.Pages.Controllers {
|
|||||||
return RedirectToAction("Edit", new { draft.Id });
|
return RedirectToAction("Edit", new { draft.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[ValidateAntiForgeryTokenOrchard]
|
||||||
|
public ActionResult Publish(int id) {
|
||||||
|
if (!Services.Authorizer.Authorize(Permissions.PublishPages, T("Couldn't publish page")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
var page = _pageService.GetLatest(id);
|
||||||
|
if (page == null)
|
||||||
|
return new NotFoundResult();
|
||||||
|
|
||||||
|
_pageService.Publish(page);
|
||||||
|
Services.ContentManager.Flush();
|
||||||
|
Services.Notifier.Information(T("Page successfully published."));
|
||||||
|
|
||||||
|
return RedirectToAction("List");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ValidateAntiForgeryTokenOrchard]
|
||||||
|
public ActionResult Unpublish(int id) {
|
||||||
|
if (!Services.Authorizer.Authorize(Permissions.PublishPages, T("Couldn't unpublish page")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
var page = _pageService.GetLatest(id);
|
||||||
|
if (page == null)
|
||||||
|
return new NotFoundResult();
|
||||||
|
|
||||||
|
_pageService.Unpublish(page);
|
||||||
|
Services.ContentManager.Flush();
|
||||||
|
Services.Notifier.Information(T("Page successfully unpublished."));
|
||||||
|
|
||||||
|
return RedirectToAction("List");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ValidateAntiForgeryTokenOrchard]
|
||||||
public ActionResult Delete(int id) {
|
public ActionResult Delete(int id) {
|
||||||
Page page = _pageService.Get(id);
|
var page = _pageService.GetLatest(id);
|
||||||
if (page == null)
|
if (page == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
@@ -249,7 +281,7 @@ namespace Orchard.Pages.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
_pageService.Delete(page);
|
_pageService.Delete(page);
|
||||||
Services.Notifier.Information(T("Page was successfully deleted"));
|
Services.Notifier.Information(T("Page successfully deleted"));
|
||||||
|
|
||||||
return RedirectToAction("List");
|
return RedirectToAction("List");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<PagesViewModel>" %>
|
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<PagesViewModel>" %>
|
||||||
|
<%@ Import Namespace="Orchard.ContentManagement.Aspects"%>
|
||||||
|
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||||
|
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||||
<%@ Import Namespace="Orchard.Pages.ViewModels"%>
|
<%@ Import Namespace="Orchard.Pages.ViewModels"%>
|
||||||
<h1><%=Html.TitleForPage(T("Manage Pages").ToString())%></h1>
|
<h1><%=Html.TitleForPage(T("Manage Pages").ToString())%></h1>
|
||||||
@@ -53,24 +56,36 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
|||||||
}
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<%=_Encoded("No Draft")%> | <%
|
<%=_Encoded("No Draft")%> | <%
|
||||||
|
} %>
|
||||||
|
</li>
|
||||||
|
<li><%
|
||||||
|
if (pageEntry.Page.ScheduledPublishUtc.HasValue && pageEntry.Page.ScheduledPublishUtc.Value > DateTime.UtcNow) { %>
|
||||||
|
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/scheduled.gif") %>" alt="<%=_Encoded("Scheduled") %>" title="<%=_Encoded("The page is scheduled for publishing") %>" /><%=_Encoded("Scheduled")%>
|
||||||
|
<%=Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||||
}
|
}
|
||||||
// Scheduled
|
else if (pageEntry.Page.IsPublished) { %>
|
||||||
if (!pageEntry.Page.IsPublished) {
|
<%=_Encoded("Published: ") + Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().VersionPublishedUtc.Value) %><%
|
||||||
if (pageEntry.Page.ScheduledPublishUtc != null) { %>
|
}
|
||||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/scheduled.gif") %>" alt="<%=_Encoded("Scheduled") %>" title="<%=_Encoded("The page is scheduled for publishing") %>" /><%=string.Format("Scheduled: {0:d}", pageEntry.Page.ScheduledPublishUtc.Value) %> | <%
|
else { %>
|
||||||
}
|
<%=_Encoded("Last modified: ") + Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().ModifiedUtc.Value) %><%
|
||||||
} %>
|
} %> |
|
||||||
</li>
|
|
||||||
<li><%--Author--%>
|
|
||||||
<%=_Encoded("By {0}", pageEntry.Page.Creator.UserName)%>
|
|
||||||
</li>
|
</li>
|
||||||
|
<li><%=_Encoded("By {0}", pageEntry.Page.Creator.UserName)%></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="related"><%
|
<div class="related"><%
|
||||||
if (pageEntry.Page.HasPublished) { %>
|
if (pageEntry.Page.HasPublished) { %>
|
||||||
<%=Html.ActionLink("View", "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug })%><%=_Encoded("|")%><%
|
<%=Html.ActionLink("View", "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug }, new {title = _Encoded("View Page")})%><%=_Encoded(" | ")%><%
|
||||||
} %>
|
if (pageEntry.Page.HasDraft) { %>
|
||||||
<%=Html.ActionLink(T("Edit").ToString(), "Edit", new { id = pageEntry.PageId })%>
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.Action("Publish", new {id = pageEntry.Page.Id})) %>" title="<%=_Encoded("Publish Draft")%>"><%=_Encoded("Publish Draft")%></a><%=_Encoded(" | ")%><%
|
||||||
|
} %>
|
||||||
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.Action("Unpublish", new {id = pageEntry.Page.Id})) %>" title="<%=_Encoded("Unpublish Page")%>"><%=_Encoded("Unpublish")%></a><%=_Encoded(" | ")%><%
|
||||||
|
}
|
||||||
|
else { %>
|
||||||
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.Action("Publish", new {id = pageEntry.Page.Id})) %>" title="<%=_Encoded("Publish Page")%>"><%=_Encoded("Publish")%></a><%=_Encoded(" | ")%><%
|
||||||
|
} %>
|
||||||
|
<%=Html.ActionLink(_Encoded("Edit").ToString(), "Edit", new {id = pageEntry.Page.Id}, new {title = _Encoded("Edit Page")})%><%=_Encoded(" | ")%>
|
||||||
|
<a href="<%=Html.AntiForgeryTokenGetUrl(Url.Action("Delete", new {id = pageEntry.Page.Id})) %>" title="<%=_Encoded("Delete Page")%>"><%=_Encoded("Delete")%></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user