mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Setting up proper buttons on blog post list and extra dates (not yet complete)
--HG-- branch : dev
This commit is contained in:
@@ -1,74 +1,63 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Themes"%>
|
||||
<%@ Import Namespace="Orchard.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<div class="properties">
|
||||
<h3><%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id))%></h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<%if (Model.IsPublished)
|
||||
{ %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/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.Blogs/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded(" Not Published")%>
|
||||
<% } %>
|
||||
|
|
||||
<li><%
|
||||
if (Model.Item.HasPublished) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/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.Blogs/Content/Admin/images/offline.gif") %>" alt="<%=_Encoded("Offline") %>" title="<%=_Encoded("The page is currently offline") %>" /><%=_Encoded(" Not Published")%><%
|
||||
} %> |
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<% if (Model.IsDraft) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The post has a draft") %>" /><%=Html.PublishedState(Model.Item)%>
|
||||
<% }
|
||||
else
|
||||
{ %>
|
||||
<%=_Encoded("No draft")%>
|
||||
<% } %>
|
||||
|
|
||||
<li><%
|
||||
if (Model.Item.HasDraft) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/draft.gif") %>" alt="<%=_Encoded("Draft") %>" title="<%=_Encoded("The post has a draft") %>" /><%=Html.PublishedState(Model.Item)%><%
|
||||
}
|
||||
else { %>
|
||||
<%=_Encoded("No draft")%><%
|
||||
} %> |
|
||||
</li>
|
||||
|
||||
<%--This should show publised date, last modified, or scheduled.
|
||||
<li>
|
||||
<li><%
|
||||
if (Model.Item.ScheduledPublishUtc.HasValue && Model.Item.ScheduledPublishUtc.Value > DateTime.UtcNow) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/scheduled.gif") %>" alt="<%=_Encoded("Scheduled") %>" title="<%=_Encoded("The post is scheduled for publishing") %>" /><%=_Encoded("Scheduled")%>
|
||||
|
|
||||
</li>--%>
|
||||
|
||||
<li>
|
||||
<%=_Encoded("By {0}", Model.Item.Creator.UserName)%>
|
||||
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||
}
|
||||
else if (Model.Item.IsPublished) { %>
|
||||
<%=_Encoded("Published: ") + Html.PublishedWhen(Model.Item) %><%
|
||||
}
|
||||
else { %>
|
||||
<%=_Encoded("Last modified: {todo}") %><%
|
||||
} %> |
|
||||
</li>
|
||||
<li><%=_Encoded("By {0}", Model.Item.Creator.UserName)%></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="related">
|
||||
|
||||
<%if (Model.IsPublished){ %>
|
||||
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%>
|
||||
<% } %>
|
||||
|
||||
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%>
|
||||
|
||||
<%if (Model.Item.ContentItem.VersionRecord.Published == false) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^
|
||||
<div class="related"><%
|
||||
if (Model.Item.HasPublished){ %>
|
||||
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" title="<%=_Encoded("View Post")%>"><%=_Encoded("View")%></a><%=_Encoded(" | ")%><%
|
||||
if (Model.Item.HasDraft) { %>
|
||||
<a href="#" title="<%=_Encoded("Publish Draft")%>"><%=_Encoded("Publish Draft")%></a><%=_Encoded(" | ")%><%
|
||||
} %>
|
||||
<a href="#" title="<%=_Encoded("Unpublish Post")%>"><%=_Encoded("Unpublish")%></a><%=_Encoded(" | ")%><%
|
||||
}
|
||||
else { %>
|
||||
<a href="#" title="<%=_Encoded("Publish Post")%>"><%=_Encoded("Publish")%></a><%=_Encoded(" | ")%><%
|
||||
} %>
|
||||
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Id) %>" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit")%></a><%=_Encoded(" | ")%><%--
|
||||
if (Model.Item.ContentItem.VersionRecord.Published == false) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^
|
||||
using (Html.BeginFormAntiForgeryPost(Url.BlogPostPublish(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
|
||||
|
||||
<button type="submit" class="linkButton" title="<%=_Encoded("Publish") %>"><%=_Encoded("Publish")%></button><%=_Encoded(" | ")%><%
|
||||
}
|
||||
}--%><%
|
||||
using (Html.BeginFormAntiForgeryPost(Url.BlogPostDelete(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
|
||||
<button type="submit" class="linkButton" title="<%=_Encoded("Delete") %>"><%=_Encoded("Delete") %></button><%
|
||||
} %>
|
||||
|
||||
<% using (Html.BeginFormAntiForgeryPost(Url.BlogPostDelete(Model.Item.Blog.Slug, Model.Item.Id), FormMethod.Post, new { @class = "inline" })) { %>
|
||||
<button type="submit" class="linkButton" title="<%=_Encoded("Delete") %>"><%=_Encoded("Delete") %></button>
|
||||
<%
|
||||
} %>
|
||||
|
||||
<br /><%Html.Zone("meta");%>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
@@ -10,10 +10,11 @@
|
||||
<div class="secondary">
|
||||
<% Html.Zone("secondary");%>
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/>
|
||||
<% if (Model.IsDraft) { %>
|
||||
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Blogs", Controller = "BlogPostAdmin", id=Model.Item.Id }, new { @class = "button" })%>
|
||||
<% } %>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/><%
|
||||
//TODO: (erikpo) In the future, remove the HasPublished check so the user can delete the content item from here if the choose to
|
||||
if (Model.Item.HasDraft && Model.Item.HasPublished) { %>
|
||||
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Blogs", Controller = "BlogPostAdmin", id=Model.Item.Id }, new { @class = "button" })%><%
|
||||
} %>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@@ -10,10 +10,11 @@
|
||||
<div class="secondary">
|
||||
<% Html.Zone("secondary");%>
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/>
|
||||
<% if (Model.IsDraft) { %>
|
||||
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Pages", Controller = "Admin", Model.Item.Id }, new { @class = "button" })%>
|
||||
<% } %>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="<%=_Encoded("Save") %>"/><%
|
||||
//TODO: (erikpo) In the future, remove the HasPublished check so the user can delete the content item from here if the choose to
|
||||
if (Model.Item.HasDraft && Model.Item.HasPublished) { %>
|
||||
<%=Html.ActionLink(T("Discard Draft").ToString(), "DiscardDraft", new { Area = "Orchard.Pages", Controller = "Admin", Model.Item.Id }, new { @class = "button" })%><%
|
||||
} %>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@@ -116,9 +116,18 @@ namespace Orchard.Mvc.Html {
|
||||
return value.HasValue ? htmlHelper.DateTime(value.Value) : defaultIfNull;
|
||||
}
|
||||
|
||||
//TODO: (erikpo) This format should come from a site setting
|
||||
public static string DateTime(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull, string customFormat) {
|
||||
return value.HasValue ? htmlHelper.DateTime(value.Value, customFormat) : defaultIfNull;
|
||||
}
|
||||
|
||||
public static string DateTime(this HtmlHelper htmlHelper, DateTime value) {
|
||||
return value.ToString("MMM d yyyy h:mm tt");
|
||||
//TODO: (erikpo) This default format should come from a site setting
|
||||
return htmlHelper.DateTime(value, "MMM d yyyy h:mm tt");
|
||||
}
|
||||
|
||||
public static string DateTime(this HtmlHelper htmlHelper, DateTime value, string customFormat) {
|
||||
//TODO: (erikpo) In the future, convert this to "local" time before calling ToString
|
||||
return value.ToString(customFormat);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@@ -36,16 +36,6 @@ namespace Orchard.Mvc.ViewModels {
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public ZoneCollection Zones { get; private set; }
|
||||
|
||||
public bool IsPublished {
|
||||
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Published; }
|
||||
}
|
||||
public bool IsLatest {
|
||||
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Latest; }
|
||||
}
|
||||
public bool IsDraft {
|
||||
get { return IsLatest && !IsPublished; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ContentItemViewModel<TPart> : ContentItemViewModel where TPart : IContent {
|
||||
|
Reference in New Issue
Block a user