Files
Orchard/src/Orchard.Web/Core/Common/Providers/BodyAspectHandler.cs
skewed 0d47a5a628 Some work towards standardizing on (some) template zone names and positions...
--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044851
2010-01-02 07:51:55 +00:00

35 lines
1.8 KiB
C#

using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.ViewModels;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.Core.Common.Providers {
public class BodyAspectHandler : ContentHandler {
private const string TemplatePrefix = "Body";
private const string TemplateName = "Parts/Common.Body";
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {
Filters.Add(new StorageFilter<BodyRecord>(bodyRepository) { AutomaticallyCreateMissingRecord = true });
OnGetDisplayViewModel<BodyAspect>((context, body) => {
var model = new BodyDisplayViewModel { BodyAspect = body };
context.AddDisplay(new TemplateViewModel(model, TemplatePrefix) { TemplateName = TemplateName, ZoneName = "primary" });
});
OnGetEditorViewModel<BodyAspect>((context, body) => {
var model = new BodyEditorViewModel { BodyAspect = body, TextEditorTemplate = DefaultTextEditorTemplate };
context.AddEditor(new TemplateViewModel(model, TemplatePrefix) { TemplateName = TemplateName, ZoneName = "primary" });
});
OnUpdateEditorViewModel<BodyAspect>((context, body) => {
var model = new BodyEditorViewModel { BodyAspect = body, TextEditorTemplate = DefaultTextEditorTemplate };
context.Updater.TryUpdateModel(model, TemplatePrefix, null, null);
context.AddEditor(new TemplateViewModel(model, TemplatePrefix) { TemplateName = TemplateName, ZoneName = "primary" });
});
}
}
}