mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Merge branch 'dev' of https://github.com/gcsuk/Orchard into use-nuget-instead-of-lib-folder
Conflicts: src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj
This commit is contained in:
commit
181ddd58b2
@ -41,6 +41,10 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
private bool IsActivable() {
|
||||
// don't activate if no HttpContext
|
||||
if (_workContext.HttpContext == null)
|
||||
return false;
|
||||
|
||||
// activate on front-end only
|
||||
if (AdminFilter.IsApplied(new RequestContext(_workContext.HttpContext, new RouteData())))
|
||||
return false;
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class ButtonElementDriver : FormsElementDriver<Button> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public ButtonElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public ButtonElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(Button element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedText = _tokenizer.Replace(element.Text, context.GetTokenData());
|
||||
context.ElementShape.ProcessedText = _tokenizer.Replace(element.Text, context.GetTokenData(), new ReplaceOptions {Encoding = ReplaceOptions.NoEncode});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -10,8 +10,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class CheckboxElementDriver : FormsElementDriver<CheckBox> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public CheckboxElementDriver(IFormManager formManager, ITokenizer tokenizer)
|
||||
: base(formManager) {
|
||||
public CheckboxElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer)
|
||||
: base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -67,8 +67,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(CheckBox element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.Value, context.GetTokenData());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,11 +4,12 @@ using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Services;
|
||||
|
||||
namespace Orchard.DynamicForms.Drivers {
|
||||
public class CommonFormElementDriver : FormsElementDriver<FormElement> {
|
||||
|
||||
public CommonFormElementDriver(IFormManager formManager, IShapeFactory shapeFactory) : base(formManager) {
|
||||
public CommonFormElementDriver(IFormsBasedElementServices formsServices, IShapeFactory shapeFactory) : base(formsServices) {
|
||||
New = shapeFactory;
|
||||
}
|
||||
|
||||
@ -44,7 +45,6 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
protected override void OnDisplaying(FormElement element, ElementDisplayingContext context) {
|
||||
context.ElementShape.Metadata.Wrappers.Add("FormElement_Wrapper");
|
||||
context.ElementShape.Child.Add(New.PlaceChildContent(Source: context.ElementShape));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class EmailFieldElementDriver : FormsElementDriver<EmailField>{
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public EmailFieldElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public EmailFieldElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(EmailField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,18 +3,18 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.DynamicForms.Helpers;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
namespace Orchard.DynamicForms.Drivers {
|
||||
public class EnumerationElementDriver : FormsElementDriver<Enumeration> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
public EnumerationElementDriver(IFormManager formManager, ITokenizer tokenizer)
|
||||
: base(formManager) {
|
||||
public EnumerationElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer)
|
||||
: base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
var tokenData = context.GetTokenData();
|
||||
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData);
|
||||
context.ElementShape.ProcessedOptions = _tokenizer.Replace(element.Options, tokenData).ToArray();
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedOptions = _tokenizer.Replace(element.Options, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode }).ToArray();
|
||||
context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType));
|
||||
context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Fieldset element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedLegend = _tokenizer.Replace(element.Legend, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLegend = _tokenizer.Replace(element.Legend, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.DynamicForms.Helpers;
|
||||
using Orchard.DynamicForms.Services;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
@ -24,14 +23,14 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public FormElementDriver(
|
||||
IFormManager formManager,
|
||||
IFormsBasedElementServices formsServices,
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IFormService formService,
|
||||
ICurrentControllerAccessor currentControllerAccessor,
|
||||
ICultureAccessor cultureAccessor,
|
||||
ITokenizer tokenizer)
|
||||
|
||||
: base(formManager) {
|
||||
: base(formsServices) {
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_formService = formService;
|
||||
_currentControllerAccessor = currentControllerAccessor;
|
||||
|
@ -1,16 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
namespace Orchard.DynamicForms.Drivers {
|
||||
public class HiddenFieldElementDriver : FormsElementDriver<HiddenField> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
public HiddenFieldElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public HiddenFieldElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(HiddenField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.Value, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class LabelElementDriver : FormsElementDriver<Label> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public LabelElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public LabelElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
}
|
||||
|
||||
protected override void OnDisplaying(Label element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedText = _tokenizer.Replace(element.Text, context.GetTokenData());
|
||||
context.ElementShape.ProcessedText = _tokenizer.Replace(element.Text, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedFor = _tokenizer.Replace(element.For, context.GetTokenData());
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class PasswordFieldElementDriver : FormsElementDriver<PasswordField>{
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public PasswordFieldElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public PasswordFieldElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(PasswordField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
}
|
||||
}
|
||||
}
|
@ -6,16 +6,14 @@ using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.DynamicForms.Helpers;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Projections.Models;
|
||||
using Orchard.Projections.Services;
|
||||
using Orchard.Tokens;
|
||||
using Orchard.Utility.Extensions;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
namespace Orchard.DynamicForms.Drivers {
|
||||
@ -25,8 +23,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public QueryElementDriver(IFormManager formManager, IProjectionManager projectionManager, IContentManager contentManager, ITokenizer tokenizer)
|
||||
: base(formManager) {
|
||||
public QueryElementDriver(IFormsBasedElementServices formsServices, IProjectionManager projectionManager, IContentManager contentManager, ITokenizer tokenizer)
|
||||
: base(formsServices) {
|
||||
_projectionManager = projectionManager;
|
||||
_contentManager = contentManager;
|
||||
_tokenizer = tokenizer;
|
||||
@ -149,7 +147,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
foreach (var contentItem in contentItems) {
|
||||
var data = new {Content = contentItem};
|
||||
var value = _tokenizer.Replace(valueExpression, data);
|
||||
var text = _tokenizer.Replace(textExpression, data);
|
||||
var text = _tokenizer.Replace(textExpression, data, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
|
||||
yield return new SelectListItem {
|
||||
Text = text,
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -11,8 +11,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class RadioButtonElementDriver : FormsElementDriver<RadioButton> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public RadioButtonElementDriver(IFormManager formManager, ITokenizer tokenizer)
|
||||
: base(formManager) {
|
||||
public RadioButtonElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer)
|
||||
: base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(RadioButton element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.Value, context.GetTokenData());
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
private readonly IOrchardServices _services;
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public ReCaptchaElementDriver(IFormManager formManager, IOrchardServices services, ITokenizer tokenizer) : base(formManager) {
|
||||
public ReCaptchaElementDriver(IFormsBasedElementServices formsServices, IOrchardServices services, ITokenizer tokenizer) : base(formsServices) {
|
||||
_services = services;
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Taxonomies.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
@ -19,8 +19,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
private readonly ITaxonomyService _taxonomyService;
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public TaxonomyElementDriver(IFormManager formManager, ITaxonomyService taxonomyService, ITokenizer tokenizer)
|
||||
: base(formManager) {
|
||||
public TaxonomyElementDriver(IFormsBasedElementServices formsServices, ITaxonomyService taxonomyService, ITokenizer tokenizer)
|
||||
: base(formsServices) {
|
||||
_taxonomyService = taxonomyService;
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
@ -127,7 +127,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
var tokenData = context.GetTokenData();
|
||||
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData);
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, tokenData, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.TermOptions = GetTermOptions(element, context.DisplayType, taxonomyId, tokenData).ToArray();
|
||||
context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}__{1}", typeName, element.InputType));
|
||||
context.ElementShape.Metadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, element.InputType));
|
||||
|
@ -1,16 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
namespace Orchard.DynamicForms.Drivers {
|
||||
public class TextAreaElementDriver : FormsElementDriver<TextArea> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
public TextAreaElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public TextAreaElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -90,8 +89,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(TextArea element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class TextFieldElementDriver : FormsElementDriver<TextField>{
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public TextFieldElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public TextFieldElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(TextField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions {Encoding = ReplaceOptions.NoEncode});
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class UrlFieldElementDriver : FormsElementDriver<UrlField> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public UrlFieldElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public UrlFieldElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
|
||||
protected override void OnDisplaying(UrlField element, ElementDisplayingContext context) {
|
||||
context.ElementShape.ProcessedName = _tokenizer.Replace(element.Name, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData());
|
||||
context.ElementShape.ProcessedValue = _tokenizer.Replace(element.RuntimeValue, context.GetTokenData());
|
||||
context.ElementShape.ProcessedLabel = _tokenizer.Replace(element.Label, context.GetTokenData(), new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
|
||||
context.ElementShape.ProcessedValue = element.RuntimeValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DynamicForms.Elements;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Tokens;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Orchard.DynamicForms.Drivers {
|
||||
public class ValidationMessageElementDriver : FormsElementDriver<ValidationMessage> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public ValidationMessageElementDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
|
||||
public ValidationMessageElementDriver(IFormsBasedElementServices formsServices, ITokenizer tokenizer) : base(formsServices) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ using Orchard.Tokens;
|
||||
|
||||
namespace Orchard.DynamicForms.Helpers {
|
||||
public static class TokenizerExtensions {
|
||||
public static IEnumerable<SelectListItem> Replace(this ITokenizer tokenizer, IEnumerable<SelectListItem> items, IDictionary<string, object> data) {
|
||||
public static IEnumerable<SelectListItem> Replace(this ITokenizer tokenizer, IEnumerable<SelectListItem> items, IDictionary<string, object> data, ReplaceOptions options) {
|
||||
return items.Select(item => new SelectListItem {
|
||||
Text = tokenizer.Replace(item.Text, data),
|
||||
Text = tokenizer.Replace(item.Text, data, options),
|
||||
Value = item.Value,
|
||||
Disabled = item.Disabled,
|
||||
Group = item.Group,
|
||||
|
@ -219,7 +219,9 @@
|
||||
<Compile Include="Handlers\WorkflowValidatorCoordinator.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Services\FieldsetModelMap.cs" />
|
||||
<Compile Include="Services\FormElementServices.cs" />
|
||||
<Compile Include="Services\FormModelMap.cs" />
|
||||
<Compile Include="Services\IFormElementServices.cs" />
|
||||
<Compile Include="Services\Models\FormSubmissionTokenContext.cs" />
|
||||
<Compile Include="Handlers\ValidatorsCoordinator.cs" />
|
||||
<Compile Include="Handlers\FormSubmissionCoordinator.cs" />
|
||||
|
@ -0,0 +1,14 @@
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Localization.Services;
|
||||
|
||||
namespace Orchard.DynamicForms.Services {
|
||||
public class FormElementServices : IFormElementServices {
|
||||
public FormElementServices(IFormManager formManager, ICultureManager cultureManager) {
|
||||
FormManager = formManager;
|
||||
CultureManager = cultureManager;
|
||||
}
|
||||
|
||||
public IFormManager FormManager { get; private set; }
|
||||
public ICultureManager CultureManager { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Localization.Services;
|
||||
|
||||
namespace Orchard.DynamicForms.Services {
|
||||
public interface IFormElementServices : IDependency
|
||||
{
|
||||
IFormManager FormManager { get; }
|
||||
ICultureManager CultureManager { get; }
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ using Orchard.Projections.ViewModels;
|
||||
using Orchard.Tokens;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
using DescribeContext = Orchard.Forms.Services.DescribeContext;
|
||||
|
||||
namespace Orchard.Layouts.Drivers {
|
||||
@ -32,13 +33,13 @@ namespace Orchard.Layouts.Drivers {
|
||||
private readonly IDisplayHelperFactory _displayHelperFactory;
|
||||
|
||||
public ProjectionElementDriver(
|
||||
IFormManager formManager,
|
||||
IFormsBasedElementServices formsServices,
|
||||
IProjectionManager projectionManager,
|
||||
IOrchardServices services,
|
||||
IRepository<LayoutRecord> layoutRepository,
|
||||
ITokenizer tokenizer,
|
||||
IDisplayHelperFactory displayHelperFactory)
|
||||
: base(formManager) {
|
||||
: base(formsServices) {
|
||||
|
||||
_projectionManager = projectionManager;
|
||||
_contentManager = services.ContentManager;
|
||||
|
@ -5,13 +5,14 @@ using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
using Orchard.Layouts.Services;
|
||||
|
||||
namespace Orchard.Layouts.Drivers {
|
||||
public class ShapeElementDriver : FormsElementDriver<Shape> {
|
||||
private readonly IShapeFactory _shapeFactory;
|
||||
|
||||
public ShapeElementDriver(IFormManager formManager, IShapeFactory shapeFactory)
|
||||
: base(formManager) {
|
||||
public ShapeElementDriver(IFormsBasedElementServices formsServices, IShapeFactory shapeFactory)
|
||||
: base(formsServices) {
|
||||
_shapeFactory = shapeFactory;
|
||||
}
|
||||
|
||||
|
@ -3,18 +3,34 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Forms.Services;
|
||||
using Orchard.Layouts.Framework.Elements;
|
||||
using Orchard.Layouts.Helpers;
|
||||
using Orchard.Layouts.Services;
|
||||
|
||||
namespace Orchard.Layouts.Framework.Drivers {
|
||||
public abstract class FormsElementDriver<TElement> : ElementDriver<TElement>, IFormProvider where TElement : Element {
|
||||
private readonly IFormManager _formManager;
|
||||
private readonly ICultureAccessor _cultureAccessor;
|
||||
|
||||
protected FormsElementDriver(IFormManager formManager) {
|
||||
_formManager = formManager;
|
||||
protected FormsElementDriver(IFormsBasedElementServices formsServices) {
|
||||
_formManager = formsServices.FormManager;
|
||||
_cultureAccessor = formsServices.CultureAccessor;
|
||||
}
|
||||
|
||||
protected dynamic BuildForm(ElementEditorContext context, string formName, string position = null) {
|
||||
// TODO: Fix Forms API so that it works with prefixes. Right now only binding implements prefix, but building a form ignores the specified prefix.
|
||||
var form = _formManager.Bind(_formManager.Build(formName), context.ValueProvider);
|
||||
|
||||
// If not a post-back, we need to bind the form with the element's data values. Otherwise, bind the form with the posted values.
|
||||
var valueProvider = context.Updater == null
|
||||
? context.Element.Data.ToValueProvider(_cultureAccessor.CurrentCulture)
|
||||
: context.ValueProvider;
|
||||
|
||||
var form = _formManager.Bind(_formManager.Build(formName), valueProvider);
|
||||
|
||||
if (context.Updater != null) {
|
||||
// Update the element's data dictionary with the posted values.
|
||||
Action<object> process = s => UpdateElementProperty(s, context);
|
||||
FormNodesProcessor.ProcessForm(form, process);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(position)) {
|
||||
form.Metadata.Position = position;
|
||||
@ -34,11 +50,37 @@ namespace Orchard.Layouts.Framework.Drivers {
|
||||
|
||||
protected dynamic BuildForms(ElementEditorContext context) {
|
||||
// TODO: Fix Forms API so that it works with prefixes. Right now only binding implements prefix, but building a form ignores the specified prefix.
|
||||
var forms = FormNames.Reverse().Select(x => _formManager.Bind(_formManager.Build(x), context.ValueProvider)).ToArray();
|
||||
|
||||
// If not a post-back, we need to bind the form with the element's data values. Otherwise, bind the form with the posted values.
|
||||
var valueProvider = context.Updater == null
|
||||
? context.Element.Data.ToValueProvider(_cultureAccessor.CurrentCulture)
|
||||
: context.ValueProvider;
|
||||
|
||||
var forms = FormNames.Reverse().Select(x => {
|
||||
var shape = _formManager.Bind(_formManager.Build(x), valueProvider);
|
||||
|
||||
if (context.Updater != null) {
|
||||
// Update the element's data dictionary with the posted values.
|
||||
Action<object> process = s => UpdateElementProperty(s, context);
|
||||
FormNodesProcessor.ProcessForm(shape, process);
|
||||
}
|
||||
|
||||
return shape;
|
||||
}).ToArray();
|
||||
var formShape = context.ShapeFactory.ElementEditor__Forms(Forms: forms);
|
||||
return formShape;
|
||||
}
|
||||
|
||||
private void UpdateElementProperty(dynamic formElementShape, ElementEditorContext context) {
|
||||
var name = (string)formElementShape.Name;
|
||||
if (name != null) {
|
||||
var value = context.ValueProvider.GetValue(context.Prefix + name);
|
||||
if (value != null) {
|
||||
context.Element.Data[name] = value.AttemptedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Describe(DescribeContext context) {
|
||||
DescribeForm(context);
|
||||
}
|
||||
|
@ -355,12 +355,14 @@
|
||||
<Compile Include="Helpers\SnippetHtmlExtensions.cs" />
|
||||
<Compile Include="Helpers\StringHelper.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Services\FormElementServices.cs" />
|
||||
<Compile Include="Services\ICurrentThemeShapeBindingResolver.cs" />
|
||||
<Compile Include="Services\CurrentThemeShapeBindingResolver.cs" />
|
||||
<Compile Include="Providers\PlaceableContentElementHarvester.cs" />
|
||||
<Compile Include="Elements\RecycleBin.cs" />
|
||||
<Compile Include="Models\SnippetDescriptor.cs" />
|
||||
<Compile Include="Models\SnippetFieldDescriptor.cs" />
|
||||
<Compile Include="Services\IFormElementServices.cs" />
|
||||
<Compile Include="ViewModels\SnippetViewModel.cs" />
|
||||
<Compile Include="ViewModels\SnippetFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\PlaceableContentItemViewModel.cs" />
|
||||
|
@ -0,0 +1,13 @@
|
||||
using Orchard.Forms.Services;
|
||||
|
||||
namespace Orchard.Layouts.Services {
|
||||
public class FormsBasedElementServices : IFormsBasedElementServices {
|
||||
public FormsBasedElementServices(IFormManager formManager, ICultureAccessor cultureAccessor) {
|
||||
FormManager = formManager;
|
||||
CultureAccessor = cultureAccessor;
|
||||
}
|
||||
|
||||
public IFormManager FormManager { get; private set; }
|
||||
public ICultureAccessor CultureAccessor { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using Orchard.Forms.Services;
|
||||
|
||||
namespace Orchard.Layouts.Services {
|
||||
public interface IFormsBasedElementServices : IDependency
|
||||
{
|
||||
IFormManager FormManager { get; }
|
||||
ICultureAccessor CultureAccessor { get; }
|
||||
}
|
||||
}
|
@ -14,8 +14,9 @@ namespace Orchard.MediaProcessing.Handlers {
|
||||
}
|
||||
|
||||
protected override void Published(PublishContentContext context) {
|
||||
_signals.Trigger("MediaProcessing_Published_" + context.ContentItem.As<ImageProfilePart>().Name);
|
||||
if (context.ContentItem.Has<ImageProfilePart>())
|
||||
_signals.Trigger("MediaProcessing_Published_" + context.ContentItem.As<ImageProfilePart>().Name);
|
||||
base.Published(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ namespace Orchard.MediaProcessing.Services {
|
||||
string GetImageProfileUrl(string path, string profileName, ContentItem contentItem);
|
||||
string GetImageProfileUrl(string path, string profileName, FilterRecord customFilter);
|
||||
string GetImageProfileUrl(string path, string profileName, FilterRecord customFilter, ContentItem contentItem);
|
||||
string GetImageProfileUrl(string path, string profileName, ContentItem contentItem, params FilterRecord[] customFilters);
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public string GetImageProfileUrl(string path, string profileName) {
|
||||
return GetImageProfileUrl(path, profileName, null, null);
|
||||
public string GetImageProfileUrl(string path, string profileName) {
|
||||
return GetImageProfileUrl(path, profileName, null, new FilterRecord[] { });
|
||||
}
|
||||
|
||||
public string GetImageProfileUrl(string path, string profileName, ContentItem contentItem) {
|
||||
@ -57,6 +57,10 @@ namespace Orchard.MediaProcessing.Services {
|
||||
}
|
||||
|
||||
public string GetImageProfileUrl(string path, string profileName, FilterRecord customFilter, ContentItem contentItem) {
|
||||
return GetImageProfileUrl(path, profileName, contentItem, customFilter);
|
||||
}
|
||||
|
||||
public string GetImageProfileUrl(string path, string profileName, ContentItem contentItem, params FilterRecord[] customFilters) {
|
||||
|
||||
// path is the publicUrl of the media, so it might contain url-encoded chars
|
||||
|
||||
@ -108,7 +112,7 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
ImageProfilePart profilePart;
|
||||
|
||||
if (customFilter == null) {
|
||||
if (customFilters == null || !customFilters.Any()) {
|
||||
profilePart = _profileService.GetImageProfileByName(profileName);
|
||||
if (profilePart == null)
|
||||
return String.Empty;
|
||||
@ -116,7 +120,9 @@ namespace Orchard.MediaProcessing.Services {
|
||||
else {
|
||||
profilePart = _services.ContentManager.New<ImageProfilePart>("ImageProfile");
|
||||
profilePart.Name = profileName;
|
||||
profilePart.Filters.Add(customFilter);
|
||||
foreach (var customFilter in customFilters) {
|
||||
profilePart.Filters.Add(customFilter);
|
||||
}
|
||||
}
|
||||
|
||||
// prevent two requests from processing the same file at the same time
|
||||
|
@ -35,6 +35,8 @@ namespace Orchard.Themes.Controllers {
|
||||
private readonly IThemeService _themeService;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
|
||||
private const string AlreadyEnabledFeatures = "Orchard.Themes.AlreadyEnabledFeatures";
|
||||
|
||||
public AdminController(
|
||||
IEnumerable<IExtensionDisplayEventHandler> extensionDisplayEventHandlers,
|
||||
IOrchardServices services,
|
||||
@ -132,8 +134,11 @@ namespace Orchard.Themes.Controllers {
|
||||
|
||||
Services.Notifier.Error(T("Theme {0} was not found", themeId));
|
||||
} else {
|
||||
var alreadyEnabledFeatures = GetEnabledFeatures();
|
||||
_themeService.EnableThemeFeatures(themeId);
|
||||
_previewTheme.SetPreviewTheme(themeId);
|
||||
alreadyEnabledFeatures.Except(new[] { themeId });
|
||||
TempData[AlreadyEnabledFeatures] = alreadyEnabledFeatures;
|
||||
}
|
||||
|
||||
return this.RedirectLocal(returnUrl, "~/");
|
||||
@ -161,6 +166,18 @@ namespace Orchard.Themes.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (TempData.ContainsKey(AlreadyEnabledFeatures)) {
|
||||
|
||||
var alreadyEnabledFeatures = TempData[AlreadyEnabledFeatures] as IEnumerable<string>;
|
||||
if (alreadyEnabledFeatures != null) {
|
||||
var afterEnabledFeatures = GetEnabledFeatures();
|
||||
if (afterEnabledFeatures.Count() > alreadyEnabledFeatures.Count()) {
|
||||
var disableFeatures = afterEnabledFeatures.Except(alreadyEnabledFeatures);
|
||||
_themeService.DisablePreviewFeatures(disableFeatures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_previewTheme.SetPreviewTheme(null);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
@ -252,5 +269,9 @@ namespace Orchard.Themes.Controllers {
|
||||
return string.IsNullOrEmpty(value);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetEnabledFeatures() {
|
||||
return _featureManager.GetEnabledFeatures().Select(f => f.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Themes.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Themes.Events {
|
||||
public class ThemeDisableEventHandler : IFeatureEventHandler {
|
||||
private readonly IFeatureManager _featureManager;
|
||||
private readonly ISiteThemeService _siteThemeService;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public ThemeDisableEventHandler(
|
||||
IFeatureManager featureManager,
|
||||
ISiteThemeService siteThemeService,
|
||||
INotifier notifier) {
|
||||
_featureManager = featureManager;
|
||||
_siteThemeService = siteThemeService;
|
||||
_notifier = notifier;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void Installing(Feature feature) {
|
||||
}
|
||||
|
||||
public void Installed(Feature feature) {
|
||||
}
|
||||
|
||||
public void Enabling(Feature feature) {
|
||||
}
|
||||
|
||||
public void Enabled(Feature feature) {
|
||||
}
|
||||
|
||||
public void Disabling(Feature feature) {
|
||||
}
|
||||
|
||||
public void Disabled(Feature feature) {
|
||||
var currentTheme = _siteThemeService.GetCurrentThemeName();
|
||||
if (feature.Descriptor.Name == currentTheme) {
|
||||
_siteThemeService.SetSiteTheme(null);
|
||||
|
||||
// Notifications don't work in feature events. See: https://github.com/OrchardCMS/Orchard/issues/6106
|
||||
_notifier.Warning(T("The current theme was disabled, because one of its dependencies was disabled."));
|
||||
}
|
||||
}
|
||||
|
||||
public void Uninstalling(Feature feature) {
|
||||
}
|
||||
|
||||
public void Uninstalled(Feature feature) {
|
||||
}
|
||||
}
|
||||
}
|
@ -92,6 +92,7 @@
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Commands\ThemeCommands.cs" />
|
||||
<Compile Include="Drivers\DisableThemePartDriver.cs" />
|
||||
<Compile Include="Events\ThemeDisableEventHandler.cs" />
|
||||
<Compile Include="Events\IExtensionDisplayEventHandler.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Models\ThemeEntry.cs" />
|
||||
|
@ -1,9 +1,11 @@
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Themes.Services {
|
||||
public interface IThemeService : IDependency {
|
||||
void DisableThemeFeatures(string themeName);
|
||||
void EnableThemeFeatures(string themeName);
|
||||
bool IsRecentlyInstalled(ExtensionDescriptor module);
|
||||
void DisablePreviewFeatures(IEnumerable<string> features);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ namespace Orchard.Themes.Services {
|
||||
private readonly IEnumerable<IThemeSelector> _themeSelectors;
|
||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly ISiteThemeService _siteThemeService;
|
||||
|
||||
public ThemeService(
|
||||
IOrchardServices orchardServices,
|
||||
@ -25,7 +26,8 @@ namespace Orchard.Themes.Services {
|
||||
IFeatureManager featureManager,
|
||||
IEnumerable<IThemeSelector> themeSelectors,
|
||||
IVirtualPathProvider virtualPathProvider,
|
||||
ICacheManager cacheManager) {
|
||||
ICacheManager cacheManager,
|
||||
ISiteThemeService siteThemeService) {
|
||||
|
||||
Services = orchardServices;
|
||||
|
||||
@ -34,6 +36,7 @@ namespace Orchard.Themes.Services {
|
||||
_themeSelectors = themeSelectors;
|
||||
_virtualPathProvider = virtualPathProvider;
|
||||
_cacheManager = cacheManager;
|
||||
_siteThemeService = siteThemeService;
|
||||
|
||||
if (_featureManager.FeatureDependencyNotification == null) {
|
||||
_featureManager.FeatureDependencyNotification = GenerateWarning;
|
||||
@ -62,8 +65,16 @@ namespace Orchard.Themes.Services {
|
||||
: null;
|
||||
}
|
||||
|
||||
while (themes.Count > 0)
|
||||
_featureManager.DisableFeatures(new[] { themes.Dequeue() });
|
||||
var currentTheme = _siteThemeService.GetCurrentThemeName();
|
||||
|
||||
while (themes.Count > 0) {
|
||||
var themeId = themes.Dequeue();
|
||||
|
||||
// Not disabling base theme if it's the current theme.
|
||||
if (themeId != currentTheme) {
|
||||
_featureManager.DisableFeatures(new[] { themeId });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableThemeFeatures(string themeName) {
|
||||
@ -79,8 +90,15 @@ namespace Orchard.Themes.Services {
|
||||
: null;
|
||||
}
|
||||
|
||||
while (themes.Count > 0)
|
||||
_featureManager.EnableFeatures(new[] {themes.Pop()});
|
||||
while (themes.Count > 0) {
|
||||
var themeId = themes.Pop();
|
||||
foreach (var featureId in _featureManager.EnableFeatures(new[] { themeId }, true)) {
|
||||
if (themeId != featureId) {
|
||||
var featureName = _featureManager.GetAvailableFeatures().First(f => f.Id.Equals(featureId, StringComparison.OrdinalIgnoreCase)).Name;
|
||||
Services.Notifier.Information(T("{0} was enabled", featureName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ExtensionDescriptor GetRequestTheme(RequestContext requestContext) {
|
||||
@ -172,5 +190,12 @@ namespace Orchard.Themes.Services {
|
||||
: "{0}, "), fn).ToString()).ToArray())
|
||||
: featuresInQuestion.First()));
|
||||
}
|
||||
|
||||
public void DisablePreviewFeatures(IEnumerable<string> features) {
|
||||
foreach (var featureId in _featureManager.DisableFeatures(features,true)) {
|
||||
var featureName = _featureManager.GetAvailableFeatures().First(f => f.Id.Equals(featureId, StringComparison.OrdinalIgnoreCase)).Name;
|
||||
Services.Notifier.Information(T("{0} was disabled", featureName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,4 +153,4 @@ namespace Orchard.Users.Activities {
|
||||
get { return T("User is approved."); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
}
|
||||
|
||||
public ContentPartDefinitionBuilder RemoveField(string fieldName) {
|
||||
var existingField = _fields.SingleOrDefault(x => x.Name == fieldName);
|
||||
var existingField = _fields.FirstOrDefault(x => x.Name == fieldName);
|
||||
if (existingField != null) {
|
||||
_fields.Remove(existingField);
|
||||
}
|
||||
@ -162,4 +162,4 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user