#17177: Moving content wrappers to features

Work Item: 17177

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-16 11:26:22 -08:00
parent b8f9e0e8e4
commit c00953f18d
9 changed files with 58 additions and 7 deletions

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Environment.Extensions;
namespace Orchard.Core.Contents {
[OrchardFeature("Contents.ControlWrapper")]
public class ControlWrapper : IShapeTableProvider {
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content").OnDisplaying(displaying => {
if (!displaying.ShapeMetadata.DisplayType.Contains("Admin")) {
displaying.ShapeMetadata.Wrappers.Add("Content_ControlWrapper");
}
});
}
}
}

View File

@@ -15,3 +15,8 @@ Features:
Description: Rules for the Contents modules
Category: Rules
Dependencies: Orchard.Rules, Contents
Contents.ControlWrapper:
Name: Content Control Wrapper
Description: Add an Edit button on the front-end for authenticated users
Category: Content
Dependencies: Contents

View File

@@ -29,9 +29,6 @@ namespace Orchard.Core.Contents {
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
if ( !displaying.ShapeMetadata.DisplayType.Contains("Admin") )
displaying.ShapeMetadata.Wrappers.Add("Content_ControlWrapper");
}
});
}

View File

@@ -105,6 +105,7 @@
<Compile Include="Containers\ViewModels\ContainableViewModel.cs" />
<Compile Include="Containers\ViewModels\ContainerWidgetViewModel.cs" />
<Compile Include="Containers\ViewModels\ContainerViewModel.cs" />
<Compile Include="Contents\ControlWrapper.cs" />
<Compile Include="Contents\Handlers\RulesHandler.cs" />
<Compile Include="Contents\Rules\ContentEvents.cs" />
<Compile Include="Contents\Rules\ContentForms.cs" />

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Environment.Extensions;
namespace Orchard.Widgets {
[OrchardFeature("Orchard.Widgets.ControlWrapper")]
public class ControlWrapper : IShapeTableProvider {
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Widget")
.Configure(descriptor => {
descriptor.Wrappers.Add("Widget_ControlWrapper");
});
}
}
}

View File

@@ -14,3 +14,8 @@ Features:
Description: Adds a notification after creating a new Page with a direct link to create a Widget Layer for that specific page by URL.
Dependencies: Orchard.Widgets, Routable
Category: Widget
Orchard.Widgets.ControlWrapper:
Name: Widget Control Wrapper
Description: Add an Edit button on the front-end for authenticated users
Category: Widget
Dependencies: Orchard.Widgets

View File

@@ -51,6 +51,7 @@
<Compile Include="Commands\LayerCommands.cs" />
<Compile Include="Commands\WidgetCommands.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="ControlWrapper.cs" />
<Compile Include="Drivers\LayerPartDriver.cs" />
<Compile Include="Handlers\LayerHintHandler.cs" />
<Compile Include="Drivers\WidgetPartDriver.cs" />

View File

@@ -11,7 +11,6 @@ namespace Orchard.Widgets {
.Configure(descriptor => {
// todo: have "alternates" for chrome
descriptor.Wrappers.Add("Widget_Wrapper");
descriptor.Wrappers.Add("Widget_ControlWrapper");
})
.OnCreated(created => {
var widget = created.Shape;
@@ -24,10 +23,11 @@ namespace Orchard.Widgets {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
var widgetPart = contentItem.As<WidgetPart>();
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
var zoneName = widgetPart.Zone;
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
widget.Classes.Add("widget-" + zoneName.HtmlClassify());
// Widget__[ZoneName] e.g. Widget-SideBar
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);

View File

@@ -273,6 +273,11 @@ namespace Orchard.Environment {
/// </summary>
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor, string tenant) {
lock (_syncLock) {
if (_shellContexts == null) {
return;
}
var context =_shellContexts.FirstOrDefault(x => x.Settings.Name == tenant);
// some shells might need to be started, e.g. created by command line