mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
Added work context providers for the current site and user
--HG-- branch : theming
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<html lang="en" class="static @Html.ClassForPage()">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@Html.Title(Html.SiteName())</title>
|
||||
<title>@Html.Title(WorkContext.CurrentSite.SiteName)</title>
|
||||
@//could be a resource - at least need to get at the right location and this is something
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/modules/orchard.themes/Content/orchard.ico" />
|
||||
@{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@using Orchard.Mvc.Html
|
||||
<header>
|
||||
<h1>@Html.SiteName()</h1>
|
||||
<header>
|
||||
<h1>@WorkContext.CurrentSite.SiteName</h1>
|
||||
</header>
|
||||
@@ -1,10 +1,7 @@
|
||||
@using System.Web.Mvc
|
||||
@using Orchard.Security
|
||||
@{ var user = Html.Resolve<IAuthenticationService>().GetAuthenticatedUser(); }
|
||||
|
||||
<div id="user-display">
|
||||
@if (Request.IsAuthenticated) {
|
||||
@T("Welcome, <strong>{0}</strong>!", user.UserName)
|
||||
@T("Welcome, <strong>{0}</strong>!", WorkContext.CurrentUser.UserName)
|
||||
@Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl })
|
||||
@:| @Html.ActionLink("Admin", "Index", new {Area = "Dashboard", Controller = "Admin"})
|
||||
} else {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class SiteServiceExtensions {
|
||||
public static string SiteName(this HtmlHelper html) {
|
||||
return html.Resolve<ISiteService>().GetSiteSettings().SiteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,8 @@
|
||||
<Compile Include="Mvc\IOrchardViewPage.cs" />
|
||||
<Compile Include="Mvc\Spooling\HtmlStringWriter.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\Razor\RazorViewEngine.cs" />
|
||||
<Compile Include="Security\CurrentUserWorkContext.cs" />
|
||||
<Compile Include="Settings\CurrentSiteWorkContext.cs" />
|
||||
<Compile Include="UI\Zones\PageWorkContext.cs" />
|
||||
<Compile Include="UI\Zones\ZoneHoldingBehavior.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\ThemeAwareness\ConfiguredEnginesCache.cs" />
|
||||
@@ -676,7 +678,6 @@
|
||||
<Compile Include="Mvc\AntiForgery\AntiForgeryAuthorizationFilter.cs" />
|
||||
<Compile Include="Mvc\Html\FileRegistrationContext.cs" />
|
||||
<Compile Include="Mvc\Html\MvcFormAntiForgeryPost.cs" />
|
||||
<Compile Include="Mvc\Html\SiteServiceExtensions.cs" />
|
||||
<Compile Include="Tasks\Scheduling\IScheduledTaskHandler.cs" />
|
||||
<Compile Include="Tasks\Scheduling\IScheduledTaskManager.cs" />
|
||||
<Compile Include="Tasks\Scheduling\ScheduledTaskContext.cs" />
|
||||
|
||||
15
src/Orchard/Security/CurrentUserWorkContext.cs
Normal file
15
src/Orchard/Security/CurrentUserWorkContext.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Orchard.Security {
|
||||
public class CurrentUserWorkContext : IWorkContextStateProvider {
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
|
||||
public CurrentUserWorkContext(IAuthenticationService authenticationService) {
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
public T Get<T>(string name) {
|
||||
if (name == "CurrentUser")
|
||||
return (T)_authenticationService.GetAuthenticatedUser();
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/Orchard/Settings/CurrentSiteWorkContext.cs
Normal file
15
src/Orchard/Settings/CurrentSiteWorkContext.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Orchard.Settings {
|
||||
public class CurrentSiteWorkContext : IWorkContextStateProvider {
|
||||
private readonly ISiteService _siteService;
|
||||
|
||||
public CurrentSiteWorkContext(ISiteService siteService) {
|
||||
_siteService = siteService;
|
||||
}
|
||||
|
||||
public T Get<T>(string name) {
|
||||
if (name == "CurrentSite")
|
||||
return (T)_siteService.GetSiteSettings();
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user