Skip to content

Commit

Permalink
Merge pull request #2 from OrchardCMS/dev
Browse files Browse the repository at this point in the history
Merge of orchardCore
  • Loading branch information
Tsjerno authored Aug 16, 2018
2 parents d80eb3f + 152c932 commit 3521303
Show file tree
Hide file tree
Showing 57 changed files with 663 additions and 196 deletions.
16 changes: 8 additions & 8 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageManagement Include="AspNet.Security.OpenIdConnect.Primitives" Version="2.0.0-rc3-final" />
<PackageManagement Include="Castle.Core" Version="4.3.1" />
<PackageManagement Include="Irony.Core" Version="1.0.7" />
<PackageManagement Include="Fluid.Core" Version="1.0.0-beta-9442" />
<PackageManagement Include="Jint" Version="3.0.0-beta-1210" />
<PackageManagement Include="Fluid.Core" Version="1.0.0-beta-9452" />
<PackageManagement Include="Jint" Version="3.0.0-beta-1247" />
<PackageManagement Include="Lucene.Net" Version="4.8.0-beta00005" />
<PackageManagement Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00005" />
<PackageManagement Include="Lucene.Net.QueryParser" Version="4.8.0-beta00005" />
Expand All @@ -39,12 +39,12 @@
<PackageManagement Include="xunit" Version="2.3.1" />
<PackageManagement Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageManagement Include="YamlDotNet" Version="5.0.1" />
<PackageManagement Include="YesSql.Abstractions" Version="2.0.0-beta-1215" />
<PackageManagement Include="YesSql.Core" Version="2.0.0-beta-1215" />
<PackageManagement Include="YesSql.Provider.MySql" Version="1.0.0-beta-1215" />
<PackageManagement Include="YesSql.Provider.PostgreSql" Version="1.0.0-beta-1215" />
<PackageManagement Include="YesSql.Provider.SqLite" Version="1.0.0-beta-1215" />
<PackageManagement Include="YesSql.Provider.SqlServer" Version="1.0.0-beta-1215" />
<PackageManagement Include="YesSql.Abstractions" Version="2.0.0-beta-1220" />
<PackageManagement Include="YesSql.Core" Version="2.0.0-beta-1220" />
<PackageManagement Include="YesSql.Provider.MySql" Version="1.0.0-beta-1220" />
<PackageManagement Include="YesSql.Provider.PostgreSql" Version="1.0.0-beta-1220" />
<PackageManagement Include="YesSql.Provider.SqLite" Version="1.0.0-beta-1220" />
<PackageManagement Include="YesSql.Provider.SqlServer" Version="1.0.0-beta-1220" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ namespace OrchardCore.ContentFields.Fields
{
public class NumericFieldDisplayDriver : ContentFieldDisplayDriver<NumericField>
{
private readonly CultureInfo _cultureInfo;

public NumericFieldDisplayDriver(IStringLocalizer<NumericFieldDisplayDriver> localizer)
{
T = localizer;

_cultureInfo = CultureInfo.InvariantCulture; // Todo: Get CurrentCulture from site settings
}

public IStringLocalizer T { get; set; }
Expand All @@ -42,7 +38,7 @@ public override IDisplayResult Edit(NumericField field, BuildFieldEditorContext
return Initialize<EditNumericFieldViewModel>("NumericField_Edit", model =>
{
var settings = context.PartFieldDefinition.Settings.ToObject<NumericFieldSettings>();
model.Value = context.IsNew ? settings.DefaultValue : Convert.ToString(field.Value, _cultureInfo);
model.Value = context.IsNew ? settings.DefaultValue : Convert.ToString(field.Value, CultureInfo.CurrentUICulture);

model.Field = field;
model.Part = context.ContentPart;
Expand Down Expand Up @@ -71,7 +67,7 @@ public override async Task<IDisplayResult> UpdateAsync(NumericField field, IUpda
updater.ModelState.AddModelError(Prefix, T["The {0} field is required.", context.PartFieldDefinition.DisplayName()]);
}
}
else if (!decimal.TryParse(viewModel.Value, NumberStyles.Any, _cultureInfo, out value))
else if (!decimal.TryParse(viewModel.Value, NumberStyles.Any, CultureInfo.CurrentUICulture, out value))
{
updater.ModelState.AddModelError(Prefix, T["{0} is an invalid number.", context.PartFieldDefinition.DisplayName()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="related">
@if (settings.Creatable)
{
<a asp-route-area="OrchardCore.Contents" asp-route-action="Create" asp-route-id="@Model.Name" class="btn btn-success btn-sm" role="button">@T["Create New {0}", Model.DisplayName]</a>
<a asp-route-area="OrchardCore.Contents" asp-route-action="Create" asp-route-id="@Model.Name" asp-route-returnUrl="@FullRequestPath" class="btn btn-success btn-sm" role="button">@T["Create New {0}", Model.DisplayName]</a>
}
<a asp-route-action="List" asp-route-area="OrchardCore.Contents" asp-route-id="@Model.Name" class="btn btn-secondary btn-sm" role="button">@T["List Items"]</a>
<a asp-route-action="Edit" asp-route-area="OrchardCore.ContentTypes" asp-route-id="@Model.Name" class="btn btn-primary btn-sm" role="button">@T["Edit"]</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ public async Task<IActionResult> Create(string id)

[HttpPost, ActionName("Create")]
[FormValueRequired("submit.Save")]
public Task<IActionResult> CreatePOST(string id, string returnUrl)
public Task<IActionResult> CreatePOST(string id, [Bind(Prefix = "submit.Save")] string submitSave, string returnUrl)
{
return CreatePOST(id, returnUrl, contentItem =>
var stayOnSamePage = submitSave == "submit.SaveAndContinue";
return CreatePOST(id, returnUrl, stayOnSamePage, contentItem =>
{
var typeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType);

Expand All @@ -331,17 +332,19 @@ public Task<IActionResult> CreatePOST(string id, string returnUrl)

[HttpPost, ActionName("Create")]
[FormValueRequired("submit.Publish")]
public async Task<IActionResult> CreateAndPublishPOST(string id, string returnUrl)
public async Task<IActionResult> CreateAndPublishPOST(string id, [Bind(Prefix = "submit.Publish")] string submitPublish, string returnUrl)
{
var stayOnSamePage = submitPublish == "submit.PublishAndContinue";
// pass a dummy content to the authorization check to check for "own" variations
var dummyContent = await _contentManager.NewAsync(id);


if (!await _authorizationService.AuthorizeAsync(User, Permissions.PublishContent, dummyContent))
{
return Unauthorized();
}

return await CreatePOST(id, returnUrl, async contentItem =>
return await CreatePOST(id, returnUrl, stayOnSamePage, async contentItem =>
{
await _contentManager.PublishAsync(contentItem);

Expand All @@ -353,7 +356,7 @@ public async Task<IActionResult> CreateAndPublishPOST(string id, string returnUr
});
}

private async Task<IActionResult> CreatePOST(string id, string returnUrl, Func<ContentItem, Task> conditionallyPublish)
private async Task<IActionResult> CreatePOST(string id, string returnUrl, bool stayOnSamePage, Func<ContentItem, Task> conditionallyPublish)
{
var contentItem = await _contentManager.NewAsync(id);

Expand All @@ -374,12 +377,18 @@ private async Task<IActionResult> CreatePOST(string id, string returnUrl, Func<C

await conditionallyPublish(contentItem);

if (!string.IsNullOrEmpty(returnUrl))
if ((!string.IsNullOrEmpty(returnUrl)) && (!stayOnSamePage))
{
return LocalRedirect(returnUrl);
}

var adminRouteValues = (await _contentManager.PopulateAspectAsync<ContentItemMetadata>(contentItem)).AdminRouteValues;

if (!string.IsNullOrEmpty(returnUrl))
{
adminRouteValues.Add("returnUrl", returnUrl);
}

return RedirectToRoute(adminRouteValues);
}

Expand Down Expand Up @@ -421,8 +430,13 @@ public async Task<IActionResult> Edit(string contentItemId)

[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Save")]
public Task<IActionResult> EditPOST(string contentItemId, string returnUrl)
{
public Task<IActionResult> EditPOST(string contentItemId, [Bind(Prefix = "submit.Save")] string submitSave, string returnUrl)
{
if (submitSave == "submit.SaveAndContinue")
{
returnUrl = Request.Path.Add(Request.QueryString);
}

return EditPOST(contentItemId, returnUrl, contentItem =>
{
var typeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType);
Expand All @@ -437,8 +451,9 @@ public Task<IActionResult> EditPOST(string contentItemId, string returnUrl)

[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Publish")]
public async Task<IActionResult> EditAndPublishPOST(string contentItemId, string returnUrl)
public async Task<IActionResult> EditAndPublishPOST(string contentItemId, [Bind(Prefix ="submit.Publish")] string submitPublish, string returnUrl)
{

var content = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);

if (content == null)
Expand All @@ -451,6 +466,12 @@ public async Task<IActionResult> EditAndPublishPOST(string contentItemId, string
return Unauthorized();
}

if (submitPublish == "submit.PublishAndContinue")
{
returnUrl = Request.Path.Add(Request.QueryString);
}


return await EditPOST(contentItemId, returnUrl, async contentItem =>
{
await _contentManager.PublishAsync(contentItem);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
@*@if (Authorizer.Authorize(Permissions.PublishContent, (IContent)Model.ContentItem)) {*@
<button type="submit" name="submit.Publish" class="publish-button btn btn-success" value="submit.Publish">@T["Publish"]</button>
@{
var returnUrl = Context.Request.Query["returnUrl"];
}
@if (String.IsNullOrWhiteSpace(returnUrl))
{
<button type="submit" name="submit.Publish" class="publish-button btn btn-success" value="submit.Publish">@T["Publish"]</button>
}
else
{
<div class="btn-group">
<button class="publish-button btn btn-success" type="submit" name="submit.Publish" value="submit.Publish">@T["Publish"]</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-reference="parent" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">@T["Toggle Dropdown"]</span>
</button>
<div class="dropdown-menu">
<button class="dropdown-item" type="submit" name="submit.Publish" value="submit.PublishAndContinue">@T["Publish And Continue"]</button>
</div>
</div>
}

@* } *@

Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
<button class="primaryAction btn btn-primary" type="submit" name="submit.Save" value="submit.Save">@T["Save Draft"]</button>
@{
var returnUrl = Context.Request.Query["returnUrl"];
}
@if (String.IsNullOrWhiteSpace(returnUrl))
{
<button class="primaryAction btn btn-primary" type="submit" name="submit.Save" value="submit.Save">@T["Save Draft"]</button>
}
else
{
<div class="btn-group">
<button class="btn btn-primary" type="submit" name="submit.Save" value="submit.Save">@T["Save Draft"]</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-reference="parent" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">@T["Toggle Dropdown"]</span>
</button>
<div class="dropdown-menu">
<button class="dropdown-item" type="submit" name="submit.Save" value="submit.SaveAndContinue">@T["Save Draft And Continue"]</button>
</div>
</div>
}
13 changes: 12 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Liquid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Gives access to the current site settings, e.g `Site.SiteName`.
| -------- | ------- |------------ |
| `BaseUrl` | | The base URL of the site |
| `Calendar` | | The site's calendar |
| `Culture` | `en-us` | The site's culture as an ISO language code |
| `Culture` | `en-us` | The site's default culture as an ISO language code |
| `MaxPagedCount` | `0` | The maximum number of pages that can be paged |
| `MaxPageSize` | `100` | The maximum page size that can be set by a user |
| `PageSize` | `10` | The default page size of lists |
Expand Down Expand Up @@ -254,6 +254,17 @@ The following properties are available on the `Request` object.
| `Scheme` | `https` | The scheme of the request |
| `Method` | `GET` | The HTTP method |

### Culture

Represents the current culture.

The following properties are available on the `Culture` object.

| Property | Example | Description |
| --------- | ---- |------------ |
| `Name` | `en-US` | The requests's culture as an ISO language code |
| `Dir` | `rtl` | The text writing directionality |

## Shape Filters

These filters let you create and filter shapes.
Expand Down
3 changes: 2 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Localization/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
Website = "http://orchardproject.net",
Version = "2.0.0",
Description = "Provides support for UI localization.",
Category = "Infrastructure"
Category = "Internationalization",
Dependencies = new[] { "OrchardCore.Settings" }
)]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
35 changes: 24 additions & 11 deletions src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OrchardCore.Modules;
using OrchardCore.Settings;

namespace OrchardCore.Localization
{
Expand All @@ -12,23 +13,35 @@ namespace OrchardCore.Localization
/// </summary>
public class Startup : StartupBase
{
public override void Configure(IApplicationBuilder app, IRouteBuilder routes, IServiceProvider serviceProvider)
public override void ConfigureServices(IServiceCollection services)
{
app.UseRequestLocalization(new RequestLocalizationOptions()
{
//TODO set supported cultures
});
services.AddPortableObjectLocalization(options => options.ResourcesPath = "Localization");

base.Configure(app, routes, serviceProvider);
// Override the default localization file locations with Orchard specific ones
services.Replace(ServiceDescriptor.Singleton<ILocalizationFileLocationProvider, ModularPoFileLocationProvider>());
}

public override void ConfigureServices(IServiceCollection services)
public override void Configure(IApplicationBuilder app, IRouteBuilder routes, IServiceProvider serviceProvider)
{
services.AddPortableObjectLocalization(options => options.ResourcesPath = "Localization");
var siteSettings = serviceProvider.GetService<ISiteService>().GetSiteSettingsAsync().GetAwaiter().GetResult();

// Override the default localization file locations with Orchard specific ones
services.Replace(
ServiceDescriptor.Singleton<ILocalizationFileLocationProvider, ModularPoFileLocationProvider>());
var options = new RequestLocalizationOptions();

// If no specific default culture is defined, use the system language by not calling SetDefaultCulture
if (!String.IsNullOrEmpty(siteSettings.Culture))
{
options.SetDefaultCulture(siteSettings.Culture);
}

if (siteSettings.SupportedCultures.Length > 0)
{
options
.AddSupportedCultures(siteSettings.SupportedCultures)
.AddSupportedUICultures(siteSettings.SupportedCultures)
;
}

app.UseRequestLocalization(options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ public async Task<IActionResult> Create(CreateOpenIdApplicationViewModel model,
Type = model.Type
};

if (model.AllowLogoutEndpoint)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
}
else
{
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.Endpoints.Logout);
}

if (model.AllowAuthorizationCodeFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode);
Expand Down Expand Up @@ -241,6 +250,7 @@ public async Task<IActionResult> Edit(string id, string returnUrl = null)
AllowImplicitFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Implicit),
AllowPasswordFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Password),
AllowRefreshTokenFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.RefreshToken),
AllowLogoutEndpoint = await HasPermissionAsync(OpenIddictConstants.Permissions.Endpoints.Logout),
ClientId = await _applicationManager.GetClientIdAsync(application),
ConsentType = await _applicationManager.GetConsentTypeAsync(application),
DisplayName = await _applicationManager.GetDisplayNameAsync(application),
Expand Down Expand Up @@ -339,6 +349,15 @@ await _applicationManager.GetIdAsync(application), StringComparison.Ordinal))
descriptor.ClientSecret = null;
}

if (model.AllowLogoutEndpoint)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
}
else
{
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.Endpoints.Logout);
}

if (model.AllowAuthorizationCodeFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public async Task ExecuteAsync(RecipeExecutionContext context)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization);
}
if (model.AllowRefreshTokenFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
}
if (model.AllowAuthorizationCodeFlow || model.AllowClientCredentialsFlow ||
model.AllowPasswordFlow || model.AllowRefreshTokenFlow)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CreateOpenIdApplicationViewModel
public bool AllowAuthorizationCodeFlow { get; set; }
public bool AllowRefreshTokenFlow { get; set; }
public bool AllowImplicitFlow { get; set; }
public bool AllowLogoutEndpoint { get; set; }

public class RoleEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class EditOpenIdApplicationViewModel
public bool AllowAuthorizationCodeFlow { get; set; }
public bool AllowRefreshTokenFlow { get; set; }
public bool AllowImplicitFlow { get; set; }
public bool AllowLogoutEndpoint { get; set; }

public class RoleEntry
{
Expand Down
Loading

0 comments on commit 3521303

Please sign in to comment.