mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Removed Zones integration.
This commit is contained in:
@@ -34,11 +34,6 @@ namespace Orchard.Layouts.Elements {
|
||||
get { return Width.GetValueOrDefault() + Offset.GetValueOrDefault(); }
|
||||
}
|
||||
|
||||
public string ZoneName {
|
||||
get { return this.Retrieve(x => x.ZoneName); }
|
||||
set { this.Store(x => x.ZoneName, value); }
|
||||
}
|
||||
|
||||
public bool? Collapsible {
|
||||
get { return this.Retrieve(x => x.Collapsible); }
|
||||
set { this.Store(x => x.Collapsible, value); }
|
||||
|
@@ -33,7 +33,6 @@ namespace Orchard.Layouts.Handlers {
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
OnPublished<LayoutPart>(UpdateTemplateClients);
|
||||
OnPublished<LayoutPart>(InvalidateLayoutZones);
|
||||
OnIndexing<LayoutPart>(IndexLayout);
|
||||
}
|
||||
|
||||
@@ -50,10 +49,6 @@ namespace Orchard.Layouts.Handlers {
|
||||
UpdateTemplateClients(part);
|
||||
}
|
||||
|
||||
private void InvalidateLayoutZones(PublishContentContext context, LayoutPart part) {
|
||||
_signals.Trigger(Signals.LayoutZones);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively updates all layouts that use the specified layout as its template.
|
||||
/// </summary>
|
||||
|
@@ -731,13 +731,12 @@ var LayoutEditor;
|
||||
})(LayoutEditor || (LayoutEditor = {}));
|
||||
var LayoutEditor;
|
||||
(function (LayoutEditor) {
|
||||
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) {
|
||||
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, collapsible, rule, children) {
|
||||
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
|
||||
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
|
||||
|
||||
this.width = width;
|
||||
this.offset = offset;
|
||||
this.zoneName = zoneName;
|
||||
this.collapsible = collapsible;
|
||||
|
||||
var _hasPendingChange = false;
|
||||
@@ -830,7 +829,6 @@ var LayoutEditor;
|
||||
var result = this.elementToObject();
|
||||
result.width = this.width;
|
||||
result.offset = this.offset;
|
||||
result.zoneName = this.zoneName;
|
||||
result.collapsible = this.collapsible;
|
||||
result.children = this.childrenToObject();
|
||||
return result;
|
||||
@@ -846,7 +844,6 @@ var LayoutEditor;
|
||||
value.isTemplated,
|
||||
value.width,
|
||||
value.offset,
|
||||
value.zoneName,
|
||||
value.collapsible,
|
||||
value.rule,
|
||||
LayoutEditor.childrenFrom(value.children));
|
||||
@@ -865,7 +862,6 @@ var LayoutEditor;
|
||||
isTemplated: false,
|
||||
width: 12 / value,
|
||||
offset: 0,
|
||||
zoneName: null,
|
||||
collapsible: null,
|
||||
children: []
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1,12 +1,11 @@
|
||||
var LayoutEditor;
|
||||
(function (LayoutEditor) {
|
||||
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) {
|
||||
LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, collapsible, rule, children) {
|
||||
LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
|
||||
LayoutEditor.Container.call(this, ["Grid", "Content"], children);
|
||||
|
||||
this.width = width;
|
||||
this.offset = offset;
|
||||
this.zoneName = zoneName;
|
||||
this.collapsible = collapsible;
|
||||
|
||||
var _hasPendingChange = false;
|
||||
@@ -99,7 +98,6 @@
|
||||
var result = this.elementToObject();
|
||||
result.width = this.width;
|
||||
result.offset = this.offset;
|
||||
result.zoneName = this.zoneName;
|
||||
result.collapsible = this.collapsible;
|
||||
result.children = this.childrenToObject();
|
||||
return result;
|
||||
@@ -115,7 +113,6 @@
|
||||
value.isTemplated,
|
||||
value.width,
|
||||
value.offset,
|
||||
value.zoneName,
|
||||
value.collapsible,
|
||||
value.rule,
|
||||
LayoutEditor.childrenFrom(value.children));
|
||||
@@ -134,7 +131,6 @@
|
||||
isTemplated: false,
|
||||
width: 12 / value,
|
||||
offset: 0,
|
||||
zoneName: null,
|
||||
collapsible: null,
|
||||
children: []
|
||||
});
|
||||
|
@@ -74,7 +74,6 @@ namespace Orchard.Layouts.Services {
|
||||
base.ToElement(element, node);
|
||||
element.Width = (int?)node["width"];
|
||||
element.Offset = (int?)node["offset"];
|
||||
element.ZoneName = (string) node["zoneName"];
|
||||
element.Collapsible = ReadBoolean(node["collapsible"]);
|
||||
}
|
||||
|
||||
@@ -82,7 +81,6 @@ namespace Orchard.Layouts.Services {
|
||||
base.FromElement(element, describeContext, node);
|
||||
node["width"] = element.Width;
|
||||
node["offset"] = element.Offset;
|
||||
node["zoneName"] = element.ZoneName;
|
||||
node["collapsible"] = element.Collapsible;
|
||||
}
|
||||
}
|
||||
|
@@ -55,15 +55,5 @@ namespace Orchard.Layouts.Services {
|
||||
IEnumerable<Element> CreateDefaultLayout();
|
||||
void Exporting(ExportLayoutContext context);
|
||||
void Importing(ImportLayoutContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Collects all zones as defined in all layouts in the system.
|
||||
/// </summary>
|
||||
IEnumerable<string> GetZones();
|
||||
|
||||
/// <summary>
|
||||
/// Recursively collects all zones of the specified layout and of its selected template, if any.
|
||||
/// </summary>
|
||||
IEnumerable<string> GetZones(ILayoutAspect layout);
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
@@ -10,7 +9,6 @@ using Orchard.Layouts.Framework.Elements;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Models;
|
||||
using Orchard.Layouts.Settings;
|
||||
using Orchard.Validation;
|
||||
|
||||
namespace Orchard.Layouts.Services {
|
||||
public class LayoutManager : ILayoutManager {
|
||||
@@ -18,23 +16,17 @@ namespace Orchard.Layouts.Services {
|
||||
private readonly ILayoutSerializer _serializer;
|
||||
private readonly IElementDisplay _elementDisplay;
|
||||
private readonly IElementManager _elementManager;
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly ISignals _signals;
|
||||
|
||||
public LayoutManager(
|
||||
IContentManager contentManager,
|
||||
ILayoutSerializer serializer,
|
||||
IElementDisplay elementDisplay,
|
||||
IElementManager elementManager,
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals) {
|
||||
IContentManager contentManager,
|
||||
ILayoutSerializer serializer,
|
||||
IElementDisplay elementDisplay,
|
||||
IElementManager elementManager) {
|
||||
|
||||
_contentManager = contentManager;
|
||||
_serializer = serializer;
|
||||
_elementDisplay = elementDisplay;
|
||||
_elementManager = elementManager;
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
}
|
||||
|
||||
public IEnumerable<LayoutPart> GetTemplates() {
|
||||
@@ -83,37 +75,6 @@ namespace Orchard.Layouts.Services {
|
||||
context.Layout.LayoutData = _serializer.Serialize(elementTree);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetZones() {
|
||||
return _cacheManager.Get("LayoutZones", context => {
|
||||
context.Monitor(_signals.When(Signals.LayoutZones));
|
||||
return GetZones(GetLayouts());
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetZones(ILayoutAspect layout) {
|
||||
Argument.ThrowIfNull(layout, "layout");
|
||||
|
||||
var key = String.Format("LayoutZones-{0}", layout.Id);
|
||||
return _cacheManager.Get(key, context => {
|
||||
context.Monitor(_signals.When(Signals.LayoutZones));
|
||||
|
||||
var layouts = new List<ILayoutAspect>();
|
||||
var currentTemplate = layout.TemplateId != null ? GetLayout(layout.TemplateId.Value) : default(LayoutPart);
|
||||
|
||||
// Add the layout itself to the chain of layouts to harvest zones from.
|
||||
layouts.Add(layout);
|
||||
|
||||
// Walk up the chain of templates and collect each one for zone harvesting.
|
||||
while (currentTemplate != null) {
|
||||
layouts.Add(currentTemplate);
|
||||
currentTemplate = currentTemplate.TemplateId != null ? GetLayout(currentTemplate.TemplateId.Value) : default(LayoutPart);
|
||||
}
|
||||
|
||||
// Harvest the zones from the chain of layouts.
|
||||
return GetZones(layouts);
|
||||
});
|
||||
}
|
||||
|
||||
public dynamic RenderLayout(string data, string displayType = null, IContent content = null) {
|
||||
var elements = _serializer.Deserialize(data, new DescribeElementsContext { Content = content });
|
||||
var layoutRoot = _elementDisplay.DisplayElements(elements, content, displayType);
|
||||
@@ -138,7 +99,7 @@ namespace Orchard.Layouts.Services {
|
||||
var nonTemplatedElements = ExtractNonTemplatedElements(layout).ToList();
|
||||
|
||||
foreach (var element in nonTemplatedElements) {
|
||||
|
||||
|
||||
// Move the element to the template and try to maintain its index.
|
||||
var column = element.Container as Column;
|
||||
var indexInTemplate = templateColumns.Any() ? 0 : -1;
|
||||
@@ -213,19 +174,5 @@ namespace Orchard.Layouts.Services {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetZones(IEnumerable<ILayoutAspect> layouts) {
|
||||
var zoneNames = new HashSet<string>();
|
||||
|
||||
foreach (var layoutPart in layouts) {
|
||||
var elements = LoadElements(layoutPart).Flatten();
|
||||
var columns = elements.Where(x => x is Column).Cast<Column>().Where(x => !String.IsNullOrWhiteSpace(x.ZoneName)).ToList();
|
||||
|
||||
foreach (var column in columns)
|
||||
zoneNames.Add(column.ZoneName);
|
||||
}
|
||||
|
||||
return zoneNames.OrderBy(x => x);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
namespace Orchard.Layouts {
|
||||
public static class Signals {
|
||||
public static readonly object ElementDescriptors = new object();
|
||||
public static readonly object LayoutZones = new object();
|
||||
}
|
||||
}
|
@@ -1,10 +1,6 @@
|
||||
@using Orchard.Layouts.ViewModels
|
||||
@{
|
||||
var additionalItems = new[] {
|
||||
new LayoutEditorPropertiesItem {
|
||||
Label = "Zone Name:",
|
||||
Model = "element.zoneName"
|
||||
},
|
||||
new LayoutEditorPropertiesItem {
|
||||
Label = "Collapsible",
|
||||
Model = "element.collapsible",
|
||||
|
Reference in New Issue
Block a user