mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
Binary file not shown.
@@ -43,6 +43,7 @@ namespace Orchard.Core.Shapes {
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(() => creating.New.Zone())))
|
||||
.OnCreated(created => {
|
||||
var layout = created.Shape;
|
||||
|
||||
layout.Head = created.New.DocumentZone(ZoneName: "Head");
|
||||
layout.Body = created.New.DocumentZone(ZoneName: "Body");
|
||||
layout.Tail = created.New.DocumentZone(ZoneName: "Tail");
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using ClaySharp;
|
||||
using ClaySharp.Behaviors;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
|
||||
@@ -168,34 +167,12 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
private void DumpShape(IShape shape) {
|
||||
var members = new Dictionary<string, object>();
|
||||
((IClayBehaviorProvider) (dynamic) shape).Behavior.GetMembers(() => null, shape, members);
|
||||
|
||||
var b = ((IClayBehaviorProvider) (dynamic) shape).Behavior as ClayBehaviorCollection;
|
||||
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
// seek the PropBehavior if exists
|
||||
var propBehavior = b.OfType<PropBehavior>().FirstOrDefault();
|
||||
|
||||
if (propBehavior == null)
|
||||
return;
|
||||
|
||||
// retrieve the internal dictionary for properties
|
||||
var props = propBehavior.GetType().GetField("_props", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField).GetValue(propBehavior) as Dictionary<object, object>;
|
||||
|
||||
if (props == null)
|
||||
return;
|
||||
|
||||
if (props.Keys.Count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var key in props.Keys) {
|
||||
// ignore private members (added dynmically by the shape wrapper)
|
||||
if (key.ToString().StartsWith("_")) {
|
||||
continue;
|
||||
}
|
||||
Dump(props[key], key.ToString());
|
||||
foreach (var key in members.Keys.Where(key => !key.StartsWith("_"))) {
|
||||
// ignore private members (added dynamically by the shape wrapper)
|
||||
Dump(members[key], key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Themes.Models;
|
||||
|
||||
namespace Orchard.Themes.Services {
|
||||
@@ -17,7 +15,6 @@ namespace Orchard.Themes.Services {
|
||||
public const string CurrentThemeSignal = "SiteCurrentTheme";
|
||||
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly ISignals _signals;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
@@ -25,22 +22,14 @@ namespace Orchard.Themes.Services {
|
||||
public SiteThemeService(
|
||||
IOrchardServices orchardServices,
|
||||
IExtensionManager extensionManager,
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals) {
|
||||
|
||||
_orchardServices = orchardServices;
|
||||
_extensionManager = extensionManager;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ExtensionDescriptor GetSiteTheme() {
|
||||
string currentThemeName = GetCurrentThemeName();
|
||||
@@ -48,7 +37,7 @@ namespace Orchard.Themes.Services {
|
||||
}
|
||||
|
||||
public void SetSiteTheme(string themeName) {
|
||||
var site = _workContextAccessor.GetContext().CurrentSite;
|
||||
var site = _orchardServices.WorkContext.CurrentSite;
|
||||
site.As<ThemeSiteSettingsPart>().CurrentThemeName = themeName;
|
||||
|
||||
_signals.Trigger(CurrentThemeSignal);
|
||||
|
||||
@@ -40,91 +40,93 @@
|
||||
}
|
||||
|
||||
@if (Model.TotalItemCount > 1) {
|
||||
<div class="pager-footer">
|
||||
using (Html.BeginFormAntiForgeryPost()) {
|
||||
<div class="pager-footer">
|
||||
|
||||
@if (totalPageCount > 1 || Model.PageSize == 0 || Model.PageSize > pageSizes.First()) {
|
||||
<div class="page-size-options">
|
||||
<input type="hidden" name="Page" value="1" />
|
||||
<label for="pageSize">@T("Show:")</label>
|
||||
<select id="pageSize" name="PageSize">
|
||||
@Html.SelectOption((int)Model.PageSize, 0, T("All").ToString())
|
||||
@foreach (int size in pageSizes.OrderBy(p => p)) {
|
||||
@Html.SelectOption((int)Model.PageSize, size, size.ToString())
|
||||
}
|
||||
</select>
|
||||
@if (totalPageCount > 1 || Model.PageSize == 0 || Model.PageSize > pageSizes.First()) {
|
||||
<div class="page-size-options">
|
||||
<input type="hidden" name="Page" value="1" />
|
||||
<label for="pageSize">@T("Show:")</label>
|
||||
<select id="pageSize" name="PageSize">
|
||||
@Html.SelectOption((int)Model.PageSize, 0, T("All").ToString())
|
||||
@foreach (int size in pageSizes.OrderBy(p => p)) {
|
||||
@Html.SelectOption((int)Model.PageSize, size, size.ToString())
|
||||
}
|
||||
</select>
|
||||
|
||||
<button id="submit-pager" type="submit">@T("Apply")</button>
|
||||
</div>
|
||||
}
|
||||
<button id="submit-pager" type="submit">@T("Apply")</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<span class="page-results">@T("Showing items {0} - {1} of {2}", (Model.Page - 1) * (int)Model.PageSize + 1, Model.PageSize == 0 ? Model.TotalItemCount : Math.Min(Model.TotalItemCount, (Model.Page) * (int)Model.PageSize), Model.TotalItemCount)</span>
|
||||
<span class="page-results">@T("Showing items {0} - {1} of {2}", (Model.Page - 1) * (int)Model.PageSize + 1, Model.PageSize == 0 ? Model.TotalItemCount : Math.Min(Model.TotalItemCount, (Model.Page) * (int)Model.PageSize), Model.TotalItemCount)</span>
|
||||
|
||||
@if (totalPageCount > 1) {
|
||||
routeData["pageSize"] = Model.PageSize;
|
||||
@tag.StartElement
|
||||
@if (totalPageCount > 1) {
|
||||
routeData["pageSize"] = Model.PageSize;
|
||||
@tag.StartElement
|
||||
|
||||
// first
|
||||
if (firstPage > 1) {
|
||||
if (routeData.ContainsKey("page")) {
|
||||
routeData.Remove("page");
|
||||
// first
|
||||
if (firstPage > 1) {
|
||||
if (routeData.ContainsKey("page")) {
|
||||
routeData.Remove("page");
|
||||
}
|
||||
|
||||
<li class="page-first">
|
||||
@Html.ActionLink(T("<<").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
|
||||
<li class="page-first">
|
||||
@Html.ActionLink(T("<<").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
|
||||
// previous page
|
||||
if (Model.Page > 1) {
|
||||
if (Model.Page == 2 && routeData.ContainsKey("page")) {
|
||||
routeData.Remove("page");
|
||||
} else {
|
||||
routeData["page"] = Model.Page - 1;
|
||||
}
|
||||
|
||||
<li class="page-previous">
|
||||
@Html.ActionLink((string)previousText, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
|
||||
// page numbers
|
||||
for (var p = firstPage; p <= lastPage; p++) {
|
||||
<li class="page-@p">
|
||||
@if (p == Model.Page) {
|
||||
<span>@p</span>
|
||||
} else {
|
||||
if (p == 1) {
|
||||
// previous page
|
||||
if (Model.Page > 1) {
|
||||
if (Model.Page == 2 && routeData.ContainsKey("page")) {
|
||||
routeData.Remove("page");
|
||||
} else {
|
||||
routeData["page"] = p;
|
||||
routeData["page"] = Model.Page - 1;
|
||||
}
|
||||
@Html.ActionLink(p.ToString(), (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
|
||||
<li class="page-previous">
|
||||
@Html.ActionLink((string)previousText, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
|
||||
// next page
|
||||
if (Model.Page < totalPageCount) {
|
||||
routeData["page"] = Model.Page + 1;
|
||||
// page numbers
|
||||
for (var p = firstPage; p <= lastPage; p++) {
|
||||
<li class="page-@p">
|
||||
@if (p == Model.Page) {
|
||||
<span>@p</span>
|
||||
} else {
|
||||
if (p == 1) {
|
||||
routeData.Remove("page");
|
||||
} else {
|
||||
routeData["page"] = p;
|
||||
}
|
||||
@Html.ActionLink(p.ToString(), (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
}
|
||||
</li>
|
||||
}
|
||||
|
||||
<li class="page-next">
|
||||
@Html.ActionLink((string)nextText, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
// next page
|
||||
if (Model.Page < totalPageCount) {
|
||||
routeData["page"] = Model.Page + 1;
|
||||
|
||||
// last page
|
||||
if (lastPage < totalPageCount) {
|
||||
routeData["page"] = totalPageCount;
|
||||
<li class="page-next">
|
||||
@Html.ActionLink((string)nextText, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
|
||||
<li class="page-last">
|
||||
@Html.ActionLink(T(">>").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
// last page
|
||||
if (lastPage < totalPageCount) {
|
||||
routeData["page"] = totalPageCount;
|
||||
|
||||
@tag.EndElement
|
||||
}
|
||||
<li class="page-last">
|
||||
@Html.ActionLink(T(">>").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null)
|
||||
</li>
|
||||
}
|
||||
|
||||
</div>
|
||||
@tag.EndElement
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@using(Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
@@ -133,7 +135,7 @@
|
||||
// Add the event handler for value change in the select field
|
||||
$("#pageSize").change(function () {
|
||||
var self = $(this);
|
||||
var form = self.closest("form");
|
||||
var form = self.parents("form");
|
||||
|
||||
// Submit form
|
||||
form.submit();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using System.Diagnostics;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
|
||||
namespace Orchard.DisplayManagement {
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
[DebuggerTypeProxy(typeof(ShapeDebugView))]
|
||||
public class Shape : IShape, IEnumerable {
|
||||
private const string DefaultPosition = "5";
|
||||
|
||||
@@ -46,7 +48,5 @@ namespace Orchard.DisplayManagement.Shapes {
|
||||
public virtual IEnumerator GetEnumerator() {
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
62
src/Orchard/DisplayManagement/Shapes/ShapeDebugView.cs
Normal file
62
src/Orchard/DisplayManagement/Shapes/ShapeDebugView.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using ClaySharp;
|
||||
|
||||
namespace Orchard.DisplayManagement.Shapes {
|
||||
public class ShapeDebugView {
|
||||
private readonly Shape _shape;
|
||||
|
||||
public ShapeDebugView(Shape shape) {
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
public ShapeMetadata Metadata { get { return _shape.Metadata; } }
|
||||
|
||||
public string Id { get { return _shape.Id; } }
|
||||
public IList<string> Classes { get { return _shape.Classes; } }
|
||||
public IDictionary<string, string> Attributes { get { return _shape.Attributes; } }
|
||||
public IEnumerable<dynamic> Items { get { return _shape.Items; } }
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||
public KeyValuePairs[] ClayProperties {
|
||||
get {
|
||||
var members = new Dictionary<string, object>();
|
||||
((IClayBehaviorProvider)_shape).Behavior.GetMembers(() => null, _shape, members);
|
||||
|
||||
return members.Keys.Select(key => new KeyValuePairs(key, members[key])).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay(" { _shapeType == null ? _value : \"Shape: \" + _shapeType}", Name = "{_key,nq}")]
|
||||
public class KeyValuePairs {
|
||||
|
||||
public KeyValuePairs(object key, object value) {
|
||||
try {
|
||||
var dynProxyGetTarget = value.GetType().GetMethod("DynProxyGetTarget");
|
||||
if (dynProxyGetTarget != null) {
|
||||
_value = dynProxyGetTarget.Invoke(value, null);
|
||||
_shapeType = ((IShape)_value).Metadata.Type;
|
||||
}
|
||||
else {
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
_value = value;
|
||||
}
|
||||
|
||||
_key = key;
|
||||
}
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private object _key;
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private object _shapeType;
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||
private object _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,6 +172,7 @@
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapeTableBuilder.cs" />
|
||||
<Compile Include="DisplayManagement\Implementation\IShapeDisplayEvents.cs" />
|
||||
<Compile Include="DisplayManagement\Implementation\IShapeFactoryEvents.cs" />
|
||||
<Compile Include="DisplayManagement\Shapes\ShapeDebugView.cs" />
|
||||
<Compile Include="DisplayManagement\Shapes\ITagBuilderFactory.cs" />
|
||||
<Compile Include="Environment\CollectionOrderModule.cs" />
|
||||
<Compile Include="Environment\Extensions\OrchardSuppressDependencyAttribute.cs" />
|
||||
@@ -869,7 +870,6 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in New Issue
Block a user