mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Implementing a some fundamental alternate binding names for core shapes
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@@ -11,7 +10,7 @@ using System.Web.Mvc.Html;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI;
|
||||
using Orchard.UI.Resources;
|
||||
@@ -48,13 +47,15 @@ namespace Orchard.Core.Shapes {
|
||||
|
||||
// 'Zone' shapes are built on the Zone base class
|
||||
builder.Describe("Zone")
|
||||
.OnCreating(creating => creating.BaseType = typeof (Zone));
|
||||
//.OnDisplaying(displaying => {
|
||||
// var name = displaying.Shape.ZoneName.ToLower();
|
||||
// var zone = displaying.Shape;
|
||||
// zone.Classes.Add("zone-" + name);
|
||||
// zone.Classes.Add("zone");
|
||||
// });
|
||||
.OnCreating(creating => creating.BaseType = typeof(Zone))
|
||||
.OnDisplaying(displaying => {
|
||||
var zone = displaying.Shape;
|
||||
ShapeMetadata zoneMetadata = zone.Metadata;
|
||||
String name = zone.ZoneName;
|
||||
zone.Classes.Add("zone-" + name.ToLower());
|
||||
zone.Classes.Add("zone");
|
||||
zoneMetadata.Alternates.Add("Zone__" + name);
|
||||
});
|
||||
|
||||
//builder.Describe("menu")
|
||||
// .OnDisplaying(displaying => {
|
||||
@@ -126,15 +127,15 @@ namespace Orchard.Core.Shapes {
|
||||
var progress = 1;
|
||||
var flatPositionComparer = new FlatPositionComparer();
|
||||
var ordering = unordered.Select(item => {
|
||||
var position = (item == null || item.GetType().GetProperty("Metadata") == null || item.Metadata.GetType().GetProperty("Position") == null)
|
||||
? null
|
||||
: item.Metadata.Position;
|
||||
return new {item, position};
|
||||
}).ToList();
|
||||
var position = (item == null || item.GetType().GetProperty("Metadata") == null || item.Metadata.GetType().GetProperty("Position") == null)
|
||||
? null
|
||||
: item.Metadata.Position;
|
||||
return new { item, position };
|
||||
}).ToList();
|
||||
|
||||
// since this isn't sticking around (hence, the "hack" in the name), throwing (in) a gnome
|
||||
while (i < ordering.Count()) {
|
||||
if (flatPositionComparer.Compare(ordering[i].position, ordering[i-1].position) > -1) {
|
||||
if (flatPositionComparer.Compare(ordering[i].position, ordering[i - 1].position) > -1) {
|
||||
if (i == progress)
|
||||
progress = ++i;
|
||||
else
|
||||
@@ -142,8 +143,8 @@ namespace Orchard.Core.Shapes {
|
||||
}
|
||||
else {
|
||||
var higherThanItShouldBe = ordering[i];
|
||||
ordering[i] = ordering[i-1];
|
||||
ordering[i-1] = higherThanItShouldBe;
|
||||
ordering[i] = ordering[i - 1];
|
||||
ordering[i - 1] = higherThanItShouldBe;
|
||||
if (i > 1)
|
||||
--i;
|
||||
}
|
||||
@@ -161,8 +162,8 @@ namespace Orchard.Core.Shapes {
|
||||
x = string.IsNullOrWhiteSpace(x) ? "5" : x.TrimStart(':'); // ':' is _sometimes_ used as a partition identifier
|
||||
y = string.IsNullOrWhiteSpace(y) ? "5" : y.TrimStart(':');
|
||||
|
||||
var xParts = x.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yParts = y.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var xParts = x.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yParts = y.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (var i = 0; i < xParts.Count(); i++) {
|
||||
if (yParts.Length < i - 1) // x is further defined meaning it comes after y (e.g. x == 1.2.3 and y == 1.2)
|
||||
return 1;
|
||||
@@ -251,7 +252,7 @@ namespace Orchard.Core.Shapes {
|
||||
|
||||
private static void WriteResources(HtmlHelper html, ISite site, IResourceManager rm, string resourceType, ResourceLocation? includeLocation, ResourceLocation? excludeLocation) {
|
||||
bool debugMode;
|
||||
switch(site.ResourceDebugMode) {
|
||||
switch (site.ResourceDebugMode) {
|
||||
case ResourceDebugMode.Enabled:
|
||||
debugMode = true;
|
||||
break;
|
||||
|
@@ -139,6 +139,7 @@
|
||||
<Content Include="Themes\TheThemeMachine\Styles\site.css" />
|
||||
<Content Include="Themes\TheThemeMachine\Theme.png" />
|
||||
<Content Include="Themes\TheThemeMachine\Theme.txt" />
|
||||
<None Include="Themes\Classic\Views\Zone-Navigation.cshtml" />
|
||||
<None Include="Themes\TheThemeMachine\Views\TempFeatured.cshtml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
@@ -55,7 +55,7 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
return target(displayContext);
|
||||
}
|
||||
};
|
||||
descriptor.Bindings[_shapeType] = binding;
|
||||
descriptor.Bindings[_bindingName] = binding;
|
||||
|
||||
});
|
||||
}
|
||||
|
@@ -7,19 +7,19 @@ using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
public interface ITagBuilderFactory : IDependency {
|
||||
TagBuilder Create(dynamic shape, string tagName);
|
||||
OrchardTagBuilder Create(dynamic shape, string tagName);
|
||||
}
|
||||
|
||||
public class TagBuilder : System.Web.Mvc.TagBuilder {
|
||||
public TagBuilder(string tagName) : base(tagName) { }
|
||||
public class OrchardTagBuilder : TagBuilder {
|
||||
public OrchardTagBuilder(string tagName) : base(tagName) { }
|
||||
|
||||
public IHtmlString StartElement { get { return new HtmlString(ToString(TagRenderMode.StartTag)); } }
|
||||
public IHtmlString EndElement { get { return new HtmlString(ToString(TagRenderMode.EndTag)); } }
|
||||
}
|
||||
|
||||
public class TagBuilderFactory : ITagBuilderFactory {
|
||||
public TagBuilder Create(dynamic shape, string tagName) {
|
||||
var tagBuilder = new TagBuilder(tagName);
|
||||
public OrchardTagBuilder Create(dynamic shape, string tagName) {
|
||||
var tagBuilder = new OrchardTagBuilder(tagName);
|
||||
tagBuilder.MergeAttributes(shape.Attributes, false);
|
||||
foreach (var cssClass in shape.Classes ?? Enumerable.Empty<string>())
|
||||
tagBuilder.AddCssClass(cssClass);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Resources;
|
||||
|
||||
@@ -22,5 +23,8 @@ namespace Orchard.Mvc {
|
||||
void SetMeta(MetaEntry meta);
|
||||
void AppendMeta(string name, string content, string contentSeparator);
|
||||
void AppendMeta(MetaEntry meta, string contentSeparator);
|
||||
|
||||
bool HasText(object thing);
|
||||
OrchardTagBuilder Tag(dynamic shape, string tagName);
|
||||
}
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
return !string.IsNullOrWhiteSpace(thing as string);
|
||||
}
|
||||
|
||||
public TagBuilder Tag(dynamic shape, string tagName) {
|
||||
public OrchardTagBuilder Tag(dynamic shape, string tagName) {
|
||||
return Html.Resolve<ITagBuilderFactory>().Create(shape, tagName);
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,7 @@ namespace Orchard.Mvc {
|
||||
return !string.IsNullOrWhiteSpace(thing as string);
|
||||
}
|
||||
|
||||
public TagBuilder Tag(dynamic shape, string tagName) {
|
||||
public OrchardTagBuilder Tag(dynamic shape, string tagName) {
|
||||
return Html.Resolve<ITagBuilderFactory>().Create(shape, tagName);
|
||||
}
|
||||
|
||||
|
@@ -92,7 +92,7 @@ namespace Orchard.Mvc {
|
||||
return !string.IsNullOrWhiteSpace(thing as string);
|
||||
}
|
||||
|
||||
public TagBuilder Tag(dynamic shape, string tagName) {
|
||||
public OrchardTagBuilder Tag(dynamic shape, string tagName) {
|
||||
return Html.Resolve<ITagBuilderFactory>().Create(shape, tagName);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user