diff --git a/src/Orchard.Tests/UI/ShapeTests.cs b/src/Orchard.Tests/UI/ShapeTests.cs index 59ea45769..fd2ea3bc4 100644 --- a/src/Orchard.Tests/UI/ShapeTests.cs +++ b/src/Orchard.Tests/UI/ShapeTests.cs @@ -23,8 +23,10 @@ namespace Orchard.Tests.UI { builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); - builder.RegisterType().As(); + //builder.RegisterType().As(); builder.RegisterType().As(); + + throw new NotImplementedException("this test fixture needs to move to modules tests now"); } protected override void Resolve(IContainer container) { diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index a5688921d..119965824 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -223,6 +223,7 @@ + @@ -345,6 +346,10 @@ + + {76BCD43B-7BA5-4B63-B1E1-861641CA2686} + ClaySharp + {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} Orchard.Framework diff --git a/src/Orchard.Web/Core/Shapes/CoreShapes.cs b/src/Orchard.Web/Core/Shapes/CoreShapes.cs new file mode 100644 index 000000000..235a83f38 --- /dev/null +++ b/src/Orchard.Web/Core/Shapes/CoreShapes.cs @@ -0,0 +1,46 @@ +using System.Web; +using System.Web.Mvc; +using System.Web.Mvc.Html; +using Orchard.DisplayManagement; +using Orchard.DisplayManagement.Descriptors; +using Orchard.Environment.Extensions.Models; +using Orchard.UI; +using Orchard.UI.Zones; + +namespace Orchard.Core.Shapes { + public class CoreShapes : IShapeDescriptorBindingStrategy { + public Feature Feature { get; set; } + + public void Discover(ShapeTableBuilder builder) { + // the root page shape named 'Layout' is wrapped with 'Document' + // and has an automatic zone creating behavior + builder.Describe.Named("Layout").From(Feature.Descriptor) + .OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(creating.ShapeFactory))) + .Configure(descriptor => descriptor.Wrappers.Add("Document")); + + // 'Zone' shapes are built on the Zone base class + builder.Describe.Named("Zone").From(Feature.Descriptor) + .OnCreating(creating => creating.BaseType = typeof(Zone)); + } + + static object DetermineModel(HtmlHelper Html, object Model) { + bool isNull = ((dynamic)Model) == null; + return isNull ? Html.ViewData.Model : Model; + } + + [Shape] + public IHtmlString Partial(HtmlHelper Html, string TemplateName, object Model) { + return Html.Partial(TemplateName, DetermineModel(Html, Model)); + } + + [Shape] + public IHtmlString DisplayTemplate(HtmlHelper Html, string TemplateName, object Model, string Prefix) { + return Html.Partial(TemplateName, DetermineModel(Html, Model)); + } + + [Shape] + public IHtmlString EditorTemplate(HtmlHelper Html, string TemplateName, object Model, string Prefix) { + return Html.Partial(TemplateName, DetermineModel(Html, Model)); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs index 0feb72e09..10863af45 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs @@ -8,6 +8,7 @@ using Orchard.Commands.Builtin; using Orchard.ContentManagement; using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.MetaData.Builders; +using Orchard.Core.Shapes; using Orchard.Data.Migration.Interpreters; using Orchard.Data.Providers; using Orchard.Data.Migration; diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 1071c9391..48f76baa0 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -309,6 +309,7 @@ + diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/DumpShapeTable.cshtml b/src/Orchard.Web/Themes/TheAdmin/Views/DumpShapeTable.cshtml new file mode 100644 index 000000000..f07cf3f3a --- /dev/null +++ b/src/Orchard.Web/Themes/TheAdmin/Views/DumpShapeTable.cshtml @@ -0,0 +1,18 @@ +@using Orchard +@using Orchard.DisplayManagement.Descriptors +@{ + var workContext = ViewContext.GetWorkContext(); + var shapeTable = workContext.Resolve().GetShapeTable(workContext.CurrentTheme.ThemeName); + +
    + @foreach(var descriptor in shapeTable.Descriptors) { +
  • @descriptor.Key : @descriptor.Value.BindingSource + @if(descriptor.Value.FrameTypes.Any()){ + foreach(var ft in descriptor.Value.FrameTypes) { + @(" +"+ft) + } + } +
  • + } +
+} diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx b/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx index f47cfcfe6..094b15b62 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx @@ -1,26 +1,45 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Security" %> +<%@ Import Namespace="Orchard.DisplayManagement.Descriptors" %> +<%@ Import Namespace="Orchard" %> <% -Model.Content.Add(Model.Metadata.ChildContent, "5"); + Model.Content.Add(Model.Metadata.ChildContent, "5"); -// these are just hacked together to fire existing partials... can change -Model.Header.Add(Display.Header()); -Model.Header.Add(Display.User(CurrentUser:Html.Resolve().GetAuthenticatedUser()), "after"); + // these are just hacked together to fire existing partials... can change + Model.Header.Add(Display.Header()); -Html.RegisterStyle("site.css", "1"); -Html.RegisterStyle("ie.css", "1").WithCondition("if (lte IE 8)").ForMedia("screen, projection"); -Html.RegisterStyle("ie6.css", "1").WithCondition("if (lte IE 6)").ForMedia("screen, projection"); -Html.RegisterFootScript("admin.js", "1"); + var thisUser = Html.Resolve().GetAuthenticatedUser(); -// these are just hacked together to fire existing partials... can change + Model.Header.Add(Display.User(CurrentUser: thisUser), "after"); -//Model.Zones.AddRenderPartial("header", "Header", Model); -//Model.Zones.AddRenderPartial("header:after", "User", Model); // todo: (heskew) should be a user display or widget + Model.CurrentUser = thisUser; + Model.Header.Add(Display.Partial(TemplateName: "User"), "after"); + + var userDisplay = thisUser.ContentItem.ContentManager.BuildDisplayModel(thisUser, "Detail"); + Model.Content.Add(userDisplay); + + Html.RegisterStyle("site.css", "1"); + Html.RegisterStyle("ie.css", "1").WithCondition("if (lte IE 8)").ForMedia("screen, projection"); + Html.RegisterStyle("ie6.css", "1").WithCondition("if (lte IE 6)").ForMedia("screen, projection"); + Html.RegisterFootScript("admin.js", "1"); + + // these are just hacked together to fire existing partials... can change + + //Model.Zones.AddRenderPartial("header", "Header", Model); + //Model.Zones.AddRenderPartial("header:after", "User", Model); // todo: (heskew) should be a user display or widget %> - +
- -
<%: Display(Model.Content) %>
- + +
+ <%: Display(Model.Content) %>
+
- + + +<%: Display.DumpShapeTable() %> diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingModule.cs b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingModule.cs index 4ece18252..2a49ed394 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingModule.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingModule.cs @@ -20,15 +20,15 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy { sa, mi, registration, - () => GetFeatureDescriptor(registration)))) + () => GetFeature(registration)))) .ToArray(); if (occurrences.Any()) _occurrences.AddRange(occurrences); } - private static FeatureDescriptor GetFeatureDescriptor(IComponentRegistration registration) { - object value; return registration.Metadata.TryGetValue("Feature", out value) ? value as FeatureDescriptor : null; + private static Feature GetFeature(IComponentRegistration registration) { + object value; return registration.Metadata.TryGetValue("Feature", out value) ? value as Feature : null; } } } \ No newline at end of file diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs index 4adb7d309..b45cb84d9 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs @@ -35,7 +35,7 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy { var shapeType = occurrence.ShapeAttribute.ShapeType ?? occurrence.MethodInfo.Name; builder.Describe .Named(shapeType) - .From(occurrence.Feature) + .From(occurrence.Feature.Descriptor) .BoundAs( occurrence.MethodInfo.DeclaringType.FullName + "::" + occurrence.MethodInfo.Name, descriptor => CreateDelegate(occurrence, descriptor)); diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeOccurrence.cs b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeOccurrence.cs index 050a75368..ba7cf1db4 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeOccurrence.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeOccurrence.cs @@ -5,9 +5,9 @@ using Orchard.Environment.Extensions.Models; namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy { public class ShapeAttributeOccurrence { - private readonly Func _feature; + private readonly Func _feature; - public ShapeAttributeOccurrence(ShapeAttribute shapeAttribute, MethodInfo methodInfo, IComponentRegistration registration, Func feature) { + public ShapeAttributeOccurrence(ShapeAttribute shapeAttribute, MethodInfo methodInfo, IComponentRegistration registration, Func feature) { ShapeAttribute = shapeAttribute; MethodInfo = methodInfo; Registration = registration; @@ -17,6 +17,6 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy { public ShapeAttribute ShapeAttribute { get; private set; } public MethodInfo MethodInfo { get; private set; } public IComponentRegistration Registration { get; private set; } - public FeatureDescriptor Feature { get { return _feature(); } } + public Feature Feature { get { return _feature(); } } } } \ No newline at end of file diff --git a/src/Orchard/Mvc/IOrchardViewPage.cs b/src/Orchard/Mvc/IOrchardViewPage.cs new file mode 100644 index 000000000..47cdbc58e --- /dev/null +++ b/src/Orchard/Mvc/IOrchardViewPage.cs @@ -0,0 +1,12 @@ +using Orchard.Localization; + +namespace Orchard.Mvc { + /// + /// This interface ensures all base view pages implement the + /// same set of additional members + /// + public interface IOrchardViewPage { + Localizer T { get; } + dynamic Display { get; } + } +} \ No newline at end of file diff --git a/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs b/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs index 0766d1d4f..d1075ffad 100644 --- a/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs +++ b/src/Orchard/Mvc/ViewEngines/Razor/WebViewPage.cs @@ -6,7 +6,7 @@ using Orchard.Security.Permissions; namespace Orchard.Mvc.ViewEngines.Razor { - public abstract class WebViewPage : System.Web.Mvc.WebViewPage { + public abstract class WebViewPage : System.Web.Mvc.WebViewPage, IOrchardViewPage { private object _display; private object _new; private Localizer _localizer = NullLocalizer.Instance; diff --git a/src/Orchard/Mvc/ViewPage.cs b/src/Orchard/Mvc/ViewPage.cs index d6e41a671..9972a5fd1 100644 --- a/src/Orchard/Mvc/ViewPage.cs +++ b/src/Orchard/Mvc/ViewPage.cs @@ -8,7 +8,7 @@ using Orchard.Security; using Orchard.Security.Permissions; namespace Orchard.Mvc { - public class ViewPage : System.Web.Mvc.ViewPage { + public class ViewPage : System.Web.Mvc.ViewPage, IOrchardViewPage { private object _display; private Localizer _localizer = NullLocalizer.Instance; diff --git a/src/Orchard/Mvc/ViewUserControl.cs b/src/Orchard/Mvc/ViewUserControl.cs index 5c81d426f..bce46f231 100644 --- a/src/Orchard/Mvc/ViewUserControl.cs +++ b/src/Orchard/Mvc/ViewUserControl.cs @@ -7,7 +7,7 @@ using Orchard.Security; using Orchard.Security.Permissions; namespace Orchard.Mvc { - public class ViewUserControl : System.Web.Mvc.ViewUserControl { + public class ViewUserControl : System.Web.Mvc.ViewUserControl,IOrchardViewPage { private object _display; private object _new; private Localizer _localizer = NullLocalizer.Instance; diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index db1420352..6288a3360 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -145,6 +145,7 @@ + diff --git a/src/Orchard/UI/Zones/PageWorkContext.cs b/src/Orchard/UI/Zones/PageWorkContext.cs index 04266cccf..37d2a22b1 100644 --- a/src/Orchard/UI/Zones/PageWorkContext.cs +++ b/src/Orchard/UI/Zones/PageWorkContext.cs @@ -1,8 +1,6 @@ using System.Linq; using ClaySharp.Implementation; using Orchard.DisplayManagement; -using Orchard.DisplayManagement.Descriptors; -using Orchard.Environment.Extensions.Models; namespace Orchard.UI.Zones { public class PageWorkContext : IWorkContextStateProvider { @@ -19,23 +17,4 @@ namespace Orchard.UI.Zones { return default(T); } } - - public class CoreShapes : IShapeDescriptorBindingStrategy { - public void Discover(ShapeTableBuilder builder) { - var feature = new FeatureDescriptor { - Name = "Orchard.Framework", - Extension = new ExtensionDescriptor { - Name = "Orchard.Framework", - ExtensionType = "Module", - } - }; - - builder.Describe.Named("Layout").From(feature) - .OnCreating(context => context.Behaviors.Add(new ZoneHoldingBehavior(context.ShapeFactory))) - .Configure(d => d.FrameTypes.Add("Document")); - - builder.Describe.Named("Zone").From(feature) - .OnCreating(context => context.BaseType = typeof(Zone)); - } - } }