mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Merge
--HG-- branch : theming
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.UI;
|
||||
using Orchard.UI.Zones;
|
||||
@@ -21,7 +22,7 @@ namespace Orchard.Core.Shapes {
|
||||
// and has an automatic zone creating behavior
|
||||
builder.Describe.Named("Layout").From(Feature.Descriptor)
|
||||
.Configure(descriptor => descriptor.Wrappers.Add("Document"))
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => creating.New.Zone())))
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => CreateZone(creating, name))))
|
||||
.OnCreated(created => {
|
||||
created.Shape.Head = created.New.DocumentZone();
|
||||
created.Shape.Body = created.New.DocumentZone();
|
||||
@@ -35,18 +36,24 @@ namespace Orchard.Core.Shapes {
|
||||
// 'Zone' shapes are built on the Zone base class
|
||||
builder.Describe.Named("Zone").From(Feature.Descriptor)
|
||||
.OnCreating(creating => creating.BaseType = typeof(Zone));
|
||||
|
||||
|
||||
// 'List' shapes start with several empty collections
|
||||
builder.Describe.Named("List").From(Feature.Descriptor)
|
||||
.OnCreated(created => {
|
||||
created.Shape.Tag = "ul";
|
||||
created.Shape.Classes = new List<string>();
|
||||
created.Shape.Attributes = new Dictionary<string, string>();
|
||||
created.Shape.ItemClasses = new List<string>();
|
||||
created.Shape.ItemAttributes = new Dictionary<string, string>();
|
||||
});
|
||||
}
|
||||
|
||||
private object CreateZone(ShapeCreatingContext context, string zoneName) {
|
||||
var name = zoneName.ToLower();
|
||||
|
||||
var zone = context.New.Zone();
|
||||
zone.Id = "zone-" + name;
|
||||
zone.Classes.Add(zone.Id);
|
||||
zone.Classes.Add("zone");
|
||||
return zone;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,3 +1,10 @@
|
||||
<ul id="Menu-@Model.MenuName" class="Menu Menu-@Model.MenuName">
|
||||
@DisplayChildren(Model)
|
||||
</ul><!-- /Menu-@Model.MenuName -->
|
||||
@{
|
||||
// these should move somewhere else
|
||||
Model.Id = "menu-" + Model.MenuName.ToLower();
|
||||
Model.Classes.Add(Model.Id);
|
||||
Model.Classes.Add("menu");
|
||||
var tag = Html.Resolve<Orchard.DisplayManagement.Shapes.ITagBuilderFactory>().Create(Model, "ul");
|
||||
}
|
||||
@tag.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement <!-- /@Model.Id -->
|
||||
|
@@ -1,9 +1,6 @@
|
||||
@{
|
||||
var id = Model.Id;
|
||||
if (id == null && Model.ZoneName != null) {
|
||||
id = (Model.Parent.Id == null ? "" : Model.Parent.Id + "-") + "Zone-" + Model.ZoneName;
|
||||
}
|
||||
var tag = Html.Resolve<Orchard.DisplayManagement.Shapes.ITagBuilderFactory>().Create(Model, "div");
|
||||
}
|
||||
<div id="@id" class="Zone Zone-@Model.ZoneName">
|
||||
@DisplayChildren(Model)
|
||||
</div><!-- /@id -->
|
||||
@tag.StartElement
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement <!-- /@Model.Id -->
|
||||
|
@@ -310,9 +310,6 @@
|
||||
<Content Include="Themes\TheAdmin\Styles\images\orchardLogo.gif" />
|
||||
<Content Include="Themes\TheAdmin\Theme.png" />
|
||||
<None Include="Themes\TheAdmin\Views\DumpShapeTable.cshtml" />
|
||||
<None Include="Themes\TheAdmin\Views\MenuItem.cshtml" />
|
||||
<None Include="Themes\TheAdmin\Views\Menu.cshtml" />
|
||||
<None Include="Themes\TheAdmin\Views\Menu.ascx_" />
|
||||
<Content Include="Themes\TheAdmin\Views\User.ascx" />
|
||||
<Content Include="Themes\TheAdmin\Views\Header.ascx" />
|
||||
<Content Include="Themes\Web.config" />
|
||||
|
@@ -1,3 +0,0 @@
|
||||
<ul id="Menu-@Model.MenuName" class="Menu Menu-@Model.MenuName">
|
||||
@DisplayChildren(Model)
|
||||
</ul><!-- /Menu-@Model.MenuName -->
|
@@ -1,9 +0,0 @@
|
||||
@{
|
||||
// odd formatting in this file is to cause more attractive results in the output.
|
||||
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
|
||||
}
|
||||
<li><a href="@Model.Href">@Model.Text</a>@{ if (items.Any()) {
|
||||
<ul>
|
||||
@DisplayChildren(Model)
|
||||
</ul>}}
|
||||
</li>
|
31
src/Orchard/DisplayManagement/Shapes/ITagBuilderFactory.cs
Normal file
31
src/Orchard/DisplayManagement/Shapes/ITagBuilderFactory.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
public interface ITagBuilderFactory : IDependency {
|
||||
TagBuilder Create(dynamic shape, string tagName);
|
||||
}
|
||||
|
||||
public class TagBuilder : System.Web.Mvc.TagBuilder {
|
||||
public TagBuilder(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);
|
||||
tagBuilder.MergeAttributes(shape.Attributes, false);
|
||||
foreach (var cssClass in shape.Classes ?? Enumerable.Empty<string>())
|
||||
tagBuilder.AddCssClass(cssClass);
|
||||
if (!string.IsNullOrEmpty(shape.Id))
|
||||
tagBuilder.GenerateId(shape.Id);
|
||||
return tagBuilder;
|
||||
}
|
||||
}
|
||||
}
|
@@ -145,6 +145,7 @@
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapeDescriptorAlterationBuilder.cs" />
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapeTable.cs" />
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapeTableBuilder.cs" />
|
||||
<Compile Include="DisplayManagement\Shapes\ITagBuilderFactory.cs" />
|
||||
<Compile Include="Mvc\IOrchardViewPage.cs" />
|
||||
<Compile Include="Mvc\Spooling\HtmlStringWriter.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\Razor\RazorViewEngine.cs" />
|
||||
|
Reference in New Issue
Block a user