mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Compare commits
18 Commits
issue/6193
...
issue/8814
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12f285caf5 | ||
|
|
f3e9f9550d | ||
|
|
4c1afb119b | ||
|
|
b254fc5463 | ||
|
|
32e7d862f9 | ||
|
|
6e4fefd873 | ||
|
|
fc8b681b4e | ||
|
|
86bcf413e7 | ||
|
|
0d9fccb624 | ||
|
|
62038ed1bb | ||
|
|
6eab0a1260 | ||
|
|
e60a845359 | ||
|
|
23fb9dff92 | ||
|
|
0bce8e634b | ||
|
|
0faf196f74 | ||
|
|
fdbb06ba8d | ||
|
|
15cad85d1e | ||
|
|
0b86413e60 |
@@ -49,8 +49,8 @@
|
||||
<HintPath>..\..\..\packages\Iesi.Collections.4.0.4\lib\net461\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="Antlr3.Runtime" version="3.5.1" targetFramework="net48" />
|
||||
<package id="Iesi.Collections" version="4.0.4" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@@ -4,7 +4,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="NUnit" version="2.5.10.11092" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="NUnit" version="2.5.10.11092" targetFramework="net48" />
|
||||
<package id="Orchard.FluentPath" version="1.0.0.1" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
<package id="SpecFlow" version="1.9.0" targetFramework="net48" />
|
||||
</packages>
|
||||
</packages>
|
||||
@@ -20,7 +20,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
|
||||
@@ -110,8 +110,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Core, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Orchard.NuGet.Core.1.1.0.0\lib\NuGet.Core.dll</HintPath>
|
||||
|
||||
@@ -15,6 +15,7 @@ using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Settings.Handlers;
|
||||
using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Metadata.Records;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Settings.Services;
|
||||
using Orchard.DisplayManagement;
|
||||
@@ -110,7 +111,12 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
||||
return new[] { typeof(UserPartRecord),
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentPartDefinitionRecord),
|
||||
typeof(ContentPartFieldDefinitionRecord),
|
||||
typeof(ContentFieldDefinitionRecord),
|
||||
typeof(ContentTypeDefinitionRecord),
|
||||
typeof(ContentTypePartDefinitionRecord)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Settings.Handlers;
|
||||
using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Metadata.Records;
|
||||
using Orchard.Core.Settings.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
@@ -54,7 +55,12 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
typeof(UserPartRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentTypeRecord));
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentPartDefinitionRecord),
|
||||
typeof(ContentPartFieldDefinitionRecord),
|
||||
typeof(ContentFieldDefinitionRecord),
|
||||
typeof(ContentTypeDefinitionRecord),
|
||||
typeof(ContentTypePartDefinitionRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
|
||||
@@ -14,6 +14,7 @@ using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Settings.Handlers;
|
||||
using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Metadata.Records;
|
||||
using Orchard.Core.Settings.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
@@ -59,7 +60,12 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
typeof(UserPartRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentTypeRecord));
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentPartDefinitionRecord),
|
||||
typeof(ContentPartFieldDefinitionRecord),
|
||||
typeof(ContentFieldDefinitionRecord),
|
||||
typeof(ContentTypeDefinitionRecord),
|
||||
typeof(ContentTypePartDefinitionRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.Net;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Warmup.Services;
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace Orchard.Tests.Modules.Warmup {
|
||||
|
||||
[Test]
|
||||
public void StatusCodeShouldBe404ForUnexistingResources() {
|
||||
var download = _webDownloader.Download("http://orchardproject.net/yepyep");
|
||||
var download = _webDownloader.Download("https://orchardcore.net/" + Guid.NewGuid());
|
||||
Assert.That(download, Is.Not.Null);
|
||||
Assert.That(download.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||
Assert.That(download.Content, Is.Null);
|
||||
@@ -28,7 +29,7 @@ namespace Orchard.Tests.Modules.Warmup {
|
||||
|
||||
[Test]
|
||||
public void StatusCodeShouldBe200ForValidRequests() {
|
||||
var download = _webDownloader.Download("http://orchardproject.net/");
|
||||
var download = _webDownloader.Download("https://orchardcore.net/");
|
||||
Assert.That(download, Is.Not.Null);
|
||||
Assert.That(download.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
Assert.That(download.Content, Is.Not.Empty);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="NUnit" version="2.5.10.11092" targetFramework="net48" />
|
||||
<package id="Orchard.FluentPath" version="1.0.0.1" targetFramework="net48" />
|
||||
<package id="Orchard.NuGet.Core" version="1.1.0.0" targetFramework="net48" />
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
|
||||
@@ -110,8 +110,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="NUnit" version="2.5.10.11092" targetFramework="net48" />
|
||||
<package id="NUnitTestAdapter" version="2.3.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -53,6 +53,12 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Antlr3.Runtime.3.5.1\lib\net40-client\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Iesi.Collections.4.0.4\lib\net461\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\lib\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -60,15 +66,24 @@
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq.EagerFetching, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Remotion.Linq.EagerFetching.2.2.0\lib\net45\Remotion.Linq.EagerFetching.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
@@ -659,4 +674,4 @@
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr3.Runtime" version="3.5.1" targetFramework="net48" />
|
||||
<package id="Iesi.Collections" version="4.0.4" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
</packages>
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@@ -45,7 +45,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
<package id="XMLDiffPatch" version="1.0.8.28" targetFramework="net48" />
|
||||
</packages>
|
||||
</packages>
|
||||
@@ -18,6 +18,7 @@ namespace Orchard.Autoroute.Settings {
|
||||
public AutorouteSettings() {
|
||||
PerItemConfiguration = false;
|
||||
AllowCustomPattern = true;
|
||||
AllowSetAsHomePage = true;
|
||||
UseCulturePattern = false;
|
||||
AutomaticAdjustmentOnEdit = false;
|
||||
PatternDefinitions = "[]";
|
||||
@@ -27,6 +28,7 @@ namespace Orchard.Autoroute.Settings {
|
||||
|
||||
public bool PerItemConfiguration { get; set; }
|
||||
public bool AllowCustomPattern { get; set; }
|
||||
public bool AllowSetAsHomePage { get; set; }
|
||||
public bool UseCulturePattern { get; set; }
|
||||
public bool AutomaticAdjustmentOnEdit { get; set; }
|
||||
public bool? IsDefault { get; set; }
|
||||
@@ -100,6 +102,7 @@ namespace Orchard.Autoroute.Settings {
|
||||
public void Build(ContentTypePartDefinitionBuilder builder) {
|
||||
builder.WithSetting("AutorouteSettings.PerItemConfiguration", PerItemConfiguration.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("AutorouteSettings.AllowCustomPattern", AllowCustomPattern.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("AutorouteSettings.AllowSetAsHomePage", AllowSetAsHomePage.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("AutorouteSettings.UseCulturePattern", UseCulturePattern.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", AutomaticAdjustmentOnEdit.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("AutorouteSettings.PatternDefinitions", PatternDefinitions);
|
||||
|
||||
@@ -15,7 +15,15 @@
|
||||
<div>
|
||||
@Html.CheckBoxFor(m => m.AllowCustomPattern)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowCustomPattern)">@T("Allow custom patterns")</label>
|
||||
<span class="hint">@T("Allow the user to change the pattern on each item")</span>
|
||||
<span class="hint">@T("Allow the user to change the pattern on each item.")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
@Html.CheckBoxFor(m => m.AllowSetAsHomePage)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowSetAsHomePage)">@T("Allow \"Set as home page\"")</label>
|
||||
<span class="hint">@T("Allow the user to set a content item of this type as the home page.")</span>
|
||||
<span class="hint">@T("NOTE: Certain combinations of content type definitions and permission settings can create circumstances for non-Admin users with Dashboard access to remove the home page without the ability to set another one. Use this option with caution.")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
</fieldset>
|
||||
@if (!Model.IsHomePage) {
|
||||
if (AuthorizedFor(Permissions.SetHomePage)) {
|
||||
if (AuthorizedFor(Permissions.SetHomePage) && Model.Settings.AllowSetAsHomePage) {
|
||||
<fieldset>
|
||||
<span class="checkbox-and-label">
|
||||
@Html.CheckBoxFor(m => m.PromoteToHomePage)
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -115,8 +115,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Orchard.WindowsAzure.Diagnostics" version="2.7.0.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
|
||||
@@ -107,8 +107,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
@@ -220,4 +220,4 @@
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -96,6 +96,8 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
return newPath;
|
||||
}
|
||||
|
||||
private static string GetFolderName(string path) => path.Substring(path.LastIndexOf('/') + 1);
|
||||
|
||||
public string Combine(string path1, string path2) {
|
||||
if (path1 == null) {
|
||||
throw new ArgumentNullException("path1");
|
||||
@@ -148,10 +150,10 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
}
|
||||
|
||||
return BlobClient.ListBlobs(prefix)
|
||||
.OfType<CloudBlockBlob>()
|
||||
.Where(blobItem => !blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
||||
.Select(blobItem => new AzureBlobFileStorage(blobItem, _absoluteRoot))
|
||||
.ToArray();
|
||||
.OfType<CloudBlockBlob>()
|
||||
.Where(blobItem => !blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
||||
.Select(blobItem => new AzureBlobFileStorage(blobItem, _absoluteRoot))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public IEnumerable<IStorageFolder> ListFolders(string path) {
|
||||
@@ -201,6 +203,11 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
|
||||
public void CreateFolder(string path) {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
|
||||
if (FileSystemStorageProvider.FolderNameContainsInvalidCharacters(GetFolderName(path))) {
|
||||
throw new InvalidNameCharacterException("The directory name contains invalid character(s)");
|
||||
}
|
||||
|
||||
Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path));
|
||||
|
||||
// Creating a virtually hidden file to make the directory an existing concept
|
||||
@@ -232,7 +239,11 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
newPath = ConvertToRelativeUriPath(newPath);
|
||||
|
||||
// Workaround for https://github.com/Azure/azure-storage-net/issues/892
|
||||
if (FileSystemStorageProvider.FolderNameContainsInvalidCharacters(GetFolderName(newPath))) {
|
||||
throw new InvalidNameCharacterException("The new directory name contains invalid character(s)");
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/Azure/azure-storage-net/issues/892.
|
||||
// Renaming a folder by only changing the casing corrupts all the files in the folder.
|
||||
if (path.Equals(newPath, StringComparison.OrdinalIgnoreCase)) {
|
||||
var tempPath = Guid.NewGuid().ToString() + "/";
|
||||
@@ -277,6 +288,10 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
newPath = ConvertToRelativeUriPath(newPath);
|
||||
|
||||
if (FileSystemStorageProvider.FileNameContainsInvalidCharacters(Path.GetFileName(newPath))) {
|
||||
throw new InvalidNameCharacterException("The new file name contains invalid character(s)");
|
||||
}
|
||||
|
||||
Container.EnsureBlobExists(String.Concat(_root, path));
|
||||
Container.EnsureBlobDoesNotExist(String.Concat(_root, newPath));
|
||||
|
||||
@@ -301,6 +316,10 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
public IStorageFile CreateFile(string path) {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
|
||||
if (FileSystemStorageProvider.FileNameContainsInvalidCharacters(Path.GetFileName(path))) {
|
||||
throw new InvalidNameCharacterException("The file name contains invalid character(s)");
|
||||
}
|
||||
|
||||
if (Container.BlobExists(String.Concat(_root, path))) {
|
||||
throw new ArgumentException("File " + path + " already exists");
|
||||
}
|
||||
@@ -388,10 +407,7 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
public string GetName() {
|
||||
var path = GetPath();
|
||||
return path.Substring(path.LastIndexOf('/') + 1);
|
||||
}
|
||||
public string GetName() => GetFolderName(GetPath());
|
||||
|
||||
public string GetPath() {
|
||||
return _blob.Uri.ToString().Substring(_rootPath.Length).Trim('/');
|
||||
@@ -416,11 +432,12 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
long size = 0;
|
||||
|
||||
foreach (var blobItem in directoryBlob.ListBlobs()) {
|
||||
if (blobItem is CloudBlockBlob)
|
||||
size += ((CloudBlockBlob)blobItem).Properties.Length;
|
||||
|
||||
if (blobItem is CloudBlobDirectory)
|
||||
size += GetDirectorySize((CloudBlobDirectory)blobItem);
|
||||
if (blobItem is CloudBlockBlob blob) {
|
||||
size += blob.Properties.Length;
|
||||
}
|
||||
else if (blobItem is CloudBlobDirectory directory) {
|
||||
size += GetDirectorySize(directory);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
<package id="Microsoft.WindowsAzure.Caching" version="2.4.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Orchard.WindowsAzure.ServiceRuntime" version="2.7.0.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
<package id="System.Spatial" version="5.8.4" targetFramework="net48" />
|
||||
<package id="WindowsAzure.Storage" version="5.0.2" targetFramework="net48" />
|
||||
</packages>
|
||||
</packages>
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -47,11 +47,11 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
</packages>
|
||||
</packages>
|
||||
@@ -66,7 +66,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -198,6 +198,13 @@ namespace Orchard.CustomForms.Controllers {
|
||||
|
||||
contentItem.As<ICommonPart>().Container = customForm.ContentItem;
|
||||
|
||||
// save the submitted form
|
||||
if (customForm.SaveContentItem) {
|
||||
conditionallyPublish(contentItem);
|
||||
// Refresh content item
|
||||
contentItem = _contentManager.Get(contentItem.Id, VersionOptions.Latest);
|
||||
}
|
||||
|
||||
// triggers any event
|
||||
_rulesManager.TriggerEvent("CustomForm", "Submitted",
|
||||
() => new Dictionary<string, object> { { "Content", contentItem } });
|
||||
@@ -210,11 +217,6 @@ namespace Orchard.CustomForms.Controllers {
|
||||
returnUrl = _tokenizer.Replace(customForm.RedirectUrl, new Dictionary<string, object> { { "Content", contentItem } });
|
||||
}
|
||||
|
||||
// save the submitted form
|
||||
if (customForm.SaveContentItem) {
|
||||
conditionallyPublish(contentItem);
|
||||
}
|
||||
|
||||
// writes a confirmation message
|
||||
if (customForm.CustomMessage) {
|
||||
if (!String.IsNullOrWhiteSpace(customForm.Message)) {
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.DynamicForms.Helpers {
|
||||
public static class NameValueCollectionExtensions {
|
||||
public static string ToQueryString(this NameValueCollection nameValues) {
|
||||
return String.Join("&", (from string name in nameValues select String.Concat(name, "=", HttpUtility.UrlEncode(nameValues[name]))).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,6 @@
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Handlers\ReadFormValuesHandler.cs" />
|
||||
<Compile Include="Services\FormElementEventHandlerBase.cs" />
|
||||
<Compile Include="Helpers\NameValueCollectionExtensions.cs" />
|
||||
<Compile Include="Models\Submission.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Services\FormService.cs" />
|
||||
|
||||
@@ -467,4 +467,4 @@ namespace Orchard.DynamicForms.Services {
|
||||
return validatorElementType == elementType || validatorElementType.IsAssignableFrom(elementType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -4,46 +4,41 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class EnumerationFieldDriver : ContentFieldDriver<EnumerationField> {
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
private const string TemplateName = "Fields/Enumeration.Edit";
|
||||
|
||||
public EnumerationFieldDriver(IOrchardServices services) {
|
||||
Services = services;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
private static string GetPrefix(ContentField field, ContentPart part) {
|
||||
return part.PartDefinition.Name + "." + field.Name;
|
||||
}
|
||||
private static string GetPrefix(ContentField field, ContentPart part) =>
|
||||
part.PartDefinition.Name + "." + field.Name;
|
||||
|
||||
private static string GetDifferentiator(EnumerationField field, ContentPart part) {
|
||||
return field.Name;
|
||||
}
|
||||
private static string GetDifferentiator(EnumerationField field) => field.Name;
|
||||
|
||||
protected override DriverResult Display(ContentPart part, EnumerationField field, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Fields_Enumeration", GetDifferentiator(field, part),
|
||||
() => shapeHelper.Fields_Enumeration());
|
||||
return ContentShape("Fields_Enumeration", GetDifferentiator(field), () => shapeHelper.Fields_Enumeration());
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, EnumerationField field, dynamic shapeHelper) {
|
||||
return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field, part),
|
||||
() => {
|
||||
if (part.IsNew() && String.IsNullOrEmpty(field.Value)) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
|
||||
if (!String.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
field.Value = settings.DefaultValue;
|
||||
}
|
||||
return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field), () => {
|
||||
if (part.IsNew() && string.IsNullOrEmpty(field.Value)) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
|
||||
if (!string.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
field.SelectedValues = new string[] { settings.DefaultValue };
|
||||
}
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, EnumerationField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
@@ -7,28 +7,16 @@ namespace Orchard.Fields.Fields {
|
||||
private const char Separator = ';';
|
||||
|
||||
public string Value {
|
||||
get { return Storage.Get<string>(); }
|
||||
set { Storage.Set(value ?? String.Empty); }
|
||||
get => Storage.Get<string>()?.Trim(Separator) ?? "";
|
||||
set => Storage.Set(string.IsNullOrWhiteSpace(value)
|
||||
? string.Empty
|
||||
// It is now the responsibility of this field to (re-)add the separators.
|
||||
: Separator + value.Trim(Separator) + Separator);
|
||||
}
|
||||
|
||||
public string[] SelectedValues {
|
||||
get {
|
||||
var value = Value;
|
||||
if(string.IsNullOrWhiteSpace(value)) {
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
return value.Split(new [] { Separator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
set {
|
||||
if (value == null || value.Length == 0) {
|
||||
Value = String.Empty;
|
||||
}
|
||||
else {
|
||||
Value = Separator + string.Join(Separator.ToString(), value) + Separator;
|
||||
}
|
||||
}
|
||||
get => Value?.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0];
|
||||
set => Value = value?.Length > 0 ? string.Join(Separator.ToString(), value) : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
@model Orchard.Fields.Fields.EnumerationField
|
||||
|
||||
@using Orchard.Fields.Settings;
|
||||
|
||||
@{
|
||||
var settings = Model.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
|
||||
string[] options = (!String.IsNullOrWhiteSpace(settings.Options)) ? settings.Options.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None) : new string[] { T("Select an option").ToString() };
|
||||
}
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Value)" @if (settings.Required) { <text> class="required" </text> }>@Model.DisplayName</label>
|
||||
<label for="@Html.FieldIdFor(m => m.Value)" @if (settings.Required) { <text> class="required" </text> }>@Model.DisplayName</label>
|
||||
@switch (settings.ListMode) {
|
||||
case ListMode.Dropdown:
|
||||
@Html.DropDownListFor(m => m.Value, new SelectList(options, Model.Value), settings.Required ? new { required = "required" } : null)
|
||||
@Html.DropDownListFor(m => m.Value, new SelectList(options, Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)
|
||||
break;
|
||||
|
||||
case ListMode.Radiobutton:
|
||||
foreach (var option in options) {
|
||||
if (string.IsNullOrWhiteSpace(option)) {
|
||||
<label>@Html.RadioButton("Value", "", string.IsNullOrWhiteSpace(Model.Value), settings.Required ? new { required = "required" } : null)<i>@T("unset")</i></label> }
|
||||
<label>@Html.RadioButton("Value", "", string.IsNullOrWhiteSpace(Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)<i>@T("unset")</i></label>
|
||||
}
|
||||
else {
|
||||
<label>@Html.RadioButton("Value", option, (option == Model.Value), settings.Required ? new { required = "required" } : null)@option</label> }
|
||||
<label>@Html.RadioButton("Value", option, (option == Model.SelectedValues.FirstOrDefault()), settings.Required ? new { required = "required" } : null)@option</label>
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -95,8 +95,8 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<package id="Microsoft.Owin.Security" version="4.2.2" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Owin" version="1.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.3.10\lib\net461\NHibernate.dll</HintPath>
|
||||
<Reference Include="NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.5.5.2\lib\net48\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
|
||||
<package id="NHibernate" version="5.5.2" targetFramework="net48" />
|
||||
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
|
||||
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
|
||||
</packages>
|
||||
</packages>
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.CulturePicker.Services;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization.Providers;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Mvc.Extensions;
|
||||
|
||||
namespace Orchard.Localization.Controllers {
|
||||
[OrchardFeature("Orchard.Localization.CultureSelector")]
|
||||
public class UserCultureSelectorController : Controller {
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly ICultureStorageProvider _cultureStorageProvider;
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public UserCultureSelectorController(
|
||||
IOrchardServices services,
|
||||
ILocalizationService localizationService,
|
||||
ICultureStorageProvider cultureStorageProvider) {
|
||||
Services = services;
|
||||
_localizationService = localizationService;
|
||||
_cultureStorageProvider = cultureStorageProvider;
|
||||
}
|
||||
|
||||
public ActionResult ChangeCulture(string culture) {
|
||||
if (string.IsNullOrEmpty(culture)) {
|
||||
throw new ArgumentNullException(culture);
|
||||
}
|
||||
|
||||
var returnUrl = Utils.GetReturnUrl(Services.WorkContext.HttpContext.Request);
|
||||
if (string.IsNullOrEmpty(returnUrl))
|
||||
returnUrl = "";
|
||||
|
||||
if (_localizationService.TryGetRouteForUrl(returnUrl, out AutoroutePart currentRoutePart)
|
||||
&& _localizationService.TryFindLocalizedRoute(currentRoutePart.ContentItem, culture, out AutoroutePart localizedRoutePart)) {
|
||||
returnUrl = localizedRoutePart.Path;
|
||||
}
|
||||
|
||||
_cultureStorageProvider.SetCulture(culture);
|
||||
if (!returnUrl.StartsWith("~/")) {
|
||||
returnUrl = "~/" + returnUrl;
|
||||
}
|
||||
|
||||
return this.RedirectLocal(returnUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ Features:
|
||||
Orchard.Localization:
|
||||
Description: Enables localization of content items.
|
||||
Category: Content
|
||||
Dependencies: Settings
|
||||
Dependencies: Settings, Orchard.Autoroute
|
||||
Name: Content Localization
|
||||
Orchard.Localization.DateTimeFormat:
|
||||
Description: Enables PO-based translation of date/time formats and names of days and months.
|
||||
@@ -30,7 +30,7 @@ Features:
|
||||
Description: Enables transliteration of the autoroute slug when creating a piece of content.
|
||||
Category: Content
|
||||
Name: URL Transliteration
|
||||
Dependencies: Orchard.Localization.Transliteration, Orchard.Autoroute
|
||||
Dependencies: Orchard.Localization.Transliteration
|
||||
Orchard.Localization.CultureNeutralPartsAndFields:
|
||||
Description: Enables the synchronization among localizations of parts and fields specifically marked as "Culture Neutral".
|
||||
Category: Content
|
||||
|
||||
@@ -89,10 +89,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminCultureSelectorController.cs" />
|
||||
<Compile Include="Extensions\Constants.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\TransliterationAdminController.cs" />
|
||||
<Compile Include="Controllers\AdminCultureSelectorController.cs" />
|
||||
<Compile Include="Controllers\UserCultureSelectorController.cs" />
|
||||
<Compile Include="Extensions\MetaDataExtensions.cs" />
|
||||
<Compile Include="Handlers\LocalizationCultureNeutralityHandler.cs" />
|
||||
<Compile Include="Models\TransliterationSpecificationRecord.cs" />
|
||||
@@ -120,6 +121,7 @@
|
||||
<Compile Include="Services\LocalizationService.cs" />
|
||||
<Compile Include="Services\TransliterationService.cs" />
|
||||
<Compile Include="Events\TransliterationSlugEventHandler.cs" />
|
||||
<Compile Include="Services\Utils.cs" />
|
||||
<Compile Include="Settings\LocalizationCultureNeutralityEditorEvents.cs" />
|
||||
<Compile Include="Settings\LocalizationCultureNeutralitySettings.cs" />
|
||||
<Compile Include="ViewModels\ContentLocalizationsViewModel.cs" />
|
||||
@@ -196,8 +198,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\UserCultureSelector.cshtml" />
|
||||
<Content Include="Views\DefinitionTemplates\LocalizationCultureNeutralitySettings.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
@@ -233,4 +234,4 @@
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
@@ -19,7 +18,8 @@ namespace Orchard.Localization.Selectors {
|
||||
private const string AdminCookieName = "OrchardCurrentCulture-Admin";
|
||||
private const int DefaultExpireTimeYear = 1;
|
||||
|
||||
public CookieCultureSelector(IHttpContextAccessor httpContextAccessor,
|
||||
public CookieCultureSelector(
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IClock clock,
|
||||
ShellSettings shellSettings) {
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
@@ -36,11 +36,10 @@ namespace Orchard.Localization.Selectors {
|
||||
|
||||
var cookie = new HttpCookie(cookieName, culture) {
|
||||
Expires = _clock.UtcNow.AddYears(DefaultExpireTimeYear),
|
||||
Domain = httpContext.Request.IsLocal ? null : httpContext.Request.Url.Host
|
||||
};
|
||||
|
||||
cookie.Domain = !httpContext.Request.IsLocal ? httpContext.Request.Url.Host : null;
|
||||
|
||||
if (!String.IsNullOrEmpty(_shellSettings.RequestUrlPrefix)) {
|
||||
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix)) {
|
||||
cookie.Path = GetCookiePath(httpContext);
|
||||
}
|
||||
|
||||
@@ -73,4 +72,4 @@ namespace Orchard.Localization.Selectors {
|
||||
return cookiePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization.Models;
|
||||
|
||||
@@ -10,5 +11,7 @@ namespace Orchard.Localization.Services {
|
||||
void SetContentCulture(IContent content, string culture);
|
||||
IEnumerable<LocalizationPart> GetLocalizations(IContent content);
|
||||
IEnumerable<LocalizationPart> GetLocalizations(IContent content, VersionOptions versionOptions);
|
||||
bool TryFindLocalizedRoute(ContentItem routableContent, string cultureName, out AutoroutePart localizedRoute);
|
||||
bool TryGetRouteForUrl(string url, out AutoroutePart route);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Autoroute.Models;
|
||||
using Orchard.Autoroute.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Localization.Models;
|
||||
|
||||
namespace Orchard.Localization.Services {
|
||||
public class LocalizationService : ILocalizationService {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ICultureManager _cultureManager;
|
||||
private readonly IHomeAliasService _homeAliasService;
|
||||
|
||||
|
||||
public LocalizationService(IContentManager contentManager, ICultureManager cultureManager) {
|
||||
public LocalizationService(IContentManager contentManager, ICultureManager cultureManager, IHomeAliasService homeAliasService) {
|
||||
_contentManager = contentManager;
|
||||
_cultureManager = cultureManager;
|
||||
_homeAliasService = homeAliasService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning: Returns only the first item of same culture localizations.
|
||||
/// </summary>
|
||||
public LocalizationPart GetLocalizedContentItem(IContent content, string culture) =>
|
||||
GetLocalizedContentItem(content, culture, null);
|
||||
|
||||
public LocalizationPart GetLocalizedContentItem(IContent content, string culture) {
|
||||
return GetLocalizedContentItem(content, culture, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning: Returns only the first item of same culture localizations.
|
||||
/// </summary>
|
||||
public LocalizationPart GetLocalizedContentItem(IContent content, string culture, VersionOptions versionOptions) {
|
||||
var cultureRecord = _cultureManager.GetCultureByName(culture);
|
||||
|
||||
if (cultureRecord == null) return null;
|
||||
if (cultureRecord == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var localized = content.As<LocalizationPart>();
|
||||
|
||||
if (localized == null) return null;
|
||||
if (localized == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (localized?.Culture.Culture == culture) return localized;
|
||||
if (localized.Culture?.Culture == culture) return localized;
|
||||
|
||||
// Warning: Returns only the first of same culture localizations.
|
||||
return GetLocalizationsQuery(localized, versionOptions)
|
||||
.Where<LocalizationPartRecord>(l => l.CultureId == cultureRecord.Id)
|
||||
.Where<LocalizationPartRecord>(localization => localization.CultureId == cultureRecord.Id)
|
||||
.Slice(1)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public string GetContentCulture(IContent content) {
|
||||
var localized = content.As<LocalizationPart>();
|
||||
|
||||
return localized?.Culture == null ? _cultureManager.GetSiteCulture() : localized.Culture.Culture;
|
||||
}
|
||||
public string GetContentCulture(IContent content) =>
|
||||
content.As<LocalizationPart>()?.Culture?.Culture ?? _cultureManager.GetSiteCulture();
|
||||
|
||||
public void SetContentCulture(IContent content, string culture) {
|
||||
var localized = content.As<LocalizationPart>();
|
||||
@@ -51,30 +60,83 @@ namespace Orchard.Localization.Services {
|
||||
localized.Culture = _cultureManager.GetCultureByName(culture);
|
||||
}
|
||||
|
||||
public IEnumerable<LocalizationPart> GetLocalizations(IContent content) {
|
||||
return GetLocalizations(content, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// Warning: May contain more than one localization of the same culture.
|
||||
/// </summary>
|
||||
public IEnumerable<LocalizationPart> GetLocalizations(IContent content) => GetLocalizations(content, null);
|
||||
|
||||
/// <summary>
|
||||
/// Warning: May contain more than one localization of the same culture.
|
||||
/// </summary>
|
||||
public IEnumerable<LocalizationPart> GetLocalizations(IContent content, VersionOptions versionOptions) {
|
||||
if (content.ContentItem.Id == 0) return Enumerable.Empty<LocalizationPart>();
|
||||
|
||||
var localized = content.As<LocalizationPart>();
|
||||
|
||||
return GetLocalizationsQuery(localized, versionOptions)
|
||||
.Where<LocalizationPartRecord>(l => l.Id != localized.Id) // Exclude the current content.
|
||||
.Where<LocalizationPartRecord>(localization => localization.Id != localized.Id) // Exclude the current content.
|
||||
.List();
|
||||
}
|
||||
|
||||
public bool TryGetRouteForUrl(string url, out AutoroutePart route) {
|
||||
route = _contentManager.Query<AutoroutePart, AutoroutePartRecord>()
|
||||
.ForVersion(VersionOptions.Published)
|
||||
.Where(r => r.DisplayAlias == url)
|
||||
.List()
|
||||
.FirstOrDefault();
|
||||
|
||||
route = route ?? _homeAliasService.GetHomePage(VersionOptions.Latest).As<AutoroutePart>();
|
||||
|
||||
return route != null;
|
||||
}
|
||||
|
||||
public bool TryFindLocalizedRoute(ContentItem routableContent, string cultureName, out AutoroutePart localizedRoute) {
|
||||
if (!routableContent.Parts.Any(p => p.Is<ILocalizableAspect>())) {
|
||||
localizedRoute = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
IEnumerable<LocalizationPart> localizations = GetLocalizations(routableContent, VersionOptions.Published);
|
||||
|
||||
ILocalizableAspect localizationPart = null, siteCultureLocalizationPart = null;
|
||||
foreach (var localization in localizations) {
|
||||
if (localization.Culture.Culture.Equals(cultureName, StringComparison.InvariantCultureIgnoreCase)) {
|
||||
localizationPart = localization;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (localization.Culture == null && siteCultureLocalizationPart == null) {
|
||||
siteCultureLocalizationPart = localization;
|
||||
}
|
||||
}
|
||||
|
||||
if (localizationPart == null) {
|
||||
localizationPart = siteCultureLocalizationPart;
|
||||
}
|
||||
|
||||
localizedRoute = localizationPart?.As<AutoroutePart>();
|
||||
|
||||
return localizedRoute != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning: May contain more than one localization of the same culture.
|
||||
/// </summary>
|
||||
private IContentQuery<LocalizationPart> GetLocalizationsQuery(LocalizationPart localizationPart, VersionOptions versionOptions) {
|
||||
var masterId = localizationPart.HasTranslationGroup ?
|
||||
localizationPart.Record.MasterContentItemId : localizationPart.Id;
|
||||
var masterId = localizationPart.HasTranslationGroup
|
||||
? localizationPart.Record.MasterContentItemId
|
||||
: localizationPart.Id;
|
||||
|
||||
var query = versionOptions == null ?
|
||||
_contentManager.Query<LocalizationPart>() : _contentManager.Query<LocalizationPart>(versionOptions);
|
||||
var query = _contentManager.Query<LocalizationPart>(localizationPart.ContentItem.ContentType);
|
||||
|
||||
// Warning: May contain more than one localization of the same culture.
|
||||
return query.Where<LocalizationPartRecord>(l => l.Id == masterId || l.MasterContentItemId == masterId);
|
||||
if (versionOptions == null) {
|
||||
query = query.ForVersion(versionOptions);
|
||||
}
|
||||
|
||||
return query
|
||||
.Where<LocalizationPartRecord>(localization => localization.Id == masterId || localization.MasterContentItemId == masterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.CulturePicker.Services {
|
||||
public static class Utils {
|
||||
public static string GetReturnUrl(HttpRequestBase request) {
|
||||
if (request.UrlReferrer == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
string localUrl = GetAppRelativePath(request.UrlReferrer.AbsolutePath, request);
|
||||
return HttpUtility.UrlDecode(localUrl);
|
||||
}
|
||||
|
||||
public static string GetAppRelativePath(string logicalPath, HttpRequestBase request) {
|
||||
if (request.ApplicationPath == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
logicalPath = logicalPath.ToLower();
|
||||
string appPath = request.ApplicationPath.ToLower();
|
||||
if (appPath != "/") {
|
||||
appPath += "/";
|
||||
}
|
||||
else {
|
||||
return logicalPath.Substring(1);
|
||||
}
|
||||
|
||||
return logicalPath.Replace(appPath, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@using Orchard.Localization.Services
|
||||
|
||||
@{
|
||||
var currentCulture = WorkContext.CurrentCulture;
|
||||
var supportedCultures = WorkContext.Resolve<ICultureManager>().ListCultures().ToList();
|
||||
}
|
||||
|
||||
<div id="culture-selection">
|
||||
<ul>
|
||||
@foreach (var supportedCulture in supportedCultures)
|
||||
{
|
||||
var url = Url.Action(
|
||||
"ChangeCulture",
|
||||
"UserCultureSelector",
|
||||
new
|
||||
{
|
||||
area = "Orchard.Localization",
|
||||
culture = supportedCulture,
|
||||
returnUrl = Html.ViewContext.HttpContext.Request.RawUrl
|
||||
});
|
||||
|
||||
<li>
|
||||
@if (supportedCulture.Equals(currentCulture))
|
||||
{
|
||||
<a href="@url">@T("{0} (current)", supportedCulture)</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="@url">@supportedCulture</a>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -111,10 +111,16 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
url = mediaPart.FileName,
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex, "Unexpected exception when uploading a media.");
|
||||
catch (InvalidNameCharacterException) {
|
||||
statuses.Add(new {
|
||||
error = T(ex.Message).Text,
|
||||
error = T("The file name contains invalid character(s)").Text,
|
||||
progress = 1.0,
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex, T("Unexpected exception when uploading a media.").Text);
|
||||
statuses.Add(new {
|
||||
error = ex.Message,
|
||||
progress = 1.0,
|
||||
});
|
||||
}
|
||||
@@ -134,7 +140,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return HttpNotFound();
|
||||
|
||||
// Check permission
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, replaceMedia.FolderPath) && _mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, replaceMedia.FolderPath))
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, replaceMedia.FolderPath) && _mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, replaceMedia.FolderPath))
|
||||
&& !_mediaLibraryService.CanManageMediaFolder(replaceMedia.FolderPath)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
@@ -142,7 +148,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
var statuses = new List<object>();
|
||||
|
||||
var settings = Services.WorkContext.CurrentSite.As<MediaLibrarySettingsPart>();
|
||||
|
||||
|
||||
// Loop through each file in the request
|
||||
for (int i = 0; i < HttpContext.Request.Files.Count; i++) {
|
||||
// Pointer to file
|
||||
@@ -150,7 +156,8 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
var filename = Path.GetFileName(file.FileName);
|
||||
|
||||
// if the file has been pasted, provide a default name
|
||||
if (file.ContentType.Equals("image/png", StringComparison.InvariantCultureIgnoreCase) && !filename.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
if (file.ContentType.Equals("image/png", StringComparison.InvariantCultureIgnoreCase)
|
||||
&& !filename.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
filename = "clipboard.png";
|
||||
}
|
||||
|
||||
@@ -180,13 +187,15 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
if (mediaItemsUsingTheFile == 1) { // if the file is referenced only by the deleted media content, the file too can be removed.
|
||||
try {
|
||||
_mediaLibraryService.DeleteFile(replaceMedia.FolderPath, replaceMedia.FileName);
|
||||
} catch (ArgumentException) { // File not found by FileSystemStorageProvider is thrown as ArgumentException.
|
||||
}
|
||||
catch (ArgumentException) { // File not found by FileSystemStorageProvider is thrown as ArgumentException.
|
||||
statuses.Add(new {
|
||||
error = T("Error when deleting file to replace: file {0} does not exist in folder {1}. Media has been updated anyway.", replaceMedia.FileName, replaceMedia.FolderPath).Text,
|
||||
progress = 1.0
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// it changes the media file name
|
||||
replaceMedia.FileName = filename;
|
||||
}
|
||||
@@ -210,7 +219,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex, "Unexpected exception when uploading a media.");
|
||||
Logger.Error(ex, T("Unexpected exception when uploading a media.").Text);
|
||||
|
||||
statuses.Add(new {
|
||||
error = T(ex.Message).Text,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.MediaLibrary.Models;
|
||||
@@ -36,7 +36,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
public ActionResult Create(string folderPath) {
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, folderPath) || _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, folderPath))) {
|
||||
Services.Notifier.Error(T("Couldn't create media folder"));
|
||||
return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary", folderPath = folderPath });
|
||||
return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary", folderPath });
|
||||
}
|
||||
|
||||
// If the user is trying to access a folder above his boundaries, redirect him to his home folder
|
||||
@@ -68,28 +68,32 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var failed = false;
|
||||
try {
|
||||
bool valid = String.IsNullOrWhiteSpace(viewModel.Name) || Regex.IsMatch(viewModel.Name, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$");
|
||||
if (!valid) {
|
||||
throw new ArgumentException(T("Folder contains invalid characters").ToString());
|
||||
}
|
||||
else {
|
||||
_mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
|
||||
Services.Notifier.Information(T("Media folder created"));
|
||||
}
|
||||
_mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
|
||||
Services.Notifier.Information(T("Media folder created"));
|
||||
}
|
||||
catch (InvalidNameCharacterException) {
|
||||
Services.Notifier.Error(T("The folder name contains invalid character(s)."));
|
||||
failed = true;
|
||||
}
|
||||
catch (ArgumentException argumentException) {
|
||||
Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message));
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" });
|
||||
}
|
||||
|
||||
public ActionResult Edit(string folderPath) {
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, folderPath) || _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, folderPath))) {
|
||||
Services.Notifier.Error(T("Couldn't edit media folder"));
|
||||
return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary", folderPath = folderPath });
|
||||
return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary", folderPath });
|
||||
}
|
||||
|
||||
if (!_mediaLibraryService.CanManageMediaFolder(folderPath)) {
|
||||
@@ -125,7 +129,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
var viewModel = new MediaManagerFolderEditViewModel();
|
||||
UpdateModel(viewModel);
|
||||
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, viewModel.FolderPath)
|
||||
if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, viewModel.FolderPath)
|
||||
|| _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, viewModel.FolderPath))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
@@ -136,14 +140,12 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
}
|
||||
|
||||
try {
|
||||
bool valid = String.IsNullOrWhiteSpace(viewModel.Name) || Regex.IsMatch(viewModel.Name, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$");
|
||||
if (!valid) {
|
||||
throw new ArgumentException(T("Folder contains invalid characters").ToString());
|
||||
}
|
||||
else {
|
||||
_mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name);
|
||||
Services.Notifier.Information(T("Media folder renamed"));
|
||||
}
|
||||
_mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name);
|
||||
Services.Notifier.Information(T("Media folder renamed"));
|
||||
}
|
||||
catch (InvalidNameCharacterException) {
|
||||
Services.Notifier.Error(T("The folder name contains invalid character(s)."));
|
||||
return View(viewModel);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Editing Folder failed: {0}", exception.Message));
|
||||
@@ -198,7 +200,7 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
// don't try to rename the file if there is no associated media file
|
||||
if (!string.IsNullOrEmpty(media.FileName)) {
|
||||
// check permission on source folder
|
||||
if(!_mediaLibraryService.CheckMediaFolderPermission(Permissions.DeleteMediaContent, media.FolderPath)) {
|
||||
if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.DeleteMediaContent, media.FolderPath)) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Localization;
|
||||
using Orchard.MediaLibrary.Models;
|
||||
using Orchard.MediaLibrary.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.MediaLibrary.MediaFileName
|
||||
{
|
||||
namespace Orchard.MediaLibrary.MediaFileName {
|
||||
public class MediaFileNameDriver : ContentPartDriver<MediaPart> {
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
@@ -58,6 +58,8 @@ namespace Orchard.MediaLibrary.MediaFileName
|
||||
var priorFileName = model.FileName;
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if (model.FileName != null && !model.FileName.Equals(priorFileName, StringComparison.OrdinalIgnoreCase)) {
|
||||
var fieldName = "MediaFileNameEditorSettings.FileName";
|
||||
|
||||
try {
|
||||
_mediaLibraryService.RenameFile(part.FolderPath, priorFileName, model.FileName);
|
||||
part.FileName = model.FileName;
|
||||
@@ -65,10 +67,13 @@ namespace Orchard.MediaLibrary.MediaFileName
|
||||
_notifier.Add(NotifyType.Success, T("File '{0}' was renamed to '{1}'", priorFileName, model.FileName));
|
||||
}
|
||||
catch (OrchardException) {
|
||||
updater.AddModelError("MediaFileNameEditorSettings.FileName", T("Unable to rename file. Invalid Windows file path."));
|
||||
updater.AddModelError(fieldName, T("Unable to rename file. Invalid Windows file path."));
|
||||
}
|
||||
catch (Exception) {
|
||||
updater.AddModelError("MediaFileNameEditorSettings.FileName", T("Unable to rename file"));
|
||||
catch (InvalidNameCharacterException) {
|
||||
updater.AddModelError(fieldName, T("The file name contains invalid character(s)."));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
updater.AddModelError(fieldName, T("Unable to rename file: {0}", exception.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Localization;
|
||||
using Orchard.MediaLibrary.Factories;
|
||||
using Orchard.MediaLibrary.Models;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.Validation;
|
||||
using Orchard.MediaLibrary.Providers;
|
||||
using Orchard.Validation;
|
||||
|
||||
namespace Orchard.MediaLibrary.Services {
|
||||
public class MediaLibraryService : IMediaLibraryService {
|
||||
@@ -21,7 +21,6 @@ namespace Orchard.MediaLibrary.Services {
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
private readonly IEnumerable<IMediaFactorySelector> _mediaFactorySelectors;
|
||||
private readonly IMediaFolderProvider _mediaFolderProvider;
|
||||
private static char[] HttpUnallowed = new char[] { '<', '>', '*', '%', '&', ':', '\\', '?', '#' };
|
||||
|
||||
public MediaLibraryService(
|
||||
IOrchardServices orchardServices,
|
||||
@@ -146,12 +145,6 @@ namespace Orchard.MediaLibrary.Services {
|
||||
}
|
||||
|
||||
public string GetUniqueFilename(string folderPath, string filename) {
|
||||
|
||||
// remove any char which is unallowed in an HTTP request
|
||||
foreach (var unallowedChar in HttpUnallowed) {
|
||||
filename = filename.Replace(unallowedChar.ToString(), "");
|
||||
}
|
||||
|
||||
// compute a unique filename
|
||||
var uniqueFilename = filename;
|
||||
var index = 1;
|
||||
@@ -178,9 +171,9 @@ namespace Orchard.MediaLibrary.Services {
|
||||
var mediaFile = BuildMediaFile(relativePath, storageFile);
|
||||
|
||||
using (var stream = storageFile.OpenRead()) {
|
||||
var mediaFactory = GetMediaFactory(stream, mimeType, contentType);
|
||||
if (mediaFactory == null)
|
||||
throw new Exception(T("No media factory available to handle this resource.").Text);
|
||||
var mediaFactory = GetMediaFactory(stream, mimeType, contentType)
|
||||
?? throw new Exception(T("No media factory available to handle this resource.").Text);
|
||||
|
||||
var mediaPart = mediaFactory.CreateMedia(stream, mediaFile.Name, mimeType, contentType);
|
||||
if (mediaPart != null) {
|
||||
mediaPart.FolderPath = relativePath;
|
||||
@@ -257,7 +250,7 @@ namespace Orchard.MediaLibrary.Services {
|
||||
if (_orchardServices.Authorizer.Authorize(Permissions.ManageMediaContent)) {
|
||||
return true;
|
||||
}
|
||||
if (_orchardServices.WorkContext.CurrentUser==null)
|
||||
if (_orchardServices.WorkContext.CurrentUser == null)
|
||||
return _orchardServices.Authorizer.Authorize(permission);
|
||||
// determines the folder type: public, user own folder (my), folder of another user (private)
|
||||
var rootedFolderPath = this.GetRootedFolderPath(folderPath) ?? "";
|
||||
@@ -269,7 +262,7 @@ namespace Orchard.MediaLibrary.Services {
|
||||
isMyfolder = true;
|
||||
}
|
||||
|
||||
if(isMyfolder) {
|
||||
if (isMyfolder) {
|
||||
return _orchardServices.Authorizer.Authorize(Permissions.ManageOwnMedia);
|
||||
}
|
||||
else { // other
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Orchard.MediaProcessing.Controllers {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage media profiles")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var viewModel = new AdminIndexViewModel {ImageProfiles = new List<ImageProfileEntry>(), Options = new AdminIndexOptions()};
|
||||
var viewModel = new AdminIndexViewModel { ImageProfiles = new List<ImageProfileEntry>(), Options = new AdminIndexOptions() };
|
||||
UpdateModel(viewModel);
|
||||
|
||||
var checkedItems = viewModel.ImageProfiles.Where(c => c.IsChecked);
|
||||
@@ -133,7 +133,7 @@ namespace Orchard.MediaProcessing.Controllers {
|
||||
Category = f.Category,
|
||||
Type = f.Type,
|
||||
FilterRecordId = filter.Id,
|
||||
DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext {State = FormParametersHelper.ToDynamic(filter.State)}).Text : filter.Description
|
||||
DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext { State = FormParametersHelper.ToDynamic(filter.State) }).Text : filter.Description
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace Orchard.MediaProcessing.Controllers {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Services.ContentManager.Remove(profile.ContentItem);
|
||||
_profileService.DeleteImageProfile(id);
|
||||
Services.Notifier.Success(T("Image Profile {0} deleted", profile.Name));
|
||||
|
||||
return RedirectToAction("Index");
|
||||
@@ -175,7 +175,7 @@ namespace Orchard.MediaProcessing.Controllers {
|
||||
throw new ArgumentException("direction");
|
||||
}
|
||||
|
||||
return RedirectToAction("Edit", new {id});
|
||||
return RedirectToAction("Edit", new { id });
|
||||
}
|
||||
|
||||
public ActionResult Preview(int id) {
|
||||
@@ -185,6 +185,36 @@ namespace Orchard.MediaProcessing.Controllers {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Purge(int id) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage media profiles")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (_profileService.PurgeImageProfile(id)) {
|
||||
Services.Notifier.Information(T("The Image Profile has been purged"));
|
||||
}
|
||||
else {
|
||||
Services.Notifier.Warning(T("Unable to purge the Image Profile, it may already have been purged"));
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult PurgeObsolete() {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage media profiles")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (_profileService.PurgeObsoleteImageProfiles()) {
|
||||
Services.Notifier.Information(T("The obsolete Image Profiles have been purged"));
|
||||
}
|
||||
else {
|
||||
Services.Notifier.Warning(T("Unable to purge the obsolete Image Profiles"));
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,4 @@ namespace Orchard.MediaProcessing.Models {
|
||||
get { return Record.FileNames; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,12 @@ namespace Orchard.MediaProcessing.Services {
|
||||
void DeleteImageProfile(int id);
|
||||
void MoveUp(int filterId);
|
||||
void MoveDown(int filterId);
|
||||
bool PurgeImageProfile(int id);
|
||||
bool PurgeObsoleteImageProfiles();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ImageProfileServiceExtensions {
|
||||
public static string GetNameHashCode(this IImageProfileService service, string name) =>
|
||||
name.GetHashCode().ToString("x").ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.MediaProcessing.Services {
|
||||
// path is the publicUrl of the media, so it might contain url-encoded chars
|
||||
|
||||
// try to load the processed filename from cache
|
||||
var filePath = _fileNameProvider.GetFileName(profileName, System.Web.HttpUtility.UrlDecode(path));
|
||||
var filePath = _fileNameProvider.GetFileName(profileName, HttpUtility.UrlDecode(path));
|
||||
bool process = false;
|
||||
|
||||
// Before checking everything else, ensure that the content item that needs to be processed has a ImagePart.
|
||||
@@ -79,10 +79,10 @@ namespace Orchard.MediaProcessing.Services {
|
||||
if (checkForProfile) {
|
||||
//after reboot the app cache is empty so we reload the image in the cache if it exists in the _Profiles folder
|
||||
if (string.IsNullOrEmpty(filePath)) {
|
||||
var profileFilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, System.Web.HttpUtility.UrlDecode(path)));
|
||||
var profileFilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, HttpUtility.UrlDecode(path)));
|
||||
|
||||
if (_storageProvider.FileExists(profileFilePath)) {
|
||||
_fileNameProvider.UpdateFileName(profileName, System.Web.HttpUtility.UrlDecode(path), profileFilePath);
|
||||
_fileNameProvider.UpdateFileName(profileName, HttpUtility.UrlDecode(path), profileFilePath);
|
||||
filePath = profileFilePath;
|
||||
}
|
||||
}
|
||||
@@ -93,28 +93,24 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
process = true;
|
||||
}
|
||||
|
||||
// the processd file doesn't exist anymore, process it
|
||||
else if (!_storageProvider.FileExists(filePath)) {
|
||||
Logger.Debug("Processed file no longer exists, processing required, profile {0} for image {1}", profileName, path);
|
||||
|
||||
process = true;
|
||||
}
|
||||
|
||||
// if the original file is more recent, process it
|
||||
else {
|
||||
DateTime pathLastUpdated;
|
||||
if (TryGetImageLastUpdated(path, out pathLastUpdated)) {
|
||||
var filePathLastUpdated = _storageProvider.GetFile(filePath).GetLastUpdated();
|
||||
else if (TryGetImageLastUpdated(path, out DateTime pathLastUpdated)) {
|
||||
var filePathLastUpdated = _storageProvider.GetFile(filePath).GetLastUpdated();
|
||||
|
||||
if (pathLastUpdated > filePathLastUpdated) {
|
||||
Logger.Debug("Original file more recent, processing required, profile {0} for image {1}", profileName, path);
|
||||
if (pathLastUpdated > filePathLastUpdated) {
|
||||
Logger.Debug("Original file more recent, processing required, profile {0} for image {1}", profileName, path);
|
||||
|
||||
process = true;
|
||||
}
|
||||
process = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Since media with no ImagePart have no profile, filePath is null, so it's set again to its original path on the storage provider.
|
||||
if (string.IsNullOrWhiteSpace(filePath)) {
|
||||
filePath = _storageProvider.GetStoragePath(path);
|
||||
@@ -129,9 +125,11 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
if (customFilters == null || !customFilters.Any(c => c != null)) {
|
||||
profilePart = _profileService.GetImageProfileByName(profileName);
|
||||
if (profilePart == null)
|
||||
return String.Empty;
|
||||
} else {
|
||||
if (profilePart == null) {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
else {
|
||||
profilePart = _services.ContentManager.New<ImageProfilePart>("ImageProfile");
|
||||
profilePart.Name = profileName;
|
||||
foreach (var customFilter in customFilters) {
|
||||
@@ -142,13 +140,13 @@ namespace Orchard.MediaProcessing.Services {
|
||||
// prevent two requests from processing the same file at the same time
|
||||
// this is only thread safe at the machine level, so there is a try/catch later
|
||||
// to handle cross machines concurrency
|
||||
lock (String.Intern(path)) {
|
||||
lock (string.Intern(path)) {
|
||||
using (var image = GetImage(path)) {
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var filterContext = new FilterContext { Media = image, FilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, System.Web.HttpUtility.UrlDecode(path))) };
|
||||
var filterContext = new FilterContext { Media = image, FilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, HttpUtility.UrlDecode(path))) };
|
||||
|
||||
var tokens = new Dictionary<string, object>();
|
||||
// if a content item is provided, use it while tokenizing
|
||||
@@ -166,7 +164,7 @@ namespace Orchard.MediaProcessing.Services {
|
||||
descriptor.Filter(filterContext);
|
||||
}
|
||||
|
||||
_fileNameProvider.UpdateFileName(profileName, System.Web.HttpUtility.UrlDecode(path), filterContext.FilePath);
|
||||
_fileNameProvider.UpdateFileName(profileName, HttpUtility.UrlDecode(path), filterContext.FilePath);
|
||||
|
||||
if (!filterContext.Saved) {
|
||||
try {
|
||||
@@ -187,7 +185,8 @@ namespace Orchard.MediaProcessing.Services {
|
||||
// the storage provider may have altered the filepath
|
||||
filterContext.FilePath = newFile.GetPath();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Error(e, "A profile could not be processed: " + path);
|
||||
}
|
||||
}
|
||||
@@ -215,14 +214,14 @@ namespace Orchard.MediaProcessing.Services {
|
||||
try {
|
||||
var file = _storageProvider.GetFile(storagePath);
|
||||
return file.OpenRead();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Error(e, "path:" + path + " storagePath:" + storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
// http://blob.storage-provider.net/my-image.jpg
|
||||
Uri absoluteUri;
|
||||
if (Uri.TryCreate(path, UriKind.Absolute, out absoluteUri)) {
|
||||
if (Uri.TryCreate(path, UriKind.Absolute, out Uri absoluteUri)) {
|
||||
return new WebClient().OpenRead(absoluteUri);
|
||||
}
|
||||
|
||||
@@ -248,13 +247,12 @@ namespace Orchard.MediaProcessing.Services {
|
||||
}
|
||||
|
||||
private string FormatProfilePath(string profileName, string path) {
|
||||
|
||||
var filenameWithExtension = Path.GetFileName(path) ?? "";
|
||||
var fileLocation = path.Substring(0, path.Length - filenameWithExtension.Length);
|
||||
|
||||
return _storageProvider.Combine(
|
||||
_storageProvider.Combine(profileName.GetHashCode().ToString("x").ToLowerInvariant(), fileLocation.GetHashCode().ToString("x").ToLowerInvariant()),
|
||||
filenameWithExtension);
|
||||
_storageProvider.Combine(_profileService.GetNameHashCode(profileName), _profileService.GetNameHashCode(fileLocation)),
|
||||
filenameWithExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Logging;
|
||||
using Orchard.MediaProcessing.Models;
|
||||
|
||||
namespace Orchard.MediaProcessing.Services {
|
||||
public class ImageProfileService : IImageProfileService {
|
||||
public class ImageProfileService : Component, IImageProfileService {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly IRepository<FilterRecord> _filterRepository;
|
||||
private readonly ISignals _signals;
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
|
||||
public ImageProfileService(
|
||||
IContentManager contentManager,
|
||||
IContentManager contentManager,
|
||||
ICacheManager cacheManager,
|
||||
IRepository<FilterRecord> filterRepository,
|
||||
ISignals signals) {
|
||||
ISignals signals,
|
||||
IStorageProvider storageProvider) {
|
||||
_contentManager = contentManager;
|
||||
_cacheManager = cacheManager;
|
||||
_filterRepository = filterRepository;
|
||||
_signals = signals;
|
||||
_storageProvider = storageProvider;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ImageProfilePart GetImageProfile(int id) {
|
||||
return _contentManager.Get<ImageProfilePart>(id);
|
||||
}
|
||||
@@ -70,6 +73,7 @@ namespace Orchard.MediaProcessing.Services {
|
||||
var profile = _contentManager.Get(id);
|
||||
|
||||
if (profile != null) {
|
||||
DeleteImageProfileFolder(profile.As<ImageProfilePart>().Name);
|
||||
_contentManager.Remove(profile);
|
||||
}
|
||||
}
|
||||
@@ -115,5 +119,43 @@ namespace Orchard.MediaProcessing.Services {
|
||||
next.Position = filter.Position;
|
||||
filter.Position = temp;
|
||||
}
|
||||
|
||||
public bool PurgeImageProfile(int id) {
|
||||
var profile = GetImageProfile(id);
|
||||
try {
|
||||
DeleteImageProfileFolder(profile.Name);
|
||||
profile.FileNames.Clear();
|
||||
_signals.Trigger("MediaProcessing_Saved_" + profile.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to purge image profile '{0}'", profile.Name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PurgeObsoleteImageProfiles() {
|
||||
var profiles = GetAllImageProfiles();
|
||||
try {
|
||||
if (profiles != null) {
|
||||
var validPaths = profiles.Select(profile => _storageProvider.Combine("_Profiles", this.GetNameHashCode(profile.Name)));
|
||||
foreach (var folder in _storageProvider.ListFolders("_Profiles").Select(f => f.GetPath())) {
|
||||
if (!validPaths.Any(folder.StartsWith)) {
|
||||
_storageProvider.DeleteFolder(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to purge obsolete image profiles");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteImageProfileFolder(string profileName) {
|
||||
var folder = _storageProvider.Combine("_Profiles", this.GetNameHashCode(profileName));
|
||||
_storageProvider.DeleteFolder(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user