mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-16 09:20:44 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
commit
af3a348770
@ -44,6 +44,12 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
layers.First() :
|
layers.First() :
|
||||||
layers.FirstOrDefault(layer => layer.Id == id);
|
layers.FirstOrDefault(layer => layer.Id == id);
|
||||||
|
|
||||||
|
if (currentLayer == null) {
|
||||||
|
// Incorrect layer id passed
|
||||||
|
Services.Notifier.Error(T("Layer not found: {1}", id));
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
currentLayerWidgets = _widgetsService.GetWidgets().Where(widgetPart => widgetPart.LayerPart.Id == currentLayer.Id);
|
currentLayerWidgets = _widgetsService.GetWidgets().Where(widgetPart => widgetPart.LayerPart.Id == currentLayer.Id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -237,7 +243,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
Services.Notifier.Error(T("Removing Layer failed: {0}", exception.Message));
|
Services.Notifier.Error(T("Removing Layer failed: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index", "Admin", new { id });
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult EditWidget(int id) {
|
public ActionResult EditWidget(int id) {
|
||||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Themes;
|
using Orchard.Themes;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
|
|
||||||
@ -78,11 +79,21 @@ namespace Orchard.Widgets.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteLayer(int layerId) {
|
public void DeleteLayer(int layerId) {
|
||||||
|
// Delete widgets in the layer
|
||||||
|
foreach (WidgetPart widgetPart in GetWidgets(layerId)) {
|
||||||
|
DeleteWidget(widgetPart.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete actual layer
|
||||||
_contentManager.Remove(GetLayer(layerId).ContentItem);
|
_contentManager.Remove(GetLayer(layerId).ContentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidgetPart GetWidget(int widgetId) {
|
public WidgetPart GetWidget(int widgetId) {
|
||||||
return GetWidgets().FirstOrDefault(widgetPart => widgetPart.Id == widgetId);
|
return _contentManager
|
||||||
|
.Query<WidgetPart, WidgetPartRecord>()
|
||||||
|
.Where(widget => widget.Id == widgetId)
|
||||||
|
.List()
|
||||||
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidgetPart CreateWidget(int layerId, string widgetType, string title, string position, string zone) {
|
public WidgetPart CreateWidget(int layerId, string widgetType, string title, string position, string zone) {
|
||||||
|
Loading…
Reference in New Issue
Block a user