2009-11-25 01:34:23 +00:00
|
|
|
using System;
|
2009-12-09 23:07:00 +00:00
|
|
|
using System.Web.Mvc;
|
2010-01-28 06:53:58 +00:00
|
|
|
using Orchard.ContentManagement;
|
2010-01-10 11:18:28 +00:00
|
|
|
using Orchard.ContentManagement.Aspects;
|
2009-11-25 23:12:19 +00:00
|
|
|
using Orchard.Core.Common.Models;
|
|
|
|
using Orchard.Security;
|
2009-11-20 23:31:49 +00:00
|
|
|
|
|
|
|
namespace Orchard.Blogs.Models {
|
2010-01-11 21:05:24 +00:00
|
|
|
public class BlogPost : ContentPart {
|
2009-12-09 23:07:00 +00:00
|
|
|
[HiddenInput(DisplayValue = false)]
|
2010-01-28 06:53:58 +00:00
|
|
|
public int Id {
|
|
|
|
get { return ContentItem.Id; }
|
|
|
|
}
|
2009-12-09 23:07:00 +00:00
|
|
|
|
2009-12-10 00:03:10 +00:00
|
|
|
public string Title {
|
|
|
|
get { return this.As<RoutableAspect>().Title; }
|
|
|
|
}
|
2009-12-09 23:07:00 +00:00
|
|
|
|
2009-12-10 00:03:10 +00:00
|
|
|
public string Slug {
|
|
|
|
get { return this.As<RoutableAspect>().Slug; }
|
2010-01-15 23:44:22 +00:00
|
|
|
set { this.As<RoutableAspect>().Slug = value; }
|
2009-12-10 00:03:10 +00:00
|
|
|
}
|
2009-12-09 23:07:00 +00:00
|
|
|
|
2009-12-10 01:49:09 +00:00
|
|
|
public Blog Blog {
|
2010-01-10 11:18:28 +00:00
|
|
|
get { return this.As<ICommonAspect>().Container.As<Blog>(); }
|
|
|
|
set { this.As<ICommonAspect>().Container = value; }
|
2009-12-10 00:03:10 +00:00
|
|
|
}
|
2009-12-09 23:07:00 +00:00
|
|
|
|
2009-12-10 00:03:10 +00:00
|
|
|
public IUser Creator {
|
2010-01-10 11:18:28 +00:00
|
|
|
get { return this.As<ICommonAspect>().Owner; }
|
|
|
|
set { this.As<ICommonAspect>().Owner = value; }
|
2009-12-10 00:03:10 +00:00
|
|
|
}
|
2009-12-09 23:07:00 +00:00
|
|
|
|
2010-01-28 06:53:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-25 04:42:26 +00:00
|
|
|
public DateTime? PublishedUtc {
|
|
|
|
get { return this.As<ICommonAspect>().VersionPublishedUtc; }
|
2009-12-09 23:07:00 +00:00
|
|
|
}
|
2010-01-25 04:42:26 +00:00
|
|
|
|
2010-01-28 06:53:58 +00:00
|
|
|
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; }
|
|
|
|
}
|
2009-11-20 23:31:49 +00:00
|
|
|
}
|
|
|
|
}
|