mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Not attempting to show a widget zone preview image if the currently active theme doesn't have one.
--HG-- branch : dev
This commit is contained in:
@@ -6,6 +6,7 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.Core.Contents.Controllers;
|
using Orchard.Core.Contents.Controllers;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
using Orchard.FileSystems.VirtualPath;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Mvc.Extensions;
|
using Orchard.Mvc.Extensions;
|
||||||
@@ -25,16 +26,19 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
|
|
||||||
private readonly IWidgetsService _widgetsService;
|
private readonly IWidgetsService _widgetsService;
|
||||||
private readonly ISiteThemeService _siteThemeService;
|
private readonly ISiteThemeService _siteThemeService;
|
||||||
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
|
|
||||||
public AdminController(
|
public AdminController(
|
||||||
IOrchardServices services,
|
IOrchardServices services,
|
||||||
IWidgetsService widgetsService,
|
IWidgetsService widgetsService,
|
||||||
IShapeFactory shapeFactory,
|
IShapeFactory shapeFactory,
|
||||||
ISiteThemeService siteThemeService) {
|
ISiteThemeService siteThemeService,
|
||||||
|
IVirtualPathProvider virtualPathProvider) {
|
||||||
|
|
||||||
Services = services;
|
Services = services;
|
||||||
_widgetsService = widgetsService;
|
_widgetsService = widgetsService;
|
||||||
_siteThemeService = siteThemeService;
|
_siteThemeService = siteThemeService;
|
||||||
|
_virtualPathProvider = virtualPathProvider;
|
||||||
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
@@ -67,13 +71,17 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
IEnumerable<string> allZones = _widgetsService.GetZones();
|
IEnumerable<string> allZones = _widgetsService.GetZones();
|
||||||
IEnumerable<string> currentThemesZones = _widgetsService.GetZones(currentTheme);
|
IEnumerable<string> currentThemesZones = _widgetsService.GetZones(currentTheme);
|
||||||
|
|
||||||
|
string zonePreviewImagePath = string.Format("{0}/{1}/ThemeZonePreview.png", currentTheme.Location, currentTheme.Id);
|
||||||
|
string zonePreviewImage = _virtualPathProvider.FileExists(zonePreviewImagePath) ? zonePreviewImagePath : null;
|
||||||
|
|
||||||
dynamic viewModel = Shape.ViewModel()
|
dynamic viewModel = Shape.ViewModel()
|
||||||
.CurrentTheme(currentTheme)
|
.CurrentTheme(currentTheme)
|
||||||
.CurrentLayer(currentLayer)
|
.CurrentLayer(currentLayer)
|
||||||
.Layers(layers)
|
.Layers(layers)
|
||||||
.Widgets(_widgetsService.GetWidgets())
|
.Widgets(_widgetsService.GetWidgets())
|
||||||
.Zones(currentThemesZones)
|
.Zones(currentThemesZones)
|
||||||
.OrphanZones(allZones.Except(currentThemesZones));
|
.OrphanZones(allZones.Except(currentThemesZones))
|
||||||
|
.ZonePreviewImage(zonePreviewImage);
|
||||||
|
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)viewModel);
|
return View((object)viewModel);
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#layout-widgets-placement {
|
#layout-widgets-placement {
|
||||||
|
clear:left;
|
||||||
float:left;
|
float:left;
|
||||||
width:65%;
|
width:65%;
|
||||||
}
|
}
|
||||||
#layout-widgets-assistance {
|
#layout-widgets-assistance {
|
||||||
float:right;
|
float:right;
|
||||||
|
position:relative;
|
||||||
|
top:-30px;
|
||||||
width:35%;
|
width:35%;
|
||||||
}
|
}
|
||||||
.widgets-container {
|
.widgets-container {
|
||||||
@@ -17,6 +20,7 @@ padding:2px 2px;
|
|||||||
|
|
||||||
|
|
||||||
#widgets-layers-control {
|
#widgets-layers-control {
|
||||||
|
float:left;
|
||||||
margin-bottom:-20px;
|
margin-bottom:-20px;
|
||||||
}
|
}
|
||||||
#widgets-layers-control label {
|
#widgets-layers-control label {
|
||||||
@@ -163,8 +167,12 @@ color:#333;
|
|||||||
margin-top:5px;
|
margin-top:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#widgets-layer-visibility {
|
#widgets-theme-zone-preview {
|
||||||
margin-top:20px;
|
margin:30px 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main #widgets-layer-visibility h3 {
|
||||||
|
margin-top:0;
|
||||||
}
|
}
|
||||||
#widgets-layer-visibility li {
|
#widgets-layer-visibility li {
|
||||||
cursor:default;
|
cursor:default;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div id="layout-widgets-assistance">
|
<div id="layout-widgets-assistance">
|
||||||
<div id="widgets-assistance">
|
<div id="widgets-assistance">
|
||||||
<div class="widgets-container">
|
<div class="widgets-container">
|
||||||
@Display.WidgetSimplePreview(CurrentTheme: Model.CurrentTheme)
|
@Display.WidgetSimplePreview(ZonePreviewImage: Model.ZonePreviewImage, CurrentTheme: Model.CurrentTheme)
|
||||||
@Display.WidgetLayerVisibility(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
|
@Display.WidgetLayerVisibility(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
@using Orchard.Environment.Extensions.Models
|
@using Orchard.Environment.Extensions.Models
|
||||||
<p id="widgets-theme-zone-preview">@Html.Image(Href(Html.ThemePath((ExtensionDescriptor) Model.CurrentTheme, "/ThemeZonePreview.png")), T("{0} zone preview", (string)Model.CurrentTheme.Name).Text, null)</p>
|
@if (HasText(Model.ZonePreviewImage)) {
|
||||||
|
<p id="widgets-theme-zone-preview">@Html.Image(Href((string)Model.ZonePreviewImage), T("{0} zone preview", (string)Model.CurrentTheme.Name).Text, null)</p>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user