mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Changing up Widget wrappers a little
--HG-- branch : dev
This commit is contained in:
@@ -117,13 +117,13 @@
|
|||||||
</None>
|
</None>
|
||||||
<None Include="Views\Admin\Index.cshtml" />
|
<None Include="Views\Admin\Index.cshtml" />
|
||||||
<Content Include="Views\Items_Widget.Editor.cshtml" />
|
<Content Include="Views\Items_Widget.Editor.cshtml" />
|
||||||
<None Include="Views\Widget.Manage.cshtml" />
|
<None Include="Views\Widget.ControlWrapper.cshtml" />
|
||||||
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetPart.cshtml" />
|
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetPart.cshtml" />
|
||||||
<None Include="Views\EditorTemplates\Parts\Widgets.LayerPart.cshtml" />
|
<None Include="Views\EditorTemplates\Parts\Widgets.LayerPart.cshtml" />
|
||||||
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetBagPart.cshtml" />
|
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetBagPart.cshtml" />
|
||||||
<Content Include="Views\Items_Widget.cshtml" />
|
<Content Include="Views\Items_Widget.cshtml" />
|
||||||
<Content Include="Views\Items\Content-WidgetPage.cshtml" />
|
<Content Include="Views\Items\Content-WidgetPage.cshtml" />
|
||||||
<None Include="Views\Widget.cshtml" />
|
<None Include="Views\Widget.Wrapper.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" />
|
||||||
|
@@ -4,33 +4,25 @@ using Orchard.Widgets.Models;
|
|||||||
|
|
||||||
namespace Orchard.Widgets {
|
namespace Orchard.Widgets {
|
||||||
public class Shapes : IShapeTableProvider {
|
public class Shapes : IShapeTableProvider {
|
||||||
private readonly IOrchardServices _orchardServices;
|
|
||||||
|
|
||||||
public Shapes(IOrchardServices orchardServices) {
|
|
||||||
_orchardServices = orchardServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Discover(ShapeTableBuilder builder) {
|
public void Discover(ShapeTableBuilder builder) {
|
||||||
builder.Describe("Items_Widget")
|
builder.Describe("Items_Widget")
|
||||||
.Configure(descriptor => {
|
.Configure(descriptor => {
|
||||||
// todo: have "alternates" for chrome
|
// todo: have "alternates" for chrome
|
||||||
if (_orchardServices.Authorizer.Authorize(Permissions.ManageWidgets))
|
descriptor.Wrappers.Add("Widget_Wrapper");
|
||||||
descriptor.Wrappers.Add("Widget_Manage");
|
descriptor.Wrappers.Add("Widget_ControlWrapper");
|
||||||
else
|
|
||||||
descriptor.Wrappers.Add("Widget");
|
|
||||||
})
|
})
|
||||||
.OnCreated(created => {
|
.OnCreated(created => {
|
||||||
var widget = created.Shape;
|
var widget = created.Shape;
|
||||||
widget.Main.Add(created.New.PlaceChildContent(Source: widget));
|
widget.Main.Add(created.New.PlaceChildContent(Source: widget));
|
||||||
})
|
})
|
||||||
.OnDisplaying(displaying => {
|
.OnDisplaying(displaying => {
|
||||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
var widget = displaying.Shape;
|
||||||
|
widget.Classes.Add("widget");
|
||||||
|
ContentItem contentItem = widget.ContentItem;
|
||||||
if (contentItem != null) {
|
if (contentItem != null) {
|
||||||
var zoneName = contentItem.As<WidgetPart>().Zone;
|
var zoneName = contentItem.As<WidgetPart>().Zone;
|
||||||
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType);
|
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType);
|
||||||
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName);
|
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName);
|
||||||
//...would like...if '__' was collapsible
|
|
||||||
//displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName + "__" + contentItem.ContentType);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,14 @@
|
|||||||
|
@using Orchard.ContentManagement;
|
||||||
|
@using Orchard.Widgets;
|
||||||
|
@{
|
||||||
|
if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||||
|
Model.Classes.Add("widget-manage");
|
||||||
|
}
|
||||||
|
var tag = Tag(Model, "div");
|
||||||
|
}
|
||||||
|
@tag.StartElement
|
||||||
|
@if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||||
|
<div class="manage-actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
||||||
|
}
|
||||||
|
@Display(Model.Main)
|
||||||
|
@tag.EndElement
|
@@ -1,5 +0,0 @@
|
|||||||
@using Orchard.ContentManagement;
|
|
||||||
<div class="widget widget-manage">
|
|
||||||
<div class="actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
|
||||||
@Display(Model.Main)
|
|
||||||
</div>
|
|
@@ -0,0 +1,14 @@
|
|||||||
|
@using Orchard.ContentManagement;
|
||||||
|
@using Orchard.Widgets;
|
||||||
|
@{
|
||||||
|
if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||||
|
Model.Classes.Add("widget-manage");
|
||||||
|
}
|
||||||
|
var tag = Tag(Model, "div");
|
||||||
|
}
|
||||||
|
@tag.StartElement
|
||||||
|
@if (AuthorizedFor(Permissions.ManageWidgets)) {
|
||||||
|
<div class="manage-actions">@Html.ItemEditLinkWithReturnUrl(T("Edit").Text, (ContentItem)Model.ContentItem)</div>
|
||||||
|
}
|
||||||
|
@Display(Model.Main)
|
||||||
|
@tag.EndElement
|
@@ -1 +0,0 @@
|
|||||||
@Display(Model.Main)
|
|
Reference in New Issue
Block a user