-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Navbar shape for Liquid (#15532)
- Loading branch information
1 parent
bf0afdb
commit 980f322
Showing
11 changed files
with
125 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
src/OrchardCore.Modules/OrchardCore.Admin/Views/Navbar.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 3 additions & 31 deletions
34
...odules/OrchardCore.ContentLocalization/Drivers/ContentCulturePickerNavbarDisplayDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Localization; | ||
using OrchardCore.Admin.Models; | ||
using OrchardCore.ContentLocalization.ViewModels; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.Views; | ||
using OrchardCore.Localization; | ||
|
||
namespace OrchardCore.ContentLocalization.Drivers; | ||
|
||
public class ContentCulturePickerNavbarDisplayDriver : DisplayDriver<Navbar> | ||
{ | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
private readonly ILocalizationService _localizationService; | ||
|
||
public ContentCulturePickerNavbarDisplayDriver( | ||
IHttpContextAccessor httpContextAccessor, | ||
ILocalizationService localizationService) | ||
{ | ||
_httpContextAccessor = httpContextAccessor; | ||
_localizationService = localizationService; | ||
} | ||
|
||
public override async Task<IDisplayResult> DisplayAsync(Navbar model, BuildDisplayContext context) | ||
public override IDisplayResult Display(Navbar model) | ||
{ | ||
var supportedCultures = (await _localizationService.GetSupportedCulturesAsync()).Select(c => CultureInfo.GetCultureInfo(c)); | ||
|
||
return Initialize<CulturePickerViewModel>("ContentCulturePicker", model => | ||
{ | ||
model.SupportedCultures = supportedCultures; | ||
model.CurrentCulture = _httpContextAccessor | ||
.HttpContext | ||
.Features | ||
.Get<IRequestCultureFeature>()?.RequestCulture?.Culture ?? CultureInfo.CurrentUICulture; | ||
|
||
}).RenderWhen(() => Task.FromResult(supportedCultures.Count() > 1)) | ||
.Location("Detail", "Content:5"); | ||
return View("ContentCulturePicker", model) | ||
.Location("Detail", "Content:5"); | ||
} | ||
} |
21 changes: 19 additions & 2 deletions
21
src/OrchardCore.Modules/OrchardCore.ContentLocalization/Views/ContentCulturePicker.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters