mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Adding a GetDisplays operation to the content manager system
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041463
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Orchard.Media.Models {
|
||||
Filters.Add(new StorageFilterForRecord<MediaSettingsRecord>(repository) { AutomaticallyCreateMissingRecord = true });
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetContentEditorsContext context) {
|
||||
protected override void GetEditors(GetEditorsContext context) {
|
||||
var model = context.ContentItem.As<MediaSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
|
@@ -29,7 +29,7 @@ namespace Orchard.Roles.Models {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetContentEditorsContext context) {
|
||||
protected override void GetEditors(GetEditorsContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRoles>();
|
||||
if (userRoles != null) {
|
||||
var roles =
|
||||
|
@@ -31,6 +31,7 @@ namespace Orchard.Wikis.Controllers
|
||||
var model = new PageShowViewModel {
|
||||
Page = _contentManager.Get<WikiPage>(id)
|
||||
};
|
||||
model.Displays = _contentManager.GetDisplays(model.Page.ContentItem);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,6 @@ using Orchard.Wikis.Models;
|
||||
namespace Orchard.Wikis.ViewModels {
|
||||
public class PageShowViewModel {
|
||||
public WikiPage Page { get; set; }
|
||||
public IList<ModelTemplate> Chunks { get; set; }
|
||||
public IEnumerable<ModelTemplate> Displays { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,9 @@
|
||||
<div>
|
||||
body
|
||||
</div>
|
||||
<%foreach (var display in Model.Displays) { %>
|
||||
<%=Html.DisplayFor(m=>display.Model, display.TemplateName, display.Prefix) %>
|
||||
<%} %>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<% Html.Include("footer"); %>
|
||||
|
@@ -107,8 +107,17 @@ namespace Orchard.Models {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<ModelTemplate> GetDisplays(ContentItem contentItem) {
|
||||
var context = new GetDisplaysContext(contentItem);
|
||||
foreach (var driver in Drivers) {
|
||||
driver.GetDisplays(context);
|
||||
}
|
||||
return context.Displays;
|
||||
}
|
||||
|
||||
public IEnumerable<ModelTemplate> GetEditors(ContentItem contentItem) {
|
||||
var context = new GetContentEditorsContext(contentItem);
|
||||
var context = new GetEditorsContext(contentItem);
|
||||
foreach (var driver in Drivers) {
|
||||
driver.GetEditors(context);
|
||||
}
|
||||
|
@@ -70,7 +70,13 @@ namespace Orchard.Models.Driver {
|
||||
Loaded(context);
|
||||
}
|
||||
|
||||
void IContentHandler.GetEditors(GetContentEditorsContext context) {
|
||||
|
||||
void IContentHandler.GetDisplays(GetDisplaysContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.GetDisplays(context);
|
||||
GetDisplays(context);
|
||||
}
|
||||
void IContentHandler.GetEditors(GetEditorsContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.GetEditors(context);
|
||||
GetEditors(context);
|
||||
@@ -90,8 +96,8 @@ namespace Orchard.Models.Driver {
|
||||
protected virtual void Creating(CreateContentContext context) { }
|
||||
protected virtual void Created(CreateContentContext context) { }
|
||||
|
||||
protected virtual void GetEditors(GetContentEditorsContext context) {}
|
||||
|
||||
protected virtual void GetDisplays(GetDisplaysContext context) { }
|
||||
protected virtual void GetEditors(GetEditorsContext context) { }
|
||||
protected virtual void UpdateEditors(UpdateContentContext context) {}
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.UI.Models;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class GetContentEditorsContext {
|
||||
public GetContentEditorsContext(ContentItem part) {
|
||||
ContentItem = part;
|
||||
Editors= new List<ModelTemplate>();
|
||||
}
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public IList<ModelTemplate> Editors { get; set; }
|
||||
}
|
||||
}
|
22
src/Orchard/Models/Driver/GetEditorsContext.cs
Normal file
22
src/Orchard/Models/Driver/GetEditorsContext.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.UI.Models;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class GetEditorsContext {
|
||||
public GetEditorsContext(ContentItem part) {
|
||||
ContentItem = part;
|
||||
Editors= new List<ModelTemplate>();
|
||||
}
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public IList<ModelTemplate> Editors { get; set; }
|
||||
}
|
||||
|
||||
public class GetDisplaysContext {
|
||||
public GetDisplaysContext(ContentItem part) {
|
||||
ContentItem = part;
|
||||
Displays = new List<ModelTemplate>();
|
||||
}
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public IList<ModelTemplate> Displays { get; set; }
|
||||
}
|
||||
}
|
@@ -7,7 +7,8 @@
|
||||
void Loading(LoadContentContext context);
|
||||
void Loaded(LoadContentContext context);
|
||||
|
||||
void GetEditors(GetContentEditorsContext context);
|
||||
void GetDisplays(GetDisplaysContext context);
|
||||
void GetEditors(GetEditorsContext context);
|
||||
void UpdateEditors(UpdateContentContext context);
|
||||
}
|
||||
}
|
@@ -5,7 +5,8 @@ using System.Text;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
interface IContentTemplateFilter : IContentFilter {
|
||||
void GetEditors(GetContentEditorsContext context);
|
||||
void GetDisplays(GetDisplaysContext context);
|
||||
void GetEditors(GetEditorsContext context);
|
||||
void UpdateEditors(UpdateContentContext context);
|
||||
}
|
||||
}
|
||||
|
@@ -6,10 +6,17 @@ using System.Text;
|
||||
namespace Orchard.Models.Driver {
|
||||
public abstract class TemplateFilterBase<TPart> : IContentTemplateFilter where TPart : class, IContentItemPart {
|
||||
|
||||
protected virtual void GetEditors(GetContentEditorsContext context, TPart instance) { }
|
||||
protected virtual void GetDisplays(GetDisplaysContext context, TPart instance) { }
|
||||
protected virtual void GetEditors(GetEditorsContext context, TPart instance) { }
|
||||
protected virtual void UpdateEditors(UpdateContentContext context, TPart instance) { }
|
||||
|
||||
void IContentTemplateFilter.GetEditors(GetContentEditorsContext context) {
|
||||
|
||||
void IContentTemplateFilter.GetDisplays(GetDisplaysContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
GetDisplays(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentTemplateFilter.GetEditors(GetEditorsContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
GetEditors(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace Orchard.Models.Driver {
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
protected override void GetEditors(GetContentEditorsContext context, ContentPartForRecord<TRecord> part) {
|
||||
protected override void GetEditors(GetEditorsContext context, ContentPartForRecord<TRecord> part) {
|
||||
context.Editors.Add(ModelTemplate.For(part.Record, _prefix));
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
namespace Orchard.Models.Driver {
|
||||
public class UpdateContentContext : GetContentEditorsContext {
|
||||
public class UpdateContentContext : GetEditorsContext {
|
||||
public UpdateContentContext(ContentItem contentItem, IUpdateModel updater) : base(contentItem) {
|
||||
Updater = updater;
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ namespace Orchard.Models {
|
||||
ContentItem Get(int id);
|
||||
void Create(ContentItem contentItem);
|
||||
|
||||
IEnumerable<ModelTemplate> GetDisplays(ContentItem contentItem);
|
||||
IEnumerable<ModelTemplate> GetEditors(ContentItem contentItem);
|
||||
IEnumerable<ModelTemplate> UpdateEditors(ContentItem contentItem, IUpdateModel updater);
|
||||
}
|
||||
|
@@ -147,7 +147,7 @@
|
||||
<Compile Include="Models\Driver\ContentItemBuilder.cs" />
|
||||
<Compile Include="Models\Driver\ContentHandler.cs" />
|
||||
<Compile Include="Models\Driver\ActivatingContentContext.cs" />
|
||||
<Compile Include="Models\Driver\GetContentEditorsContext.cs" />
|
||||
<Compile Include="Models\Driver\GetEditorsContext.cs" />
|
||||
<Compile Include="Models\Driver\StorageFilterForRecord.cs" />
|
||||
<Compile Include="Models\Driver\StorageFilterBase.cs" />
|
||||
<Compile Include="Models\Driver\TemplateFilterBase.cs" />
|
||||
|
Reference in New Issue
Block a user