mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-20 16:22:27 +00:00
* Initial work for user settings page * Finish user setting and slot setting pages * Don't show slot upload date on home page and fix team pick redirection * Fix upload image button alignment on mobile * Fix image upload on iPhone * Remove unused css and add selected button color * Fix login email check and bump ChromeDriver to 105 * Remove duplicated code and allow users to leave fields empty * Add unpublish button on level settings and move settings button position * Don't show edit button on mini card * Self review bug fixes and users can no longer use an in-use email
74 lines
No EOL
2.6 KiB
C#
74 lines
No EOL
2.6 KiB
C#
#nullable enable
|
|
using LBPUnion.ProjectLighthouse.Configuration;
|
|
using LBPUnion.ProjectLighthouse.Localization;
|
|
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
|
using LBPUnion.ProjectLighthouse.Types;
|
|
using Microsoft.AspNetCore.Localization;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
|
|
|
public class BaseLayout : PageModel
|
|
{
|
|
public readonly Database Database;
|
|
|
|
public readonly List<PageNavigationItem> NavigationItems = new();
|
|
|
|
public readonly List<PageNavigationItem> NavigationItemsRight = new();
|
|
public string Description = string.Empty;
|
|
|
|
public bool IsMobile;
|
|
|
|
public bool ShowTitleInPage = true;
|
|
|
|
public string Title = string.Empty;
|
|
|
|
private User? user;
|
|
public BaseLayout(Database database)
|
|
{
|
|
this.Database = database;
|
|
|
|
this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderUsers, "/users/0", "user friends"));
|
|
this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderPhotos, "/photos/0", "camera"));
|
|
this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderSlots, "/slots/0", "globe americas"));
|
|
}
|
|
|
|
public new User? User {
|
|
get {
|
|
if (this.user != null) return this.user;
|
|
|
|
return this.user = this.Database.UserFromWebRequest(this.Request);
|
|
}
|
|
set => this.user = value;
|
|
}
|
|
|
|
private string? language;
|
|
private string? timeZone;
|
|
|
|
public string GetLanguage()
|
|
{
|
|
if (ServerStatics.IsUnitTesting) return LocalizationManager.DefaultLang;
|
|
if (this.language != null) return this.language;
|
|
|
|
if (this.User != null) return this.language = this.User.Language;
|
|
|
|
IRequestCultureFeature? requestCulture = this.Request.HttpContext.Features.Get<IRequestCultureFeature>();
|
|
if (requestCulture == null) return this.language = LocalizationManager.DefaultLang;
|
|
|
|
return this.language = requestCulture.RequestCulture.UICulture.Name;
|
|
}
|
|
|
|
public string GetTimeZone()
|
|
{
|
|
if (ServerStatics.IsUnitTesting) return TimeZoneInfo.Local.Id;
|
|
if (this.timeZone != null) return this.timeZone;
|
|
|
|
string userTimeZone = this.User?.TimeZone ?? TimeZoneInfo.Local.Id;
|
|
|
|
return this.timeZone = userTimeZone;
|
|
}
|
|
|
|
public string Translate(TranslatableString translatableString) => translatableString.Translate(this.GetLanguage());
|
|
public string Translate(TranslatableString translatableString, params object?[] format) => translatableString.Translate(this.GetLanguage(), format);
|
|
} |