mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
namespace Orchard.Blogs.Extensions {
|
||||
@@ -9,7 +11,7 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -17,7 +19,7 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
public DateTime? PublishedUtc {
|
||||
get { return this.As<ICommonAspect>().VersionPublishedUtc; }
|
||||
}
|
||||
|
||||
public DateTime? ScheduledPublishUtc { get; set; }
|
||||
|
||||
private string _scheduledPublishUtcDate;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.Aspects"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
@@ -30,20 +31,20 @@
|
||||
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||
}
|
||||
else if (Model.Item.IsPublished) { %>
|
||||
<%=_Encoded("Published: ") + Html.PublishedWhen(Model.Item) %><%
|
||||
<%=_Encoded("Published: ") + Html.DateTimeRelative(Model.Item.As<ICommonAspect>().VersionPublishedUtc.Value)%><%
|
||||
}
|
||||
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><%=_Encoded("By {0}", Model.Item.Creator == null ? String.Empty : Model.Item.Creator.UserName)%></li>
|
||||
<li><%=_Encoded("By {0}", Model.Item.Creator.UserName)%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="related"><%
|
||||
if (Model.Item.HasPublished){ %>
|
||||
<a href="<%=Url.BlogPost(Model.Item) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%><%
|
||||
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(" | ")%><%
|
||||
}
|
||||
@@ -51,7 +52,7 @@
|
||||
<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="<%=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");%>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
@@ -6,6 +6,7 @@ using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Mvc.AntiForgery;
|
||||
using Orchard.Mvc.Results;
|
||||
using Orchard.Pages.Models;
|
||||
using Orchard.Pages.Services;
|
||||
@@ -210,7 +211,6 @@ namespace Orchard.Pages.Controllers {
|
||||
return RedirectToAction("Edit", "Admin", new { id = model.Page.Item.ContentItem.Id });
|
||||
}
|
||||
|
||||
|
||||
public ActionResult DiscardDraft(int id) {
|
||||
// get the current draft version
|
||||
var draft = Services.ContentManager.Get(id, VersionOptions.Draft);
|
||||
@@ -239,9 +239,41 @@ namespace Orchard.Pages.Controllers {
|
||||
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) {
|
||||
Page page = _pageService.Get(id);
|
||||
var page = _pageService.GetLatest(id);
|
||||
if (page == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
@@ -249,7 +281,7 @@ namespace Orchard.Pages.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_pageService.Delete(page);
|
||||
Services.Notifier.Information(T("Page was successfully deleted"));
|
||||
Services.Notifier.Information(T("Page successfully deleted"));
|
||||
|
||||
return RedirectToAction("List");
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Security;
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
<%@ 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.Pages.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("Manage Pages").ToString())%></h1>
|
||||
<%-- todo: Add helper text here when ready. <p><%=_Encoded("Possible text about setting up a page goes here.")%></p>--%>
|
||||
<div class="manage"><%=Html.ActionLink(T("Add a page").ToString(), "Create", new { }, new { @class = "button primaryAction" })%></div>
|
||||
<% using (Html.BeginFormAntiForgeryPost())
|
||||
{ %>
|
||||
<div class="manage"><%=Html.ActionLink(T("Add a page").ToString(), "Create", new { }, new { @class = "button primaryAction" })%></div><%
|
||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%=Html.ValidationSummary()%>
|
||||
<fieldset class="actions bulk">
|
||||
<label for="publishActions"><%=_Encoded("Actions:")%></label>
|
||||
@@ -27,85 +29,70 @@
|
||||
<input class="button" type="submit" name="submit.Filter" value="<%=_Encoded("Apply") %>"/>
|
||||
</fieldset>
|
||||
<fieldset class="pageList">
|
||||
|
||||
|
||||
<ul class="contentItems">
|
||||
<%
|
||||
int pageIndex = 0;
|
||||
foreach (var pageEntry in Model.PageEntries)
|
||||
{
|
||||
var pi = pageIndex; %>
|
||||
<li>
|
||||
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<input type="hidden" value="<%=Model.PageEntries[pageIndex].PageId %>" name="<%=Html.NameOf(m => m.PageEntries[pi].PageId) %>"/>
|
||||
<input type="checkbox" value="true" name="<%=Html.NameOf(m => m.PageEntries[pi].IsChecked) %>"/>
|
||||
|
||||
<h3><%=Html.ActionLink(pageEntry.Page.Title, "Edit", new { id = pageEntry.PageId })%></h3>
|
||||
|
||||
<ul class="pageStatus">
|
||||
<li><%--Published or not--%>
|
||||
<% if (pageEntry.Page.HasPublished)
|
||||
{ %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/online.gif") %>" alt="<%=_Encoded("Online") %>" title="<%=_Encoded("The page is currently online") %>" /><%=_Encoded("Published") %> |
|
||||
<% }
|
||||
else
|
||||
{ %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded("Not Published")%> |
|
||||
<% } %>
|
||||
</li>
|
||||
|
||||
|
||||
<li><%--Does the page have a draft--%>
|
||||
<% if (pageEntry.Page.HasDraft)
|
||||
{ %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The page has a draft") %>" /><%=_Encoded("Draft")%> |
|
||||
<% }
|
||||
else
|
||||
{ %>
|
||||
<%=_Encoded("No Draft")%> |
|
||||
<% } %>
|
||||
<%--Scheduled--%>
|
||||
<% if (!pageEntry.Page.IsPublished)
|
||||
{ %>
|
||||
<%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) %> |
|
||||
<% }%>
|
||||
<% } %>
|
||||
</li>
|
||||
|
||||
<ul class="contentItems"><%
|
||||
var pageIndex = 0;
|
||||
foreach (var pageEntry in Model.PageEntries) {
|
||||
var pi = pageIndex; %>
|
||||
<li>
|
||||
<%--Author--%>
|
||||
<%=_Encoded("By {0}", pageEntry.Page.Creator.UserName)%>
|
||||
</li>
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<input type="hidden" value="<%=Model.PageEntries[pageIndex].PageId %>" name="<%=Html.NameOf(m => m.PageEntries[pi].PageId) %>"/>
|
||||
<input type="checkbox" value="true" name="<%=Html.NameOf(m => m.PageEntries[pi].IsChecked) %>"/>
|
||||
<h3><%=Html.ActionLink(pageEntry.Page.Title, "Edit", new { id = pageEntry.PageId })%></h3>
|
||||
<ul class="pageStatus">
|
||||
<li><%
|
||||
// Published or not
|
||||
if (pageEntry.Page.HasPublished) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/online.gif") %>" alt="<%=_Encoded("Online") %>" title="<%=_Encoded("The page is currently online") %>" /><%=_Encoded("Published") %> | <%
|
||||
}
|
||||
else { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded("Not Published")%> | <%
|
||||
} %>
|
||||
</li>
|
||||
<li><%
|
||||
// Does the page have a draft
|
||||
if (pageEntry.Page.HasDraft) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The page has a draft") %>" /><%=_Encoded("Draft")%> | <%
|
||||
}
|
||||
else { %>
|
||||
<%=_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")%><%
|
||||
}
|
||||
else if (pageEntry.Page.IsPublished) { %>
|
||||
<%=_Encoded("Published: ") + Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().VersionPublishedUtc.Value) %><%
|
||||
}
|
||||
else { %>
|
||||
<%=_Encoded("Last modified: ") + Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().ModifiedUtc.Value) %><%
|
||||
} %> |
|
||||
</li>
|
||||
<li><%=_Encoded("By {0}", pageEntry.Page.Creator.UserName)%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="related"><%
|
||||
if (pageEntry.Page.HasPublished) { %>
|
||||
<%=Html.ActionLink("View", "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug }, new {title = _Encoded("View Page")})%><%=_Encoded(" | ")%><%
|
||||
if (pageEntry.Page.HasDraft) { %>
|
||||
<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 style="clear:both;"></div>
|
||||
</div>
|
||||
</li><%
|
||||
pageIndex++;
|
||||
} %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="related">
|
||||
|
||||
<% if (pageEntry.Page.HasPublished)
|
||||
{ %>
|
||||
<%=Html.ActionLink("View", "Item", new { controller = "Page", slug = pageEntry.Page.PublishedSlug })%>
|
||||
<%=_Encoded("|")%>
|
||||
<% }
|
||||
else
|
||||
{%>
|
||||
<%=""%>
|
||||
<% } %>
|
||||
|
||||
|
||||
<%=Html.ActionLink(T("Edit").ToString(), "Edit", new { id = pageEntry.PageId })%>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</li>
|
||||
<%
|
||||
pageIndex++;
|
||||
</fieldset><%
|
||||
} %>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<% } %>
|
||||
|
||||
<div class="manage"><%=Html.ActionLink(T("Add a page").ToString(), "Create", new { }, new { @class = "button primaryAction" })%></div>
|
||||
|
Reference in New Issue
Block a user