mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
#17177: Moving content wrappers to features
Work Item: 17177 --HG-- branch : 1.x
This commit is contained in:
19
src/Orchard.Web/Core/Contents/ControlWrapper.cs
Normal file
19
src/Orchard.Web/Core/Contents/ControlWrapper.cs
Normal 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");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -15,3 +15,8 @@ Features:
|
|||||||
Description: Rules for the Contents modules
|
Description: Rules for the Contents modules
|
||||||
Category: Rules
|
Category: Rules
|
||||||
Dependencies: Orchard.Rules, Contents
|
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
|
||||||
|
@@ -29,9 +29,6 @@ namespace Orchard.Core.Contents {
|
|||||||
|
|
||||||
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
|
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
|
||||||
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
|
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
|
||||||
|
|
||||||
if ( !displaying.ShapeMetadata.DisplayType.Contains("Admin") )
|
|
||||||
displaying.ShapeMetadata.Wrappers.Add("Content_ControlWrapper");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -105,6 +105,7 @@
|
|||||||
<Compile Include="Containers\ViewModels\ContainableViewModel.cs" />
|
<Compile Include="Containers\ViewModels\ContainableViewModel.cs" />
|
||||||
<Compile Include="Containers\ViewModels\ContainerWidgetViewModel.cs" />
|
<Compile Include="Containers\ViewModels\ContainerWidgetViewModel.cs" />
|
||||||
<Compile Include="Containers\ViewModels\ContainerViewModel.cs" />
|
<Compile Include="Containers\ViewModels\ContainerViewModel.cs" />
|
||||||
|
<Compile Include="Contents\ControlWrapper.cs" />
|
||||||
<Compile Include="Contents\Handlers\RulesHandler.cs" />
|
<Compile Include="Contents\Handlers\RulesHandler.cs" />
|
||||||
<Compile Include="Contents\Rules\ContentEvents.cs" />
|
<Compile Include="Contents\Rules\ContentEvents.cs" />
|
||||||
<Compile Include="Contents\Rules\ContentForms.cs" />
|
<Compile Include="Contents\Rules\ContentForms.cs" />
|
||||||
|
18
src/Orchard.Web/Modules/Orchard.Widgets/ControlWrapper.cs
Normal file
18
src/Orchard.Web/Modules/Orchard.Widgets/ControlWrapper.cs
Normal 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");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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.
|
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
|
Dependencies: Orchard.Widgets, Routable
|
||||||
Category: Widget
|
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
|
||||||
|
@@ -51,6 +51,7 @@
|
|||||||
<Compile Include="Commands\LayerCommands.cs" />
|
<Compile Include="Commands\LayerCommands.cs" />
|
||||||
<Compile Include="Commands\WidgetCommands.cs" />
|
<Compile Include="Commands\WidgetCommands.cs" />
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
|
<Compile Include="ControlWrapper.cs" />
|
||||||
<Compile Include="Drivers\LayerPartDriver.cs" />
|
<Compile Include="Drivers\LayerPartDriver.cs" />
|
||||||
<Compile Include="Handlers\LayerHintHandler.cs" />
|
<Compile Include="Handlers\LayerHintHandler.cs" />
|
||||||
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
||||||
|
@@ -11,7 +11,6 @@ namespace Orchard.Widgets {
|
|||||||
.Configure(descriptor => {
|
.Configure(descriptor => {
|
||||||
// todo: have "alternates" for chrome
|
// todo: have "alternates" for chrome
|
||||||
descriptor.Wrappers.Add("Widget_Wrapper");
|
descriptor.Wrappers.Add("Widget_Wrapper");
|
||||||
descriptor.Wrappers.Add("Widget_ControlWrapper");
|
|
||||||
})
|
})
|
||||||
.OnCreated(created => {
|
.OnCreated(created => {
|
||||||
var widget = created.Shape;
|
var widget = created.Shape;
|
||||||
@@ -24,10 +23,11 @@ namespace Orchard.Widgets {
|
|||||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||||
if (contentItem != null) {
|
if (contentItem != null) {
|
||||||
var widgetPart = contentItem.As<WidgetPart>();
|
var widgetPart = contentItem.As<WidgetPart>();
|
||||||
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
|
|
||||||
|
|
||||||
var zoneName = widgetPart.Zone;
|
var zoneName = widgetPart.Zone;
|
||||||
|
|
||||||
|
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
|
||||||
|
widget.Classes.Add("widget-" + zoneName.HtmlClassify());
|
||||||
|
|
||||||
// Widget__[ZoneName] e.g. Widget-SideBar
|
// Widget__[ZoneName] e.g. Widget-SideBar
|
||||||
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);
|
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);
|
||||||
|
|
||||||
|
@@ -273,7 +273,12 @@ namespace Orchard.Environment {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor, string tenant) {
|
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor, string tenant) {
|
||||||
lock (_syncLock) {
|
lock (_syncLock) {
|
||||||
var context = _shellContexts.FirstOrDefault(x => x.Settings.Name == tenant);
|
|
||||||
|
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
|
// some shells might need to be started, e.g. created by command line
|
||||||
if(context == null) {
|
if(context == null) {
|
||||||
|
Reference in New Issue
Block a user