mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding ContentType class and GetContentTypes methods to IContentManager and IContentProvider
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042626
This commit is contained in:
@@ -3,6 +3,8 @@ using Orchard.Models;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class Blog : ContentPart<BlogRecord> {
|
||||
public readonly static ContentType ContentType = new ContentType { Name = "blog", DisplayName = "Blog" };
|
||||
|
||||
public int Id { get { return ContentItem.Id; } }
|
||||
public string Name { get { return this.As<RoutableAspect>().Title; } }
|
||||
public string Slug { get { return this.As<RoutableAspect>().Slug; } }
|
||||
|
@@ -5,6 +5,8 @@ using Orchard.Security;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPost : ContentPart<BlogPostRecord> {
|
||||
public readonly static ContentType ContentType = new ContentType { Name = "blogpost", DisplayName = "Blog Post" };
|
||||
|
||||
public Blog Blog { get; set; }
|
||||
public string Title { get { return this.As<RoutableAspect>().Title; } }
|
||||
public string Body { get { return this.As<BodyAspect>().Body; } }
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
@@ -5,6 +6,10 @@ using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPostProvider : ContentProvider {
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] { BlogPost.ContentType };
|
||||
}
|
||||
|
||||
public BlogPostProvider(IRepository<BlogPostRecord> repository, IContentManager contentManager) {
|
||||
Filters.Add(new ActivatingFilter<BlogPost>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<CommonAspect>("blogpost"));
|
||||
|
@@ -1,9 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogProvider : ContentProvider {
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] { Blog.ContentType };
|
||||
}
|
||||
|
||||
public BlogProvider(IRepository<BlogRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Blog>("blog"));
|
||||
Filters.Add(new ActivatingFilter<CommonAspect>("blog"));
|
||||
|
@@ -1,19 +1,25 @@
|
||||
using Orchard.Core.Common.Models;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxContentProvider : ContentProvider {
|
||||
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] {SandboxPage.ContentType};
|
||||
}
|
||||
|
||||
public SandboxContentProvider(
|
||||
IRepository<SandboxPageRecord> pageRepository,
|
||||
IRepository<SandboxSettingsRecord> settingsRepository) {
|
||||
|
||||
// define the "sandboxpage" content type
|
||||
Filters.Add(new ActivatingFilter<SandboxPage>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<CommonAspect>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<SandboxPage>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<CommonAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new StorageFilter<SandboxPageRecord>(pageRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
|
||||
// add settings to site, and simple record-template gui
|
||||
|
@@ -4,6 +4,8 @@ using Orchard.Models;
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxPage : ContentPart<SandboxPageRecord>, IContentDisplayInfo {
|
||||
|
||||
public readonly static ContentType ContentType = new ContentType {Name = "sandboxpage", DisplayName = "Sandbox Page"};
|
||||
|
||||
string IContentDisplayInfo.DisplayText {
|
||||
get { return Record.Name; }
|
||||
}
|
||||
@@ -17,4 +19,4 @@ namespace Orchard.Sandbox.Models {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ using Orchard.Security;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public sealed class User : ContentPart<UserRecord>, IUser {
|
||||
public readonly static ContentType ContentType = new ContentType { Name = "user", DisplayName = "User Profile" };
|
||||
|
||||
public int Id {
|
||||
get { return ContentItem.Id; }
|
||||
}
|
||||
|
@@ -1,8 +1,14 @@
|
||||
using Orchard.Data;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Users.Models {
|
||||
public class UserProvider : ContentProvider {
|
||||
public override IEnumerable<ContentType> GetContentTypes() {
|
||||
return new[] { User.ContentType };
|
||||
}
|
||||
|
||||
public UserProvider(IRepository<UserRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<User>("user"));
|
||||
Filters.Add(new StorageFilter<UserRecord>(repository));
|
||||
|
Reference in New Issue
Block a user