mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +08:00
Removed PageRecord since it's no longer needed.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045370
This commit is contained in:
@@ -5,7 +5,7 @@ using Orchard.Core.Common.Models;
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Pages.Models {
|
namespace Orchard.Pages.Models {
|
||||||
public class Page : ContentPart<PageRecord> {
|
public class Page : ContentPart {
|
||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public int Id { get { return ContentItem.Id; } }
|
public int Id { get { return ContentItem.Id; } }
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ using Orchard.ContentManagement.Handlers;
|
|||||||
namespace Orchard.Pages.Models {
|
namespace Orchard.Pages.Models {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class PageHandler : ContentHandler {
|
public class PageHandler : ContentHandler {
|
||||||
public PageHandler(IRepository<PageRecord> repository, IRepository<CommonVersionRecord> commonRepository) {
|
public PageHandler(IRepository<CommonVersionRecord> commonRepository) {
|
||||||
Filters.Add(new ActivatingFilter<Page>(PageDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<Page>(PageDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<CommonAspect>(PageDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<CommonAspect>(PageDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(PageDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(PageDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<RoutableAspect>(PageDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<RoutableAspect>(PageDriver.ContentType.Name));
|
||||||
Filters.Add(new ActivatingFilter<BodyAspect>(PageDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<BodyAspect>(PageDriver.ContentType.Name));
|
||||||
Filters.Add(new StorageFilter<PageRecord>(repository));
|
|
||||||
Filters.Add(new StorageFilter<CommonVersionRecord>(commonRepository));
|
Filters.Add(new StorageFilter<CommonVersionRecord>(commonRepository));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Orchard.ContentManagement.Records;
|
|
||||||
|
|
||||||
namespace Orchard.Pages.Models {
|
|
||||||
public class PageRecord : ContentPartRecord {
|
|
||||||
public virtual DateTime? Published { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -80,7 +80,6 @@
|
|||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
<Compile Include="Models\Page.cs" />
|
<Compile Include="Models\Page.cs" />
|
||||||
<Compile Include="Models\PageHandler.cs" />
|
<Compile Include="Models\PageHandler.cs" />
|
||||||
<Compile Include="Models\PageRecord.cs" />
|
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Routes.cs" />
|
<Compile Include="Routes.cs" />
|
||||||
|
|||||||
@@ -18,29 +18,30 @@ namespace Orchard.Pages.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Page> Get(PageStatus status) {
|
public IEnumerable<Page> Get(PageStatus status) {
|
||||||
|
IEnumerable<ContentItem> contentItems;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case PageStatus.All:
|
case PageStatus.All:
|
||||||
return _contentManager.Query<Page, PageRecord>(VersionOptions.Latest).List();
|
contentItems = _contentManager.Query(VersionOptions.Latest, "page").List();
|
||||||
|
break;
|
||||||
case PageStatus.Published:
|
case PageStatus.Published:
|
||||||
return _contentManager.Query<Page, PageRecord>(VersionOptions.Published).List();
|
contentItems = _contentManager.Query(VersionOptions.Published, "page").List();
|
||||||
|
break;
|
||||||
case PageStatus.Offline:
|
case PageStatus.Offline:
|
||||||
IEnumerable<Page> allPages = _contentManager.Query<Page, PageRecord>(VersionOptions.Latest).List();
|
contentItems = _contentManager.Query(VersionOptions.Latest, "page").List().Where(ci => !ci.VersionRecord.Published);
|
||||||
List<Page> offlinePages = new List<Page>();
|
break;
|
||||||
foreach (var page in allPages) {
|
|
||||||
if (page.ContentItem.VersionRecord.Published == false) {
|
|
||||||
offlinePages.Add(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return offlinePages;
|
|
||||||
default:
|
default:
|
||||||
return new List<Page>();
|
contentItems = new List<Page>().Cast<ContentItem>();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return contentItems.Select(ci => ci.As<Page>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page Get(string slug) {
|
public Page Get(string slug) {
|
||||||
return _contentManager.Query<Page, PageRecord>()
|
return
|
||||||
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
_contentManager.Query("page").Join<RoutableRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault
|
||||||
.List().FirstOrDefault();
|
().As<Page>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page GetLatest(int id) {
|
public Page GetLatest(int id) {
|
||||||
@@ -48,9 +49,9 @@ namespace Orchard.Pages.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Page GetLatest(string slug) {
|
public Page GetLatest(string slug) {
|
||||||
return _contentManager.Query<Page, PageRecord>(VersionOptions.Latest)
|
return
|
||||||
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
_contentManager.Query(VersionOptions.Latest, "page").Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
||||||
.Slice(0, 1).FirstOrDefault();
|
.Slice(0, 1).FirstOrDefault().As<Page>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page GetPageOrDraft(string slug) {
|
public Page GetPageOrDraft(string slug) {
|
||||||
|
|||||||
Reference in New Issue
Block a user