mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge branch '1.8.x' into 1.x
Conflicts: src/Orchard.Web/Modules/Orchard.MediaLibrary/Services/MediaLibraryService.cs src/Orchard.Web/Modules/Orchard.Modules/styles/orchard-modules-admin.css src/Orchard.Web/Modules/Orchard.Taxonomies/Services/TaxonomyService.cs src/Orchard.Web/Modules/Orchard.Widgets/Filters/WidgetFilter.cs src/Orchard/Mvc/Routes/RoutePublisher.cs
This commit is contained in:
@@ -1,35 +1,29 @@
|
||||
FOR %%b in (
|
||||
"%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
|
||||
"%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
|
||||
|
||||
if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" goto initialize2k8on64Dev12
|
||||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" goto initialize2k8Dev12
|
||||
if exist "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto initialize2k8on64Dev11
|
||||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto initialize2k8Dev11
|
||||
|
||||
"%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
|
||||
"%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
|
||||
) do (
|
||||
if exist %%b (
|
||||
call %%b x86
|
||||
goto build
|
||||
)
|
||||
)
|
||||
|
||||
echo "Unable to detect suitable environment. Build may not succeed."
|
||||
goto build
|
||||
|
||||
|
||||
:initialize2k8Dev12
|
||||
call "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8on64Dev12
|
||||
call "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8Dev11
|
||||
call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8on64Dev11
|
||||
call "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:build
|
||||
if "%~1"=="" msbuild /t:Build Orchard.proj
|
||||
msbuild /t:%~1 Orchard.proj
|
||||
|
||||
SET target=%1
|
||||
SET project=%2
|
||||
|
||||
IF "%target%" == "" SET target=Build
|
||||
IF "%project%" =="" SET project=Orchard.proj
|
||||
|
||||
msbuild /t:%target% %project%
|
||||
|
||||
pause
|
||||
goto end
|
||||
|
||||
|
||||
:end
|
||||
|
@@ -1,35 +1,6 @@
|
||||
SET target=%1
|
||||
|
||||
if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" goto initialize2k8on64Dev12
|
||||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" goto initialize2k8Dev12
|
||||
if exist "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto initialize2k8on64Dev11
|
||||
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" goto initialize2k8Dev11
|
||||
IF "%target%"=="" SET target=Build
|
||||
|
||||
echo "Unable to detect suitable environment. Build may not succeed."
|
||||
goto build
|
||||
ClickToBuild %target% AzurePackage.proj
|
||||
|
||||
|
||||
:initialize2k8Dev12
|
||||
call "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8on64Dev12
|
||||
call "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8Dev11
|
||||
call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:initialize2k8on64Dev11
|
||||
call "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
|
||||
goto build
|
||||
|
||||
:build
|
||||
if "%~1"=="" msbuild /t:Build AzurePackage.proj
|
||||
msbuild /t:%~1 AzurePackage.proj
|
||||
|
||||
pause
|
||||
goto end
|
||||
|
||||
|
||||
:end
|
||||
|
@@ -1,2 +1 @@
|
||||
if "%~1"=="" call clicktobuild
|
||||
call clicktobuild %~1
|
||||
clicktobuild %*
|
||||
|
@@ -0,0 +1,993 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.DesignerTools.Services;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
|
||||
namespace Orchard.Tests.Modules.DesignerTools.Services
|
||||
{
|
||||
public class TestObject
|
||||
{
|
||||
public int SomeInteger { get; set; }
|
||||
public bool SomeBoolean { get; set; }
|
||||
public string SomeString { get; set; }
|
||||
public TestObject ChildObject { get; set; }
|
||||
}
|
||||
|
||||
public class TestIShape : IShape
|
||||
{
|
||||
public ShapeMetadata Metadata { get; set; }
|
||||
|
||||
public int SomeInteger { get; set; }
|
||||
public bool SomeBoolean { get; set; }
|
||||
public string SomeString { get; set; }
|
||||
|
||||
public TestIShape ChildObject { get; set; }
|
||||
}
|
||||
|
||||
public class TestShape : Shape
|
||||
{
|
||||
public int SomeInteger { get; set; }
|
||||
public bool SomeBoolean { get; set; }
|
||||
public string SomeString { get; set; }
|
||||
|
||||
public TestShape ChildObject { get; set; }
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class ObjectDumperTests
|
||||
{
|
||||
private static void ComparareJsonObject(JObject expectedResult, string json) {
|
||||
var objectDumperJson = JToken.Parse("{" + json + "}");
|
||||
|
||||
Assert.IsTrue(JToken.DeepEquals(expectedResult, objectDumperJson));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpNull() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(null, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "null"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpValueTypeInteger() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(1337, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "1337"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpValueTypeBoolean() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(true, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "True"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpString() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump("Never gonna give you up", "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", ""Never gonna give you up""));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpEnumerable() {
|
||||
var enumerable = new[] { 1, 2, 3 }.AsEnumerable();
|
||||
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(enumerable, "Model");
|
||||
|
||||
Assert.Throws(typeof(NullReferenceException), () => {
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpEnumerable_DepthTwo() {
|
||||
var enumerable = new[] { 1, 2, 3 }.AsEnumerable();
|
||||
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(enumerable, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "Int32[]"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", "1")),
|
||||
new JObject(
|
||||
new JProperty("name", "[1]"),
|
||||
new JProperty("value", "2")),
|
||||
new JObject(
|
||||
new JProperty("name", "[2]"),
|
||||
new JProperty("value", "3"))
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpDictionary() {
|
||||
var dictionary = new Dictionary<string, int> { { "One", 1 }, { "Two", 2 }, {"Three", 3} };
|
||||
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(dictionary, "Model");
|
||||
|
||||
Assert.Throws(typeof(NullReferenceException), () => {
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpDictionary_DepthTwo() {
|
||||
var dictionary = new Dictionary<string, int> { { "One", 1 }, { "Two", 2 }, { "Three", 3 } };
|
||||
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(dictionary, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "Dictionary<String, Int32>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "["One"]"),
|
||||
new JProperty("value", "1")),
|
||||
new JObject(
|
||||
new JProperty("name", "["Two"]"),
|
||||
new JProperty("value", "2")),
|
||||
new JObject(
|
||||
new JProperty("name", "["Three"]"),
|
||||
new JProperty("value", "3"))
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpContentItem_DepthTwo() {
|
||||
var contentItem = new ContentItem { ContentType = "TestContentType" };
|
||||
var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
|
||||
contentItem.Weld(testingPart);
|
||||
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(contentItem, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "ContentItem"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Id"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "Version"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "ContentType"),
|
||||
new JProperty("value", ""TestContentType""))
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpContentItem_DepthFour() {
|
||||
var contentItem = new ContentItem { ContentType = "TestContentType" };
|
||||
var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
|
||||
contentItem.Weld(testingPart);
|
||||
|
||||
var objectDumper = new ObjectDumper(4);
|
||||
var xElement = objectDumper.Dump(contentItem, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "ContentItem"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Id"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "Version"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "ContentType"),
|
||||
new JProperty("value", ""TestContentType"")),
|
||||
new JObject(
|
||||
new JProperty("name", "TestingPart"),
|
||||
new JProperty("value", "ContentPart"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Zones"),
|
||||
new JProperty("value", "ZoneCollection")),
|
||||
new JObject(
|
||||
new JProperty("name", "Id"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "TypeDefinition"),
|
||||
new JProperty("value", "null")),
|
||||
new JObject(
|
||||
new JProperty("name", "TypePartDefinition"),
|
||||
new JProperty("value", "ContentTypePartDefinition")),
|
||||
new JObject(
|
||||
new JProperty("name", "PartDefinition"),
|
||||
new JProperty("value", "ContentPartDefinition"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Name"),
|
||||
new JProperty("value", ""TestingPart""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Settings"),
|
||||
new JProperty("value", "SettingsDictionary")),
|
||||
new JObject(
|
||||
new JProperty("name", "Fields"),
|
||||
new JProperty("value", "List<ContentField>"))))))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpContentItem_DepthSix() {
|
||||
var contentItem = new ContentItem { ContentType = "TestContentType" };
|
||||
var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
|
||||
contentItem.Weld(testingPart);
|
||||
|
||||
var objectDumper = new ObjectDumper(6);
|
||||
var xElement = objectDumper.Dump(contentItem, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "ContentItem"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Id"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "Version"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "ContentType"),
|
||||
new JProperty("value", ""TestContentType"")),
|
||||
new JObject(
|
||||
new JProperty("name", "TestingPart"),
|
||||
new JProperty("value", "ContentPart"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Zones"),
|
||||
new JProperty("value", "ZoneCollection")),
|
||||
new JObject(
|
||||
new JProperty("name", "Id"),
|
||||
new JProperty("value", "0")),
|
||||
new JObject(
|
||||
new JProperty("name", "TypeDefinition"),
|
||||
new JProperty("value", "null")),
|
||||
new JObject(
|
||||
new JProperty("name", "TypePartDefinition"),
|
||||
new JProperty("value", "ContentTypePartDefinition"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "PartDefinition"),
|
||||
new JProperty("value", "ContentPartDefinition"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Name"),
|
||||
new JProperty("value", ""TestingPart"")),
|
||||
new JObject(
|
||||
new JProperty("name", "Fields"),
|
||||
new JProperty("value", "ContentPartFieldDefinition[]")),
|
||||
new JObject(
|
||||
new JProperty("name", "Settings"),
|
||||
new JProperty("value", "SettingsDictionary"))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Settings"),
|
||||
new JProperty("value", "SettingsDictionary"))))),
|
||||
new JObject(
|
||||
new JProperty("name", "PartDefinition"),
|
||||
new JProperty("value", "ContentPartDefinition"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Name"),
|
||||
new JProperty("value", ""TestingPart"")),
|
||||
new JObject(
|
||||
new JProperty("name", "Fields"),
|
||||
new JProperty("value", "ContentPartFieldDefinition[]")),
|
||||
new JObject(
|
||||
new JProperty("name", "Settings"),
|
||||
new JProperty("value", "SettingsDictionary"))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Settings"),
|
||||
new JProperty("value", "SettingsDictionary")),
|
||||
new JObject(
|
||||
new JProperty("name", "Fields"),
|
||||
new JProperty("value", "List<ContentField>"))))))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpObject_DepthOne() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(new TestObject
|
||||
{
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
Assert.Throws(typeof (NullReferenceException), () => {
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpObject_DepthTwo() {
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(new TestObject
|
||||
{
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestObject"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "SomeInteger"),
|
||||
new JProperty("value", "1337")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeBoolean"),
|
||||
new JProperty("value", "True")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeString"),
|
||||
new JProperty("value", ""Never gonna give you up"")),
|
||||
new JObject(
|
||||
new JProperty("name", "ChildObject"),
|
||||
new JProperty("value", "null")
|
||||
)
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpObjectAndChild_DepthTwo() {
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(new TestObject
|
||||
{
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up",
|
||||
ChildObject = new TestObject() {
|
||||
SomeInteger = 58008,
|
||||
SomeBoolean = false,
|
||||
SomeString = "Never gonna let you down",
|
||||
}
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestObject"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "SomeInteger"),
|
||||
new JProperty("value", "1337")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeBoolean"),
|
||||
new JProperty("value", "True")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeString"),
|
||||
new JProperty("value", ""Never gonna give you up""))
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpObjectAndChild_DepthThree() {
|
||||
var objectDumper = new ObjectDumper(3);
|
||||
var xElement = objectDumper.Dump(new TestObject
|
||||
{
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up",
|
||||
ChildObject = new TestObject() {
|
||||
SomeInteger = 58008,
|
||||
SomeBoolean = false,
|
||||
SomeString = "Never gonna let you down",
|
||||
}
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestObject"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "SomeInteger"),
|
||||
new JProperty("value", "1337")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeBoolean"),
|
||||
new JProperty("value", "True")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeString"),
|
||||
new JProperty("value", ""Never gonna give you up"")),
|
||||
new JObject(
|
||||
new JProperty("name", "ChildObject"),
|
||||
new JProperty("value", "TestObject"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "SomeInteger"),
|
||||
new JProperty("value", "58008")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeBoolean"),
|
||||
new JProperty("value", "False")),
|
||||
new JObject(
|
||||
new JProperty("name", "SomeString"),
|
||||
new JProperty("value", ""Never gonna let you down"")),
|
||||
new JObject(
|
||||
new JProperty("name", "ChildObject"),
|
||||
new JProperty("value", "null")
|
||||
)
|
||||
))
|
||||
)
|
||||
)));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpIShape_DepthOne() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var xElement = objectDumper.Dump(new TestIShape {
|
||||
Metadata = new ShapeMetadata() {
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
Assert.Throws(typeof(NullReferenceException), () => {
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpIShape_DepthTwo() {
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var xElement = objectDumper.Dump(new TestIShape {
|
||||
Metadata = new ShapeMetadata() {
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpIShape_DepthThree() {
|
||||
var objectDumper = new ObjectDumper(3);
|
||||
var xElement = objectDumper.Dump(new TestIShape {
|
||||
Metadata = new ShapeMetadata() {
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpIShape_DepthFour() {
|
||||
var objectDumper = new ObjectDumper(4);
|
||||
var xElement = objectDumper.Dump(new TestIShape {
|
||||
Metadata = new ShapeMetadata() {
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
}, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShape_DepthOne() {
|
||||
var objectDumper = new ObjectDumper(1);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata()
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Add("Child Item");
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
Assert.Throws(typeof(NullReferenceException), () =>
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShape_DepthTwo() {
|
||||
var objectDumper = new ObjectDumper(2);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata()
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Add("Child Item");
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShape_DepthThree() {
|
||||
var objectDumper = new ObjectDumper(3);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata()
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"),
|
||||
new JProperty("children",new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Classes"),
|
||||
new JProperty("value", "List<String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", ""bodyClass1"")),
|
||||
new JObject(
|
||||
new JProperty("name", "[1]"),
|
||||
new JProperty("value", ""bodyClass2""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Attributes"),
|
||||
new JProperty("value", "Dictionary<String, String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "["onClick"]"),
|
||||
new JProperty("value", ""dhtmlIsBad""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Items"),
|
||||
new JProperty("value", "List<Object>")))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShape_DepthFour() {
|
||||
var objectDumper = new ObjectDumper(4);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata()
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Add("Child Item");
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Classes"),
|
||||
new JProperty("value", "List<String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", ""bodyClass1"")),
|
||||
new JObject(
|
||||
new JProperty("name", "[1]"),
|
||||
new JProperty("value", ""bodyClass2""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Attributes"),
|
||||
new JProperty("value", "Dictionary<String, String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "["onClick"]"),
|
||||
new JProperty("value", ""dhtmlIsBad""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Items"),
|
||||
new JProperty("value", "List<Object>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", ""Child Item""))))))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShapeAndChild_DepthFour() {
|
||||
var objectDumper = new ObjectDumper(4);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Add(new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata
|
||||
{
|
||||
Type = "TestContentChildType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentChildType_Detail", "TestContentChildType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Child Para</p>"),
|
||||
Wrappers = new[] { "TestContentChildType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
});
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Classes"),
|
||||
new JProperty("value", "List<String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", ""bodyClass1"")),
|
||||
new JObject(
|
||||
new JProperty("name", "[1]"),
|
||||
new JProperty("value", ""bodyClass2""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Attributes"),
|
||||
new JProperty("value", "Dictionary<String, String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "["onClick"]"),
|
||||
new JProperty("value", ""dhtmlIsBad""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Items"),
|
||||
new JProperty("value", "List<Object>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", "TestContentChildType Shape"))))))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DumpShapeAndChild_DepthSix() {
|
||||
var objectDumper = new ObjectDumper(6);
|
||||
var testShape = new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata
|
||||
{
|
||||
Type = "TestContentType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Para</p>"),
|
||||
Wrappers = new[] { "TestContentType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
};
|
||||
|
||||
testShape.Classes.Add("bodyClass1");
|
||||
testShape.Classes.Add("bodyClass2");
|
||||
|
||||
testShape.Add(new TestShape
|
||||
{
|
||||
Metadata = new ShapeMetadata
|
||||
{
|
||||
Type = "TestContentChildType",
|
||||
DisplayType = "Detail",
|
||||
Alternates = new[] { "TestContentChildType_Detail", "TestContentChildType_Detail_2" },
|
||||
Position = "1",
|
||||
ChildContent = new HtmlString("<p>Test Child Para</p>"),
|
||||
Wrappers = new[] { "TestContentChildType_Wrapper" }
|
||||
},
|
||||
SomeInteger = 1337,
|
||||
SomeBoolean = true,
|
||||
SomeString = "Never gonna give you up"
|
||||
});
|
||||
|
||||
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
|
||||
|
||||
var xElement = objectDumper.Dump(testShape, "Model");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
|
||||
var json = stringBuilder.ToString();
|
||||
|
||||
var jObject = new JObject(
|
||||
new JProperty("name", "Model"),
|
||||
new JProperty("value", "TestContentType Shape"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Classes"),
|
||||
new JProperty("value", "List<String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", ""bodyClass1"")),
|
||||
new JObject(
|
||||
new JProperty("name", "[1]"),
|
||||
new JProperty("value", ""bodyClass2""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Attributes"),
|
||||
new JProperty("value", "Dictionary<String, String>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "["onClick"]"),
|
||||
new JProperty("value", ""dhtmlIsBad""))))),
|
||||
new JObject(
|
||||
new JProperty("name", "Items"),
|
||||
new JProperty("value", "List<Object>"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "[0]"),
|
||||
new JProperty("value", "TestContentChildType Shape"),
|
||||
new JProperty("children", new JArray(
|
||||
new JObject(
|
||||
new JProperty("name", "Classes"),
|
||||
new JProperty("value", "List<String>")),
|
||||
new JObject(
|
||||
new JProperty("name", "Attributes"),
|
||||
new JProperty("value", "Dictionary<String, String>")),
|
||||
new JObject(
|
||||
new JProperty("name", "Items"),
|
||||
new JProperty("value", "List<Object>")))))))))));
|
||||
|
||||
ComparareJsonObject(jObject, json);
|
||||
}
|
||||
}
|
||||
}
|
@@ -99,6 +99,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\moq\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\newtonsoft.json\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nhibernate\NHibernate.dll</HintPath>
|
||||
@@ -143,6 +147,7 @@
|
||||
<Compile Include="Autoroute\DefaultSlugServiceTests.cs" />
|
||||
<Compile Include="CodeGeneration\Commands\CodeGenerationCommandsTests.cs" />
|
||||
<Compile Include="Comments\Services\CommentServiceTests.cs" />
|
||||
<Compile Include="DesignerTools\Services\ObjectDumperTests.cs" />
|
||||
<Compile Include="Email\EmailChannelTests.cs" />
|
||||
<Compile Include="ImageProcessing\ImageProcessingTests.cs" />
|
||||
<Compile Include="ImportExport\Services\ImportExportServiceTests.cs" />
|
||||
@@ -217,6 +222,10 @@
|
||||
<Project>{14C049FD-B35B-415A-A824-87F26B26E7FD}</Project>
|
||||
<Name>Orchard.Comments</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.DesignerTools\Orchard.DesignerTools.csproj">
|
||||
<Project>{4A4595EF-6C37-4F99-96ED-4AE0B9E438D3}</Project>
|
||||
<Name>Orchard.DesignerTools</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Email\Orchard.Email.csproj">
|
||||
<Project>{05660f47-d649-48bd-9ded-df4e01e7cff9}</Project>
|
||||
<Name>Orchard.Email</Name>
|
||||
|
@@ -93,6 +93,17 @@ namespace Orchard.Tests.Mvc {
|
||||
Assert.That(where, Is.EqualTo("after"));
|
||||
action.EndInvoke(asyncResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RouteDescriptorWithNameCreatesNamedRouteInCollection() {
|
||||
_routes.MapRoute("foo", "{controller}");
|
||||
|
||||
var publisher = _container.Resolve<IRoutePublisher>();
|
||||
var routeDescriptor = Desc("yarg", "bar");
|
||||
publisher.Publish(new[] { routeDescriptor });
|
||||
|
||||
Assert.That(_routes["yarg"], Is.Not.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,10 @@
|
||||
@using Orchard.Utility.Extensions;
|
||||
|
||||
<a href="@Url.Action("Clone", "Admin", new { Id = Model.ContentItem.Id, ReturnUrl = Request.ToUrlString(), Area = "Contents" })" itemprop="UnsafeUrl">@T("Clone")</a>@T(" | ")
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.Core.Contents
|
||||
@using Orchard.Utility.Extensions
|
||||
@{
|
||||
ContentPart contentPart = Model.ContentPart;
|
||||
}
|
||||
@if (Authorizer.Authorize(Permissions.EditContent, contentPart)) {
|
||||
<a href="@Url.Action("Clone", "Admin", new { Id = Model.ContentItem.Id, ReturnUrl = Request.ToUrlString(), Area = "Contents" })" itemprop="UnsafeUrl">@T("Clone")</a>
|
||||
@T(" | ")
|
||||
}
|
@@ -93,7 +93,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
// inject the current page
|
||||
if (!part.AddCurrentPage) {
|
||||
if (!part.AddCurrentPage && selectedPath != null) {
|
||||
result.RemoveAt(result.Count - 1);
|
||||
}
|
||||
|
||||
|
@@ -50,8 +50,8 @@ namespace Orchard.ArchiveLater.Drivers {
|
||||
);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart part, dynamic shapeHelper) {
|
||||
var model = new ArchiveLaterViewModel(part) {
|
||||
private ArchiveLaterViewModel BuildViewModelFromPart(ArchiveLaterPart part) {
|
||||
return new ArchiveLaterViewModel(part) {
|
||||
ArchiveLater = part.ScheduledArchiveUtc.Value.HasValue,
|
||||
Editor = new DateTimeEditor() {
|
||||
ShowDate = true,
|
||||
@@ -60,13 +60,17 @@ namespace Orchard.ArchiveLater.Drivers {
|
||||
Time = _dateLocalizationServices.ConvertToLocalizedTimeString(part.ScheduledArchiveUtc.Value),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart part, dynamic shapeHelper) {
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
return ContentShape("Parts_ArchiveLater_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new ArchiveLaterViewModel(part);
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if (model.ArchiveLater) {
|
||||
|
@@ -87,14 +87,8 @@ namespace Orchard.Autoroute.Handlers {
|
||||
return;
|
||||
}
|
||||
|
||||
// should it become the home page ?
|
||||
if (part.DisplayAlias != "/" && _orchardServices.Authorizer.Authorize(Permissions.SetHomePage)) {
|
||||
// if it's the current home page, do nothing
|
||||
var currentHomePages = _orchardServices.ContentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias == "").List();
|
||||
if (currentHomePages.Any(x => x.Id == part.Id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check for permalink conflict, unless we are trying to set the home page
|
||||
if (part.DisplayAlias != "/") {
|
||||
var previous = part.Path;
|
||||
if (!_autorouteService.Value.ProcessPath(part))
|
||||
_orchardServices.Notifier.Warning(T("Permalinks in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
public const string MediaStorageFeatureName = "Orchard.Azure.Media";
|
||||
public const string MediaStorageStorageConnectionStringSettingName = "Orchard.Azure.Media.StorageConnectionString";
|
||||
public const string MediaStorageRootFolderPathSettingName = "Orchard.Azure.Media.RootFolderPath";
|
||||
public const string MediaStorageContainerName = "media"; // Container names must be lower case.
|
||||
public const string MediaStoragePublicHostName = "Orchard.Azure.Media.StoragePublicHostName";
|
||||
|
||||
|
@@ -13,8 +13,11 @@ namespace Orchard.Azure.Services.FileSystems.Media {
|
||||
|
||||
public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
|
||||
: this(pca.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
|
||||
Constants.MediaStorageContainerName, shellSettings.Name, mimeTypeProvider,
|
||||
pca.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null)) {
|
||||
Constants.MediaStorageContainerName,
|
||||
pca.GetSetting(Constants.MediaStorageRootFolderPathSettingName, shellSettings.Name, null) ?? shellSettings.Name,
|
||||
mimeTypeProvider,
|
||||
pca.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null))
|
||||
{
|
||||
}
|
||||
|
||||
public AzureBlobStorageProvider(string storageConnectionString, string containerName, string rootFolderPath, IMimeTypeProvider mimeTypeProvider, string publicHostName)
|
||||
|
@@ -181,7 +181,7 @@ namespace Orchard.Comments {
|
||||
);
|
||||
|
||||
// populate the CommentsPartRecord.CommentsCount property
|
||||
foreach (var commentsPart in _contentManager.Query<CommentsPart>().List()) {
|
||||
foreach (var commentsPart in _contentManager.Query<CommentsPart, CommentsPartRecord>().List()) {
|
||||
_commentService.ProcessCommentsCount(commentsPart.Id);
|
||||
}
|
||||
|
||||
|
@@ -30,8 +30,12 @@ namespace Orchard.ContentPicker.Drivers {
|
||||
protected override DriverResult Display(ContentPart part, Fields.ContentPickerField field, string displayType, dynamic shapeHelper) {
|
||||
return Combined(
|
||||
ContentShape("Fields_ContentPicker", GetDifferentiator(field, part), () => shapeHelper.Fields_ContentPicker()),
|
||||
ContentShape("Fields_ContentPicker_SummaryAdmin", GetDifferentiator(field, part), () => shapeHelper.Fields_ContentPicker_SummaryAdmin())
|
||||
);
|
||||
ContentShape("Fields_ContentPicker_SummaryAdmin", GetDifferentiator(field, part), () => {
|
||||
var unpublishedIds = field.Ids.Except(field.ContentItems.Select(x => x.Id));
|
||||
var unpublishedContentItems = _contentManager.GetMany<ContentItem>(unpublishedIds, VersionOptions.Latest, QueryHints.Empty).ToList();
|
||||
|
||||
return shapeHelper.Fields_ContentPicker_SummaryAdmin(UnpublishedContentItems: unpublishedContentItems);
|
||||
}));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, Fields.ContentPickerField field, dynamic shapeHelper) {
|
||||
@@ -40,10 +44,10 @@ namespace Orchard.ContentPicker.Drivers {
|
||||
var model = new ContentPickerFieldViewModel {
|
||||
Field = field,
|
||||
Part = part,
|
||||
ContentItems = _contentManager.GetMany<ContentItem>(field.Ids, VersionOptions.Published, QueryHints.Empty).ToList(),
|
||||
ContentItems = _contentManager.GetMany<ContentItem>(field.Ids, VersionOptions.Latest, QueryHints.Empty).ToList()
|
||||
};
|
||||
|
||||
model.SelectedIds = string.Concat(",", field.Ids);
|
||||
model.SelectedIds = string.Join(",", field.Ids);
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Fields/ContentPicker.Edit", Model: model, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
|
@@ -48,7 +48,8 @@
|
||||
var multiple = $(self).data("multiple");
|
||||
var addButton = $(self).find(".button.add");
|
||||
var removeText = $(self).data("remove-text");
|
||||
var template = '<tr><td> </td><td><span data-id="{contentItemId}" data-fieldid="@idsFieldId" class="content-picker-item">{edit-link}</span></td><td><span data-id="{contentItemId}" class="content-picker-remove button grey">' + removeText + '</span></td></tr>';
|
||||
var notPublishedText = $(self).data("not-published-text");
|
||||
var template = '<tr><td> </td><td><span data-id="{contentItemId}" data-fieldid="@idsFieldId" class="content-picker-item">{edit-link}{status-text}</span></td><td><span data-id="{contentItemId}" class="content-picker-remove button grey">' + removeText + '</span></td></tr>';
|
||||
var selectedItemsFieldname = $(self).data("selected-items-fieldname");
|
||||
var baseUrl = $(self).data("base-url");
|
||||
var partName = $(self).data("part-name");
|
||||
@@ -78,7 +79,9 @@
|
||||
addButton.click(function() {
|
||||
addButton.trigger("orchard-admin-contentpicker-open", {
|
||||
callback: function(data) {
|
||||
var tmpl = template.replace( /\{contentItemId\}/g , data.id).replace( /\{edit-link\}/g , data.editLink);
|
||||
var tmpl = template.replace( /\{contentItemId\}/g , data.id)
|
||||
.replace( /\{edit-link\}/g , data.editLink)
|
||||
.replace( /\{status-text}/g , data.published? "" : " - " + notPublishedText);
|
||||
var content = $(tmpl);
|
||||
$(self).find('table.content-picker tbody').append(content);
|
||||
|
||||
|
@@ -24,7 +24,8 @@
|
||||
data-base-url="@baseUrl"
|
||||
data-part-name="@HttpUtility.JavaScriptStringEncode(partName)"
|
||||
data-field-name="@HttpUtility.JavaScriptStringEncode(fieldName)"
|
||||
data-remove-text="@T("Remove")">
|
||||
data-remove-text="@T("Remove")"
|
||||
data-not-published-text="@T("Not Published")">
|
||||
@if (!String.IsNullOrWhiteSpace(displayName)) {
|
||||
<label @if(required) { <text>class="required"</text> }>@displayName</label>
|
||||
}
|
||||
@@ -47,7 +48,7 @@
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<span data-id="@contentItem.Id" data-fieldid="@idsFieldId" class="content-picker-item">@Html.ItemEditLink(contentItem)</span>
|
||||
<span data-id="@contentItem.Id" data-fieldid="@idsFieldId" class="content-picker-item">@Html.ItemEditLink(contentItem) @if(!contentItem.HasPublished()) {<text> - </text>@T("Not Published")}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span data-id="@contentItem.Id" class="content-picker-remove button grey">@T("Remove")</span>
|
||||
|
@@ -1,10 +1,12 @@
|
||||
@using Orchard.ContentPicker.Fields
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.ContentPicker.Fields
|
||||
@using Orchard.Utility.Extensions;
|
||||
|
||||
@{
|
||||
var field = (ContentPickerField) Model.ContentField;
|
||||
string name = field.DisplayName;
|
||||
var contentItems = field.ContentItems;
|
||||
var unpublishedContentItems = (IEnumerable<ContentItem>)Model.UnpublishedContentItems;
|
||||
}
|
||||
<p class="content-picker-field content-picker-field-@name.HtmlClassify()">
|
||||
<span class="name">@name:</span>
|
||||
@@ -17,7 +19,17 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
<span class="value">@T("No content items.")</span>
|
||||
<span class="value">@T("No published content items.")</span>
|
||||
}
|
||||
|
||||
@if (unpublishedContentItems.Any()) {
|
||||
<span>@T(" | ") @T("Not Published"):</span>
|
||||
foreach (var contentItem in unpublishedContentItems) {
|
||||
<span class="value">@Html.ItemEditLink(contentItem)</span>
|
||||
if (contentItem != unpublishedContentItems.Last()) {
|
||||
<span>,</span>
|
||||
}
|
||||
}
|
||||
}
|
||||
</p>
|
||||
|
||||
|
@@ -33,31 +33,24 @@ namespace Orchard.ContentTypes.Extensions {
|
||||
return builder.WithSetting("ContentTypeSettings.Placement." + placementType, String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines a custom placement
|
||||
/// </summary>
|
||||
public static ContentTypeDefinitionBuilder Placement(this ContentTypeDefinitionBuilder builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) {
|
||||
var serializer = new JavaScriptSerializer();
|
||||
var placementSettings = GetPlacement(builder.Build(), placementType).ToList();
|
||||
|
||||
placementSettings = placementSettings.Where(x => x.ShapeType != shapeType && x.Differentiator != differentiator).ToList();
|
||||
|
||||
placementSettings.Add(new PlacementSettings {
|
||||
ShapeType = shapeType,
|
||||
Differentiator = differentiator,
|
||||
Zone = zone,
|
||||
Position = position
|
||||
});
|
||||
|
||||
var placement = serializer.Serialize(placementSettings.ToArray());
|
||||
|
||||
/// <summary>
|
||||
/// Defines a custom placement
|
||||
/// </summary>
|
||||
public static ContentTypeDefinitionBuilder Placement(this ContentTypeDefinitionBuilder builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) {
|
||||
var placement = AddPlacement(builder.Build(), placementType, shapeType, differentiator, zone, position);
|
||||
return builder.WithSetting("ContentTypeSettings.Placement." + placementType, placement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a placement the string representation of a placement
|
||||
/// </summary>
|
||||
public static ContentTypeDefinition Placement(this ContentTypeDefinition builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) {
|
||||
/// <summary>
|
||||
/// Adds a placement the string representation of a placement
|
||||
/// </summary>
|
||||
public static ContentTypeDefinition Placement(this ContentTypeDefinition builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) {
|
||||
var placement = AddPlacement(builder, placementType, shapeType, differentiator, zone, position);
|
||||
builder.Settings["ContentTypeSettings.Placement." + placementType] = placement;
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static string AddPlacement(ContentTypeDefinition builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) {
|
||||
var serializer = new JavaScriptSerializer();
|
||||
var placementSettings = GetPlacement(builder, placementType).ToList();
|
||||
|
||||
@@ -71,10 +64,8 @@ namespace Orchard.ContentTypes.Extensions {
|
||||
});
|
||||
|
||||
var placement = serializer.Serialize(placementSettings.ToArray());
|
||||
builder.Settings["ContentTypeSettings.Placement." + placementType] = placement;
|
||||
return builder;
|
||||
return placement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a placement the string representation of a placement
|
||||
/// </summary>
|
||||
@@ -91,8 +82,6 @@ namespace Orchard.ContentTypes.Extensions {
|
||||
currentSettings.TryGetValue("ContentTypeSettings.Placement." + placementType, out placement);
|
||||
|
||||
return String.IsNullOrEmpty(placement) ? new PlacementSettings[0] : serializer.Deserialize<PlacementSettings[]>(placement);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
@@ -151,6 +153,11 @@ namespace Orchard.DesignerTools.Services {
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((o is ContentPart && (member.Name == "ContentItem"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SafeCall(() => DumpMember(o, member));
|
||||
}
|
||||
|
||||
@@ -294,5 +301,52 @@ namespace Orchard.DesignerTools.Services {
|
||||
SaveCurrentNode();
|
||||
_current.Add(_current = new XElement(tag));
|
||||
}
|
||||
|
||||
public static void ConvertToJSon(XElement x, StringBuilder sb) {
|
||||
if (x == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (x.Name.ToString()) {
|
||||
case "ul":
|
||||
var first = true;
|
||||
foreach (var li in x.Elements()) {
|
||||
if (!first) sb.Append(",");
|
||||
ConvertToJSon(li, sb);
|
||||
first = false;
|
||||
}
|
||||
break;
|
||||
case "li":
|
||||
var name = x.Element("h1").Value;
|
||||
var value = x.Element("span").Value;
|
||||
|
||||
sb.AppendFormat("\"name\": \"{0}\", ", FormatJsonValue(name));
|
||||
sb.AppendFormat("\"value\": \"{0}\"", FormatJsonValue(value));
|
||||
|
||||
var ul = x.Element("ul");
|
||||
if (ul != null && ul.Descendants().Any()) {
|
||||
sb.Append(", \"children\": [");
|
||||
first = true;
|
||||
foreach (var li in ul.Elements()) {
|
||||
sb.Append(first ? "{ " : ", {");
|
||||
ConvertToJSon(li, sb);
|
||||
sb.Append(" }");
|
||||
first = false;
|
||||
}
|
||||
sb.Append("]");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string FormatJsonValue(string value) {
|
||||
if (String.IsNullOrEmpty(value)) {
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
// replace " by \" in json strings
|
||||
return HttpUtility.HtmlEncode(value).Replace(@"\", @"\\").Replace("\"", @"\""").Replace("\r\n", @"\n").Replace("\r", @"\n").Replace("\n", @"\n");
|
||||
}
|
||||
}
|
||||
}
|
@@ -112,7 +112,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
var dump = new ObjectDumper(6).Dump(context.Shape, "Model");
|
||||
|
||||
var sb = new StringBuilder();
|
||||
ConvertToJSon(dump, sb);
|
||||
ObjectDumper.ConvertToJSon(dump, sb);
|
||||
shape._Dump = sb.ToString();
|
||||
|
||||
shape.Template = null;
|
||||
@@ -165,53 +165,6 @@ namespace Orchard.DesignerTools.Services {
|
||||
public void Displayed(ShapeDisplayedContext context) {
|
||||
}
|
||||
|
||||
public static void ConvertToJSon(XElement x, StringBuilder sb) {
|
||||
if(x == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (x.Name.ToString()) {
|
||||
case "ul" :
|
||||
var first = true;
|
||||
foreach(var li in x.Elements()) {
|
||||
if (!first) sb.Append(",");
|
||||
ConvertToJSon(li, sb);
|
||||
first = false;
|
||||
}
|
||||
break;
|
||||
case "li":
|
||||
var name = x.Element("h1").Value;
|
||||
var value = x.Element("span").Value;
|
||||
|
||||
sb.AppendFormat("\"name\": \"{0}\", ", FormatJsonValue(name));
|
||||
sb.AppendFormat("\"value\": \"{0}\"", FormatJsonValue(value));
|
||||
|
||||
var ul = x.Element("ul");
|
||||
if (ul != null && ul.Descendants().Any()) {
|
||||
sb.Append(", \"children\": [");
|
||||
first = true;
|
||||
foreach (var li in ul.Elements()) {
|
||||
sb.Append(first ? "{ " : ", {");
|
||||
ConvertToJSon(li, sb);
|
||||
sb.Append(" }");
|
||||
first = false;
|
||||
}
|
||||
sb.Append("]");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string FormatJsonValue(string value) {
|
||||
if(String.IsNullOrEmpty(value)) {
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
// replace " by \" in json strings
|
||||
return HttpUtility.HtmlEncode(value).Replace(@"\", @"\\").Replace("\"", @"\""").Replace("\r\n", @"\n").Replace("\r", @"\n").Replace("\n", @"\n");
|
||||
}
|
||||
|
||||
private static string FormatShapeFilename(string shape, string shapeType, string displayType, string themePrefix, string extension) {
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(displayType)) {
|
||||
|
@@ -60,8 +60,8 @@ shapeTracingMetadataHost[@Model.ShapeId].shape = {
|
||||
</text>
|
||||
}
|
||||
],
|
||||
html: '@Html.Raw(ShapeTracingFactory.FormatJsonValue(RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString()))))',
|
||||
templateContent: '@Html.Raw(ShapeTracingFactory.FormatJsonValue(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.").ToString() : (string)Model.TemplateContent))',
|
||||
html: '@Html.Raw(ObjectDumper.FormatJsonValue(RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString()))))',
|
||||
templateContent: '@Html.Raw(ObjectDumper.FormatJsonValue(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.").ToString() : (string)Model.TemplateContent))',
|
||||
model: { @(new MvcHtmlString((string)@Model.Dump)) }
|
||||
};
|
||||
|
||||
|
@@ -47,7 +47,7 @@
|
||||
@Html.SelectOption((object)true, Model.DefaultValue.HasValue && Model.DefaultValue == true, T("True").ToString())
|
||||
@Html.SelectOption((object)false, Model.DefaultValue.HasValue && Model.DefaultValue == false, T("False").ToString())
|
||||
</select>
|
||||
<span class="hint">@T("When Checkbox is selected, the label for 'on' will be used.")</span>
|
||||
<span class="hint">@T("The default value to select.")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
|
@@ -29,7 +29,7 @@ namespace Orchard.MediaLibrary.Factories {
|
||||
|
||||
if (!String.IsNullOrEmpty(contentType)) {
|
||||
var contentDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
|
||||
if (contentDefinition == null || contentDefinition.Parts.All(x => x.PartDefinition.Name != typeof (ImagePart).Name)) {
|
||||
if (contentDefinition == null || contentDefinition.Parts.All(x => x.PartDefinition.Name != typeof(ImagePart).Name)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -65,12 +65,36 @@ namespace Orchard.MediaLibrary.Factories {
|
||||
return null;
|
||||
}
|
||||
|
||||
using (var image = Image.FromStream(stream)) {
|
||||
imagePart.Width = image.Width;
|
||||
imagePart.Height = image.Height;
|
||||
try {
|
||||
using (var image = Image.FromStream(stream)) {
|
||||
imagePart.Width = image.Width;
|
||||
imagePart.Height = image.Height;
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
// Still trying to get .ico dimensions when it's blocked in System.Drawing, see: https://orchard.codeplex.com/workitem/20644
|
||||
|
||||
if (mimeType != "image/x-icon" && mimeType != "image/vnd.microsoft.icon") {
|
||||
throw;
|
||||
}
|
||||
|
||||
TryFillDimensionsForIco(stream, imagePart);
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
private void TryFillDimensionsForIco(Stream stream, ImagePart imagePart) {
|
||||
stream.Position = 0;
|
||||
using (var binaryReader = new BinaryReader(stream)) {
|
||||
// Reading out the necessary bytes that indicate the image dimensions. For the file format see:
|
||||
// http://en.wikipedia.org/wiki/ICO_%28file_format%29
|
||||
// Reading out leading bytes containing unneded information.
|
||||
binaryReader.ReadBytes(6);
|
||||
// Reading out dimensions. If there are multiple icons bundled in the same file then this is the first image.
|
||||
imagePart.Width = binaryReader.ReadByte();
|
||||
imagePart.Height = binaryReader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -73,6 +73,8 @@ namespace Orchard.MediaLibrary.Services {
|
||||
|
||||
var query = contentManager.Query<MediaPart>(versionOptions);
|
||||
|
||||
query = query.Join<MediaPartRecord>();
|
||||
|
||||
if (!String.IsNullOrEmpty(mediaType)) {
|
||||
query = query.ForType(new[] { mediaType });
|
||||
}
|
||||
@@ -112,6 +114,8 @@ namespace Orchard.MediaLibrary.Services {
|
||||
break;
|
||||
}
|
||||
|
||||
query = query.Join<MediaPartRecord>();
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@@ -25,13 +25,15 @@ namespace Orchard.Modules.Commands {
|
||||
[OrchardSwitch]
|
||||
public bool Summary { get; set; }
|
||||
|
||||
[CommandHelp("feature list [/Summary:true|false]\r\n\t" + "Display list of available features")]
|
||||
[CommandHelp("feature list [/Summary:true|false] [partial_feature_name]" + "\r\n\tDisplay list of available features" + "\r\n\tFilter the list by partial_feature_name, if given ")]
|
||||
[CommandName("feature list")]
|
||||
[OrchardSwitches("Summary")]
|
||||
public void List() {
|
||||
public void List(params string[] featureNames)
|
||||
{
|
||||
var enabled = _shellDescriptor.Features.Select(x => x.Name);
|
||||
Func<string, bool> filter = featureNames.Any() ? new Func<string, bool>(f => f.IndexOf(featureNames[0], 0, StringComparison.InvariantCultureIgnoreCase)>=0) : new Func<string, bool>(f => true);
|
||||
if (Summary) {
|
||||
foreach (var feature in _featureManager.GetAvailableFeatures().OrderBy(f => f.Id)) {
|
||||
foreach (var feature in _featureManager.GetAvailableFeatures().Where(f => filter(f.Name)).OrderBy(f => f.Id)) {
|
||||
Context.Output.WriteLine(T("{0}, {1}", feature.Id, enabled.Contains(feature.Id) ? T("Enabled") : T("Disabled")));
|
||||
}
|
||||
}
|
||||
@@ -39,7 +41,7 @@ namespace Orchard.Modules.Commands {
|
||||
Context.Output.WriteLine(T("List of available features"));
|
||||
Context.Output.WriteLine(T("--------------------------"));
|
||||
|
||||
var categories = _featureManager.GetAvailableFeatures().ToList().GroupBy(f => f.Category);
|
||||
var categories = _featureManager.GetAvailableFeatures().Where(f=>filter(f.Name)).ToList().GroupBy(f => f.Category);
|
||||
foreach (var category in categories) {
|
||||
Context.Output.WriteLine(T("Category: {0}", category.Key.OrDefault(T("General"))));
|
||||
foreach (var feature in category.OrderBy(f => f.Id)) {
|
||||
|
@@ -85,6 +85,10 @@
|
||||
var showDisable = categoryName.ToString() != "Core";
|
||||
var showEnable = Model.IsAllowed(feature.Descriptor.Extension) && !missingDependencies.Any() && feature.Descriptor.Id != "Orchard.Setup";
|
||||
|
||||
if (missingDependencies.Any()) {
|
||||
featureClassName += " missingDependencies";
|
||||
}
|
||||
|
||||
<li class="@featureClassName" id="@featureId" title="@T("{0} is {1}", Html.AttributeEncode(featureName), featureState)">
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
|
@@ -21,6 +21,11 @@ html.dyn #main ul.features button { display:none; }
|
||||
width:32.2%;
|
||||
}
|
||||
|
||||
.features.summary-view .missingDependencies{
|
||||
line-height:1em;
|
||||
}
|
||||
|
||||
|
||||
.features.detail-view .feature {
|
||||
padding:.25em 0;
|
||||
border-bottom:1px solid #CCC;
|
||||
|
@@ -3,10 +3,12 @@ using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Commands;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Packaging.Commands {
|
||||
[OrchardFeature("PackagingServices")]
|
||||
public class PackagingCommands : DefaultOrchardCommandHandler {
|
||||
private static readonly string ApplicationPath = HostingEnvironment.MapPath("~/");
|
||||
|
||||
|
@@ -60,22 +60,26 @@ namespace Orchard.PublishLater.Drivers {
|
||||
);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part, dynamic shapeHelper) {
|
||||
var model = new PublishLaterViewModel(part) {
|
||||
Editor = new DateTimeEditor() {
|
||||
private PublishLaterViewModel BuildViewModelFromPart(PublishLaterPart part) {
|
||||
return new PublishLaterViewModel(part) {
|
||||
Editor = new DateTimeEditor() {
|
||||
ShowDate = true,
|
||||
ShowTime = true,
|
||||
Date = !part.IsPublished() ? _dateLocalizationServices.ConvertToLocalizedDateString(part.ScheduledPublishUtc.Value) : "",
|
||||
Time = !part.IsPublished() ? _dateLocalizationServices.ConvertToLocalizedTimeString(part.ScheduledPublishUtc.Value) : "",
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part, dynamic shapeHelper) {
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
return ContentShape("Parts_PublishLater_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new PublishLaterViewModel(part);
|
||||
var model = BuildViewModelFromPart(part);
|
||||
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
|
@@ -213,41 +213,37 @@ namespace Orchard.SecureSocketsLayer.Services {
|
||||
private string MakeInsecure(string path) {
|
||||
var settings = GetSettings();
|
||||
if (settings == null) return path;
|
||||
var builder = new UriBuilder {
|
||||
Scheme = Uri.UriSchemeHttp,
|
||||
var insecureHostName = settings.InsecureHostName;
|
||||
var builder = new UriBuilder(insecureHostName.Trim('/') + path) {
|
||||
Scheme = Uri.UriSchemeHttp,
|
||||
Port = 80
|
||||
};
|
||||
var insecureHostName = settings.InsecureHostName;
|
||||
SetHost(insecureHostName, builder);
|
||||
builder.Path = path;
|
||||
SetPort(insecureHostName, builder);
|
||||
return builder.Uri.ToString();
|
||||
}
|
||||
|
||||
private string MakeSecure(string path) {
|
||||
var settings = GetSettings();
|
||||
if (settings == null) return path;
|
||||
var builder = new UriBuilder {
|
||||
Scheme = Uri.UriSchemeHttps,
|
||||
var secureHostName = settings.SecureHostName;
|
||||
var builder = new UriBuilder(secureHostName.Trim('/') + path) {
|
||||
Scheme = Uri.UriSchemeHttps,
|
||||
Port = 443
|
||||
};
|
||||
var secureHostName = settings.SecureHostName;
|
||||
SetHost(secureHostName, builder);
|
||||
builder.Path = path;
|
||||
SetPort(secureHostName, builder);
|
||||
return builder.Uri.ToString();
|
||||
}
|
||||
|
||||
private static void SetHost(string hostName, UriBuilder builder) {
|
||||
private static void SetPort(string hostName, UriBuilder builder) {
|
||||
if (string.IsNullOrWhiteSpace(hostName)) return;
|
||||
var splitSecuredHostName = hostName.Split(new[] {':'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var splitSecuredHostName = hostName.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (splitSecuredHostName.Length == 2) {
|
||||
int port;
|
||||
if (int.TryParse(splitSecuredHostName[1], NumberStyles.Integer, CultureInfo.InvariantCulture,
|
||||
out port)) {
|
||||
builder.Port = port;
|
||||
hostName = splitSecuredHostName[0];
|
||||
}
|
||||
}
|
||||
builder.Host = hostName;
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,7 +13,6 @@ namespace Orchard.Tags.Services {
|
||||
[OrchardFeature("Orchard.Tags.TagCloud")]
|
||||
public class TagCloudService : ITagCloudService {
|
||||
private readonly IRepository<ContentTagRecord> _contentTagRepository;
|
||||
private readonly IRepository<AutoroutePartRecord> _autorouteRepository;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly ISignals _signals;
|
||||
@@ -21,13 +20,11 @@ namespace Orchard.Tags.Services {
|
||||
|
||||
public TagCloudService(
|
||||
IRepository<ContentTagRecord> contentTagRepository,
|
||||
IRepository<AutoroutePartRecord> autorouteRepository,
|
||||
IContentManager contentManager,
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals) {
|
||||
|
||||
_contentTagRepository = contentTagRepository;
|
||||
_autorouteRepository = autorouteRepository;
|
||||
_contentManager = contentManager;
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
@@ -54,11 +51,12 @@ namespace Orchard.Tags.Services {
|
||||
slug = "";
|
||||
}
|
||||
|
||||
var containerId = _autorouteRepository.Table
|
||||
.Where(c => c.DisplayAlias == slug)
|
||||
.Select(x => x.Id)
|
||||
.ToList() // don't try to optimize with slicing as there should be only one result
|
||||
.FirstOrDefault();
|
||||
var containerId = _contentManager
|
||||
.Query<AutoroutePart, AutoroutePartRecord>(VersionOptions.Published)
|
||||
.Where(a => a.DisplayAlias == slug)
|
||||
.List() // don't try to optimize with slicing as there should be only one result
|
||||
.Select(x => x.ContentItem.Id)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (containerId == 0) {
|
||||
return new List<TagCount>();
|
||||
|
@@ -5,7 +5,7 @@
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.TagName, T("New Tag Name"))
|
||||
@Html.TextBoxFor(m => m.TagName, new { @class = "text", placeholder = T("New Tag Name") })
|
||||
@Html.TextBoxFor(m => m.TagName, new { @class = "text", placeholder = T("New Tag Name"), @required = "required" })
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit" name="submit.Create" value="yes">@T("Add Tag")</button>
|
||||
|
@@ -128,7 +128,14 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
}
|
||||
|
||||
private TermPart GetOrCreateTerm(TermEntry entry, int taxonomyId, TaxonomyField field) {
|
||||
var term = entry.Id > 0 ? _taxonomyService.GetTerm(entry.Id) : default(TermPart);
|
||||
var term = default(TermPart);
|
||||
|
||||
if (entry.Id > 0)
|
||||
term = _taxonomyService.GetTerm(entry.Id);
|
||||
|
||||
//Prevents creation of existing term
|
||||
if (term == null && !string.IsNullOrEmpty(entry.Name))
|
||||
term = _taxonomyService.GetTermByName(taxonomyId, entry.Name.Trim());
|
||||
|
||||
if (term == null) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<TaxonomyFieldSettings>();
|
||||
|
@@ -22,17 +22,12 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
OnPublished<TaxonomyPart>((context, part) => {
|
||||
var previousTermTypeName = part.TermTypeName;
|
||||
|
||||
if (previousName == null) {
|
||||
if (part.TermTypeName == null) {
|
||||
// is it a new taxonomy ?
|
||||
taxonomyService.CreateTermContentType(part);
|
||||
}
|
||||
else {
|
||||
// keep the previous term type name as it would otherwise force us
|
||||
// to update all terms to use another type
|
||||
part.TermTypeName = previousTermTypeName;
|
||||
|
||||
// update existing fields
|
||||
foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
|
||||
foreach (var field in partDefinition.Fields) {
|
||||
|
@@ -9,6 +9,9 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor;
|
||||
|
||||
namespace Orchard.Taxonomies.Handlers {
|
||||
public class TermsPartHandler : ContentHandler {
|
||||
@@ -19,14 +22,17 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IRepository<TermsPartRecord> repository,
|
||||
ITaxonomyService taxonomyService,
|
||||
IContentManager contentManager) {
|
||||
IContentManager contentManager,
|
||||
IProcessingEngine processingEngine,
|
||||
ShellSettings shellSettings,
|
||||
IShellDescriptorManager shellDescriptorManager) {
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_contentManager = contentManager;
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
OnPublished<TermsPart>((context, part) => RecalculateCount(taxonomyService, part));
|
||||
OnUnpublished<TermsPart>((context, part) => RecalculateCount(taxonomyService, part));
|
||||
OnRemoved<TermsPart>((context, part) => RecalculateCount(taxonomyService, part));
|
||||
OnPublished<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));
|
||||
OnUnpublished<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));
|
||||
OnRemoved<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));
|
||||
|
||||
// Tells how to load the field terms on demand, when a content item it loaded or when it has been created
|
||||
OnInitialized<TermsPart>((context, part) => InitializerTermsLoader(part));
|
||||
@@ -68,7 +74,7 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
|
||||
part._termParts = new LazyField<IEnumerable<TermContentItemPart>>();
|
||||
part._termParts.Loader(value => {
|
||||
var ids = part.Terms.Select(t => t.TermRecord.Id);
|
||||
var ids = part.Terms.Select(t => t.TermRecord.Id).Distinct();
|
||||
var terms = _contentManager.GetMany<TermPart>(ids, VersionOptions.Published, queryHint)
|
||||
.ToDictionary(t => t.Id, t => t);
|
||||
return
|
||||
@@ -82,20 +88,11 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
});
|
||||
}
|
||||
|
||||
// Retrieve the number of associated content items, for the whole hierarchy
|
||||
private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part) {
|
||||
foreach (var term in part.Terms) {
|
||||
var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
|
||||
while (termPart != null) {
|
||||
termPart.Count = (int)taxonomyService.GetContentItemsCount(termPart);
|
||||
|
||||
// Fires off a processing engine task to run the count processing after the request so it's non-blocking.
|
||||
private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) {
|
||||
processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary<string, object> { { "termsPartId", part.ContentItem.Id } });
|
||||
|
||||
// compute count for the hierarchy too
|
||||
if (termPart.Container != null) {
|
||||
var parentTerm = termPart.Container.As<TermPart>();
|
||||
termPart = parentTerm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
|
@@ -18,6 +18,8 @@ namespace Orchard.Taxonomies {
|
||||
.Column<int>("Count")
|
||||
.Column<int>("Weight")
|
||||
.Column<bool>("Selectable")
|
||||
).AlterTable("TermPartRecord", table => table
|
||||
.CreateIndex("IDX_Path", "Path")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("TermContentItem", table => table
|
||||
@@ -52,7 +54,7 @@ namespace Orchard.Taxonomies {
|
||||
.WithSetting("Stereotype", "MenuItem")
|
||||
);
|
||||
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
@@ -68,5 +70,13 @@ namespace Orchard.Taxonomies {
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int UpdateFrom3() {
|
||||
SchemaBuilder.AlterTable("TermPartRecord", table => table
|
||||
.CreateIndex("IDX_Path", "Path")
|
||||
);
|
||||
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
@@ -99,7 +99,9 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Fields\TaxonomyField.cs" />
|
||||
<Compile Include="Services\ITaxonomyService.cs" />
|
||||
<Compile Include="Services\ITermCountProcessor.cs" />
|
||||
<Compile Include="Services\TaxonomyService.cs" />
|
||||
<Compile Include="Services\TermCountProcessor.cs" />
|
||||
<Compile Include="Settings\TermPartEditorEvents.cs" />
|
||||
<Compile Include="Settings\TaxonomyFieldEditorEvents.cs" />
|
||||
<Compile Include="Settings\TermPartSettings.cs" />
|
||||
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Taxonomies.Services {
|
||||
public interface ITermCountProcessor : IEventHandler {
|
||||
void Process(int termsPartId);
|
||||
}
|
||||
}
|
@@ -59,11 +59,24 @@ namespace Orchard.Taxonomies.Services {
|
||||
}
|
||||
|
||||
// include the record in the query to optimize the query plan
|
||||
return _contentManager
|
||||
.Query<TaxonomyPart, TaxonomyPartRecord>()
|
||||
.Join<TitlePartRecord>()
|
||||
.Where(r => r.Title == name)
|
||||
.Slice(1)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public TaxonomyPart GetTaxonomyBySlug(string slug) {
|
||||
if (String.IsNullOrWhiteSpace(slug)) {
|
||||
throw new ArgumentNullException("slug");
|
||||
}
|
||||
|
||||
return _contentManager
|
||||
.Query<TaxonomyPart, TaxonomyPartRecord>()
|
||||
.Join<TitlePartRecord>()
|
||||
.Join<AutoroutePartRecord>()
|
||||
.Where(r => r.DisplayAlias == slug)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
@@ -77,9 +90,9 @@ namespace Orchard.Taxonomies.Services {
|
||||
.WithPart("TermPart")
|
||||
.WithPart("TitlePart")
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Taxonomy and Title\",\"Pattern\":\"{Content.Container.Path}/{Content.Slug}\",\"Description\":\"my-taxonomy/my-term/sub-term\"}]")
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "true")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Taxonomy and Title', Pattern: '{Content.Container.Path}/{Content.Slug}', Description: 'my-taxonomy/my-term/sub-term'}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithPart("CommonPart")
|
||||
.DisplayedAs(taxonomy.Name + " Term")
|
||||
@@ -109,30 +122,8 @@ namespace Orchard.Taxonomies.Services {
|
||||
}
|
||||
|
||||
public TermPart NewTerm(TaxonomyPart taxonomy) {
|
||||
return NewTerm(taxonomy, null);
|
||||
}
|
||||
|
||||
public TermPart NewTerm(TaxonomyPart taxonomy, IContent parent) {
|
||||
if (taxonomy == null) {
|
||||
throw new ArgumentNullException("taxonomy");
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
var parentAsTaxonomy = parent.As<TaxonomyPart>();
|
||||
if (parentAsTaxonomy != null && parentAsTaxonomy != taxonomy) {
|
||||
throw new ArgumentException("The parent of a term can't be a different taxonomy", "parent");
|
||||
}
|
||||
|
||||
var parentAsTerm = parent.As<TermPart>();
|
||||
if (parentAsTerm != null && parentAsTerm.TaxonomyId != taxonomy.Id) {
|
||||
throw new ArgumentException("The parent of a term can't be a from a different taxonomy", "parent");
|
||||
}
|
||||
}
|
||||
|
||||
var term = _contentManager.New<TermPart>(taxonomy.TermTypeName);
|
||||
term.Container = parent == null ? taxonomy : parent;
|
||||
term.TaxonomyId = taxonomy.Id;
|
||||
ProcessPath(term);
|
||||
|
||||
return term;
|
||||
}
|
||||
@@ -145,10 +136,25 @@ namespace Orchard.Taxonomies.Services {
|
||||
return TermPart.Sort(result);
|
||||
}
|
||||
|
||||
public TermPart GetTermByPath(string path) {
|
||||
return _contentManager.Query<TermPart, TermPartRecord>()
|
||||
.Join<AutoroutePartRecord>()
|
||||
.Where(rr => rr.DisplayAlias == path)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<TermPart> GetAllTerms() {
|
||||
var result = _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.List();
|
||||
return TermPart.Sort(result);
|
||||
}
|
||||
|
||||
public TermPart GetTerm(int id) {
|
||||
return _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.Where(x => x.Id == id).Slice(1).FirstOrDefault();
|
||||
.Where(x => x.Id == id).List().FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<TermPart> GetTermsForContentItem(int contentItemId, string field = null, VersionOptions versionOptions = null) {
|
||||
@@ -165,7 +171,7 @@ namespace Orchard.Taxonomies.Services {
|
||||
.Where(t => t.TaxonomyId == taxonomyId)
|
||||
.Join<TitlePartRecord>()
|
||||
.Where(r => r.Title == name)
|
||||
.Slice(1)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
@@ -276,6 +282,20 @@ namespace Orchard.Taxonomies.Services {
|
||||
return term.Path.Split(new [] {'/'}, StringSplitOptions.RemoveEmptyEntries).Select(id => GetTerm(int.Parse(id)));
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetSlugs() {
|
||||
return _contentManager
|
||||
.Query<TaxonomyPart, TaxonomyPartRecord>()
|
||||
.List()
|
||||
.Select(t => t.Slug);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetTermPaths() {
|
||||
return _contentManager
|
||||
.Query<TermPart, TermPartRecord>()
|
||||
.List()
|
||||
.Select(t => t.Slug);
|
||||
}
|
||||
|
||||
public void MoveTerm(TaxonomyPart taxonomy, TermPart term, TermPart parentTerm) {
|
||||
var children = GetChildren(term);
|
||||
term.Container = parentTerm == null ? taxonomy.ContentItem : parentTerm.ContentItem;
|
||||
|
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Taxonomies.Models;
|
||||
|
||||
namespace Orchard.Taxonomies.Services {
|
||||
public class TermCountProcessor : ITermCountProcessor {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ITaxonomyService _taxonomyService;
|
||||
|
||||
public TermCountProcessor(IContentManager contentManager, ITaxonomyService taxonomyService) {
|
||||
_contentManager = contentManager;
|
||||
_taxonomyService = taxonomyService;
|
||||
}
|
||||
|
||||
public void Process(int termsPartId) {
|
||||
var termsPart = _contentManager.Get<TermsPart>(termsPartId);
|
||||
|
||||
if (termsPart == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the number of associated content items, for the whole hierarchy
|
||||
foreach (var term in termsPart.Terms) {
|
||||
var termPart = _taxonomyService.GetTerm(term.TermRecord.Id);
|
||||
while (termPart != null) {
|
||||
termPart.Count = (int)_taxonomyService.GetContentItemsCount(termPart);
|
||||
|
||||
// compute count for the hierarchy too
|
||||
if (termPart.Container != null) {
|
||||
var parentTerm = termPart.Container.As<TermPart>();
|
||||
termPart = parentTerm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Templates.Models;
|
||||
using System;
|
||||
@@ -15,17 +16,20 @@ namespace Orchard.Templates.Services {
|
||||
private ICacheManager _cacheManager;
|
||||
private ISignals _signals;
|
||||
private IContentManager _contentManager;
|
||||
private IContentDefinitionManager _contentDefinitionManager;
|
||||
private ITemplateService _templateService;
|
||||
|
||||
public TemplateShapeBindingResolver(
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals,
|
||||
IContentManager contentManager,
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
ITemplateService templateService
|
||||
) {
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
_contentManager = contentManager;
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
@@ -54,19 +58,19 @@ namespace Orchard.Templates.Services {
|
||||
return _cacheManager.Get("Template.ShapeProcessors", ctx => {
|
||||
ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal));
|
||||
|
||||
var allTemplates = _contentManager.Query<ShapePart>().List();
|
||||
// select all name of types which contains ShapePart
|
||||
var typesWithShapePart = _contentDefinitionManager
|
||||
.ListTypeDefinitions()
|
||||
.Where(ct => ct.Parts.Any(cp => cp.PartDefinition.Name == "ShapePart"))
|
||||
.Select(ct => ct.Name)
|
||||
.ToArray();
|
||||
|
||||
return allTemplates.Select(x => {
|
||||
var name = x.Name;
|
||||
var template = x.Template;
|
||||
var processorName = x.ProcessorName;
|
||||
|
||||
return new TemplateResult {
|
||||
Name = x.Name,
|
||||
Template = x.Template,
|
||||
Processor = x.ProcessorName
|
||||
};
|
||||
var allTemplates = _contentManager.Query<ShapePart>(typesWithShapePart).List();
|
||||
|
||||
return allTemplates.Select(x => new TemplateResult {
|
||||
Name = x.Name,
|
||||
Template = x.Template,
|
||||
Processor = x.ProcessorName
|
||||
}).ToDictionary(x => x.Name, x => x);
|
||||
});
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ namespace Orchard.Widgets.Filters {
|
||||
|
||||
// Once the Rule Engine is done:
|
||||
// Get Layers and filter by zone and rule
|
||||
IEnumerable<LayerPart> activeLayers = _orchardServices.ContentManager.Query<LayerPart, LayerPartRecord>().ForType("Layer").List();
|
||||
// NOTE: .ForType("Layer") is faster than .Query<LayerPart, LayerPartRecord>()
|
||||
|
||||
var activeLayerIds = new List<int>();
|
||||
foreach (var activeLayer in activeLayers) {
|
||||
|
@@ -75,7 +75,7 @@ namespace Orchard.Widgets.Services {
|
||||
|
||||
public IEnumerable<WidgetPart> GetWidgets(int[] layerIds) {
|
||||
return _contentManager
|
||||
.Query<WidgetPart>()
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
|
||||
.Where<CommonPartRecord>(x => layerIds.Contains(x.Container.Id))
|
||||
.List();
|
||||
|
@@ -10,9 +10,13 @@ using Orchard.Workflows.Models;
|
||||
namespace Orchard.Workflows.ImportExport {
|
||||
public class WorkflowsRecipeHandler : IRecipeHandler {
|
||||
private readonly IRepository<WorkflowDefinitionRecord> _workflowDefinitionRepository;
|
||||
private readonly IRepository<ActivityRecord> _activityRepository;
|
||||
private readonly IRepository<TransitionRecord> _transitionRepository;
|
||||
|
||||
public WorkflowsRecipeHandler(IRepository<WorkflowDefinitionRecord> workflowDefinitionRepository) {
|
||||
public WorkflowsRecipeHandler(IRepository<WorkflowDefinitionRecord> workflowDefinitionRepository, IRepository<ActivityRecord> activityRepository, IRepository<TransitionRecord> transitionRepository) {
|
||||
_workflowDefinitionRepository = workflowDefinitionRepository;
|
||||
_activityRepository = activityRepository;
|
||||
_transitionRepository = transitionRepository;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -26,17 +30,13 @@ namespace Orchard.Workflows.ImportExport {
|
||||
}
|
||||
|
||||
foreach (var workflowDefinitionElement in recipeContext.RecipeStep.Step.Elements()) {
|
||||
var workflowDefinition = new WorkflowDefinitionRecord {
|
||||
Name = ProbeWorkflowDefinitionName(workflowDefinitionElement.Attribute("Name").Value),
|
||||
Enabled = Boolean.Parse(workflowDefinitionElement.Attribute("Enabled").Value)
|
||||
};
|
||||
|
||||
_workflowDefinitionRepository.Create(workflowDefinition);
|
||||
|
||||
var workflowDefinition = GetOrCreateWorkflowDefinition(workflowDefinitionElement.Attribute("Name").Value);
|
||||
var activitiesElement = workflowDefinitionElement.Element("Activities");
|
||||
var transitionsElement = workflowDefinitionElement.Element("Transitions");
|
||||
var activitiesDictionary = new Dictionary<int, ActivityRecord>();
|
||||
|
||||
workflowDefinition.Enabled = Boolean.Parse(workflowDefinitionElement.Attribute("Enabled").Value);
|
||||
|
||||
foreach (var activityElement in activitiesElement.Elements()) {
|
||||
var localId = Int32.Parse(activityElement.Attribute("Id").Value);
|
||||
var activity = new ActivityRecord {
|
||||
@@ -69,22 +69,32 @@ namespace Orchard.Workflows.ImportExport {
|
||||
recipeContext.Executed = true;
|
||||
}
|
||||
|
||||
private string ProbeWorkflowDefinitionName(string name) {
|
||||
var count = 0;
|
||||
var newName = name;
|
||||
WorkflowDefinitionRecord workflowDefinition;
|
||||
private WorkflowDefinitionRecord GetOrCreateWorkflowDefinition(string name) {
|
||||
var workflowDefinition = _workflowDefinitionRepository.Get(x => x.Name == name);
|
||||
|
||||
do {
|
||||
var localName = newName;
|
||||
workflowDefinition = _workflowDefinitionRepository.Get(x => x.Name == localName);
|
||||
if (workflowDefinition == null) {
|
||||
workflowDefinition = new WorkflowDefinitionRecord {
|
||||
Name = name
|
||||
};
|
||||
_workflowDefinitionRepository.Create(workflowDefinition);
|
||||
}
|
||||
else {
|
||||
CleanWorkFlow(workflowDefinition);
|
||||
}
|
||||
|
||||
if (workflowDefinition != null) {
|
||||
newName = string.Format("{0}-{1}", name, ++count);
|
||||
}
|
||||
return workflowDefinition;
|
||||
}
|
||||
|
||||
} while (workflowDefinition != null);
|
||||
private void CleanWorkFlow(WorkflowDefinitionRecord workflowDefinition) {
|
||||
foreach (var activityRecord in workflowDefinition.ActivityRecords) {
|
||||
_activityRepository.Delete(activityRecord);
|
||||
}
|
||||
workflowDefinition.ActivityRecords.Clear();
|
||||
|
||||
return newName;
|
||||
foreach (var transitionRecord in workflowDefinition.TransitionRecords) {
|
||||
_transitionRepository.Delete(transitionRecord);
|
||||
}
|
||||
workflowDefinition.TransitionRecords.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ namespace Upgrade.Controllers {
|
||||
|
||||
if (hasMore) {
|
||||
_orchardServices.Notifier.Warning(T("Some media files need to be migrated."));
|
||||
_orchardServices.Notifier.Information(T("{0} media files have been found, {1} media are in the library.", MediaList.Count, _orchardServices.ContentManager.Query<MediaPart>().Count()));
|
||||
_orchardServices.Notifier.Information(T("{0} media files have been found, {1} media are in the library.", MediaList.Count, _orchardServices.ContentManager.Query<MediaPart, MediaPartRecord>().Count()));
|
||||
}
|
||||
else {
|
||||
_orchardServices.Notifier.Warning(T("All media files have been migrated."));
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Data.Migration.Schema {
|
||||
public class SchemaBuilder {
|
||||
@@ -7,10 +8,13 @@ namespace Orchard.Data.Migration.Schema {
|
||||
private readonly string _featurePrefix;
|
||||
private readonly Func<string, string> _formatPrefix;
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public SchemaBuilder(IDataMigrationInterpreter interpreter, string featurePrefix = null, Func<string, string> formatPrefix = null) {
|
||||
_interpreter = interpreter;
|
||||
_featurePrefix = featurePrefix ?? String.Empty;
|
||||
_formatPrefix = formatPrefix ?? (s => s ?? String.Empty);
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IDataMigrationInterpreter Interpreter {
|
||||
@@ -46,12 +50,16 @@ namespace Orchard.Data.Migration.Schema {
|
||||
}
|
||||
|
||||
public SchemaBuilder ExecuteSql(string sql, Action<SqlStatementCommand> statement = null) {
|
||||
var sqlStatmentCommand = new SqlStatementCommand(sql);
|
||||
if ( statement != null ) {
|
||||
statement(sqlStatmentCommand);
|
||||
try {
|
||||
var sqlStatmentCommand = new SqlStatementCommand(sql);
|
||||
if (statement != null) {
|
||||
statement(sqlStatmentCommand);
|
||||
}
|
||||
Run(sqlStatmentCommand);
|
||||
return this;
|
||||
} catch (Exception ex) {
|
||||
throw new OrchardException(T("An unexpected error occured while executing the SQL statement: {0}", sql), ex); // Add the sql to the nested exception information
|
||||
}
|
||||
Run(sqlStatmentCommand);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run(ISchemaBuilderCommand command) {
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using System.Web.Http;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
@@ -60,8 +61,12 @@ namespace Orchard.Mvc.Routes {
|
||||
_routeCollection
|
||||
.OfType<HubRoute>()
|
||||
.ForEach(x => x.ReleaseShell(_shellSettings));
|
||||
|
||||
// new routes are added
|
||||
|
||||
// HACK: For inserting names in internal dictionary when inserting route to RouteCollection.
|
||||
var routeCollectionType = typeof (RouteCollection);
|
||||
var namedMap = (Dictionary<string, RouteBase>) routeCollectionType.GetField("_namedMap", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_routeCollection);
|
||||
|
||||
// new routes are added
|
||||
foreach (var routeDescriptor in routesArray) {
|
||||
// Loading session state information.
|
||||
var defaultSessionState = SessionStateBehavior.Default;
|
||||
@@ -121,6 +126,11 @@ namespace Orchard.Mvc.Routes {
|
||||
}
|
||||
|
||||
_routeCollection.Insert(index, matchedHubRoute);
|
||||
|
||||
// HACK: For inserting names in internal dictionary when inserting route to RouteCollection.
|
||||
if (!string.IsNullOrEmpty(matchedHubRoute.Name) && !namedMap.ContainsKey(matchedHubRoute.Name)) {
|
||||
namedMap[matchedHubRoute.Name] = matchedHubRoute;
|
||||
}
|
||||
}
|
||||
|
||||
matchedHubRoute.Add(shellRoute, _shellSettings);
|
||||
|
@@ -206,10 +206,9 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
&& !path.StartsWith("~/Themes", StringComparison.OrdinalIgnoreCase)
|
||||
&& !path.StartsWith("~/Media", StringComparison.OrdinalIgnoreCase)
|
||||
&& !path.StartsWith("~/Core", StringComparison.OrdinalIgnoreCase)) {
|
||||
|
||||
return base.Href("~/" + _tenantPrefix + path.Substring(2), pathParts);
|
||||
}
|
||||
|
||||
return base.Href("~/" + _tenantPrefix + path.Substring(String.IsNullOrWhiteSpace(_tenantPrefix) ? 2 : 1), pathParts);
|
||||
}
|
||||
}
|
||||
|
||||
return base.Href(path, pathParts);
|
||||
|
@@ -125,7 +125,7 @@ namespace Orchard.Security.Providers {
|
||||
|
||||
int userId;
|
||||
if (!int.TryParse(userDataId, out userId)) {
|
||||
Logger.Fatal("User id not a parsable integer");
|
||||
Logger.Error("User id not a parsable integer");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -196,12 +196,14 @@ namespace Orchard.UI.Resources {
|
||||
var resource = (from p in ResourceProviders
|
||||
from r in p.GetResources(type)
|
||||
where name.Equals(r.Key, StringComparison.OrdinalIgnoreCase)
|
||||
orderby r.Value.Version descending
|
||||
let version = r.Value.Version != null ? new Version(r.Value.Version) : null
|
||||
orderby version descending
|
||||
select r.Value).FirstOrDefault();
|
||||
if (resource == null && _dynamicManifest != null) {
|
||||
resource = (from r in _dynamicManifest.GetResources(type)
|
||||
where name.Equals(r.Key, StringComparison.OrdinalIgnoreCase)
|
||||
orderby r.Value.Version descending
|
||||
let version = r.Value.Version != null ? new Version(r.Value.Version) : null
|
||||
orderby version descending
|
||||
select r.Value).FirstOrDefault();
|
||||
}
|
||||
if (resolveInlineDefinitions && resource == null) {
|
||||
|
@@ -254,11 +254,9 @@ namespace Orchard.Utility.Extensions {
|
||||
return false;
|
||||
}
|
||||
|
||||
Array.Sort(chars);
|
||||
|
||||
for (var i = 0; i < subject.Length; i++) {
|
||||
char current = subject[i];
|
||||
if (Array.BinarySearch(chars, current) >= 0) {
|
||||
if (Array.IndexOf(chars, current) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -275,11 +273,9 @@ namespace Orchard.Utility.Extensions {
|
||||
return false;
|
||||
}
|
||||
|
||||
Array.Sort(chars);
|
||||
|
||||
for (var i = 0; i < subject.Length; i++) {
|
||||
char current = subject[i];
|
||||
if (Array.BinarySearch(chars, current) < 0) {
|
||||
if (Array.IndexOf(chars, current) < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user