2010-10-19 16:26:22 -07:00
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using JetBrains.Annotations;
|
2010-10-11 10:15:15 -07:00
|
|
|
|
using Orchard.ContentManagement;
|
2010-10-05 15:42:17 -07:00
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
|
|
|
|
using Orchard.Widgets.Models;
|
2010-10-11 10:15:15 -07:00
|
|
|
|
using Orchard.Widgets.Services;
|
2010-10-05 15:42:17 -07:00
|
|
|
|
|
|
|
|
|
namespace Orchard.Widgets.Drivers {
|
2010-10-11 10:15:15 -07:00
|
|
|
|
|
2010-10-05 15:42:17 -07:00
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public class WidgetPartDriver : ContentPartDriver<WidgetPart> {
|
2010-10-11 10:15:15 -07:00
|
|
|
|
private readonly IWidgetsService _widgetsService;
|
|
|
|
|
|
|
|
|
|
public WidgetPartDriver(IWidgetsService widgetsService) {
|
|
|
|
|
_widgetsService = widgetsService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelper) {
|
|
|
|
|
widgetPart.AvailableZones = _widgetsService.GetZones();
|
2010-10-19 16:26:22 -07:00
|
|
|
|
widgetPart.AvailableLayers = _widgetsService.GetLayers();
|
2010-10-11 10:15:15 -07:00
|
|
|
|
|
2010-10-18 14:15:39 -07:00
|
|
|
|
return ContentShape("Parts_Widgets_WidgetPart",
|
2010-12-03 22:57:42 -08:00
|
|
|
|
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix));
|
2010-10-11 10:15:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) {
|
|
|
|
|
updater.TryUpdateModel(widgetPart, Prefix, null, null);
|
|
|
|
|
return Editor(widgetPart, shapeHelper);
|
|
|
|
|
}
|
2010-10-05 15:42:17 -07:00
|
|
|
|
}
|
|
|
|
|
}
|