Using DisplayText to render usernames

It could allow profile modules to override the displayed name for a user

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-09-20 16:27:00 -07:00
parent 1d7c254114
commit 164040f442
5 changed files with 5 additions and 4 deletions

View File

@@ -11,4 +11,4 @@
// owner isn't really who last modified this, is it?
IUser owner = commonPart.As<CommonPart>() == null ? null : commonPart.As<CommonPart>().Owner;
}
@T("By {0}", owner == null ? "<null>" : owner.UserName)
@T("By {0}", owner == null ? T("unknown").ToString() : Convert.ToString(Html.ItemDisplayText(owner)))

View File

@@ -3,7 +3,7 @@
<div class="user-display">
@if (WorkContext.CurrentUser != null) {
<span class="user-actions welcome">
@T("Welcome, <strong>{0}</strong>!", new HtmlString(Html.ActionLink( WorkContext.CurrentUser.UserName, "ChangePassword", new { Controller = "Account", Area = "Orchard.Users" }).ToString()))
@T("Welcome, <strong>{0}</strong>!", new HtmlString(Html.ActionLink( Convert.ToString(Html.ItemDisplayText(WorkContext.CurrentUser)), "ChangePassword", new { Controller = "Account", Area = "Orchard.Users" }).ToString()))
</span>
<span class="user-actions">
@Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" })

View File

@@ -55,7 +55,7 @@ using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, Fo
@Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "")
}
<h2 id="commenter">@if (WorkContext.CurrentUser != null) { @T("Hi, {0}!", WorkContext.CurrentUser.UserName)}</h2>
<h2 id="commenter">@if (WorkContext.CurrentUser != null) { @T("Hi, {0}!", Convert.ToString(Html.ItemDisplayText(WorkContext.CurrentUser)))}</h2>
<fieldset class="what">
<ol>
<li>

View File

@@ -17,6 +17,7 @@ namespace Orchard.Users.Handlers {
if (part != null) {
context.Metadata.Identity.Add("User.UserName", part.UserName);
context.Metadata.DisplayText = part.UserName;
}
}
}

View File

@@ -1,2 +1,2 @@
@model dynamic
@if (Model.CurrentUser != null) {<div id="login">@T("User:") @Model.CurrentUser.UserName | @Html.ActionLink(T("Logout").ToString(), "LogOff", new { Area = "Orchard.Users", Controller = "Account" })</div>}
@if (Model.CurrentUser != null) {<div id="login">@T("User:") @Convert.ToString(Html.ItemDisplayText((Orchard.ContentManagement.IContent)Model.CurrentUser)) | @Html.ActionLink(T("Logout").ToString(), "LogOff", new { Area = "Orchard.Users", Controller = "Account" })</div>}