mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
92 lines
3.1 KiB
C#
92 lines
3.1 KiB
C#
using System;
|
|
using System.Web.Mvc;
|
|
using Orchard.ContentManagement;
|
|
using Orchard.ContentManagement.Aspects;
|
|
using Orchard.Core.Common.Models;
|
|
using Orchard.Security;
|
|
|
|
namespace Orchard.Blogs.Models {
|
|
public class BlogPost : ContentPart {
|
|
[HiddenInput(DisplayValue = false)]
|
|
public int Id {
|
|
get { return ContentItem.Id; }
|
|
}
|
|
|
|
public string Title {
|
|
get { return this.As<RoutableAspect>().Title; }
|
|
set { this.As<RoutableAspect>().Title = value; }
|
|
}
|
|
|
|
public string Slug {
|
|
get { return this.As<RoutableAspect>().Slug; }
|
|
set { this.As<RoutableAspect>().Slug = value; }
|
|
}
|
|
|
|
public string Text {
|
|
get { return this.As<BodyAspect>().Text; }
|
|
set { this.As<BodyAspect>().Text = value; }
|
|
}
|
|
|
|
public Blog Blog {
|
|
get { return this.As<ICommonAspect>().Container.As<Blog>(); }
|
|
set { this.As<ICommonAspect>().Container = value; }
|
|
}
|
|
|
|
public IUser Creator {
|
|
get { return this.As<ICommonAspect>().Owner; }
|
|
set { this.As<ICommonAspect>().Owner = value; }
|
|
}
|
|
|
|
public bool IsPublished {
|
|
get { return ContentItem.VersionRecord != null && ContentItem.VersionRecord.Published; }
|
|
}
|
|
|
|
public bool HasDraft {
|
|
get {
|
|
return (
|
|
(ContentItem.VersionRecord != null) && (
|
|
(ContentItem.VersionRecord.Published == false) ||
|
|
(ContentItem.VersionRecord.Published && ContentItem.VersionRecord.Latest == false)));
|
|
}
|
|
}
|
|
|
|
public bool HasPublished {
|
|
get {
|
|
return IsPublished || ContentItem.ContentManager.Get(Id, VersionOptions.Published) != null;
|
|
}
|
|
}
|
|
|
|
public DateTime? CreatedUtc {
|
|
get { return this.As<ICommonAspect>().CreatedUtc; }
|
|
}
|
|
|
|
public DateTime? PublishedUtc {
|
|
get { return this.As<ICommonAspect>().VersionPublishedUtc; }
|
|
}
|
|
|
|
public DateTime? ScheduledPublishUtc { get; set; }
|
|
|
|
private string _scheduledPublishUtcDate;
|
|
|
|
public string ScheduledPublishUtcDate
|
|
{
|
|
get {
|
|
return !HasPublished && !string.IsNullOrEmpty(_scheduledPublishUtcDate) || !ScheduledPublishUtc.HasValue
|
|
? _scheduledPublishUtcDate
|
|
: ScheduledPublishUtc.Value.ToShortDateString();
|
|
}
|
|
set { _scheduledPublishUtcDate = value; }
|
|
}
|
|
|
|
private string _scheduledPublishUtcTime;
|
|
|
|
public string ScheduledPublishUtcTime {
|
|
get {
|
|
return !HasPublished && !string.IsNullOrEmpty(_scheduledPublishUtcTime) || !ScheduledPublishUtc.HasValue
|
|
? _scheduledPublishUtcTime
|
|
: ScheduledPublishUtc.Value.ToShortTimeString();
|
|
}
|
|
set { _scheduledPublishUtcTime = value; }
|
|
}
|
|
}
|
|
} |