mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding Capture method to IOrchardViewPage
--HG-- branch : theming
This commit is contained in:
@@ -6,7 +6,8 @@ Model.Content.Zones.AddRenderPartial("primary:before", "CultureSelection", Model
|
||||
@Html.ValidationSummary()
|
||||
@Html.EditorForItem(m=>m.Content)
|
||||
}
|
||||
@using (Html.RenderFootContent() ) {
|
||||
|
||||
@using(Html.Capture(script => WorkContext.Page.Tail.Add(script) ){
|
||||
<script type="text/javascript">
|
||||
(function ($) {
|
||||
// grab the slug input
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentSubscriptionPartViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Messaging.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Messaging.ViewModels"%>
|
||||
<fieldset>
|
||||
<legend><%: T("Messaging")%></legend>
|
||||
<div>
|
||||
<label for="<%: Html.FieldIdFor(m => m.MessageSettings.DefaultChannelService)%>"><%: T("Default channel service for messages")%></label>
|
||||
<% if ( Model.ChannelServices.Any() ) { %>
|
||||
<select id="<%:Html.FieldIdFor(m => m.MessageSettings.DefaultChannelService) %>" name="<%:Html.FieldNameFor(m => m.MessageSettings.DefaultChannelService) %>">
|
||||
<% foreach ( var service in Model.ChannelServices ) {%>
|
||||
<option <%: Model.MessageSettings.DefaultChannelService == service ? "selected=\"selected\"" : "" %> value="<%: service %>"><%: service%></option>
|
||||
<% }
|
||||
}
|
||||
else {%>
|
||||
<span class="hint"><%: T("You must enable a messaging channel (e.g., Orchard.Email) before being able to send messages.") %></span>
|
||||
<% }%>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
@@ -0,0 +1,20 @@
|
||||
@model ContentSubscriptionPartViewModel
|
||||
@using Orchard.Core.Messaging.Models
|
||||
@using Orchard.Core.Messaging.ViewModels
|
||||
<fieldset>
|
||||
<legend>@T("Messaging")</legend>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.MessageSettings.DefaultChannelService)">@T("Default channel service for messages")</label>
|
||||
@if ( Model.ChannelServices.Any() ) {
|
||||
<select id="@Html.FieldIdFor(m => m.MessageSettings.DefaultChannelService)" name="@Html.FieldNameFor(m => m.MessageSettings.DefaultChannelService)">
|
||||
@foreach ( var service in Model.ChannelServices ) {
|
||||
<option @{ if(Model.MessageSettings.DefaultChannelService == service) { <text>selected="selected"</text> } } value="@service">@service</option>
|
||||
}
|
||||
}
|
||||
else {
|
||||
<span class="hint">@T("You must enable a messaging channel (e.g., Orchard.Email) before being able to send messages.")</span>
|
||||
}
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
@@ -255,7 +255,7 @@
|
||||
<None Include="Contents\Views\Admin\List.cshtml" />
|
||||
<None Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.cshtml" />
|
||||
<Content Include="Messaging\Module.txt" />
|
||||
<Content Include="Messaging\Views\EditorTemplates\Parts\Messaging.MessageSettings.ascx" />
|
||||
<None Include="Messaging\Views\EditorTemplates\Parts\Messaging.MessageSettings.cshtml" />
|
||||
<Content Include="PublishLater\Content\Admin\images\draft.gif" />
|
||||
<Content Include="PublishLater\Content\Admin\images\offline.gif" />
|
||||
<Content Include="PublishLater\Content\Admin\images\online.gif" />
|
||||
|
@@ -13,7 +13,7 @@
|
||||
</fieldset>
|
||||
|
||||
@Html.RegisterFootScript("jquery.slugify.js");
|
||||
@using(Html.RenderFootContent()){
|
||||
@using(Capture(script => WorkContext.Page.Tail.Add(script))){
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
//pull slug input from tab order
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
@@ -8,7 +9,6 @@ using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Collections;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Spooling;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Utility;
|
||||
@@ -18,23 +18,6 @@ using System.Web;
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class HtmlHelperExtensions {
|
||||
|
||||
private class FootContentRenderer : IDisposable {
|
||||
readonly dynamic _model;
|
||||
|
||||
public FootContentRenderer(HtmlHelper html) {
|
||||
_model = html.ViewDataContainer;
|
||||
_model.OutputStack.Push(new HtmlStringWriter());
|
||||
}
|
||||
public void Dispose() {
|
||||
var script = _model.OutputStack.Pop();
|
||||
_model.WorkContext.Page.Tail.Add(script);
|
||||
}
|
||||
}
|
||||
|
||||
public static IDisposable RenderFootContent(this HtmlHelper html) {
|
||||
return new FootContentRenderer(html);
|
||||
}
|
||||
|
||||
public static string NameOf<T>(this HtmlHelper<T> html, Expression<Action<T>> expression) {
|
||||
return Reflect.NameOf(html.ViewData.Model, expression);
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Web;
|
||||
using System;
|
||||
using System.Web;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
@@ -11,5 +12,6 @@ namespace Orchard.Mvc {
|
||||
dynamic Display { get; }
|
||||
IHtmlString DisplayChildren(object shape);
|
||||
WorkContext WorkContext { get; }
|
||||
IDisposable Capture(Action<IHtmlString> callback);
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
public dynamic Display { get { return _display; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
|
||||
|
||||
public dynamic New { get { return _new; } }
|
||||
public IDisplayHelperFactory DisplayHelperFactory { get; set; }
|
||||
public IShapeHelperFactory ShapeHelperFactory { get; set; }
|
||||
@@ -51,9 +50,27 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public IDisposable Capture(Action<IHtmlString> callback) {
|
||||
return new ViewContextSubstitution(this, callback);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class WebViewPage : WebViewPage<dynamic> {
|
||||
}
|
||||
|
||||
public class ViewContextSubstitution : IDisposable {
|
||||
public dynamic _viewPage;
|
||||
private readonly Action<IHtmlString> _callback;
|
||||
|
||||
public ViewContextSubstitution(dynamic viewPage, Action<IHtmlString> callback) {
|
||||
_viewPage = viewPage;
|
||||
_callback = callback;
|
||||
_viewPage.OutputStack.Push(new HtmlStringWriter());
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
var script = _viewPage.OutputStack.Pop().ToString();
|
||||
_callback(new HtmlString(script));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Mvc.Spooling;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
@@ -19,6 +18,7 @@ namespace Orchard.Mvc {
|
||||
public Localizer T { get { return _localizer; } }
|
||||
public dynamic Display { get { return _display; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
|
||||
public IDisplayHelperFactory DisplayHelperFactory { get; set; }
|
||||
|
||||
public IAuthorizer Authorizer { get; set; }
|
||||
@@ -49,6 +49,10 @@ namespace Orchard.Mvc {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public IDisposable Capture(Action<IHtmlString> callback) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ViewPage : ViewPage<dynamic> {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
@@ -18,6 +19,7 @@ namespace Orchard.Mvc {
|
||||
public dynamic Display { get { return _display; } }
|
||||
public dynamic New { get { return _new; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
|
||||
public IDisplayHelperFactory DisplayHelperFactory { get; set; }
|
||||
public IShapeHelperFactory ShapeHelperFactory { get; set; }
|
||||
|
||||
@@ -49,6 +51,11 @@ namespace Orchard.Mvc {
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
public IDisposable Capture(Action<IHtmlString> callback) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ViewUserControl : ViewUserControl<dynamic> {
|
||||
|
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Autofac;
|
||||
using System.Web;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI;
|
||||
|
||||
namespace Orchard {
|
||||
public abstract class WorkContext {
|
||||
|
Reference in New Issue
Block a user