diff --git a/src/Orchard.Tests/Mvc/Html/HtmlHelperExtensionsTests.cs b/src/Orchard.Tests/Mvc/Html/HtmlHelperExtensionsTests.cs index a2e757f5e..2f4e857ce 100644 --- a/src/Orchard.Tests/Mvc/Html/HtmlHelperExtensionsTests.cs +++ b/src/Orchard.Tests/Mvc/Html/HtmlHelperExtensionsTests.cs @@ -142,7 +142,7 @@ namespace Orchard.Tests.Mvc.Html { var html = new HtmlHelper(viewContext, viewDataContainer.Object); //act - var result = html.UnorderedList((IEnumerable)null, (a, b) => "", "test"); + var result = html.UnorderedList((IEnumerable)null, (a, b) => MvcHtmlString.Create(""), "test"); //assert Assert.AreEqual(string.Empty, result.ToString()); @@ -156,7 +156,7 @@ namespace Orchard.Tests.Mvc.Html { var html = new HtmlHelper(viewContext, viewDataContainer.Object); //act - var result = html.UnorderedList(new string[]{}, (a, b) => "", "test"); + var result = html.UnorderedList(new string[] { }, (a, b) => MvcHtmlString.Create(""), "test"); //assert Assert.AreEqual(string.Empty, result.ToString()); diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx b/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx index 017a42921..027fa19ee 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx +++ b/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx @@ -4,6 +4,6 @@
<%: Html.ActionLink(T("Create new type").ToString(), "CreateType", null, new { @class = "button primaryAction" })%>
<%=Html.UnorderedList( Model.Types, - (t,i) => Html.DisplayFor(m => t).ToHtmlString(), + (t,i) => Html.DisplayFor(m => t), "contentItems" ) %> \ No newline at end of file diff --git a/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx b/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx index 8e5362596..8d8a70261 100644 --- a/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx +++ b/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx @@ -6,7 +6,7 @@

<%:T("Cultures this site supports") %>

<%: Html.UnorderedList( Model.SiteCultures.OrderBy(s => s), - (s, i) => Html.DisplayFor(scvm => s, s == Model.CurrentCulture ? "CurrentCulture" : "RemovableCulture", "").ToString(), + (s, i) => Html.DisplayFor(scvm => s, s == Model.CurrentCulture ? "CurrentCulture" : "RemovableCulture", ""), "site-cultures", "culture", "odd")%> <% using (Html.BeginFormAntiForgeryPost("AddCulture")) { %> <%:Html.ValidationSummary() %> diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/Archives.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/Archives.ascx index 603ba7a01..3e74c6b85 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/Archives.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/Archives.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" AutoEventWireup="true" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> <% Html.RegisterStyle("archives.css"); %> <% Html.RegisterFootScript("archives.js"); %>
@@ -23,13 +22,13 @@ <% } %> <% } else { %> - <%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)).ToString(), "archiveMonthList") %><% + <%: Html.UnorderedList(Model.Archives, (t, i) => Html.Link(string.Format("{0:MMMM yyyy} ({1})", t.Key.ToDateTime(), t.Value), Url.BlogArchiveMonth(Model.Blog.Slug, t.Key.Year, t.Key.Month)), "archiveMonthList") %><% } } else { %> diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/Blog/List.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/Blog/List.ascx index 144186f1e..b2d11d03b 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/Blog/List.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/Blog/List.ascx @@ -1,7 +1,7 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.ViewModels"%> <%if (Model.Blogs.Count() > 0) { %> -<%: Html.UnorderedList(Model.Blogs, (b, i) => Html.DisplayForItem(b).ToHtmlString(), "blogs contentItems") %><% +<%: Html.UnorderedList(Model.Blogs, (b, i) => Html.DisplayForItem(b), "blogs contentItems") %><% } else { %>

<%: T("No blogs found.") %>

<% diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogAdmin/List.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogAdmin/List.ascx index 4ae6ab255..1ee490df0 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogAdmin/List.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogAdmin/List.ascx @@ -20,7 +20,7 @@ if (Model.Entries.Count() > 0) { %> }); // Display the summary for the blog post - return Html.DisplayForItem(entry.ContentItemViewModel).ToHtmlString(); + return Html.DisplayForItem(entry.ContentItemViewModel); }, "blogs contentItems")%><% } else { %>
<%:T("There are no blogs for you to see. Want to add one?", Url.BlogCreate())%>
<% diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogPost/ListByArchive.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogPost/ListByArchive.ascx index 5f42b0f35..3f8fb486f 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogPost/ListByArchive.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/BlogPost/ListByArchive.ascx @@ -11,4 +11,4 @@ %>
-<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%> +<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c), "blogPosts contentItems")%> diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index ce21cbb85..3d3e3c0d0 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -1,5 +1,5 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>>" %> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %> +<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> <% if (Model.Count() < 1) { %>
<%: T("There are no posts for this blog.") %>
<% } %> diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx index 8a4c0425b..8c0184511 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx +++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx @@ -44,7 +44,7 @@

<%: T("Depends on:")%>

<%: Html.UnorderedList( feature.Descriptor.Dependencies.OrderBy(s => s), - (s, i) => Html.Link(s, string.Format("#{0}", s.AsFeatureId(n => T(n)))).ToString(), + (s, i) => Html.Link(s, string.Format("#{0}", s.AsFeatureId(n => T(n)))), "", "dependency", "") %> diff --git a/src/Orchard.Web/Modules/Orchard.Sandbox/Views/Page/Index.aspx b/src/Orchard.Web/Modules/Orchard.Sandbox/Views/Page/Index.aspx index be7c70f58..2ae6a2f86 100644 --- a/src/Orchard.Web/Modules/Orchard.Sandbox/Views/Page/Index.aspx +++ b/src/Orchard.Web/Modules/Orchard.Sandbox/Views/Page/Index.aspx @@ -2,4 +2,4 @@ <%@ Import Namespace="Orchard.Sandbox.ViewModels" %>

<%: Html.TitleForPage(T("Sandbox Pages").ToString()) %>

<%: Html.ActionLink(T("Add new page").ToString(), "create") %>

-<%: Html.UnorderedList(Model.Pages, (sp, i) => Html.DisplayForItem(sp).ToHtmlString(), "pages contentItems") %> +<%: Html.UnorderedList(Model.Pages, (sp, i) => Html.DisplayForItem(sp), "pages contentItems") %> diff --git a/src/Orchard.Web/Modules/Orchard.Search/Views/Search/Index.ascx b/src/Orchard.Web/Modules/Orchard.Search/Views/Search/Index.ascx index c6ead68da..1b252a887 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Views/Search/Index.ascx +++ b/src/Orchard.Web/Modules/Orchard.Search/Views/Search/Index.ascx @@ -12,6 +12,6 @@ if (!string.IsNullOrWhiteSpace(Model.Query)) { } } if (Model.PageOfResults != null && Model.PageOfResults.Count() > 0) { %> -<%=Html.UnorderedList(Model.PageOfResults, (r, i) => Html.DisplayForItem(r.Content).ToHtmlString() , "search-results contentItems") %> +<%=Html.UnorderedList(Model.PageOfResults, (r, i) => Html.DisplayForItem(r.Content) , "search-results contentItems") %> <%=Html.Pager(Model.PageOfResults, Model.PageOfResults.PageNumber, Model.DefaultPageSize, new {q = Model.Query}) %><% } %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Index.ascx b/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Index.ascx index c729dd648..9d7b9c512 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Index.ascx +++ b/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Index.ascx @@ -8,6 +8,6 @@ "Search", new { tagName = t.TagName }, new { @class = "" /* todo: (heskew) classify according to tag use */ } - ).ToHtmlString(), + ), "tagCloud") %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Search.ascx b/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Search.ascx index 69322cdc9..3c6d22cf0 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Search.ascx +++ b/src/Orchard.Web/Modules/Orchard.Tags/Views/Home/Search.ascx @@ -2,4 +2,4 @@ <%@ Import Namespace="Orchard.Tags.ViewModels"%> <% Html.AddTitleParts(T("Tags").ToString(), T("Contents tagged with {0}", Model.TagName).ToString()); %>

<%: T("Contents tagged with {0}", Html.Encode(Model.TagName)) %>

-<%: Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "taggedPosts contentItems") %> +<%: Html.UnorderedList(Model.Items, (c, i) => Html.DisplayForItem(c), "taggedPosts contentItems") %> diff --git a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index d3add1534..3924f0158 100644 --- a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -1,5 +1,5 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>>" %> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %> +<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> <% if (Model.Count() < 1) { %>

<%: T("There are no posts for this blog.") %>

<% } %> diff --git a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index d3add1534..3924f0158 100644 --- a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -1,5 +1,5 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>>" %> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %> +<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> <% if (Model.Count() < 1) { %>

<%: T("There are no posts for this blog.") %>

<% } %> diff --git a/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx b/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx index 5f42b0f35..3f8fb486f 100644 --- a/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx +++ b/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx @@ -11,4 +11,4 @@ %> -<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%> +<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c), "blogPosts contentItems")%> diff --git a/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index 89d7c5ba6..49c4749b7 100644 --- a/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Themes/Contoso/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -2,5 +2,5 @@ <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %> +<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> <% if (Model.Count() < 1) { %>

<%: T("There are no posts for this blog.") %>

<% } %> diff --git a/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx b/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx index 183b42a79..2270ca602 100644 --- a/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx +++ b/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx @@ -7,7 +7,7 @@ foreach (var comment in Model) { %>

<%: comment.Record.CommentText %>

-<%: Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })%> said <%: Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault()), "#")%> +<%: Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })%> said <%: Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).ToString(), "#")%>
<% } %> diff --git a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx index 5f42b0f35..3f8fb486f 100644 --- a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx +++ b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Items/Blogs.BlogPost.ListByArchive.ascx @@ -11,4 +11,4 @@ %> -<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c).ToHtmlString(), "blogPosts contentItems")%> +<%: Html.UnorderedList(Model.BlogPosts, (c, i) => Html.DisplayForItem(c), "blogPosts contentItems")%> diff --git a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index 89d7c5ba6..49c4749b7 100644 --- a/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Themes/Corporate/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -2,5 +2,5 @@ <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %> +<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> <% if (Model.Count() < 1) { %>

<%: T("There are no posts for this blog.") %>

<% } %> diff --git a/src/Orchard.Web/Themes/Green/Views/Archives.ascx b/src/Orchard.Web/Themes/Green/Views/Archives.ascx index d9c0a330f..6df1c6c67 100644 --- a/src/Orchard.Web/Themes/Green/Views/Archives.ascx +++ b/src/Orchard.Web/Themes/Green/Views/Archives.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" AutoEventWireup="true" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> <% Html.RegisterStyle("archives.css"); %> <% Html.RegisterFootScript("archives.js"); %>
diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs index a51b18493..92b4b0ea5 100644 --- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs +++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs @@ -121,15 +121,23 @@ namespace Orchard.Mvc.Html { #region UnorderedList - public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass) { + public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass) { return htmlHelper.UnorderedList(items, generateContent, cssClass, null, null); } - public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass, string itemCssClass, string alternatingItemCssClass) { + public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass, string itemCssClass, string alternatingItemCssClass) { + return UnorderedList(items, (t, i) => generateContent(t, i) as IHtmlString, cssClass, t => itemCssClass, t => alternatingItemCssClass); + } + + public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass) { + return htmlHelper.UnorderedList(items, generateContent, cssClass, null, null); + } + + public static IHtmlString UnorderedList(this HtmlHelper htmlHelper, IEnumerable items, Func generateContent, string cssClass, string itemCssClass, string alternatingItemCssClass) { return UnorderedList(items, generateContent, cssClass, t => itemCssClass, t => alternatingItemCssClass); } - private static IHtmlString UnorderedList(IEnumerable items, Func generateContent, string cssClass, Func generateItemCssClass, Func generateAlternatingItemCssClass) { + private static IHtmlString UnorderedList(IEnumerable items, Func generateContent, string cssClass, Func generateItemCssClass, Func generateAlternatingItemCssClass) { if (items == null || !items.Any()) return new HtmlString(string.Empty); var sb = new StringBuilder(250);