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