Making progress on updating the content manager API fit better with the new dynamic UI composition scheme

- Includes changing display-related implementations (drivers & views) to work with shapes
- Editor implementations still on the old template model
- Orchard.Blogs is currently using a different display type instead of specifying alterations (for Blog and BlogPost)

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-11 02:06:01 -07:00
parent b7c3ada825
commit ddca57edd4
128 changed files with 635 additions and 454 deletions

View File

@@ -109,7 +109,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { }); var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
var viewModel = new OwnerEditorViewModel() { Owner = "User" }; var viewModel = new OwnerEditorViewModel() { Owner = "User" };
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true); updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
contentManager.UpdateEditorModel(item.ContentItem, updateModel.Object); contentManager.UpdateEditor(item.ContentItem, updateModel.Object);
} }
class UpdatModelStub : IUpdateModel { class UpdatModelStub : IUpdateModel {
@@ -148,7 +148,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var updater = new UpdatModelStub() { Owner = null }; var updater = new UpdatModelStub() { Owner = null };
contentManager.UpdateEditorModel(item.ContentItem, updater); contentManager.UpdateEditor(item.ContentItem, updater);
} }
[Test, Ignore("Fix pending")] [Test, Ignore("Fix pending")]
@@ -166,7 +166,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var updater = new UpdatModelStub() {Owner = ""}; var updater = new UpdatModelStub() {Owner = ""};
contentManager.UpdateEditorModel(item.ContentItem, updater); contentManager.UpdateEditor(item.ContentItem, updater);
Assert.That(updater.ModelErrors.ContainsKey("CommonPart.Owner"), Is.True); Assert.That(updater.ModelErrors.ContainsKey("CommonPart.Owner"), Is.True);
} }

View File

@@ -31,7 +31,7 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
[Test] [Test]
public void DriverHandlerShouldNotThrowException() { public void DriverHandlerShouldNotThrowException() {
var contentHandler = _container.Resolve<IContentHandler>(); var contentHandler = _container.Resolve<IContentHandler>();
contentHandler.BuildDisplayShape(null); contentHandler.BuildDisplay(null);
} }
[Test] [Test]
@@ -45,13 +45,13 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
var contentHandler = _container.Resolve<IContentHandler>(); var contentHandler = _container.Resolve<IContentHandler>();
var contentItem = new ContentItem(); var contentItem = new ContentItem();
var context = new BuildDisplayModelContext(contentItem, "", null, new ShapeHelperFactory(null)); var context = new BuildDisplayContext(null, contentItem, "", new ShapeHelperFactory(null));
driver1.Verify(x => x.BuildDisplayShape(context), Times.Never()); driver1.Verify(x => x.BuildDisplay(context), Times.Never());
driver2.Verify(x => x.BuildDisplayShape(context), Times.Never()); driver2.Verify(x => x.BuildDisplay(context), Times.Never());
contentHandler.BuildDisplayShape(context); contentHandler.BuildDisplay(context);
driver1.Verify(x => x.BuildDisplayShape(context)); driver1.Verify(x => x.BuildDisplay(context));
driver2.Verify(x => x.BuildDisplayShape(context)); driver2.Verify(x => x.BuildDisplay(context));
} }
[Test, Ignore("no implementation for IZoneCollection")] [Test, Ignore("no implementation for IZoneCollection")]
@@ -66,10 +66,10 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
var contentItem = new ContentItem(); var contentItem = new ContentItem();
contentItem.Weld(new StubPart { Foo = new[] { "a", "b", "c" } }); contentItem.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
var ctx = new BuildDisplayModelContext(contentItem, "", null, null); var ctx = new BuildDisplayContext(null, null, "", null);
var context = shapeHelperFactory.CreateHelper().Context(ctx); var context = shapeHelperFactory.CreateHelper().Context(ctx);
Assert.That(context.TopMeta, Is.Null); Assert.That(context.TopMeta, Is.Null);
contentHandler.BuildDisplayShape(ctx); contentHandler.BuildDisplay(ctx);
Assert.That(context.TopMeta, Is.Not.Null); Assert.That(context.TopMeta, Is.Not.Null);
Assert.That(context.TopMeta.Count == 1); Assert.That(context.TopMeta.Count == 1);
} }
@@ -79,20 +79,25 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
get { return "Stub"; } get { return "Stub"; }
} }
protected override DriverResult Display(StubPart part, string displayType) { protected override DriverResult Display(StubPart part, string displayType, dynamic shapeHelper) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) }; var stub = shapeHelper.Stub(ContentPart: part, Foo: string.Join(",", part.Foo));
if (displayType.StartsWith("Summary")) if (!string.IsNullOrWhiteSpace(displayType))
return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta"); stub.Metadata.Type = string.Format("{0}.{1}", stub.Metadata.Type, displayType);
return ContentShape(stub).Location("TopMeta");
return ContentPartTemplate(viewModel).Location("TopMeta"); //var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
//if (displayType.StartsWith("Summary"))
// return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta");
//return ContentPartTemplate(viewModel).Location("TopMeta");
} }
protected override DriverResult Editor(StubPart part) { protected override DriverResult Editor(StubPart part, dynamic shapeHelper) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) }; var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
return ContentPartTemplate(viewModel).Location("last", "10"); return ContentPartTemplate(viewModel).Location("last", "10");
} }
protected override DriverResult Editor(StubPart part, IUpdateModel updater) { protected override DriverResult Editor(StubPart part, IUpdateModel updater, dynamic shapeHelper) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) }; var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
updater.TryUpdateModel(viewModel, Prefix, null, null); updater.TryUpdateModel(viewModel, Prefix, null, null);
part.Foo = viewModel.Foo.Split(new[] { ',' }).Select(x => x.Trim()).ToArray(); part.Foo = viewModel.Foo.Split(new[] { ',' }).Select(x => x.Trim()).ToArray();

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models { namespace Orchard.Tests.ContentManagement.Models {
public class AlphaHandler : ContentHandler { public class AlphaHandler : ContentHandler {
public AlphaHandler() { public AlphaHandler() {
OnGetDisplayShape<Alpha>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "3")); OnGetDisplayShape<Alpha>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "3"));
} }
protected override void Activating(ActivatingContentContext context) { protected override void Activating(ActivatingContentContext context) {

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models { namespace Orchard.Tests.ContentManagement.Models {
public class FlavoredHandler : ContentHandler { public class FlavoredHandler : ContentHandler {
public FlavoredHandler() { public FlavoredHandler() {
OnGetDisplayShape<Flavored>((ctx, part) => ctx.Model.Zones["Main"].Add(part)); OnGetDisplayShape<Flavored>((ctx, part) => ctx.Shape.Zones["Main"].Add(part));
} }
protected override void Activating(ActivatingContentContext context) { protected override void Activating(ActivatingContentContext context) {
if (context.ContentType == "beta" || context.ContentType == "alpha") { if (context.ContentType == "beta" || context.ContentType == "alpha") {

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models { namespace Orchard.Tests.ContentManagement.Models {
public class StyledHandler : ContentHandler { public class StyledHandler : ContentHandler {
public StyledHandler() { public StyledHandler() {
OnGetDisplayShape<Styled>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "10")); OnGetDisplayShape<Styled>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "10"));
} }
protected override void Activating(ActivatingContentContext context) { protected override void Activating(ActivatingContentContext context) {

View File

@@ -1,13 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Web; using System.Web;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services;
using Orchard.Core.Common.Settings; using Orchard.Core.Common.Settings;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
using Orchard.Core.ContentsLocation.Models; using Orchard.Core.ContentsLocation.Models;
@@ -35,26 +33,29 @@ namespace Orchard.Core.Common.Drivers {
get { return "Body"; } get { return "Body"; }
} }
// \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/ protected override DriverResult Display(BodyPart part, string displayType, dynamic shapeHelper) {
protected override DriverResult Display(BodyPart part, string displayType) {
var bodyText = _htmlFilters.Aggregate(part.Text, (text, filter) => filter.ProcessContent(text)); var bodyText = _htmlFilters.Aggregate(part.Text, (text, filter) => filter.ProcessContent(text));
var model = new BodyDisplayViewModel { BodyPart = part, Html = new HtmlString(bodyText) }; var body = shapeHelper.Common_Body(ContentPart: part, Html: new HtmlString(bodyText));
if (!string.IsNullOrWhiteSpace(displayType))
body.Metadata.Type = string.Format("{0}.{1}", body.Metadata.Type, displayType);
var location = part.GetLocation(displayType); var location = part.GetLocation(displayType);
return Combined( //return Combined(
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null, // Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location(location) : null, // Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location), // ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location),
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null); // Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
return ContentShape(body).Location(location);
} }
protected override DriverResult Editor(BodyPart part) { protected override DriverResult Editor(BodyPart part, dynamic shapeHelper) {
var model = BuildEditorViewModel(part); var model = BuildEditorViewModel(part);
var location = part.GetLocation("Editor"); var location = part.GetLocation("Editor");
return ContentPartTemplate(model, TemplateName, Prefix).Location(location); return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
} }
protected override DriverResult Editor(BodyPart part, IUpdateModel updater) { protected override DriverResult Editor(BodyPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = BuildEditorViewModel(part); var model = BuildEditorViewModel(part);
updater.TryUpdateModel(model, Prefix, null, null); updater.TryUpdateModel(model, Prefix, null, null);

View File

@@ -35,19 +35,21 @@ namespace Orchard.Core.Common.Drivers {
public Localizer T { get; set; } public Localizer T { get; set; }
public IOrchardServices Services { get; set; } public IOrchardServices Services { get; set; }
protected override DriverResult Display(CommonPart part, string displayType) { protected override DriverResult Display(CommonPart part, string displayType, dynamic shapeHelper) {
return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata") var metadata = shapeHelper.Common_Metadata(ContentPart: part);
.LongestMatch(displayType, "Summary", "SummaryAdmin") if (!string.IsNullOrWhiteSpace(displayType))
.Location(part.GetLocation(displayType)); metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
var location = part.GetLocation(displayType);
return ContentShape(metadata).Location(location);
} }
protected override DriverResult Editor(CommonPart part) { protected override DriverResult Editor(CommonPart part, dynamic shapeHelper) {
return Combined( return Combined(
OwnerEditor(part, null), OwnerEditor(part, null),
ContainerEditor(part, null)); ContainerEditor(part, null));
} }
protected override DriverResult Editor(CommonPart instance, ContentManagement.IUpdateModel updater) { protected override DriverResult Editor(CommonPart instance, IUpdateModel updater, dynamic shapeHelper) {
// this event is hooked so the modified timestamp is changed when an edit-post occurs. // this event is hooked so the modified timestamp is changed when an edit-post occurs.
instance.ModifiedUtc = _clock.UtcNow; instance.ModifiedUtc = _clock.UtcNow;
instance.VersionModifiedUtc = _clock.UtcNow; instance.VersionModifiedUtc = _clock.UtcNow;

View File

@@ -1,6 +1,6 @@
using System;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
using Orchard.Core.Contents.ViewModels;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Mvc.Html; using Orchard.Mvc.Html;
@@ -15,11 +15,11 @@ namespace Orchard.Core.Common.Extensions {
} }
public static LocalizedString PublishedWhenForModel(this HtmlHelper<CommonMetadataViewModel> htmlHelper, Localizer T) { public static LocalizedString PublishedWhenForModel(this HtmlHelper<CommonMetadataViewModel> htmlHelper, Localizer T) {
return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model, T); return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model.VersionPublishedUtc, T);
} }
public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, CommonMetadataViewModel metadata, Localizer T) { public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
return htmlHelper.DateTimeRelative(metadata.VersionPublishedUtc, T("as a Draft"), T); return htmlHelper.DateTimeRelative(versionPublishedUtc, T("as a Draft"), T);
} }
} }
} }

View File

@@ -149,7 +149,7 @@ namespace Orchard.Core.Common.Handlers {
} }
//private void GetEditor(BuildEditorModelContext context, CommonPart instance) { //private void GetEditor(BuildEditorContext context, CommonPart instance) {
// var currentUser = _authenticationService.GetAuthenticatedUser(); // var currentUser = _authenticationService.GetAuthenticatedUser();
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) { // if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
// return; // return;
@@ -162,7 +162,7 @@ namespace Orchard.Core.Common.Handlers {
//} //}
//private void UpdateEditor(UpdateEditorModelContext context, CommonPart instance) { //private void UpdateEditor(UpdateEditorContext context, CommonPart instance) {
// // this event is hooked so the modified timestamp is changed when an edit-post occurs. // // this event is hooked so the modified timestamp is changed when an edit-post occurs.
// // kind of a loose rule of thumb. may not be sufficient // // kind of a loose rule of thumb. may not be sufficient
// instance.ModifiedUtc = _clock.UtcNow; // instance.ModifiedUtc = _clock.UtcNow;

View File

@@ -0,0 +1 @@
@Model.Html

View File

@@ -1,3 +0,0 @@
@model BodyDisplayViewModel
@using Orchard.Core.Common.ViewModels;
@Model.Html

View File

@@ -114,7 +114,7 @@ namespace Orchard.Core.Contents.Controllers {
var list = Shape.List(); var list = Shape.List();
list.AddRange(contentItems.Select(ci => _contentManager.BuildDisplayModel(ci, "SummaryAdmin"))); list.AddRange(contentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin")));
var viewModel = Shape.ViewModel() var viewModel = Shape.ViewModel()
.ContentItems(list) .ContentItems(list)
@@ -216,7 +216,7 @@ namespace Orchard.Core.Contents.Controllers {
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Cannot create content"))) if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Cannot create content")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var model = _contentManager.BuildEditorModel(contentItem); var model = _contentManager.BuildEditor(contentItem);
return View(model); return View(model);
} }
@@ -229,7 +229,7 @@ namespace Orchard.Core.Contents.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
_contentManager.Create(contentItem, VersionOptions.Draft); _contentManager.Create(contentItem, VersionOptions.Draft);
var model = _contentManager.UpdateEditorModel(contentItem, this); var model = _contentManager.UpdateEditor(contentItem, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
@@ -254,7 +254,7 @@ namespace Orchard.Core.Contents.Controllers {
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Cannot edit content"))) if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Cannot edit content")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var model = _contentManager.BuildEditorModel(contentItem); var model = _contentManager.BuildEditor(contentItem);
return View(model); return View(model);
} }
@@ -269,7 +269,7 @@ namespace Orchard.Core.Contents.Controllers {
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Couldn't edit content"))) if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Couldn't edit content")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var model = _contentManager.UpdateEditorModel(contentItem, this); var model = _contentManager.UpdateEditor(contentItem, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
return View("Edit", model); return View("Edit", model);

View File

@@ -18,7 +18,7 @@ namespace Orchard.Core.Contents.Controllers {
// /Contents/Item/Display/72 // /Contents/Item/Display/72
public ActionResult Display(int id) { public ActionResult Display(int id) {
var contentItem = _contentManager.Get(id, VersionOptions.Published); var contentItem = _contentManager.Get(id, VersionOptions.Published);
var model = _contentManager.BuildDisplayModel(contentItem); var model = _contentManager.BuildDisplay(contentItem);
return View(model); return View(model);
} }
@@ -30,7 +30,7 @@ namespace Orchard.Core.Contents.Controllers {
versionOptions = VersionOptions.Number((int)version); versionOptions = VersionOptions.Number((int)version);
var contentItem = _contentManager.Get(id, versionOptions); var contentItem = _contentManager.Get(id, versionOptions);
var model = _contentManager.BuildDisplayModel(contentItem); var model = _contentManager.BuildDisplay(contentItem);
return View("Display", model); return View("Display", model);
} }
} }

View File

@@ -1,13 +1,15 @@
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Contents.ViewModels;
using Orchard.Core.ContentsLocation.Models; using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Core.Contents.Drivers { namespace Orchard.Core.Contents.Drivers {
public class ContentsDriver : ContentPartDriver<ContentPart> { public class ContentsDriver : ContentPartDriver<ContentPart> {
protected override DriverResult Display(ContentPart part, string displayType) { protected override DriverResult Display(ContentPart part, string displayType, dynamic shapeHelper) {
var location = part.GetLocation(displayType, "secondary", null); var publish = shapeHelper.Contents_Publish(ContentPart: part);
return ContentPartTemplate(new PublishContentViewModel(part.ContentItem), "Parts/Contents.Publish").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location); if (!string.IsNullOrWhiteSpace(displayType))
publish.Metadata.Type = string.Format("{0}.{1}", publish.Metadata.Type, displayType);
var location = part.GetLocation(displayType, "Secondary", "5");
return ContentShape(publish).Location(location);
} }
} }
} }

View File

@@ -67,7 +67,7 @@ namespace Orchard.Core.Localization.Controllers {
Id = id, Id = id,
SelectedCulture = selectedCulture, SelectedCulture = selectedCulture,
SiteCultures = siteCultures, SiteCultures = siteCultures,
Content = _contentManager.BuildEditorModel(contentItem) Content = _contentManager.BuildEditor(contentItem)
}; };
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
@@ -104,13 +104,13 @@ namespace Orchard.Core.Localization.Controllers {
} }
} }
model.Content = _contentManager.UpdateEditorModel(contentItemTranslation, this); model.Content = _contentManager.UpdateEditor(contentItemTranslation, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
model.SiteCultures = _cultureManager.ListCultures().Where(s => s != _localizationService.GetContentCulture(contentItem) && s != _cultureManager.GetSiteCulture()); model.SiteCultures = _cultureManager.ListCultures().Where(s => s != _localizationService.GetContentCulture(contentItem) && s != _cultureManager.GetSiteCulture());
contentItem.As<LocalizationPart>().Culture.Culture = null; contentItem.As<LocalizationPart>().Culture.Culture = null;
model.Content = _contentManager.BuildEditorModel(contentItem); model.Content = _contentManager.BuildEditor(contentItem);
return View(model); return View(model);
} }

View File

@@ -22,15 +22,15 @@ namespace Orchard.Core.Localization.Drivers {
_localizationService = localizationService; _localizationService = localizationService;
} }
protected override DriverResult Display(LocalizationPart part, string displayType) { protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
var model = new ContentLocalizationsViewModel(part) { var contentTranslations = shapeHelper.Localization_ContentTranslations(ContentPart: part, Localizations: GetDisplayLocalizations(part));
Localizations = GetDisplayLocalizations(part) if (!string.IsNullOrWhiteSpace(displayType))
}; contentTranslations.Metadata.Type = string.Format("{0}.{1}", contentTranslations.Metadata.Type, displayType);
var location = part.GetLocation(displayType);
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations", TemplatePrefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType)); return ContentShape(contentTranslations).Location(location);
} }
protected override DriverResult Editor(LocalizationPart part) { protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
var localizations = GetEditorLocalizations(part).ToList(); var localizations = GetEditorLocalizations(part).ToList();
var model = new EditLocalizationViewModel { var model = new EditLocalizationViewModel {
SelectedCulture = part.Culture != null ? part.Culture.Culture : null, SelectedCulture = part.Culture != null ? part.Culture.Culture : null,
@@ -43,13 +43,13 @@ namespace Orchard.Core.Localization.Drivers {
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location(part.GetLocation("Editor")); return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location(part.GetLocation("Editor"));
} }
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater) { protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = new EditLocalizationViewModel(); var model = new EditLocalizationViewModel();
if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null)) { if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null)) {
_localizationService.SetContentCulture(part, model.SelectedCulture); _localizationService.SetContentCulture(part, model.SelectedCulture);
} }
return Editor(part); return Editor(part, shapeHelper);
} }
private IEnumerable<LocalizationPart> GetDisplayLocalizations(LocalizationPart part) { private IEnumerable<LocalizationPart> GetDisplayLocalizations(LocalizationPart part) {

View File

@@ -1,12 +0,0 @@
@model Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel
@{
Style.Require("Localization");
}
@if (Model.Localizations.Count() > 0) {
<div class="content-localization">
<div class="content-localizations">
<h4>@T("Translations:")</h4>
@Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
</div>
</div>
}

View File

@@ -0,0 +1,13 @@
@using Orchard.Core.Localization.Models;
@{
Style.Require("Localization");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
}
@if (localizations != null && localizations.Count() > 0) {
<div class="content-localization">
<div class="content-localizations">
<h4>@T("Translations:")</h4>
@Html.UnorderedList(localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
</div>
</div>
}

View File

@@ -22,7 +22,7 @@ namespace Orchard.Core.Messaging.Drivers {
protected override string Prefix { get { return "MessageSettings"; } } protected override string Prefix { get { return "MessageSettings"; } }
protected override DriverResult Editor(MessageSettingsPart part) { protected override DriverResult Editor(MessageSettingsPart part, dynamic shapeHelper) {
var model = new MessageSettingsPartViewModel { var model = new MessageSettingsPartViewModel {
ChannelServices = _messageQueueManager.GetAvailableChannelServices(), ChannelServices = _messageQueueManager.GetAvailableChannelServices(),
@@ -32,7 +32,7 @@ namespace Orchard.Core.Messaging.Drivers {
return ContentPartTemplate(model, "Parts/Messaging.MessageSettings"); return ContentPartTemplate(model, "Parts/Messaging.MessageSettings");
} }
protected override DriverResult Editor(MessageSettingsPart part, IUpdateModel updater) { protected override DriverResult Editor(MessageSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = new MessageSettingsPartViewModel { var model = new MessageSettingsPartViewModel {
MessageSettings = part MessageSettings = part
}; };

View File

@@ -87,7 +87,7 @@ namespace Orchard.Core.Navigation.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var menuPart = _services.ContentManager.New<MenuPart>("MenuItem"); var menuPart = _services.ContentManager.New<MenuPart>("MenuItem");
model.MenuItem = _services.ContentManager.UpdateEditorModel(menuPart, this); model.MenuItem = _services.ContentManager.UpdateEditor(menuPart, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_services.TransactionManager.Cancel(); _services.TransactionManager.Cancel();

View File

@@ -15,7 +15,7 @@ namespace Orchard.Core.Navigation.Drivers {
_workContextAccessor = workContextAccessor; _workContextAccessor = workContextAccessor;
} }
protected override DriverResult Editor(MenuItemPart itemPart, IUpdateModel updater) { protected override DriverResult Editor(MenuItemPart itemPart, IUpdateModel updater, dynamic shapeHelper) {
//todo: (heskew) need context //todo: (heskew) need context
var currentUser = _workContextAccessor.GetContext().CurrentUser; var currentUser = _workContextAccessor.GetContext().CurrentUser;

View File

@@ -24,14 +24,14 @@ namespace Orchard.Core.Navigation.Drivers {
public virtual IUser CurrentUser { get; set; } public virtual IUser CurrentUser { get; set; }
public Localizer T { get; set; } public Localizer T { get; set; }
protected override DriverResult Editor(MenuPart part) { protected override DriverResult Editor(MenuPart part, dynamic shapeHelper) {
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
return null; return null;
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(part.GetLocation("Editor")); return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(part.GetLocation("Editor"));
} }
protected override DriverResult Editor(MenuPart part, IUpdateModel updater) { protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) { if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) {
return null; return null;
} }

View File

@@ -132,7 +132,7 @@
<Compile Include="Reports\ViewModels\DisplayReportViewModel.cs" /> <Compile Include="Reports\ViewModels\DisplayReportViewModel.cs" />
<Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" /> <Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" />
<Compile Include="Routable\Controllers\ItemController.cs" /> <Compile Include="Routable\Controllers\ItemController.cs" />
<Compile Include="Routable\DataMigrations\RoutableDataMigration.cs" /> <Compile Include="Routable\Migrations.cs" />
<Compile Include="Routable\Drivers\RoutePartDriver.cs" /> <Compile Include="Routable\Drivers\RoutePartDriver.cs" />
<Compile Include="Routable\Handlers\RoutePartHandler.cs" /> <Compile Include="Routable\Handlers\RoutePartHandler.cs" />
<Compile Include="Routable\IRoutablePathConstraint.cs" /> <Compile Include="Routable\IRoutablePathConstraint.cs" />
@@ -254,12 +254,12 @@
<Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.cshtml" /> <Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.cshtml" />
<Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.cshtml" /> <Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.SummaryAdmin.cshtml" /> <Content Include="Common\Views\Common.Body.SummaryAdmin.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.SummaryAdmin.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.SummaryAdmin.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.SummaryAdmin.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.SummaryAdmin.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.SummaryAdmin.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.SummaryAdmin.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.cshtml" /> <Content Include="Common\Views\Common.Metadata.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.SummaryAdmin.cshtml" /> <Content Include="Common\Views\Common.Metadata.SummaryAdmin.cshtml" />
<Content Include="ContentsLocation\Module.txt" /> <Content Include="ContentsLocation\Module.txt" />
<Content Include="ContentsLocation\Styles\admin.css" /> <Content Include="ContentsLocation\Styles\admin.css" />
<Content Include="ContentsLocation\Views\DefinitionTemplates\LocationSettings.cshtml" /> <Content Include="ContentsLocation\Views\DefinitionTemplates\LocationSettings.cshtml" />
@@ -268,8 +268,8 @@
<Content Include="Contents\Views\Admin\List.cshtml" /> <Content Include="Contents\Views\Admin\List.cshtml" />
<Content Include="Feeds\Views\Feed.cshtml" /> <Content Include="Feeds\Views\Feed.cshtml" />
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.cshtml" /> <Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.cshtml" />
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.cshtml" /> <Content Include="Contents\Views\Contents.Publish.cshtml" />
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.SummaryAdmin.cshtml" /> <Content Include="Contents\Views\Contents.Publish.SummaryAdmin.cshtml" />
<Content Include="Messaging\Module.txt" /> <Content Include="Messaging\Module.txt" />
<Content Include="Messaging\Views\EditorTemplates\Parts\Messaging.MessageSettings.cshtml" /> <Content Include="Messaging\Views\EditorTemplates\Parts\Messaging.MessageSettings.cshtml" />
<Content Include="PublishLater\Content\Admin\images\draft.gif" /> <Content Include="PublishLater\Content\Admin\images\draft.gif" />
@@ -277,8 +277,8 @@
<Content Include="PublishLater\Content\Admin\images\online.gif" /> <Content Include="PublishLater\Content\Admin\images\online.gif" />
<Content Include="PublishLater\Content\Admin\images\published.gif" /> <Content Include="PublishLater\Content\Admin\images\published.gif" />
<Content Include="PublishLater\Content\Admin\images\scheduled.gif" /> <Content Include="PublishLater\Content\Admin\images\scheduled.gif" />
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.cshtml" /> <Content Include="PublishLater\Views\PublishLater.Metadata.cshtml" />
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.SummaryAdmin.cshtml" /> <Content Include="PublishLater\Views\PublishLater.Metadata.SummaryAdmin.cshtml" />
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.cshtml" /> <Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.cshtml" />
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.cshtml" /> <Content Include="Common\Views\EditorTemplates\Parts\Common.Container.cshtml" />
<Content Include="Common\Views\EditorTemplates\PlainTextEditor.cshtml" /> <Content Include="Common\Views\EditorTemplates\PlainTextEditor.cshtml" />
@@ -286,8 +286,8 @@
<Content Include="Contents\Views\Admin\CreatableTypeList.cshtml" /> <Content Include="Contents\Views\Admin\CreatableTypeList.cshtml" />
<Content Include="Localization\Styles\admin.css" /> <Content Include="Localization\Styles\admin.css" />
<Content Include="Localization\Styles\base.css" /> <Content Include="Localization\Styles\base.css" />
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.Summary.cshtml" /> <Content Include="Localization\Views\Localization.ContentTranslations.Summary.cshtml" />
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.cshtml" /> <Content Include="Localization\Views\Localization.ContentTranslations.cshtml" />
<Content Include="PublishLater\Module.txt" /> <Content Include="PublishLater\Module.txt" />
<Content Include="PublishLater\Styles\datetime.css" /> <Content Include="PublishLater\Styles\datetime.css" />
<Content Include="PublishLater\Views\EditorTemplates\Parts\PublishLater.cshtml" /> <Content Include="PublishLater\Views\EditorTemplates\Parts\PublishLater.cshtml" />
@@ -296,12 +296,11 @@
<Content Include="Reports\Views\Admin\Index.cshtml" /> <Content Include="Reports\Views\Admin\Index.cshtml" />
<Content Include="Localization\Module.txt" /> <Content Include="Localization\Module.txt" />
<Content Include="Localization\Views\Admin\Translate.cshtml" /> <Content Include="Localization\Views\Admin\Translate.cshtml" />
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.SummaryAdmin.cshtml" /> <Content Include="Localization\Views\Localization.ContentTranslations.SummaryAdmin.cshtml" />
<Content Include="Localization\Views\CultureSelection.cshtml" /> <Content Include="Localization\Views\CultureSelection.cshtml" />
<Content Include="Routable\Module.txt" /> <Content Include="Routable\Module.txt" />
<Content Include="Routable\Scripts\jquery.slugify.js" /> <Content Include="Routable\Scripts\jquery.slugify.js" />
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.RoutePart.cshtml" /> <Content Include="Routable\Views\EditorTemplates\Parts\Routable.RoutePart.cshtml" />
<Content Include="Routable\Views\DisplayTemplates\Parts\Routable.RoutePart.cshtml" />
<Content Include="Settings\Module.txt" /> <Content Include="Settings\Module.txt" />
<Content Include="Settings\Styles\admin.css" /> <Content Include="Settings\Styles\admin.css" />
<Content Include="Settings\Views\Admin\Index.cshtml" /> <Content Include="Settings\Views\Admin\Index.cshtml" />
@@ -346,7 +345,7 @@
<Content Include="Common\Views\Web.config" /> <Content Include="Common\Views\Web.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.cshtml" /> <Content Include="Common\Views\Common.Body.cshtml" />
<Content Include="Common\Views\EditorTemplates\Parts\Common.Body.cshtml" /> <Content Include="Common\Views\EditorTemplates\Parts\Common.Body.cshtml" />
<Content Include="Common\Views\EditorTemplates\Parts\Common.Owner.cshtml" /> <Content Include="Common\Views\EditorTemplates\Parts\Common.Owner.cshtml" />
<Content Include="Feeds\Module.txt" /> <Content Include="Feeds\Module.txt" />
@@ -362,7 +361,7 @@
<Content Include="Navigation\Views\Web.config" /> <Content Include="Navigation\Views\Web.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Summary.cshtml" /> <Content Include="Common\Views\Common.Body.Summary.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.cshtml" />
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.cshtml" /> <Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.cshtml" />
@@ -391,6 +390,7 @@
<Content Include="Shapes\Views\MenuItem.cshtml" /> <Content Include="Shapes\Views\MenuItem.cshtml" />
<Content Include="Shapes\Views\Web.config" /> <Content Include="Shapes\Views\Web.config" />
<Content Include="Dashboard\Views\Helper\Index.cshtml" /> <Content Include="Dashboard\Views\Helper\Index.cshtml" />
<Content Include="Routable\Views\Routable.RoutePart.cshtml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -7,7 +7,6 @@ using Orchard.Core.PublishLater.Models;
using Orchard.Core.PublishLater.Services; using Orchard.Core.PublishLater.Services;
using Orchard.Core.PublishLater.ViewModels; using Orchard.Core.PublishLater.ViewModels;
using Orchard.Localization; using Orchard.Localization;
using Orchard.UI.Notify;
namespace Orchard.Core.PublishLater.Drivers { namespace Orchard.Core.PublishLater.Drivers {
public class PublishLaterPartDriver : ContentPartDriver<PublishLaterPart> { public class PublishLaterPartDriver : ContentPartDriver<PublishLaterPart> {
@@ -28,18 +27,19 @@ namespace Orchard.Core.PublishLater.Drivers {
public Localizer T { get; set; } public Localizer T { get; set; }
public IOrchardServices Services { get; set; } public IOrchardServices Services { get; set; }
protected override DriverResult Display(PublishLaterPart part, string displayType) { protected override DriverResult Display(PublishLaterPart part, string displayType, dynamic shapeHelper) {
var model = new PublishLaterViewModel(part) { var metadata = shapeHelper.PublishLater_Metadata(ContentPart: part, ScheduledPublishUtc: part.ScheduledPublishUtc.Value);
ScheduledPublishUtc = part.ScheduledPublishUtc.Value if (!string.IsNullOrWhiteSpace(displayType))
}; metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType)); var location = part.GetLocation(displayType);
return ContentShape(metadata).Location(location);
} }
protected override DriverResult Editor(PublishLaterPart part) { protected override DriverResult Editor(PublishLaterPart part, dynamic shapeHelper) {
return PublishEditor(part, null); return PublishEditor(part, null);
} }
protected override DriverResult Editor(PublishLaterPart instance, IUpdateModel updater) { protected override DriverResult Editor(PublishLaterPart instance, IUpdateModel updater, dynamic shapeHelper) {
return PublishEditor(instance, updater); return PublishEditor(instance, updater);
} }

View File

@@ -43,7 +43,7 @@ namespace Orchard.Core.Routable.Controllers {
throw new ApplicationException("Ambiguous content"); throw new ApplicationException("Ambiguous content");
} }
var model = _contentManager.BuildDisplayModel<IRoutableAspect>(hits.Single()); var model = _contentManager.BuildDisplay(hits.Single());
return View(model); return View(model);
} }
@@ -66,7 +66,7 @@ namespace Orchard.Core.Routable.Controllers {
} }
} }
_contentManager.UpdateEditorModel(contentItem, this); _contentManager.UpdateEditor(contentItem, this);
_transactionManager.Cancel(); _transactionManager.Cancel();
return Json(contentItem.As<IRoutableAspect>().Slug ?? slug); return Json(contentItem.As<IRoutableAspect>().Slug ?? slug);

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement; using Orchard.ContentManagement;
@@ -35,7 +36,7 @@ namespace Orchard.Core.Routable.Drivers {
get { return "Routable"; } get { return "Routable"; }
} }
int? GetContainerId(IContent item) { static int? GetContainerId(IContent item) {
var commonPart = item.As<ICommonPart>(); var commonPart = item.As<ICommonPart>();
if (commonPart != null && commonPart.Container != null) { if (commonPart != null && commonPart.Container != null) {
return commonPart.Container.ContentItem.Id; return commonPart.Container.ContentItem.Id;
@@ -43,18 +44,15 @@ namespace Orchard.Core.Routable.Drivers {
return null; return null;
} }
protected override DriverResult Display(RoutePart part, string displayType) { protected override DriverResult Display(RoutePart part, string displayType, dynamic shapeHelper) {
var model = new RoutableDisplayViewModel {RoutePart = part}; var routePart = shapeHelper.Routable_RoutePart(ContentPart: part, Title: part.Title);
var location = part.GetLocation(displayType); if (!string.IsNullOrWhiteSpace(displayType))
routePart.Metadata.Type = string.Format("{0}.{1}", routePart.Metadata.Type, displayType);
//todo: give this part a default location var location = part.GetLocation(displayType, "Header", "5");
if (location == null || location.Zone == null) return ContentShape(routePart).Location(location);
location = new ContentLocation {Position = "5", Zone = "Header"};
return ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location);
} }
protected override DriverResult Editor(RoutePart part) { protected override DriverResult Editor(RoutePart part, dynamic shapeHelper) {
var model = new RoutableEditorViewModel { var model = new RoutableEditorViewModel {
ContentType = part.ContentItem.ContentType, ContentType = part.ContentItem.ContentType,
Id = part.ContentItem.Id, Id = part.ContentItem.Id,
@@ -81,7 +79,7 @@ namespace Orchard.Core.Routable.Drivers {
return ContentPartTemplate(model, TemplateName, Prefix).Location(location); return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
} }
protected override DriverResult Editor(RoutePart part, IUpdateModel updater) { protected override DriverResult Editor(RoutePart part, IUpdateModel updater, dynamic shapeHelper) {
var model = new RoutableEditorViewModel(); var model = new RoutableEditorViewModel();
updater.TryUpdateModel(model, Prefix, null, null); updater.TryUpdateModel(model, Prefix, null, null);
@@ -105,7 +103,7 @@ namespace Orchard.Core.Routable.Drivers {
CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id); CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
} }
return Editor(part); return Editor(part, shapeHelper);
} }
} }
} }

View File

@@ -48,8 +48,8 @@ namespace Orchard.Core.Routable.Handlers {
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze()); OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
} }
private static void SetModelProperties(BuildModelContext context, RoutePart routable) { private static void SetModelProperties(BuildShapeContext context, RoutePart routable) {
var item = context.Model; var item = context.Shape;
item.Title = routable.Title; item.Title = routable.Title;
item.Slug = routable.Slug; item.Slug = routable.Slug;
item.Path = routable.Path; item.Path = routable.Path;

View File

@@ -6,8 +6,8 @@ using Orchard.Core.Contents.Extensions;
using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Models;
using Orchard.Data.Migration; using Orchard.Data.Migration;
namespace Orchard.Core.Routable.DataMigrations { namespace Orchard.Core.Routable {
public class RoutableDataMigration : DataMigrationImpl { public class Migrations : DataMigrationImpl {
public int Create() { public int Create() {
//CREATE TABLE Routable_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id)); //CREATE TABLE Routable_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id));

View File

@@ -37,7 +37,7 @@ namespace Orchard.Core.Routable.Services {
if (contentItem == null || !contentItem.Is<RoutePart>()) if (contentItem == null || !contentItem.Is<RoutePart>())
return new NotFoundResult(); return new NotFoundResult();
var model = _contentManager.BuildDisplayModel(contentItem); var model = _contentManager.BuildDisplay(contentItem);
return new ViewResult { return new ViewResult {
ViewName = "Display", ViewName = "Display",

View File

@@ -1,2 +0,0 @@
@model Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel
<h1>@Model.Title</h1>

View File

@@ -0,0 +1 @@
<h1>@Model.Title</h1>

View File

@@ -36,7 +36,7 @@ namespace Orchard.Core.Settings.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageSettings, T("Not authorized to manage settings"))) if (!Services.Authorizer.Authorize(Permissions.ManageSettings, T("Not authorized to manage settings")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var model = Services.ContentManager.BuildEditorModel(_siteService.GetSiteSettings()); var model = Services.ContentManager.BuildEditor(_siteService.GetSiteSettings());
return View(model); return View(model);
} }
@@ -47,7 +47,7 @@ namespace Orchard.Core.Settings.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var site = _siteService.GetSiteSettings(); var site = _siteService.GetSiteSettings();
var model = Services.ContentManager.UpdateEditorModel(site, this); var model = Services.ContentManager.UpdateEditor(site, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();

View File

@@ -19,7 +19,7 @@ namespace Orchard.Core.Settings.Drivers {
protected override string Prefix { get { return "SiteSettings"; } } protected override string Prefix { get { return "SiteSettings"; } }
protected override DriverResult Editor(SiteSettingsPart part) { protected override DriverResult Editor(SiteSettingsPart part, dynamic shapeHelper) {
var site = _siteService.GetSiteSettings().As<SiteSettingsPart>(); var site = _siteService.GetSiteSettings().As<SiteSettingsPart>();
var model = new SiteSettingsPartViewModel { var model = new SiteSettingsPartViewModel {
@@ -30,7 +30,7 @@ namespace Orchard.Core.Settings.Drivers {
return ContentPartTemplate(model, "Parts/Settings.SiteSettingsPart"); return ContentPartTemplate(model, "Parts/Settings.SiteSettingsPart");
} }
protected override DriverResult Editor(SiteSettingsPart part, IUpdateModel updater) { protected override DriverResult Editor(SiteSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
var site = _siteService.GetSiteSettings().As<SiteSettingsPart>(); var site = _siteService.GetSiteSettings().As<SiteSettingsPart>();
var model = new SiteSettingsPartViewModel { Site = site }; var model = new SiteSettingsPartViewModel { Site = site };

View File

@@ -28,18 +28,19 @@ namespace ArchiveLater.Drivers {
public Localizer T { get; set; } public Localizer T { get; set; }
public IOrchardServices Services { get; set; } public IOrchardServices Services { get; set; }
protected override DriverResult Display(ArchiveLaterPart part, string displayType) { protected override DriverResult Display(ArchiveLaterPart part, string displayType, dynamic shapeHelper) {
var model = new ArchiveLaterViewModel(part) { var metadata = shapeHelper.ArchiveLater_Metadata(ContentPart: part, ScheduledArchiveUtc: part.ScheduledArchiveUtc.Value);
ScheduledArchiveUtc = part.ScheduledArchiveUtc.Value if (!string.IsNullOrWhiteSpace(displayType))
}; metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
return ContentPartTemplate(model, "Parts/ArchiveLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType)); var location = part.GetLocation(displayType);
return ContentShape(metadata).Location(location);
} }
protected override DriverResult Editor(ArchiveLaterPart part) { protected override DriverResult Editor(ArchiveLaterPart part, dynamic shapeHelper) {
return ArchiveEditor(part, null); return ArchiveEditor(part, null);
} }
protected override DriverResult Editor(ArchiveLaterPart instance, IUpdateModel updater) { protected override DriverResult Editor(ArchiveLaterPart instance, IUpdateModel updater, dynamic shapeHelper) {
return ArchiveEditor(instance, updater); return ArchiveEditor(instance, updater);
} }

View File

@@ -98,8 +98,8 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\DisplayTemplates\Parts\ArchiveLater.Metadata.cshtml" /> <Content Include="Views\ArchiveLater.Metadata.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\ArchiveLater.Metadata.SummaryAdmin.cshtml" /> <Content Include="Views\ArchiveLater.Metadata.SummaryAdmin.cshtml" />
<Content Include="Views\EditorTemplates\Parts\ArchiveLater.cshtml" /> <Content Include="Views\EditorTemplates\Parts\ArchiveLater.cshtml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

View File

@@ -52,7 +52,7 @@ namespace Orchard.Blogs.Controllers {
if (blog == null) if (blog == null)
return new NotFoundResult(); return new NotFoundResult();
var model = Services.ContentManager.BuildEditorModel(blog); var model = Services.ContentManager.BuildEditor(blog);
return View(model); return View(model);
} }
@@ -64,7 +64,7 @@ namespace Orchard.Blogs.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
_contentManager.Create(blog, VersionOptions.Draft); _contentManager.Create(blog, VersionOptions.Draft);
var model = _contentManager.UpdateEditorModel(blog, this); var model = _contentManager.UpdateEditor(blog, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
@@ -88,7 +88,7 @@ namespace Orchard.Blogs.Controllers {
if (blog == null) if (blog == null)
return new NotFoundResult(); return new NotFoundResult();
var model = Services.ContentManager.BuildEditorModel(blog); var model = Services.ContentManager.BuildEditor(blog);
return View(model); return View(model);
} }
@@ -102,7 +102,7 @@ namespace Orchard.Blogs.Controllers {
if (blog == null) if (blog == null)
return new NotFoundResult(); return new NotFoundResult();
var model = Services.ContentManager.UpdateEditorModel(blog, this); var model = Services.ContentManager.UpdateEditor(blog, this);
if (!ModelState.IsValid) if (!ModelState.IsValid)
return View(model); return View(model);
@@ -132,7 +132,7 @@ namespace Orchard.Blogs.Controllers {
var list = Shape.List(); var list = Shape.List();
list.AddRange(_blogService.Get() list.AddRange(_blogService.Get()
.Select(b => { .Select(b => {
var blog = Services.ContentManager.BuildDisplayModel(b, "SummaryAdmin.Blog"); var blog = Services.ContentManager.BuildDisplay(b, "SummaryAdmin.Blog");
blog.TotalPostCount = _blogPostService.Get(b, VersionOptions.Latest).Count(); blog.TotalPostCount = _blogPostService.Get(b, VersionOptions.Latest).Count();
return blog; return blog;
})); }));
@@ -151,7 +151,7 @@ namespace Orchard.Blogs.Controllers {
return new NotFoundResult(); return new NotFoundResult();
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed //TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
var model = Services.ContentManager.BuildDisplayModel(blogPart, "Admin.Blog"); var model = Services.ContentManager.BuildDisplay(blogPart, "Admin.Blog");
return View(model); return View(model);
} }

View File

@@ -32,7 +32,7 @@ namespace Orchard.Blogs.Controllers {
protected ILogger Logger { get; set; } protected ILogger Logger { get; set; }
public ActionResult List() { public ActionResult List() {
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary.Blog")); var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplay(b, "Summary.Blog"));
var list = Shape.List(); var list = Shape.List();
list.AddRange(blogs); list.AddRange(blogs);
@@ -53,7 +53,8 @@ namespace Orchard.Blogs.Controllers {
if (blog == null) if (blog == null)
return new NotFoundResult(); return new NotFoundResult();
var model = _services.ContentManager.BuildDisplayModel(blog, "Blog"); //todo: (heskew) "Blog" should be an alternative instead of a display type
var model = _services.ContentManager.BuildDisplay(blog, "Blog");
return View(model); return View(model);
} }

View File

@@ -34,7 +34,7 @@ namespace Orchard.Blogs.Controllers {
if (blogPost.BlogPart == null) if (blogPost.BlogPart == null)
return new NotFoundResult(); return new NotFoundResult();
var model = Services.ContentManager.BuildEditorModel(blogPost); var model = Services.ContentManager.BuildEditor(blogPost);
//todo: (heskew) unhack //todo: (heskew) unhack
model.Metadata.Type += ".BlogPost"; model.Metadata.Type += ".BlogPost";
@@ -52,7 +52,7 @@ namespace Orchard.Blogs.Controllers {
return new NotFoundResult(); return new NotFoundResult();
Services.ContentManager.Create(blogPost, VersionOptions.Draft); Services.ContentManager.Create(blogPost, VersionOptions.Draft);
var model = Services.ContentManager.UpdateEditorModel(blogPost, this); var model = Services.ContentManager.UpdateEditor(blogPost, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
@@ -80,7 +80,7 @@ namespace Orchard.Blogs.Controllers {
if (post == null) if (post == null)
return new NotFoundResult(); return new NotFoundResult();
var model = Services.ContentManager.BuildEditorModel(post); var model = Services.ContentManager.BuildEditor(post);
//todo: (heskew) unhack //todo: (heskew) unhack
model.Metadata.Type += ".BlogPost"; model.Metadata.Type += ".BlogPost";
@@ -103,7 +103,7 @@ namespace Orchard.Blogs.Controllers {
return new NotFoundResult(); return new NotFoundResult();
// Validate form input // Validate form input
var model = Services.ContentManager.UpdateEditorModel(blogPost, this); var model = Services.ContentManager.UpdateEditor(blogPost, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
return View(model); return View(model);

View File

@@ -51,7 +51,7 @@ namespace Orchard.Blogs.Controllers {
if (postPart == null) if (postPart == null)
return new NotFoundResult(); return new NotFoundResult();
var model = _services.ContentManager.BuildDisplayModel(postPart, "BlogPost"); var model = _services.ContentManager.BuildDisplay(postPart, "BlogPost");
return View(model); return View(model);
} }
@@ -66,7 +66,7 @@ namespace Orchard.Blogs.Controllers {
var archive = new ArchiveData(archiveData); var archive = new ArchiveData(archiveData);
var list = Shape.List(); var list = Shape.List();
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary.BlogPost"))); list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary.BlogPost")));
_feedManager.Register(blogPart); _feedManager.Register(blogPart);

View File

@@ -34,38 +34,50 @@ namespace Orchard.Blogs.Drivers {
protected override string Prefix { get { return ""; } } protected override string Prefix { get { return ""; } }
protected override DriverResult Display(BlogPart blogPart, string displayType) { protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
var driverResults = new List<DriverResult>();
var metadata = shapeHelper.Blogs_Blog_Manage(ContentPart: part);
metadata.Metadata.Type = "Blogs_Blog.Manage";
driverResults.Add(ContentShape(metadata).Location("manage"));
var description = shapeHelper.Blogs_Blog_Description(ContentPart: part);
description.Metadata.Type = "Blogs_Blog.Description";
driverResults.Add(ContentShape(description).Location("manage", "after"));
IEnumerable<dynamic > blogPosts = null;
if (displayType.StartsWith("Admin")) { if (displayType.StartsWith("Admin")) {
blogPosts = _blogPostService.Get(blogPart, VersionOptions.Latest) var list = shapeHelper.List();
.Select(bp => _contentManager.BuildDisplayModel(bp, "SummaryAdmin.BlogPost")); list.AddRange(_blogPostService.Get(part, VersionOptions.Latest)
.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin.BlogPost")));
var blogPostList = shapeHelper.Blogs_BlogPost_List(ContentPart: part, BlogPosts: list);
blogPostList.Metadata.Type = "Blogs_BlogPost.List.Admin";
var contentShape = ContentShape(blogPostList).Location("primary");
driverResults.Add(contentShape);
} }
else if (!displayType.Contains("Summary")) { else if (!displayType.Contains("Summary")) {
blogPosts = _blogPostService.Get(blogPart) var list = shapeHelper.List();
.Select(bp => _contentManager.BuildDisplayModel(bp, "Summary.BlogPost")); list.AddRange(_blogPostService.Get(part)
_feedManager.Register(blogPart); .Select(bp => _contentManager.BuildDisplay(bp, "Summary.BlogPost")));
var blogPostList = shapeHelper.Blogs_BlogPost_List(ContentPart: part, BlogPosts: list);
blogPostList.Metadata.Type = "Blogs_BlogPost.List";
var contentShape = ContentShape(blogPostList).Location("primary");
driverResults.Add(contentShape);
_feedManager.Register(part);
} }
var blogPostList = Shape.List(); return Combined(driverResults.ToArray());
blogPostList.AddRange(blogPosts);
return Combined(
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Manage").Location("manage"),
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Metadata").Location("metadata"),
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Description").Location("manage", "after"),
ContentPartTemplate(blogPostList, "Parts/Blogs.BlogPost.List").LongestMatch(displayType, "Admin").Location("primary"));
} }
protected override DriverResult Editor(BlogPart blogPart) { protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
var location = blogPart.GetLocation("Editor"); var location = blogPart.GetLocation("Editor");
return Combined( return Combined(
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Fields").Location(location)); ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Fields").Location(location));
} }
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater) { protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(blogPart, Prefix, null, null); updater.TryUpdateModel(blogPart, Prefix, null, null);
return Editor(blogPart); return Editor(blogPart, shapeHelper);
} }
} }
} }

View File

@@ -21,11 +21,11 @@ namespace Orchard.Blogs.Drivers {
protected override string Prefix { get { return ""; } } protected override string Prefix { get { return ""; } }
protected override DriverResult Display(BlogPostPart part, string displayType) { protected override DriverResult Display(BlogPostPart part, string displayType, dynamic shapeHelper) {
if (displayType.StartsWith("Detail")) if (displayType.StartsWith("Detail"))
_feedManager.Register(part.BlogPart); _feedManager.Register(part.BlogPart);
return base.Display(part, displayType); return null;
} }
} }
} }

View File

@@ -10,8 +10,8 @@ namespace Orchard.Blogs.Handlers {
Filters.Add(StorageFilter.For(repository)); Filters.Add(StorageFilter.For(repository));
OnGetDisplayShape<BlogPart>((context, blog) => { OnGetDisplayShape<BlogPart>((context, blog) => {
context.Model.Description = blog.Description; context.Shape.Description = blog.Description;
context.Model.PostCount = blog.PostCount; context.Shape.PostCount = blog.PostCount;
}); });
} }
} }

View File

@@ -61,8 +61,8 @@ namespace Orchard.Blogs.Handlers {
blogPost => context.ContentManager.Remove(blogPost.ContentItem))); blogPost => context.ContentManager.Remove(blogPost.ContentItem)));
} }
private static void SetModelProperties(BuildModelContext context, BlogPostPart blogPost) { private static void SetModelProperties(BuildShapeContext context, BlogPostPart blogPost) {
context.Model.Blog = blogPost.BlogPart; context.Shape.Blog = blogPost.BlogPart;
} }
Localizer T { get; set; } Localizer T { get; set; }

View File

@@ -122,12 +122,12 @@
<Content Include="Views\BlogPost\ListByArchive.cshtml" /> <Content Include="Views\BlogPost\ListByArchive.cshtml" />
<Content Include="Views\Blog\Item.cshtml" /> <Content Include="Views\Blog\Item.cshtml" />
<Content Include="Views\Blog\List.cshtml" /> <Content Include="Views\Blog\List.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Manage.cshtml" /> <Content Include="Views\Blogs.Blog.Manage.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Description.cshtml" /> <Content Include="Views\Blogs.Blog.Description.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Metadata.cshtml" /> <Content Include="Views\Common.Metadata.Admin.Blog.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.cshtml" /> <Content Include="Views\Blogs.BlogPost.List.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.cshtml" /> <Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.Admin.cshtml"> <Content Include="Views\Blogs.BlogPost.List.Admin.cshtml">
<SubType>Code</SubType> <SubType>Code</SubType>
</Content> </Content>
<Content Include="Views\Items\Content.Admin.Blog.cshtml" /> <Content Include="Views\Items\Content.Admin.Blog.cshtml" />
@@ -154,6 +154,33 @@
<Name>Orchard.Core</Name> <Name>Orchard.Core</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Views\Common.Metadata.Blog.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Localization.ContentTranslations.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Common.Body.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Tags.ShowTags.Summary.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\PublishLater.Metadata.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Common.Metadata.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Localization.ContentTranslations.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Common.Body.BlogPost.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Tags.ShowTags.BlogPost.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -4,6 +4,6 @@
} }
@if (AuthorizedFor(Orchard.Blogs.Permissions.ManageBlogs)) { @if (AuthorizedFor(Orchard.Blogs.Permissions.ManageBlogs)) {
<div class="item-properties actions"> <div class="item-properties actions">
<p><a href="@Url.BlogEdit((string)Model.Slug)" class="edit">@T("Blog Properties")</a></p> <p><a href="@Url.BlogEdit((string)Model.ContentPart.Slug)" class="edit">@T("Blog Properties")</a></p>
</div> </div>
} }

View File

@@ -14,7 +14,7 @@
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button> <button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset> </fieldset>
<fieldset class="contentItems bulk-items"> <fieldset class="contentItems bulk-items">
@Display(Model) @Display(Model.BlogPosts)
</fieldset> </fieldset>
} }
} else { } else {

View File

@@ -0,0 +1,7 @@
@{
IEnumerable<object> blogPosts = Model.BlogPosts;
}
@Display(blogPosts)
@if (blogPosts == null || blogPosts.Count() < 1) {
<p>@T("There are no posts for this blog.")</p>
}

View File

@@ -0,0 +1 @@
@Model.Html

View File

@@ -0,0 +1,9 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Common.ViewModels;
@*doing excerpt generation on the way out for now so we don't stick ourselves with needing to regen excerpts for existing data
also, doing this here, inline, until we have a pluggable processing model (both in and out)
also, ...this is ugly *@
@{
var body = new HtmlString(Html.Excerpt((string)Model.Html.ToString(), 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
}
<p>@body @Html.ItemDisplayLink(T("[more]").ToString(), (IContent)Model.ContentPart.ContentItem)</p>

View File

@@ -0,0 +1,5 @@
@using Orchard.Core.Common.Extensions;
@if (Model.Creator != null) {
<div class="metadata">
<div class="posted">@T("Published by {0} {1}", (string)Model.ContentPart.Creator.UserName, Html.PublishedWhen((DateTime?)Model.ContentPart.VersionPublishedUtc, T))</div>
</div>}

View File

@@ -1,4 +0,0 @@
@Display(Model)
@if (Model.Items.Count < 1) {
<p>@T("There are no posts for this blog.")</p>
}

View File

@@ -0,0 +1,13 @@
@using Orchard.Core.Localization.Models;
@{
Style.Require("Localization");
IEnumerable<LocalizationPart> localizations = Model.Localizations;
}
@if (localizations != null && localizations.Count() > 0) {
<div class="content-localization">
<div class="content-localizations">
<h4>@T("Translations:")</h4>
@Html.UnorderedList(localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
</div>
</div>
}

View File

@@ -0,0 +1,16 @@
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.Tags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(", "));
}
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -0,0 +1,16 @@
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.Tags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(", "));
}
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -13,13 +13,13 @@ namespace Orchard.Comments.Drivers {
protected override string Prefix { get { return "CommentSettings"; } } protected override string Prefix { get { return "CommentSettings"; } }
protected override DriverResult Editor(CommentSettingsPart part) { protected override DriverResult Editor(CommentSettingsPart part, dynamic shapeHelper) {
return ContentPartTemplate(part.Record, "Parts/Comments.SiteSettings"); return ContentPartTemplate(part.Record, "Parts/Comments.SiteSettings");
} }
protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater) { protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part.Record, Prefix, null, null); updater.TryUpdateModel(part.Record, Prefix, null, null);
return Editor(part); return Editor(part, shapeHelper);
} }
} }
} }

View File

@@ -1,7 +1,6 @@
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Comments.Models; using Orchard.Comments.Models;
using Orchard.Comments.ViewModels;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
@@ -10,27 +9,23 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers { namespace Orchard.Comments.Drivers {
[UsedImplicitly] [UsedImplicitly]
public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> { public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> {
protected override DriverResult Display(CommentsContainerPart part, string displayType) { protected override DriverResult Display(CommentsContainerPart part, string displayType, dynamic shapeHelper) {
if (displayType == "SummaryAdmin") { if (displayType.Contains("Summary")) {
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin")); // Find all contents item with this part as the container
} var parts = part.ContentItem.ContentManager.Query()
else if (displayType.Contains("Summary")) { .Where<CommonPartRecord>(rec => rec.Container == part.ContentItem.Record).List();
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location(part.GetLocation("Summary"));
// Count comments and create template
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
if (displayType == "SummaryAdmin")
return ContentShape(shapeHelper.Comments_CountAdmin(ContentPart: part, CommentCount: count, PendingCount: pendingCount)).Location(part.GetLocation("SummaryAdmin"));
return ContentShape(shapeHelper.Comments_Count(ContentPart: part, CommentCount: count, PendingCount: pendingCount)).Location(part.GetLocation("Summary"));
} }
return null; return null;
} }
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
// Find all contents item with this part as the container
var parts = contentItem.ContentManager.Query()
.Where<CommonPartRecord>(rec => rec.Container == contentItem.Record).List();
// Count comments and create template
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
return new CommentCountViewModel { Item = contentItem, CommentCount = count, PendingCount = pendingCount};
}
} }
} }

View File

@@ -1,6 +1,5 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Comments.Models; using Orchard.Comments.Models;
using Orchard.Comments.ViewModels;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models; using Orchard.Core.ContentsLocation.Models;
@@ -8,35 +7,30 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers { namespace Orchard.Comments.Drivers {
[UsedImplicitly] [UsedImplicitly]
public class CommentsPartDriver : ContentPartDriver<CommentsPart> { public class CommentsPartDriver : ContentPartDriver<CommentsPart> {
protected override DriverResult Display(CommentsPart part, string displayType) { protected override DriverResult Display(CommentsPart part, string displayType, dynamic shapeHelper) {
if (part.CommentsShown == false) { if (part.CommentsShown == false)
return null; return null;
}
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the... if (displayType.StartsWith("Detail"))
// comment count go in any given skin or what if the skin builder doesn't want the count return ContentShape(shapeHelper.Comments_Comments(ContentPart: part)).Location(part.GetLocation("Detail"));
if (displayType.StartsWith("Detail")) {
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Detail")); if (displayType == "SummaryAdmin")
} return ContentShape(shapeHelper.Comments_CountAdmin(ContentPart: part, CommentCount: part.Comments.Count, PendingCount: part.PendingComments.Count))
else if (displayType == "SummaryAdmin") { .Location(part.GetLocation("SummaryAdmin"));
var model = new CommentCountViewModel(part);
return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin")); var location = displayType.Contains("Summary")
} ? part.GetLocation("Summary")
else if (displayType.Contains("Summary")) { : part.GetLocation(displayType);
var model = new CommentCountViewModel(part);
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation("Summary")); return ContentShape(shapeHelper.Comments_Count(ContentPart: part, CommentCount: part.Comments.Count, PendingCount: part.PendingComments.Count))
} .Location(location);
else {
var model = new CommentCountViewModel(part);
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation(displayType));
}
} }
protected override DriverResult Editor(CommentsPart part) { protected override DriverResult Editor(CommentsPart part, dynamic shapeHelper) {
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor")); return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
} }
protected override DriverResult Editor(CommentsPart part, IUpdateModel updater) { protected override DriverResult Editor(CommentsPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part, Prefix, null, null); updater.TryUpdateModel(part, Prefix, null, null);
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor")); return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
} }

View File

@@ -43,6 +43,7 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\joel.net.akismet\Joel.Net.Akismet.dll</HintPath> <HintPath>..\..\..\..\lib\joel.net.akismet\Joel.Net.Akismet.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations"> <Reference Include="System.ComponentModel.DataAnnotations">
@@ -126,9 +127,9 @@
<Content Include="Views\Admin\Details.cshtml" /> <Content Include="Views\Admin\Details.cshtml" />
<Content Include="Views\Admin\Edit.cshtml" /> <Content Include="Views\Admin\Edit.cshtml" />
<Content Include="Views\Admin\Index.cshtml" /> <Content Include="Views\Admin\Index.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Comments.cshtml" /> <Content Include="Views\Comments.Comments.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Count.cshtml" /> <Content Include="Views\Comments.Count.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Comments.CountAdmin.cshtml" /> <Content Include="Views\Comments.CountAdmin.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Comments.Comments.cshtml" /> <Content Include="Views\EditorTemplates\Parts\Comments.Comments.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.cshtml" /> <Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.cshtml" />
<Content Include="Views\ListOfComments.cshtml" /> <Content Include="Views\ListOfComments.cshtml" />

View File

@@ -0,0 +1,2 @@
@using Orchard.Comments.ViewModels;
<span class="commentcount">@T.Plural("1 Comment", "{0} Comments", (int)Model.CommentCount)</span>

View File

@@ -1,4 +0,0 @@
@model Orchard.Comments.ViewModels.CommentCountViewModel
@using Orchard.Comments.ViewModels;
<span class="commentcount">@T.Plural("1 Comment", "{0} Comments", Model.CommentCount)</span>

View File

@@ -17,13 +17,13 @@ namespace Orchard.Email.Drivers {
protected override string Prefix { get { return "SmtpSettings"; } } protected override string Prefix { get { return "SmtpSettings"; } }
protected override DriverResult Editor(SmtpSettingsPart part) { protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) {
return ContentPartTemplate(part, "Parts/Smtp.SiteSettings"); return ContentPartTemplate(part, "Parts/Smtp.SiteSettings");
} }
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater) { protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part, Prefix, null, null); updater.TryUpdateModel(part, Prefix, null, null);
return Editor(part); return Editor(part, shapeHelper);
} }
} }
} }

View File

@@ -39,6 +39,7 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations"> <Reference Include="System.ComponentModel.DataAnnotations">

View File

@@ -39,8 +39,8 @@ namespace Orchard.Experimental.Controllers {
.Select(x => x.GetType()) .Select(x => x.GetType())
.SelectMany(x => AllTypes(x)) .SelectMany(x => AllTypes(x))
.Distinct(); .Distinct();
model.DisplayShape = _contentManager.BuildDisplayModel(model.Item, "Detail"); model.DisplayShape = _contentManager.BuildDisplay(model.Item, "Detail");
model.EditorShape = _contentManager.BuildEditorModel(model.Item); model.EditorShape = _contentManager.BuildEditor(model.Item);
return View(Shape.Model(model)); return View(Shape.Model(model));
} }

View File

@@ -5,15 +5,15 @@ using Orchard.Experimental.Models;
namespace Orchard.Experimental.Handlers { namespace Orchard.Experimental.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class DebugLinkHandler : ContentHandler { public class DebugLinkHandler : ContentHandler {
protected override void BuildDisplayShape(BuildDisplayModelContext context) { protected override void BuildDisplayShape(BuildDisplayContext context) {
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>(); var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
if (experimentalSettings.ShowDebugLinks) if (experimentalSettings.ShowDebugLinks)
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999"); context.Shape.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
} }
protected override void BuildEditorShape(BuildEditorModelContext context) { protected override void BuildEditorShape(BuildEditorContext context) {
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>(); var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
if (experimentalSettings.ShowDebugLinks) if (experimentalSettings.ShowDebugLinks)
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999"); context.Shape.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
} }
} }
} }

View File

@@ -41,7 +41,7 @@ namespace Orchard.Roles.Drivers {
public Localizer T { get; set; } public Localizer T { get; set; }
protected override DriverResult Editor(UserRolesPart userRolesPart) { protected override DriverResult Editor(UserRolesPart userRolesPart, dynamic shapeHelper) {
// don't show editor without apply roles permission // don't show editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart)) if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null; return null;
@@ -62,7 +62,7 @@ namespace Orchard.Roles.Drivers {
return ContentPartTemplate(model, "Parts/Roles.UserRoles"); return ContentPartTemplate(model, "Parts/Roles.UserRoles");
} }
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater) { protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater, dynamic shapeHelper) {
// don't apply editor without apply roles permission // don't apply editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart)) if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null; return null;

View File

@@ -43,7 +43,7 @@ namespace Orchard.Search.Controllers {
} }
searchResultViewModels.Add(new SearchResultViewModel { searchResultViewModels.Add(new SearchResultViewModel {
Content = _contentManager.BuildDisplayModel(contentItem, "SummaryForSearch"), Content = _contentManager.BuildDisplay(contentItem, "SummaryForSearch"),
SearchHit = searchHit SearchHit = searchHit
}); });
} }

View File

@@ -23,7 +23,7 @@ namespace Orchard.Search.Drivers {
protected override string Prefix { get { return "SearchSettings"; } } protected override string Prefix { get { return "SearchSettings"; } }
protected override DriverResult Editor(SearchSettingsPart part) { protected override DriverResult Editor(SearchSettingsPart part, dynamic shapeHelper) {
var model = new SearchSettingsViewModel(); var model = new SearchSettingsViewModel();
var searchedFields = part.SearchedFields; var searchedFields = part.SearchedFields;
@@ -37,14 +37,14 @@ namespace Orchard.Search.Drivers {
return ContentPartTemplate(model, "Parts/Search.SiteSettings"); return ContentPartTemplate(model, "Parts/Search.SiteSettings");
} }
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater) { protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = new SearchSettingsViewModel(); var model = new SearchSettingsViewModel();
if(updater.TryUpdateModel(model, Prefix, null, null)) { if(updater.TryUpdateModel(model, Prefix, null, null)) {
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray(); part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
} }
return Editor(part); return Editor(part, shapeHelper);
} }
} }
} }

View File

@@ -47,7 +47,7 @@ namespace Orchard.Tags.Controllers {
var shape = _shapeHelperFactory.CreateHelper(); var shape = _shapeHelperFactory.CreateHelper();
var list = shape.List(); var list = shape.List();
foreach (var taggedContentItem in _tagService.GetTaggedContentItems(tag.Id)) { foreach (var taggedContentItem in _tagService.GetTaggedContentItems(tag.Id)) {
list.Add(_contentManager.BuildDisplayModel(taggedContentItem, "Summary")); list.Add(_contentManager.BuildDisplay(taggedContentItem, "Summary"));
} }
var viewModel = new TagsSearchViewModel { var viewModel = new TagsSearchViewModel {

View File

@@ -23,11 +23,15 @@ namespace Orchard.Tags.Drivers {
public virtual IUser CurrentUser { get; set; } public virtual IUser CurrentUser { get; set; }
protected override DriverResult Display(TagsPart part, string displayType) { protected override DriverResult Display(TagsPart part, string displayType, dynamic shapeHelper) {
return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(part.GetLocation(displayType)); var showTags = shapeHelper.Tags_ShowTags(ContentPart: part, Tags: part.CurrentTags);
if (!string.IsNullOrWhiteSpace(displayType))
showTags.Metadata.Type = string.Format("{0}.{1}", showTags.Metadata.Type, displayType);
var location = part.GetLocation(displayType);
return ContentShape(showTags).Location(location);
} }
protected override DriverResult Editor(TagsPart part) { protected override DriverResult Editor(TagsPart part, dynamic shapeHelper) {
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part)) if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
return null; return null;
@@ -37,7 +41,7 @@ namespace Orchard.Tags.Drivers {
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor")); return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
} }
protected override DriverResult Editor(TagsPart part, IUpdateModel updater) { protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part)) if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
return null; return null;

View File

@@ -97,7 +97,7 @@
<Content Include="Views\Admin\Edit.cshtml" /> <Content Include="Views\Admin\Edit.cshtml" />
<Content Include="Views\Admin\Index.cshtml" /> <Content Include="Views\Admin\Index.cshtml" />
<Content Include="Views\Admin\Search.cshtml" /> <Content Include="Views\Admin\Search.cshtml" />
<Content Include="Views\DisplayTemplates\Parts\Tags.ShowTags.cshtml" /> <Content Include="Views\Tags.ShowTags.cshtml" />
<Content Include="Views\EditorTemplates\Parts\Tags.EditTags.cshtml" /> <Content Include="Views\EditorTemplates\Parts\Tags.EditTags.cshtml" />
<Content Include="Views\Home\Index.cshtml" /> <Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Home\Search.cshtml" /> <Content Include="Views\Home\Search.cshtml" />

View File

@@ -1,17 +0,0 @@
@model Orchard.Tags.Models.TagsPart
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.CurrentTags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(","));
}
tagsHtml.Add(Html.ActionLink(t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -0,0 +1,16 @@
@{
var tagsHtml = new List<IHtmlString>();
foreach(var t in Model.Tags) {
if (tagsHtml.Any()) {
tagsHtml.Add(new HtmlString(", "));
}
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
}
}
@if (tagsHtml.Any()) {
<p class="tags">
<span>@T("Tags:")</span>
@foreach(var htmlString in tagsHtml) { @htmlString }
</p>
}

View File

@@ -59,7 +59,7 @@ namespace Orchard.Users.Controllers {
var user = Services.ContentManager.New<IUser>("User"); var user = Services.ContentManager.New<IUser>("User");
var model = new UserCreateViewModel { var model = new UserCreateViewModel {
User = Services.ContentManager.BuildEditorModel(user) User = Services.ContentManager.BuildEditor(user)
}; };
return View(model); return View(model);
} }
@@ -70,7 +70,7 @@ namespace Orchard.Users.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var user = Services.ContentManager.New<IUser>("User"); var user = Services.ContentManager.New<IUser>("User");
model.User = Services.ContentManager.UpdateEditorModel(user, this); model.User = Services.ContentManager.UpdateEditor(user, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
return View(model); return View(model);
@@ -91,7 +91,7 @@ namespace Orchard.Users.Controllers {
model.Email, model.Email,
null, null, true)); null, null, true));
model.User = Services.ContentManager.UpdateEditorModel(user, this); model.User = Services.ContentManager.UpdateEditor(user, this);
if (ModelState.IsValid == false) { if (ModelState.IsValid == false) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();

View File

@@ -8,7 +8,7 @@ namespace Orchard.Widgets.Drivers {
public class WidgetBagPartDriver : ContentPartDriver<WidgetBagPart> { public class WidgetBagPartDriver : ContentPartDriver<WidgetBagPart> {
private const string TemplateName = "Parts/Widgets.WidgetBagPart"; private const string TemplateName = "Parts/Widgets.WidgetBagPart";
protected override DriverResult Editor(WidgetBagPart part) { protected override DriverResult Editor(WidgetBagPart part, dynamic shapeHelper) {
var location = part.GetLocation("Editor"); var location = part.GetLocation("Editor");
return ContentPartTemplate("", TemplateName, Prefix).Location(location); return ContentPartTemplate("", TemplateName, Prefix).Location(location);
} }

View File

@@ -46,7 +46,7 @@ namespace Orchard.Widgets.Filters {
var zones = workContext.Layout.Zones; var zones = workContext.Layout.Zones;
foreach (var widgetPart in widgetParts) { foreach (var widgetPart in widgetParts) {
if (activeLayerIds.Contains(widgetPart.As<ICommonPart>().Container.ContentItem.Id)) { if (activeLayerIds.Contains(widgetPart.As<ICommonPart>().Container.ContentItem.Id)) {
var widgetShape = _contentManager.BuildDisplayModel(widgetPart); var widgetShape = _contentManager.BuildDisplay(widgetPart);
zones[widgetPart.Record.Zone].Add(widgetShape, widgetPart.Record.Position); zones[widgetPart.Record.Zone].Add(widgetShape, widgetPart.Record.Position);
} }
} }

View File

@@ -168,14 +168,14 @@ namespace Orchard.ContentManagement {
var content = manager.Get<TContent>(id); var content = manager.Get<TContent>(id);
if (content == null) if (content == null)
return null; return null;
return manager.BuildDisplayModel(content, displayType); return manager.BuildDisplay(content, displayType);
} }
public static TContent BuildEditorShape<TContent>(this IContentManager manager, int id) where TContent : class, IContent { public static TContent BuildEditorShape<TContent>(this IContentManager manager, int id) where TContent : class, IContent {
var content = manager.Get<TContent>(id); var content = manager.Get<TContent>(id);
if (content == null) if (content == null)
return null; return null;
return manager.BuildEditorModel(content); return manager.BuildEditor(content);
} }
@@ -183,7 +183,7 @@ namespace Orchard.ContentManagement {
var content = manager.Get<TContent>(id); var content = manager.Get<TContent>(id);
if (content == null) if (content == null)
return null; return null;
return manager.UpdateEditorModel(content, updater); return manager.UpdateEditor(content, updater);
} }

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Orchard.ContentManagement.MetaData.Models; using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.UI;
namespace Orchard.ContentManagement { namespace Orchard.ContentManagement {
public class ContentItem : IContent { public class ContentItem : IContent {

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Autofac; using Autofac;
using ClaySharp.Implementation;
using Microsoft.CSharp.RuntimeBinder; using Microsoft.CSharp.RuntimeBinder;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData;
@@ -379,34 +378,46 @@ namespace Orchard.ContentManagement {
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })); new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
public dynamic BuildDisplayModel<TContent>(TContent content, string displayType = "") where TContent : IContent { public dynamic BuildDisplay(dynamic content, string displayType = "") {
var shapeHelper = _shapeHelperFactory.CreateHelper(); var shapeHelper = _shapeHelperFactory.CreateHelper();
var shapeTypeName = string.IsNullOrEmpty(displayType) ? "Items_Content" : ("Items_Content_" + displayType); var shapeTypeName = string.IsNullOrEmpty(displayType) ? "Items_Content" : ("Items_Content_" + displayType);
var itemShape = _shapeHelperCalls.Invoke(shapeHelper, shapeTypeName); var itemShape = _shapeHelperCalls.Invoke(shapeHelper, shapeTypeName);
itemShape.ContentItem = content.ContentItem; IContent iContent = content;
if (iContent != null)
itemShape.ContentItem = iContent.ContentItem;
var context = new BuildDisplayModelContext(content, displayType, itemShape, _shapeHelperFactory); var context = new BuildDisplayContext(itemShape, content, displayType, _shapeHelperFactory);
Handlers.Invoke(handler => handler.BuildDisplayShape(context), Logger); Handlers.Invoke(handler => handler.BuildDisplay(context), Logger);
return context.Model; return context.Shape;
} }
public dynamic BuildEditorModel<TContent>(TContent content) where TContent : IContent { public dynamic BuildEditor(dynamic content) {
var shapeHelper = _shapeHelperFactory.CreateHelper(); var shapeHelper = _shapeHelperFactory.CreateHelper();
var itemShape = shapeHelper.Items_Content_Edit(ContentItem: content.ContentItem); var itemShape = shapeHelper.Items_Content_Edit();
var context = new BuildEditorModelContext(content, itemShape, _shapeHelperFactory);
Handlers.Invoke(handler => handler.BuildEditorShape(context), Logger); IContent iContent = content;
return context.Model; if (iContent != null)
itemShape.ContentItem = iContent.ContentItem;
var context = new BuildEditorContext(itemShape, content, _shapeHelperFactory);
Handlers.Invoke(handler => handler.BuildEditor(context), Logger);
return context.Shape;
} }
public dynamic UpdateEditorModel<TContent>(TContent content, IUpdateModel updater) where TContent : IContent { public dynamic UpdateEditor(dynamic content, IUpdateModel updater) {
var shapeHelper = _shapeHelperFactory.CreateHelper(); var shapeHelper = _shapeHelperFactory.CreateHelper();
var itemShape = shapeHelper.Items_Content_Edit(ContentItem: content.ContentItem); var itemShape = shapeHelper.Items_Content_Edit();
var context = new UpdateEditorModelContext(content, updater, itemShape, _shapeHelperFactory);
Handlers.Invoke(handler => handler.UpdateEditorShape(context), Logger); IContent iContent = content;
return context.Model; if (iContent != null)
itemShape.ContentItem = iContent.ContentItem;
var context = new UpdateEditorContext(itemShape, content, updater, _shapeHelperFactory);
Handlers.Invoke(handler => handler.UpdateEditor(context), Logger);
return context.Shape;
} }
public IContentQuery<ContentItem> Query() { public IContentQuery<ContentItem> Query() {

View File

@@ -6,15 +6,15 @@ namespace Orchard.ContentManagement.Drivers {
} }
} }
protected override DriverResult Display(TPart part, string displayType) { protected override DriverResult Display(TPart part, string displayType, dynamic shapeHelper) {
return ContentPartTemplate(part); return ContentPartTemplate(part);
} }
protected override DriverResult Editor(TPart part) { protected override DriverResult Editor(TPart part, dynamic shapeHelper) {
return ContentPartTemplate(part); return ContentPartTemplate(part);
} }
protected override DriverResult Editor(TPart part, IUpdateModel updater) { protected override DriverResult Editor(TPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part, Prefix, null, null); updater.TryUpdateModel(part, Prefix, null, null);
return ContentPartTemplate(part); return ContentPartTemplate(part);
} }

View File

@@ -10,13 +10,13 @@ namespace Orchard.ContentManagement.Drivers {
_results = results.Where(x => x != null); _results = results.Where(x => x != null);
} }
public override void Apply(BuildDisplayModelContext context) { public override void Apply(BuildDisplayContext context) {
foreach (var result in _results) { foreach (var result in _results) {
result.Apply(context); result.Apply(context);
} }
} }
public override void Apply(BuildEditorModelContext context) { public override void Apply(BuildEditorContext context) {
foreach (var result in _results) { foreach (var result in _results) {
result.Apply(context); result.Apply(context);
} }

Some files were not shown because too many files have changed in this diff Show More