Merge branch 'feature/caching' into feature/messagebus

Conflicts:
	src/Orchard.sln
This commit is contained in:
Piotr Szmyd
2014-10-15 02:05:18 +02:00
1003 changed files with 42476 additions and 51256 deletions

View File

@@ -68,6 +68,7 @@ namespace Orchard.Core.Tests.Common.Providers {
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
builder.RegisterInstance(new RequestContext(new StubHttpContext(), new RouteData()));
builder.RegisterInstance(new Orchard.Environment.Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();

View File

@@ -61,8 +61,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\..\lib\castle-windsor\net45\Castle.Core.dll</HintPath>
<Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\castle\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

View File

@@ -257,6 +257,9 @@ namespace Orchard.Tests.Modules.Media.Services {
public void RenameFile(string path, string newPath) {
}
public void CopyFile(string originalPath, string duplicatePath) {
}
public IStorageFile CreateFile(string path) {
throw new NotImplementedException();
}

View File

@@ -61,8 +61,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\..\lib\castle-windsor\net45\Castle.Core.dll</HintPath>
<Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\castle\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

View File

@@ -73,6 +73,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ITransactionManager>();
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();

View File

@@ -18,6 +18,7 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
[TestFixture]
public class DefaultShapeTableManagerTests : ContainerTestBase {
protected override void Register(ContainerBuilder builder) {
builder.RegisterInstance(new Orchard.Environment.Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

View File

@@ -1,4 +1,5 @@
using Autofac;
using System.Collections.Generic;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.DisplayManagement;
@@ -17,6 +18,7 @@ namespace Orchard.Tests.DisplayManagement {
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterInstance(new Orchard.Environment.Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();

View File

@@ -1,4 +1,5 @@
using Autofac;
using System.Collections.Generic;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.DisplayManagement;
@@ -16,6 +17,7 @@ namespace Orchard.Tests.DisplayManagement {
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterInstance(new Orchard.Environment.Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();

View File

@@ -1,4 +1,5 @@
using System.Web;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
@@ -47,6 +48,7 @@ namespace Orchard.Tests.DisplayManagement {
builder.RegisterType<DefaultDisplayManager>().As<IDisplayManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterType<DisplayHelperFactory>().As<IDisplayHelperFactory>();
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

View File

@@ -58,6 +58,7 @@ namespace Orchard.Tests.Localization {
builder.RegisterType<TestCultureSelector>().As<ICultureSelector>();
builder.RegisterType<DefaultCultureManager>().As<ICultureManager>();
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();

View File

@@ -65,8 +65,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\..\lib\castle-windsor\net45\Castle.Core.dll</HintPath>
<Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\castle\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

View File

@@ -10,19 +10,13 @@ using Orchard.Security;
namespace Orchard.Core.Common.Drivers {
public class CommonPartDriver : ContentPartDriver<CommonPart> {
private readonly IContentManager _contentManager;
private readonly IAuthenticationService _authenticationService;
private readonly IAuthorizationService _authorizationService;
private readonly IMembershipService _membershipService;
public CommonPartDriver(
IOrchardServices services,
IContentManager contentManager,
IAuthenticationService authenticationService,
IAuthorizationService authorizationService,
IMembershipService membershipService) {
_contentManager = contentManager;
_authenticationService = authenticationService;
_authorizationService = authorizationService;
_membershipService = membershipService;
T = NullLocalizer.Instance;
Services = services;

View File

@@ -49,7 +49,8 @@ namespace Orchard.Core.Common.Drivers {
var viewModel = new TextFieldDriverViewModel {
Field = field,
Text = field.Value,
Settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>()
Settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>(),
ContentItem = part.ContentItem
};
return shapeHelper.EditorTemplate(TemplateName: "Fields.Common.Text.Edit", Model: viewModel, Prefix: GetPrefix(field, part));
@@ -61,7 +62,8 @@ namespace Orchard.Core.Common.Drivers {
var viewModel = new TextFieldDriverViewModel {
Field = field,
Text = field.Value,
Settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>()
Settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>(),
ContentItem = part.ContentItem
};
if(updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) {

View File

@@ -1,10 +1,12 @@
using Orchard.Core.Common.Fields;
using Orchard.ContentManagement;
using Orchard.Core.Common.Fields;
using Orchard.Core.Common.Settings;
namespace Orchard.Core.Common.ViewModels {
public class TextFieldDriverViewModel {
public TextField Field { get; set; }
public string Text { get; set; }
public TextFieldSettings Settings { get; set; }
public TextFieldSettings Settings { get; set; }
public IContent ContentItem { get; set; }
}
}

View File

@@ -7,7 +7,7 @@
@Html.ValidationMessageFor(m => m.Text)
}
else {
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required)
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem)
}
@if (HasText(Model.Settings.Hint)) {
<span class="hint">@Model.Settings.Hint</span>

View File

@@ -2,6 +2,6 @@
@using Orchard.Core.Common.ViewModels;
<fieldset>
<label>@T("Body")</label>
@Display.Body_Editor(Model)
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.EditorFlavor, Required: false, ContentItem: Model.BodyPart.ContentItem)
@Html.ValidationMessageFor(m => m.Text)
</fieldset>

View File

@@ -22,6 +22,7 @@ using Orchard.UI.Navigation;
using Orchard.UI.Notify;
using Orchard.Settings;
using Orchard.Utility.Extensions;
using Orchard.Localization.Services;
namespace Orchard.Core.Contents.Controllers {
[ValidateInput(false)]
@@ -30,6 +31,8 @@ namespace Orchard.Core.Contents.Controllers {
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly ITransactionManager _transactionManager;
private readonly ISiteService _siteService;
private readonly ICultureManager _cultureManager;
private readonly ICultureFilter _cultureFilter;
public AdminController(
IOrchardServices orchardServices,
@@ -37,12 +40,17 @@ namespace Orchard.Core.Contents.Controllers {
IContentDefinitionManager contentDefinitionManager,
ITransactionManager transactionManager,
ISiteService siteService,
IShapeFactory shapeFactory) {
IShapeFactory shapeFactory,
ICultureManager cultureManager,
ICultureFilter cultureFilter) {
Services = orchardServices;
_contentManager = contentManager;
_contentDefinitionManager = contentDefinitionManager;
_transactionManager = transactionManager;
_siteService = siteService;
_cultureManager = cultureManager;
_cultureFilter = cultureFilter;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
Shape = shapeFactory;
@@ -100,11 +108,17 @@ namespace Orchard.Core.Contents.Controllers {
break;
}
if(!String.IsNullOrWhiteSpace(model.Options.SelectedCulture)) {
query = _cultureFilter.FilterCulture(query, model.Options.SelectedCulture);
}
model.Options.SelectedFilter = model.TypeName;
model.Options.FilterOptions = GetListableTypes(false)
.Select(ctd => new KeyValuePair<string, string>(ctd.Name, ctd.DisplayName))
.ToList().OrderBy(kvp => kvp.Value);
model.Options.Cultures = _cultureManager.ListCultures();
var maxPagedCount = _siteService.GetSiteSettings().MaxPagedCount;
var pagerShape = Shape.Pager(pager).TotalItemCount(maxPagedCount > 0 ? maxPagedCount : query.Count());
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
@@ -140,6 +154,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult ListFilterPOST(ContentOptions options) {
var routeValues = ControllerContext.RouteData.Values;
if (options != null) {
routeValues["Options.SelectedCulture"] = options.SelectedCulture; //todo: don't hard-code the key
routeValues["Options.OrderBy"] = options.OrderBy; //todo: don't hard-code the key
routeValues["Options.ContentsStatus"] = options.ContentsStatus; //todo: don't hard-code the key
if (GetListableTypes(false).Any(ctd => string.Equals(ctd.Name, options.SelectedFilter, StringComparison.OrdinalIgnoreCase))) {

View File

@@ -35,10 +35,12 @@ namespace Orchard.Core.Contents.ViewModels {
ContentsStatus = ContentsStatus.Latest;
}
public string SelectedFilter { get; set; }
public string SelectedCulture { get; set; }
public IEnumerable<KeyValuePair<string, string>> FilterOptions { get; set; }
public ContentsOrder OrderBy { get; set; }
public ContentsStatus ContentsStatus { get; set; }
public ContentsBulkAction BulkAction { get; set; }
public IEnumerable<string> Cultures { get; set; }
}
public enum ContentsOrder {

View File

@@ -8,6 +8,8 @@
createLinkText = T("Create New {0}", typeDisplayName);
}
IEnumerable<string> cultures = Model.Options.Cultures;
Layout.Title = pageTitle;
}
@@ -29,10 +31,21 @@
<label for="filterResults" class="bulk-filter">@T("Show")</label>
<select id="filterResults" name="Options.SelectedFilter">
@Html.SelectOption((string)Model.Options.SelectedFilter, "", T("any (show all)").ToString())
@foreach(var filterOption in Model.Options.FilterOptions) {
@foreach (var filterOption in Model.Options.FilterOptions) {
@Html.SelectOption((string)Model.Options.SelectedFilter, (string)filterOption.Key, (string)filterOption.Value)
}
</select>
@if (cultures.Count() > 1) {
<label for="filterCultures" class="bulk-culture">@T("Culture")</label>
<select id="filterCultures" name="Options.SelectedCulture">
@Html.SelectOption((string)Model.Options.SelectedCulture, "", T("any (show all)").ToString())
@foreach (string culture in cultures) {
@Html.SelectOption((string)Model.Options.SelectedCulture, culture, System.Globalization.CultureInfo.GetCultureInfo(culture).DisplayName)
}
</select>
}
<label for="orderResults" class="bulk-order">@T("Ordered by")</label>
<select id="orderResults" name="Options.OrderBy">
@Html.SelectOption((ContentsOrder)Model.Options.OrderBy, ContentsOrder.Created, T("recently created").ToString())

View File

@@ -31,6 +31,7 @@
placeholder: 'navigation-placeholder',
revert: 50,
tabSize: 30,
rtl: window.isRTL,
tolerance: 'pointer',
toleranceElement: '> div',

View File

@@ -142,4 +142,34 @@
.menu-items-zone li a:hover {
border-color:#487328;
}
.dir-rtl .navigation-menu li div {
padding: 3px 30px 3px 10px;
}
.dir-rtl .navigation-menu li div:hover {
background: #eee url(images/move.gif) no-repeat right 7px;
}
.dir-rtl .navigation-actions {
float: left;
}
.dir-rtl .primary {
float: right;
}
.dir-rtl .secondary {
float: left;
margin: 2px -300px 0 0;
}
.dir-rtl .container {
margin: 0 0 0 350px;
}
.dir-rtl .menu-items-zone li {
padding-right: 5px;
padding-left: 65px;
}
.dir-rtl div.menu-item-actions {
left:10px;
right: inherit;
}

View File

@@ -16,7 +16,7 @@
</div>
<div>
<label for="@Html.FieldIdFor(m => m.BaseUrl)">@T("Base URL")</label>
@Html.TextBoxFor(m => m.BaseUrl, new { @class = "text medium" })
@Html.TextBoxFor(m => m.BaseUrl, new { @class = "text medium is-url" })
<span class="hint">@T("Enter the fully qualified base URL of the web site.")</span>
<span class="hint">@T("e.g., http://localhost:30320/orchardlocal, http://www.yourdomain.com")</span>
</div>

View File

@@ -40,4 +40,9 @@
background:url("images/detail-view-on.gif") no-repeat left top;
border-color:#487328;
cursor:default;
}
/* RTL */
.dir-rtl .switch-for-switchable .switch-button-group {
float: left;
}

View File

@@ -1,4 +1,5 @@
@using Orchard.Mvc.Html;
@using Orchard.Localization
@using Orchard.Mvc.Html;
@using Orchard.UI.Resources;
@{
RegisterLink(new LinkEntry {Type = "image/x-icon", Rel = "shortcut icon", Href = Url.Content("~/modules/orchard.themes/Content/orchard.ico")});
@@ -6,14 +7,17 @@
string title = Convert.ToString(Model.Title);
string siteName = Convert.ToString(WorkContext.CurrentSite.SiteName);
bool isRtl = WorkContext.CurrentCultureInfo().TextInfo.IsRightToLeft;
Html.AddPageClassNames("dir-" + (isRtl ? "rtl" : "ltr"));
}
<!DOCTYPE html>
<html lang="@WorkContext.CurrentCulture" class="static @Html.ClassForPage()">
<html lang="@WorkContext.CurrentCulture" class="static @Html.ClassForPage()" dir="@(isRtl?"rtl":"ltr")">
<head>
<meta charset="utf-8" />
<title>@Html.Title(title, siteName)</title>
@Display(Model.Head)
<script>(function(d){d.className="dyn"+d.className.substring(6,d.className.length);})(document.documentElement);</script>
<script>window.isRTL = @(isRtl.ToString().ToLowerInvariant());</script>
</head>
<body>
@* Layout (template) is in the Body zone @ the default position (nothing, zero, zilch) *@

File diff suppressed because it is too large Load Diff

View File

@@ -48,11 +48,8 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="MarkdownSharp">
<HintPath>..\..\..\..\lib\markdown\MarkdownSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
@@ -120,6 +117,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Handlers\MarkdownSiteSettingsPartHandler.cs" />
<Compile Include="Markdown.cs" />
<Compile Include="Migrations.cs" />
<Compile Include="Models\MarkdownSiteSettingsPart.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -7,7 +7,7 @@ namespace Markdown {
manifest.DefineScript("Markdown_Converter").SetUrl("Markdown.Converter.min.js", "Markdown.Converter.js");
manifest.DefineScript("Markdown_Sanitizer").SetUrl("Markdown.Sanitizer.min.js", "Markdown.Sanitizer.js").SetDependencies("Markdown_Converter");
manifest.DefineScript("Markdown_Editor").SetUrl("Markdown.Editor.min.js", "Markdown.Editor.js").SetDependencies("Markdown_Sanitizer");
manifest.DefineScript("Resizer").SetUrl("jquery.textarearesizer.min.js", "jquery.textarearesizer.js").SetDependencies("jQuery");
manifest.DefineScript("Resizer").SetUrl("jquery.textarearesizer.min.js", "jquery.textarearesizer.js").SetVersion("1.0.5").SetDependencies("jQuery");
manifest.DefineScript("OrchardMarkdown").SetUrl("orchard-markdown.min.js", "orchard-markdown.js").SetDependencies("Resizer", "Markdown_Editor");
manifest.DefineStyle("OrchardMarkdown").SetUrl("admin-markdown.css");

View File

@@ -12,6 +12,7 @@
1.0.3 Further updates including removing the textarea.focus and moving private variables to top
1.0.4 Re-instated the blur/focus events, according to information supplied by dec
1.0.5 Nick Mayne - Fixing issue with RTL when using useParentWidth. Should be looking at MarginLeft, not ignoring it.
*/
(function ($) {
@@ -60,6 +61,8 @@
if (!options.useParentWidth) {
grippie[0].style.marginRight = (grippie[0].offsetWidth - resizable[0].offsetWidth) + 'px';
} else {
grippie[0].style.marginLeft = (grippie[0].offsetWidth - resizable[0].offsetWidth) + 'px';
}
if (options.initCallback && options.callback) {

View File

@@ -1,2 +1,4 @@
(function(n){function u(r,u){function a(r){return h=i(r).y,t=n("<div id='overlay' style='position: absolute; zindex: 99; background-color: white; opacity:0.01; filter: alpha(opacity = 1); left:0; top:0;'>&nbsp;<\/div>"),o.css("opacity",.25),e.append(t[0]),t.width(e.width()),t.height(e.height()),n(document).mousemove(c).mouseup(l),!1}function c(n){var u=i(n).y,r=u-e.offset().top,c;return(h>=u&&(r-=5),r<=f.minHeight)?!1:(h=u,r=r,c=f.resizeWrapper?e:o,c.height(r-f.offsetTop),t.height(e.height()),f.callback&&f.callback(r-(f.resizeWrapper?s.outerHeight(!0):0),c),!1)}function l(){n(document).unbind("mousemove",c).unbind("mouseup",l),o.css("opacity",1),e.focus(),t.remove(),h=0}var s,h=0,f=u,o,e=n(r).addClass("processed");s=n('<div class="grippie"><\/div>').bind("mousedown",a),o=e.children(":visible"),e.append(s),f.resizeWrapper||(o=f.resizeSelector?o.filter(f.resizeSelector):o.first()),f.useParentWidth||(s[0].style.marginRight=s[0].offsetWidth-o[0].offsetWidth+"px"),f.initCallback&&f.callback&&f.callback(e.height()-s.outerHeight(!0))}function i(n){return{x:n.clientX+document.documentElement.scrollLeft,y:n.clientY+(document.documentElement.scrollTop||document.body.scrollTop)}}var t,r={useParentWidth:!1,resizeWrapper:!1,minHeight:32,offsetTop:0};n.fn.TextAreaResizer=function(t,i){return this.each(function(){t&&typeof t=="function"?(i=i||{},i.callback=t):t&&typeof t=="object"&&!i&&(i=t),u(this,n.extend({},r,i||{}))})}})(jQuery);
//@ sourceMappingURL=jquery.textarearesizer.min.js.map
(function(n){function u(r,u){function a(r){return h=i(r).y,t=n("<div id='overlay' style='position: absolute; zindex: 99; background-color: white; opacity:0.01; filter: alpha(opacity = 1); left:0; top:0;'>&nbsp;<\/div>"),o.css("opacity",.25),e.append(t[0]),t.width(e.width()),t.height(e.height()),n(document).mousemove(c).mouseup(l),!1}function c(n){var u=i(n).y,r=u-e.offset().top,c;return(h>=u&&(r-=5),r<=f.minHeight)?!1:(h=u,r=r,c=f.resizeWrapper?e:o,c.height(r-f.offsetTop),t.height(e.height()),f.callback&&f.callback(r-(f.resizeWrapper?s.outerHeight(!0):0),c),!1)}function l(){n(document).unbind("mousemove",c).unbind("mouseup",l);o.css("opacity",1);e.focus();t.remove();h=0}var s,h=0,f=u,o,e=n(r).addClass("processed");s=n('<div class="grippie"><\/div>').bind("mousedown",a);o=e.children(":visible");e.append(s);f.resizeWrapper||(o=f.resizeSelector?o.filter(f.resizeSelector):o.first());f.useParentWidth?s[0].style.marginLeft=s[0].offsetWidth-o[0].offsetWidth+"px":s[0].style.marginRight=s[0].offsetWidth-o[0].offsetWidth+"px";f.initCallback&&f.callback&&f.callback(e.height()-s.outerHeight(!0))}function i(n){return{x:n.clientX+document.documentElement.scrollLeft,y:n.clientY+(document.documentElement.scrollTop||document.body.scrollTop)}}var t,r={useParentWidth:!1,resizeWrapper:!1,minHeight:32,offsetTop:0};n.fn.TextAreaResizer=function(t,i){return this.each(function(){t&&typeof t=="function"?(i=i||{},i.callback=t):t&&typeof t=="object"&&!i&&(i=t);u(this,n.extend({},r,i||{}))})}})(jQuery);
/*
//# sourceMappingURL=jquery.textarearesizer.min.js.map
*/

View File

@@ -2,7 +2,7 @@
"version":3,
"file":"jquery.textarearesizer.min.js",
"lineCount":1,
"mappings":"CAgBC,QAAS,CAACA,CAAD,CAAI,CAwBVC,SAASA,CAAe,CAACC,CAAM,CAAEC,CAAT,CAAe,CA4BnCC,SAASA,CAAS,CAACC,CAAD,CAAI,CAYlB,OAXAC,CAAc,CAAEC,CAAa,CAACF,CAAD,CAAGG,EAAE,CAElCC,CAAQ,CAAET,CAAC,CAAC,2JAAD,CAA4J,CAEvKU,CAASC,IAAI,CAAC,SAAS,CAAE,GAAZ,CAAiB,CAC9BC,CAAOC,OAAO,CAACJ,C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XjC,EA6GZ,CAAC0D,MAAD,CAAQ",
"sources":["jquery.textarearesizer.js"],
"names":["$","textAreaResizer","target","opts","startDrag","e","iLastMousePos","mousePosition","y","overlay","resizable","css","wrapper","append","width","height","document","mousemove","performDrag","mouseup","endDrag","iThisMousePos","iMousePos","offset","top","resizing","options","minHeight","resizeWrapper","offsetTop","callback","grippie","outerHeight","unbind","focus","remove","addClass","bind","children","resizeSelector","filter","first","useParentWidth","style","marginRight","offsetWidth","initCallback","clientX","documentElement","scrollLeft","clientY","scrollTop","body","defaults","fn","TextAreaResizer","$.fn.TextAreaResizer","cb","each","extend","jQuery"]
"names":["$","textAreaResizer","target","opts","startDrag","e","iLastMousePos","mousePosition","y","overlay","resizable","css","wrapper","append","width","height","document","mousemove","performDrag","mouseup","endDrag","iThisMousePos","iMousePos","offset","top","resizing","options","minHeight","resizeWrapper","offsetTop","callback","grippie","outerHeight","unbind","focus","remove","addClass","bind","children","resizeSelector","filter","first","useParentWidth","style","marginLeft","offsetWidth","marginRight","initCallback","clientX","documentElement","scrollLeft","clientY","scrollTop","body","defaults","fn","TextAreaResizer","$.fn.TextAreaResizer","cb","each","extend","jQuery"]
}

View File

@@ -7,9 +7,10 @@
};
resizeInnerElements($(resizableSelector), 400);
$(".has-grip").TextAreaResizer(function(size, resizing) {
$(".has-grip").TextAreaResizer(function (size, resizing) {
resizing.find(resizableSelector).each(function() { resizeInnerElements($(this), size - 18); });
}, {
resizeWrapper: true
resizeWrapper: true,
useParentWidth: window.isRTL
});
})();

View File

@@ -1,2 +1,4 @@
(function(){var n=".wmd-input,.wmd-preview",t=function(n,t){t>120&&n.height(t-20)};t($(n),400),$(".has-grip").TextAreaResizer(function(i,r){r.find(n).each(function(){t($(this),i-18)})},{resizeWrapper:!0})})();
//@ sourceMappingURL=orchard-markdown.min.js.map
(function(){var n=".wmd-input,.wmd-preview",t=function(n,t){t>120&&n.height(t-20)};t($(n),400);$(".has-grip").TextAreaResizer(function(i,r){r.find(n).each(function(){t($(this),i-18)})},{resizeWrapper:!0,useParentWidth:window.isRTL})})();
/*
//# sourceMappingURL=orchard-markdown.min.js.map
*/

View File

@@ -2,7 +2,7 @@
"version":3,
"file":"orchard-markdown.min.js",
"lineCount":1,
"mappings":"CAAC,QAAQ,CAAA,CAAG,CACR,IAAIA,EAAoB,0BACpBC,EAAsBA,QAAS,CAACC,CAAE,CAAEC,CAAL,CAAW,CAClCA,CAAK,CAAE,G,EACPD,CAAEE,OAAO,CAACD,CAAK,CAAE,EAAR,CAFyB,CAIzC,CACLF,CAAmB,CAACI,CAAC,CAACL,CAAD,CAAmB,CAAE,GAAvB,CAA2B,CAE9CK,CAAC,CAAC,WAAD,CAAaC,gBAAgB,CAAC,QAAQ,CAACH,CAAI,CAAEI,CAAP,CAAiB,CACpDA,CAAQC,KAAK,CAACR,CAAD,CAAmBS,KAAK,CAAC,QAAQ,CAAA,CAAG,CAAER,CAAmB,CAACI,CAAC,CAAC,IAAD,CAAM,CAAEF,CAAK,CAAE,EAAjB,CAArB,CAAZ,CADe,CAEvD,CAAE,CACC,aAAa,CAAE,CAAA,CADhB,CAF2B,CATtB,EAcV,CAAA,CAAE",
"mappings":"CAAC,QAAQ,CAAA,CAAG,CACR,IAAIA,EAAoB,0BACpBC,EAAsB,QAAS,CAACC,CAAE,CAAEC,CAAL,CAAW,CAClCA,CAAK,CAAE,G,EACPD,CAAEE,OAAO,CAACD,CAAK,CAAE,EAAR,CAFyB,CAIzC,CACLF,CAAmB,CAACI,CAAC,CAACL,CAAD,CAAmB,CAAE,GAAvB,CAA2B,CAE9CK,CAAC,CAAC,WAAD,CAAaC,gBAAgB,CAAC,QAAS,CAACH,CAAI,CAAEI,CAAP,CAAiB,CACrDA,CAAQC,KAAK,CAACR,CAAD,CAAmBS,KAAK,CAAC,QAAQ,CAAA,CAAG,CAAER,CAAmB,CAACI,CAAC,CAAC,IAAD,CAAM,CAAEF,CAAK,CAAE,EAAjB,CAArB,CAAZ,CADgB,CAExD,CAAE,CACC,aAAa,CAAE,CAAA,CAAI,CACnB,cAAc,CAAEO,MAAMC,MAFvB,CAF2B,CATtB,EAeV,CAAA,CAAE",
"sources":["orchard-markdown.js"],
"names":["resizableSelector","resizeInnerElements","el","size","height","$","TextAreaResizer","resizing","find","each"]
"names":["resizableSelector","resizeInnerElements","el","size","height","$","TextAreaResizer","resizing","find","each","window","isRTL"]
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Web.ApplicationServices;
using Orchard.Services;
namespace Markdown.Services {
@@ -12,6 +13,7 @@ namespace Markdown.Services {
return string.Empty;
var markdown = new MarkdownSharp.Markdown();
return markdown.Transform(text);
}
}

View File

@@ -179,4 +179,31 @@ div.grippie {
.wmd-preview dd {
margin-left: 10px !important;
}
/* RTL */
.dir-rtl .wmd-button {
padding-left: 3px;
padding-right: 2px;
}
.dir-rtl .wmd-preview ol {
margin-left: inherit !important;
margin-right: 20px !important;
}
.dir-rtl .wmd-preview ul li {
margin-left: inherit !important;
margin-right: 10px !important;
}
.dir-rtl .wmd-preview pre {
margin: 0 9px 9px 0 !important;
}
.dir-rtl .wmd-preview dd {
margin-left: inherit !important;
margin-right: 10px !important;
}

View File

@@ -21,8 +21,10 @@
<fieldset class="permalink">
<label>@T("Permalink")</label>
@if (Model.Settings.AllowCustomPattern) {
<span>@Url.MakeAbsolute("/")@urlPrefix</span>
<span>@Html.TextBoxFor(m => m.CurrentUrl, new {@class = "text"})</span>
<span class="permalink-definition" dir="ltr">
<span>@Url.MakeAbsolute("/")@urlPrefix</span>
<span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text is-url" })</span>
</span>
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}", defaultPattern.Name, defaultPattern.Description)</span>
}
else {

View File

@@ -261,6 +261,18 @@ namespace Orchard.Azure.Services.FileSystems {
blob.Delete();
}
public void CopyFile(string path, string newPath) {
path = ConvertToRelativeUriPath(path);
newPath = ConvertToRelativeUriPath(newPath);
Container.EnsureBlobExists(String.Concat(_root, path));
Container.EnsureBlobDoesNotExist(String.Concat(_root, newPath));
var blob = Container.GetBlockBlobReference(String.Concat(_root, path));
var newBlob = Container.GetBlockBlobReference(String.Concat(_root, newPath));
newBlob.StartCopyFromBlob(blob);
}
public IStorageFile CreateFile(string path) {
path = ConvertToRelativeUriPath(path);

View File

@@ -17,15 +17,15 @@ namespace Orchard.Caching.Services {
_prefix = shellSettings.Name;
}
public object Get(string key) {
return _cacheStorageProvider.Get(BuildFullKey(key));
public T Get<T>(string key) {
return _cacheStorageProvider.Get<T>(BuildFullKey(key));
}
public void Put(string key, object value) {
public void Put<T>(string key, T value) {
_cacheStorageProvider.Put(BuildFullKey(key), value);
}
public void Put(string key, object value, TimeSpan validFor) {
public void Put<T>(string key, T value, TimeSpan validFor) {
_cacheStorageProvider.Put(BuildFullKey(key), value, validFor);
}
@@ -38,7 +38,7 @@ namespace Orchard.Caching.Services {
}
private string BuildFullKey(string key) {
return String.Concat(_prefix, "_", key);
return String.Concat(_prefix, ":", key);
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Web;
namespace Orchard.Caching.Services {
public class DefaultCacheStorageProvider : ICacheStorageProvider {
public void Put(string key, object value) {
public void Put<T>(string key, T value) {
HttpRuntime.Cache.Insert(
key,
value,
@@ -17,7 +17,7 @@ namespace Orchard.Caching.Services {
null);
}
public void Put(string key, object value, TimeSpan validFor) {
public void Put<T>(string key, T value, TimeSpan validFor) {
HttpRuntime.Cache.Insert(
key,
value,
@@ -44,8 +44,13 @@ namespace Orchard.Caching.Services {
}
}
public object Get(string key) {
return HttpRuntime.Cache.Get(key);
public T Get<T>(string key) {
var value = HttpRuntime.Cache.Get(key);
if (value is T) {
return (T)value;
}
return default(T);
}
}
}

View File

@@ -2,23 +2,18 @@
namespace Orchard.Caching.Services {
public interface ICacheService : IDependency {
T Get<T>(string key);
object Get(string key);
void Put(string key, object value);
void Put(string key, object value, TimeSpan validFor);
void Put<T>(string key, T value);
void Put<T>(string key, T value, TimeSpan validFor);
void Remove(string key);
void Clear();
}
public static class CachingExtensions {
public static T Get<T>(this ICacheService cacheService, string key) {
return (T)cacheService.Get(key);
}
public static T Get<T>(this ICacheService cacheService, string key, Func<T> factory) {
var result = cacheService.Get(key);
var result = cacheService.Get<T>(key);
if (result == null) {
var computed = factory();
cacheService.Put(key, computed);
@@ -26,11 +21,11 @@ namespace Orchard.Caching.Services {
}
// try to convert to T
return (T)result;
return result;
}
public static T Get<T>(this ICacheService cacheService, string key, Func<T> factory, TimeSpan validFor) {
var result = cacheService.Get(key);
var result = cacheService.Get<T>(key);
if (result == null) {
var computed = factory();
cacheService.Put(key, computed, validFor);
@@ -38,7 +33,7 @@ namespace Orchard.Caching.Services {
}
// try to convert to T
return (T)result;
return result;
}
}
}

View File

@@ -2,9 +2,9 @@
namespace Orchard.Caching.Services {
public interface ICacheStorageProvider : IDependency {
object Get(string key);
void Put(string key, object value);
void Put(string key, object value, TimeSpan validFor);
T Get<T>(string key);
void Put<T>(string key, T value);
void Put<T>(string key, T value, TimeSpan validFor);
void Remove(string key);
void Clear();
}

View File

@@ -15,4 +15,10 @@
text-align: right;
padding-right: 2em;
width: inherit;
}
/* RTL */
.dir-rtl .content-permissions .role {
padding-right: inherit;
padding-left: 2em;
}

View File

@@ -51,22 +51,11 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
@@ -98,20 +87,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
<Project>{194D3CCC-1153-474D-8176-FDE8D7D0D0BD}</Project>
<Name>Orchard.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\AlternateController.cs" />
<Compile Include="Services\ObjectDumper.cs" />
@@ -132,6 +107,16 @@
<ItemGroup>
<Content Include="Views\ShapeTracingTemplates.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2d1d92bb-4555-4cbe-8d0e-63563d6ce4c6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
<Project>{194d3ccc-1153-474d-8176-fde8d7d0d0bd}</Project>
<Name>Orchard.Widgets</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.DynamicForms.Elements;
using Orchard.Localization;
using Orchard.Workflows.Models;
using Orchard.Workflows.Services;
namespace Orchard.DynamicForms.Activities {
public class FormSubmittedActivity : Event {
public const string EventName = "DynamicFormSubmitted";
public Localizer T { get; set; }
public override bool CanStartWorkflow {
get { return true; }
}
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
var state = activityContext.GetState<string>("DynamicForms");
// "" means 'any'.
if (String.IsNullOrEmpty(state)) {
return true;
}
var form = workflowContext.Tokens["DynamicForm"] as Form;
if (form == null) {
return false;
}
var formNames = state.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return formNames.Any(x => x == form.Name);
}
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
return new[] { T("Done") };
}
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
yield return T("Done");
}
public override string Form {
get {
return "SelectDynamicForms";
}
}
public override string Name {
get { return EventName; }
}
public override LocalizedString Category {
get { return T("Forms"); }
}
public override LocalizedString Description {
get { return T("A dynamic form is submitted."); }
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Forms.Services;
using Orchard.Localization;
namespace Orchard.DynamicForms.Activities {
public class SelectDynamicForms : IFormProvider {
protected dynamic Shape { get; set; }
public Localizer T { get; set; }
public SelectDynamicForms(IShapeFactory shapeFactory) {
Shape = shapeFactory;
T = NullLocalizer.Instance;
}
public void Describe(DescribeContext context) {
context.Form("SelectDynamicForms", factory => {
var shape = (dynamic)factory;
var form = shape.Form(
Id: "AnyOfDynamicForms",
_Parts: Shape.Textbox(
Id: "dynamicforms",
Name: "DynamicForms",
Title: T("Dynamic Forms"),
Description: T("Enter a comma separated list of dynamic form names. Leave empty to handle all forms."),
Classes: new[] { "text", "large" })
);
return form;
});
}
}
}

View File

@@ -0,0 +1,18 @@
using Orchard.UI.Navigation;
namespace Orchard.DynamicForms {
public class AdminMenu : Component, INavigationProvider {
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder
.AddImageSet("dynamicforms")
.Add(T("Dynamic Forms"), "4", menu => menu
.Add(T("Manage Forms"), "1.0",
item => item
.Action("Index", "Admin", new { area = "Orchard.DynamicForms" })
.Permission(Permissions.ManageForms))
);
}
}
}

View File

@@ -0,0 +1,12 @@
using Orchard.Core.Common.Models;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
namespace Orchard.DynamicForms.Bindings {
public class BodyPartBindings : Component, IBindingProvider {
public void Describe(BindingDescribeContext context) {
context.For<BodyPart>()
.Binding("Text", (part, s) => part.Text = s);
}
}
}

View File

@@ -0,0 +1,12 @@
using Orchard.Core.Common.Fields;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
namespace Orchard.DynamicForms.Bindings {
public class TextFieldBindings : Component, IBindingProvider {
public void Describe(BindingDescribeContext context) {
context.For<TextField>()
.Binding("Text", (field, s) => field.Value = s);
}
}
}

View File

@@ -0,0 +1,12 @@
using Orchard.Core.Title.Models;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
namespace Orchard.DynamicForms.Bindings {
public class TitlePartBindings : Component, IBindingProvider {
public void Describe(BindingDescribeContext context) {
context.For<TitlePart>()
.Binding("Title", (part, s) => part.Title = s);
}
}
}

View File

@@ -0,0 +1,14 @@
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
using Orchard.Users.Models;
namespace Orchard.DynamicForms.Bindings {
public class UserPartBindings : Component, IBindingProvider {
public void Describe(BindingDescribeContext context) {
context.For<UserPart>()
.Binding("UserName", (part, s) => part.UserName = s)
.Binding("Email", (part, s) => part.Email = s)
.Binding("Password", (part, s) => part.Password = s);
}
}
}

View File

@@ -0,0 +1,21 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.ViewModels;
namespace Orchard.DynamicForms.Controllers {
public class AdminController : Controller {
private readonly IFormService _formService;
public AdminController(IFormService formService) {
_formService = formService;
}
public ActionResult Index() {
var forms = _formService.GetSubmissions().ToArray().GroupBy(x => x.FormName).ToArray();
var viewModel = new FormsIndexViewModel {
Forms = forms
};
return View(viewModel);
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Web.Mvc;
using Orchard.DynamicForms.Helpers;
using Orchard.DynamicForms.Services;
using Orchard.Layouts.Services;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.UI.Notify;
using IController = Orchard.DynamicForms.Services.IController;
namespace Orchard.DynamicForms.Controllers {
public class FormController : Controller, IController {
private readonly INotifier _notifier;
private readonly ILayoutManager _layoutManager;
private readonly IFormService _formService;
public FormController(
INotifier notifier,
ILayoutManager layoutManager,
IFormService formService) {
_notifier = notifier;
_layoutManager = layoutManager;
_formService = formService;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
}
public Localizer T { get; set; }
public ILogger Logger { get; set; }
public ActionResult Submit(int contentId, string formName) {
var layoutPart = _layoutManager.GetLayout(contentId);
var form = _formService.FindForm(layoutPart, formName);
var urlReferrer = HttpContext.Request.UrlReferrer != null ? HttpContext.Request.UrlReferrer.ToString() : "~/";
if (form == null) {
Logger.Warning("The specified form \"{0}\" could not be found.", formName);
_notifier.Warning(T("The specified form \"{0}\" could not be found."));
return Redirect(urlReferrer);
}
var values = _formService.SubmitForm(form, ValueProvider, ModelState);
this.TransferFormSubmission(form, values);
if(Response.IsRequestBeingRedirected)
return new EmptyResult();
var redirectUrl = !String.IsNullOrWhiteSpace(form.RedirectUrl) ? form.RedirectUrl : urlReferrer;
return Redirect(redirectUrl);
}
}
}

View File

@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Orchard.DynamicForms.Helpers;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.ViewModels;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.UI.Admin;
using Orchard.UI.Navigation;
using Orchard.UI.Notify;
namespace Orchard.DynamicForms.Controllers {
[Admin]
public class SubmissionAdminController : Controller {
private readonly IFormService _formService;
private readonly IOrchardServices _services;
public SubmissionAdminController(IFormService formService, IOrchardServices services) {
_formService = formService;
_services = services;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public ActionResult Index(string id, PagerParameters pagerParameters) {
var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters);
var submissions = _formService.GetSubmissions(id, pager.GetStartIndex(), pager.PageSize);
var pagerShape = _services.New.Pager(pager).TotalItemCount(submissions.TotalItemCount);
var viewModel = new SubmissionsIndexViewModel {
FormName = id,
Submissions = _formService.GenerateDataTable(submissions),
Pager = pagerShape
};
return View(viewModel);
}
public ActionResult Details(int id) {
var submission = _formService.GetSubmission(id);
if (submission == null)
return HttpNotFound();
var viewModel = new SubmissionViewModel {
Submission = submission,
NameValues = submission.ToNameValues()
};
return View(viewModel);
}
public ActionResult Delete(int id) {
var submission = _formService.GetSubmission(id);
if (submission == null)
return HttpNotFound();
_formService.DeleteSubmission(submission);
_services.Notifier.Information(T("That submission has been deleted."));
return Redirect(Request.UrlReferrer.ToString());
}
[FormValueRequired("submit.BulkEdit")]
[ActionName("Index")]
public ActionResult BulkDelete(IEnumerable<int> submissionIds) {
if (submissionIds == null || !submissionIds.Any()) {
_services.Notifier.Error(T("Please select the submissions to delete."));
}
else {
var numDeletedSubmissions = _formService.DeleteSubmissions(submissionIds);
_services.Notifier.Information(T("{0} submissions have been deleted.", numDeletedSubmissions));
}
return Redirect(Request.UrlReferrer.ToString());
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Linq;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.DynamicForms.Elements;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.ViewModels;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class BindingsElementDriver : ElementDriver<FormElement> {
private readonly IBindingManager _bindingManager;
private readonly IContentDefinitionManager _contentDefinitionManager;
public BindingsElementDriver(
IBindingManager bindingManager,
IContentDefinitionManager contentDefinitionManager) {
_bindingManager = bindingManager;
_contentDefinitionManager = contentDefinitionManager;
}
protected override EditorResult OnBuildEditor(FormElement element, ElementEditorContext context) {
var contentType = element.FormBindingContentType;
var contentTypeDefinition = !String.IsNullOrWhiteSpace(contentType) ? _contentDefinitionManager.GetTypeDefinition(contentType) : default(ContentTypeDefinition);
if (contentTypeDefinition == null)
return null;
var viewModel = new FormBindingSettings {
AvailableBindings = _bindingManager.DescribeBindingsFor(contentTypeDefinition).ToArray()
};
if (context.Updater != null) {
context.Updater.TryUpdateModel(viewModel, null, null, new[] {"AvailableBindings"});
}
var bindingsEditor = context.ShapeFactory.EditorTemplate(TemplateName: "FormBindings", Model: viewModel);
bindingsEditor.Metadata.Position = "Bindings:10";
return Editor(context, bindingsEditor);
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class ButtonDriver : FormsElementDriver<Button> {
public ButtonDriver(IFormManager formManager) : base(formManager) { }
protected override IEnumerable<string> FormNames {
get { yield return "Button"; }
}
protected override void DescribeForm(DescribeContext context) {
context.Form("Button", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "Form",
_ButtonText: shape.Textbox(
Id: "ButtonText",
Name: "ButtonText",
Title: "Text",
Value: "Submit",
Classes: new[] { "text", "medium" },
Description: T("The button text.")));
return form;
});
}
}
}

View File

@@ -0,0 +1,71 @@
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Tokens;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class CheckboxDriver : FormsElementDriver<CheckBox> {
private readonly ITokenizer _tokenizer;
public CheckboxDriver(IFormManager formManager, ITokenizer tokenizer)
: base(formManager) {
_tokenizer = tokenizer;
}
protected override EditorResult OnBuildEditor(CheckBox element, ElementEditorContext context) {
var autoLabelEditor = BuildForm(context, "AutoLabel");
var checkBoxEditor = BuildForm(context, "CheckBox");
var checkBoxValidation = BuildForm(context, "CheckBoxValidation", "Validation:10");
return Editor(context, autoLabelEditor, checkBoxEditor, checkBoxValidation);
}
protected override void DescribeForm(DescribeContext context) {
context.Form("CheckBox", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "CheckBox",
_Value: shape.Textbox(
Id: "Value",
Name: "Value",
Title: "Value",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The value of this checkbox.")));
return form;
});
context.Form("CheckBoxValidation", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "CheckBoxValidation",
_IsRequired: shape.Checkbox(
Id: "IsMandatory",
Name: "IsMandatory",
Title: "Mandatory",
Value: "true",
Description: T("Tick this checkbox to make this check box element mandatory.")),
_CustomValidationMessage: shape.Textbox(
Id: "CustomValidationMessage",
Name: "CustomValidationMessage",
Title: "Custom Validation Message",
Classes: new[] { "text", "large", "tokenized" },
Description: T("Optionally provide a custom validation message.")),
_ShowValidationMessage: shape.Checkbox(
Id: "ShowValidationMessage",
Name: "ShowValidationMessage",
Title: "Show Validation Message",
Value: "true",
Description: T("Autogenerate a validation message when a validation error occurs for the current field. Alternatively, to control the placement of the validation message you can use the ValidationMessage element instead.")));
return form;
});
}
protected override void OnDisplaying(CheckBox element, ElementDisplayContext context) {
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
}
}
}

View File

@@ -0,0 +1,51 @@
using System.Collections.Generic;
using Orchard.DisplayManagement;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class CommonFormElementDriver : FormsElementDriver<FormElement> {
public CommonFormElementDriver(IFormManager formManager, IShapeFactory shapeFactory) : base(formManager) {
New = shapeFactory;
}
public override int Priority {
get { return 500; }
}
protected override IEnumerable<string> FormNames {
get { yield return "CommonFormElement"; }
}
public dynamic New { get; set; }
protected override void DescribeForm(DescribeContext context) {
context.Form("CommonFormElement", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "CommonFormElement",
_Span: shape.Textbox(
Id: "InputName",
Name: "InputName",
Title: "Name",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The name of this form field.")),
_FormBindingContentType: shape.Hidden(
Id: "FormBindingContentType",
Name: "FormBindingContentType"));
return form;
});
}
protected override void OnDisplaying(FormElement element, ElementDisplayContext context) {
context.ElementShape.Metadata.Wrappers.Add("FormElement_Wrapper");
context.ElementShape.Child.Add(New.PlaceChildContent(Source: context.ElementShape));
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
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.Tokens;
using Orchard.Utility.Extensions;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class EnumerationDriver : FormsElementDriver<Enumeration> {
private readonly ITokenizer _tokenizer;
public EnumerationDriver(IFormManager formManager, ITokenizer tokenizer)
: base(formManager) {
_tokenizer = tokenizer;
}
protected override IEnumerable<string> FormNames {
get {
yield return "AutoLabel";
yield return "Enumeration";
}
}
protected override void DescribeForm(DescribeContext context) {
context.Form("Enumeration", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "Enumeration",
_Options: shape.Textarea(
Id: "Options",
Name: "Options",
Title: "Options",
Classes: new[] { "text", "large", "tokenized" },
Description: T("Enter one option per line. To differentiate between an option's text and value, separate the two by a colon. For example: &quot;Option 1:1&quot;")),
_InputType: shape.SelectList(
Id: "InputType",
Name: "InputType",
Title: "Input Type",
Description: T("The control to render when presenting the list of options.")));
form._InputType.Items.Add(new SelectListItem { Text = T("Select List").Text, Value = "SelectList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Multi Select List").Text, Value = "MultiSelectList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Radio List").Text, Value = "RadioList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Check List").Text, Value = "CheckList" });
return form;
});
}
protected override void OnDisplaying(Enumeration element, ElementDisplayContext context) {
var tokenizedOptions = _tokenizer.Replace(element.Options).ToArray();
var typeName = element.GetType().Name;
var category = element.Category.ToSafeName();
var displayType = context.DisplayType;
context.ElementShape.TokenizedOptions = tokenizedOptions;
context.ElementShape.Metadata.Alternates.Add(String.Format("Element__{0}__{1}__{2}", category, typeName, element.InputType));
context.ElementShape.Metadata.Alternates.Add(String.Format("Element_{0}__{1}__{2}__{3}", displayType, category, typeName, element.InputType));
}
}
}

View File

@@ -0,0 +1,154 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Orchard.ContentManagement.MetaData;
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;
using Orchard.Layouts.Services;
namespace Orchard.DynamicForms.Drivers {
public class FormDriver : FormsElementDriver<Form> {
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly IFormService _formService;
private readonly ICurrentControllerAccessor _currentControllerAccessor;
private readonly ICultureAccessor _cultureAccessor;
public FormDriver(
IFormManager formManager,
IContentDefinitionManager contentDefinitionManager,
IFormService formService,
ICurrentControllerAccessor currentControllerAccessor,
ICultureAccessor cultureAccessor)
: base(formManager) {
_contentDefinitionManager = contentDefinitionManager;
_formService = formService;
_currentControllerAccessor = currentControllerAccessor;
_cultureAccessor = cultureAccessor;
}
protected override IEnumerable<string> FormNames {
get { yield return "Form"; }
}
protected override void DescribeForm(DescribeContext context) {
context.Form("Form", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "Form",
_FormName: shape.Textbox(
Id: "FormName",
Name: "FormName",
Title: "Name",
Classes: new[] { "text", "medium" },
Description: T("The name of the form.")),
_FormAction: shape.Textbox(
Id: "FormAction",
Name: "FormAction",
Title: "Custom Target URL",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The action of the form. Leave blank to have the form submitted to the default form controller.")),
_FormMethod: shape.SelectList(
Id: "FormMethod",
Name: "FormMethod",
Title: "Method",
Description: T("The method of the form.")),
_EnableClientValidation: shape.Checkbox(
Id: "EnableClientValidation",
Name: "EnableClientValidation",
Title: "Enable Client Validation",
Value: "true",
Description: T("Enables client validation.")),
_StoreSubmission: shape.Checkbox(
Id: "StoreSubmission",
Name: "StoreSubmission",
Title: "Store Submission",
Value: "true",
Description: T("Stores the submitted form into the database.")),
_CreateContent: shape.Checkbox(
Id: "CreateContent",
Name: "CreateContent",
Title: "Create Content",
Value: "true",
Description: T("Check this to create a content item based using the submitted values. You will have to select a Content Type here and bind the form fields to the various parts and fields of the selected Content Type.")),
_ContentType: shape.SelectList(
Id: "CreateContentType",
Name: "CreateContentType",
Title: "Content Type",
Description: T("The Content Type to use when storing the submitted form values as a content item. Note that if you change the content type, you will have to update the form field bindings."),
EnabledBy: "CreateContent"),
_PublicationDraft: shape.Radio(
Id: "Publication-Draft",
Name: "Publication",
Title: "Save As Draft",
Value: "Draft",
Checked: true,
Description: T("Save the created content item as a draft."),
EnabledBy: "CreateContent"),
_PublicationPublish: shape.Radio(
Id: "Publication-Publish",
Name: "Publication",
Title: "Publish",
Value: "Publish",
Description: T("Publish the created content item."),
EnabledBy: "CreateContent"),
_Notification: shape.Textbox(
Id: "Notification",
Name: "Notification",
Title: "Show Notification",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The message to show after the form has been submitted. Leave blank if you don't want to show a message.")),
_RedirectUrl: shape.Textbox(
Id: "RedirectUrl",
Name: "RedirectUrl",
Title: "Redirect URL",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The URL to redirect to after the form has been submitted. Leave blank to stay on the same page. tip: you can use a Workflow to control what happens when this form is submitted.")));
// FormMethod
form._FormMethod.Items.Add(new SelectListItem { Text = "POST", Value = "POST" });
form._FormMethod.Items.Add(new SelectListItem { Text = "GET", Value = "GET" });
// ContentType
var contentTypes = _contentDefinitionManager.ListTypeDefinitions().Where(IsCreatableContentType).ToArray();
foreach (var contentType in contentTypes.OrderBy(x => x.DisplayName)) {
form._ContentType.Items.Add(new SelectListItem { Text = contentType.DisplayName, Value = contentType.Name });
}
return form;
});
}
protected override void OnDisplaying(Form element, ElementDisplayContext context) {
var controller = _currentControllerAccessor.CurrentController;
var values = controller.FetchPostedValues(element);
var modelState = controller.FetchModelState(element);
if (modelState != null && !modelState.IsValid) {
// Read any posted values from the previous request.
_formService.ReadElementValues(element, new NameValueCollectionValueProvider(values, _cultureAccessor.CurrentCulture));
// Add any model validation errors from the previous request.
controller.ApplyAnyModelErrors(element, modelState);
}
// Assign the binding content type to each element within the form element.
foreach (var child in element.Elements.Flatten().Where(x => x is FormElement).Cast<FormElement>()) {
child.FormBindingContentType = element.CreateContent == true ? element.ContentType : default(string);
}
}
private static bool IsCreatableContentType(ContentTypeDefinition contentTypeDefinition) {
var blacklist = new[] {"Site", "Layer"};
return !blacklist.Any(x => contentTypeDefinition.Name == x) && String.IsNullOrEmpty(contentTypeDefinition.Stereotype());
}
}
}

View File

@@ -0,0 +1,40 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Tokens;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class HiddenFieldDriver : FormsElementDriver<HiddenField> {
private readonly ITokenizer _tokenizer;
public HiddenFieldDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
_tokenizer = tokenizer;
}
protected override IEnumerable<string> FormNames {
get { yield return "HiddenField"; }
}
protected override void DescribeForm(DescribeContext context) {
context.Form("HiddenField", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "HiddenField",
_Span: shape.Textbox(
Id: "Value",
Name: "Value",
Title: "Value",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The value of this hidden field.")));
return form;
});
}
protected override void OnDisplaying(HiddenField element, ElementDisplayContext context) {
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
}
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.DynamicForms.Elements;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class IpAddressFieldDriver : ElementDriver<IpAddressField> { }
}

View File

@@ -0,0 +1,36 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class LabelDriver : FormsElementDriver<Label> {
public LabelDriver(IFormManager formManager) : base(formManager) {}
protected override IEnumerable<string> FormNames {
get { yield return "Label"; }
}
protected override void DescribeForm(DescribeContext context) {
context.Form("Label", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "Label",
_LabelText: shape.Textbox(
Id: "LabelText",
Name: "LabelText",
Title: "Text",
Classes: new[] { "text", "large" },
Description: T("The label text.")),
_LabelFor: shape.Textbox(
Id: "LabelFor",
Name: "LabelFor",
Title: "For",
Classes: new[] { "text", "large" },
Description: T("The name of the field this label is for.")));
return form;
});
}
}
}

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Tokens;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class RadioButtonDriver : FormsElementDriver<RadioButton> {
private readonly ITokenizer _tokenizer;
public RadioButtonDriver(IFormManager formManager, ITokenizer tokenizer)
: base(formManager) {
_tokenizer = tokenizer;
}
protected override IEnumerable<string> FormNames {
get {
yield return "AutoLabel";
yield return "RadioButton";
}
}
protected override void DescribeForm(DescribeContext context) {
context.Form("RadioButton", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "RadioButton",
Description: T("The label for this radio button."),
_Value: shape.Textbox(
Id: "Value",
Name: "Value",
Title: "Value",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The value of this radio button.")));
return form;
});
}
protected override void OnDisplaying(RadioButton element, ElementDisplayContext context) {
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.Value, null);
}
}
}

View File

@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Globalization;
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.Taxonomies.Models;
using Orchard.Taxonomies.Services;
using Orchard.Utility.Extensions;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
[OrchardFeature("Orchard.DynamicForms.Taxonomies")]
public class TaxonomyDriver : FormsElementDriver<Taxonomy> {
private readonly ITaxonomyService _taxonomyService;
public TaxonomyDriver(IFormManager formManager, ITaxonomyService taxonomyService)
: base(formManager) {
_taxonomyService = taxonomyService;
}
protected override IEnumerable<string> FormNames {
get {
yield return "AutoLabel";
yield return "TaxonomyForm";
}
}
protected override void DescribeForm(DescribeContext context) {
context.Form("TaxonomyForm", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "TaxonomyForm",
_OptionLabel: shape.Textbox(
Id: "OptionLabel",
Name: "OptionLabel",
Title: "Option Label",
Description: T("Optionally specify a label for the first option. If no label is specified, no empty option will be rendered.")),
_Taxonomy: shape.SelectList(
Id: "TaxonomyId",
Name: "TaxonomyId",
Title: "Taxonomy",
Description: T("Select the taxonomy to use as a source for the list.")),
_SortOrder: shape.SelectList(
Id: "SortOrder",
Name: "SortOrder",
Title: "Sort Order",
Description: T("The sort order to use when presenting the term values.")),
_ValueType_TermText: shape.Radio(
Id: "ValueType_TermText",
Name: "ValueType",
Title: "Use Term Name",
Checked: true,
Value: "TermText",
Description: T("Select this option to use the term name as the option value.")),
_ValueType_TermId: shape.Radio(
Id: "ValueType_TermId",
Name: "ValueType",
Title: "Use Term ID",
Checked: false,
Value: "TermId",
Description: T("Select this option to use the term ID as the option value.")),
_InputType: shape.SelectList(
Id: "InputType",
Name: "InputType",
Title: "Input Type",
Description: T("The control to render when presenting the list of options.")));
// Taxonomy
var taxonomies = _taxonomyService.GetTaxonomies();
foreach (var taxonomy in taxonomies) {
form._Taxonomy.Items.Add(new SelectListItem { Text = taxonomy.Name, Value = taxonomy.Id.ToString(CultureInfo.InvariantCulture) });
}
// Sort Order
form._SortOrder.Items.Add(new SelectListItem { Text = T("None").Text, Value = "" });
form._SortOrder.Items.Add(new SelectListItem { Text = T("Ascending").Text, Value = "Asc" });
form._SortOrder.Items.Add(new SelectListItem { Text = T("Descending").Text, Value = "Desc" });
// Input Type
form._InputType.Items.Add(new SelectListItem { Text = T("Select List").Text, Value = "SelectList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Multi Select List").Text, Value = "MultiSelectList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Radio List").Text, Value = "RadioList" });
form._InputType.Items.Add(new SelectListItem { Text = T("Check List").Text, Value = "CheckList" });
return form;
});
}
protected override void OnDisplaying(Taxonomy element, ElementDisplayContext context) {
var taxonomyId = element.TaxonomyId;
var typeName = element.GetType().Name;
var category = element.Category.ToSafeName();
var displayType = context.DisplayType;
context.ElementShape.TermOptions = GetTermOptions(element, taxonomyId).ToArray();
context.ElementShape.Metadata.Alternates.Add(String.Format("Element__{0}__{1}__{2}", category, typeName, element.InputType));
context.ElementShape.Metadata.Alternates.Add(String.Format("Element_{0}__{1}__{2}__{3}", displayType, category, typeName, element.InputType));
}
private IEnumerable<SelectListItem> GetTermOptions(Taxonomy element, int? taxonomyId) {
var optionLabel = element.OptionLabel;
if (!String.IsNullOrWhiteSpace(optionLabel)) {
yield return new SelectListItem { Text = optionLabel };
}
if (taxonomyId == null)
yield break;
var terms = _taxonomyService.GetTerms(taxonomyId.Value);
var valueAccessor = element.UseTermId ? (Func<TermPart, string>)(x => x.Id.ToString()) : (x => x.Name);
var projection = terms.Select(x => new SelectListItem {Text = x.Name, Value = valueAccessor(x)});
switch (element.SortOrder) {
case "Asc":
projection = projection.OrderBy(x => x.Text);
break;
case "Desc":
projection = projection.OrderByDescending(x => x.Text);
break;
}
foreach (var item in projection) {
yield return item;
}
}
}
}

View File

@@ -0,0 +1,55 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Tokens;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class TextAreaDriver : FormsElementDriver<TextArea> {
private readonly ITokenizer _tokenizer;
public TextAreaDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
_tokenizer = tokenizer;
}
protected override IEnumerable<string> FormNames {
get {
yield return "AutoLabel";
yield return "TextArea";
}
}
protected override void DescribeForm(DescribeContext context) {
context.Form("TextArea", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "TextArea",
_Value: shape.Textarea(
Id: "Value",
Name: "Value",
Title: "Value",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The value of this text area.")),
_Rows: shape.Textbox(
Id: "Rows",
Name: "Rows",
Title: "Rows",
Classes: new[] { "text", "small" },
Description: T("The number of rows for this text area.")),
_Columns: shape.Textbox(
Id: "Columns",
Name: "Columns",
Title: "Columns",
Classes: new[] { "text", "small" },
Description: T("The number of columns for this text area.")));
return form;
});
}
protected override void OnDisplaying(TextArea element, ElementDisplayContext context) {
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
}
}
}

View File

@@ -0,0 +1,81 @@
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Tokens;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Drivers {
public class TextFieldDriver : FormsElementDriver<TextField>{
private readonly ITokenizer _tokenizer;
public TextFieldDriver(IFormManager formManager, ITokenizer tokenizer) : base(formManager) {
_tokenizer = tokenizer;
}
protected override EditorResult OnBuildEditor(TextField element, ElementEditorContext context) {
var autoLabelEditor = BuildForm(context, "AutoLabel");
var textFieldEditor = BuildForm(context, "TextField");
var textFieldValidation = BuildForm(context, "TextFieldValidation", "Validation:10");
return Editor(context, autoLabelEditor, textFieldEditor, textFieldValidation);
}
protected override void DescribeForm(DescribeContext context) {
context.Form("TextField", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "TextField",
_Value: shape.Textbox(
Id: "Value",
Name: "Value",
Title: "Value",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The value of this text field.")));
return form;
});
context.Form("TextFieldValidation", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "TextFieldValidation",
_IsRequired: shape.Checkbox(
Id: "IsRequired",
Name: "IsRequired",
Title: "Required",
Value: "true",
Description: T("Tick this checkbox to make this text field a required field.")),
_MinimumLength: shape.Textbox(
Id: "MinimumLength",
Name: "MinimumLength",
Title: "Minimum Length",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The minimum length required.")),
_MaximumLength: shape.Textbox(
Id: "MaximumLength",
Name: "MaximumLength",
Title: "Maximum Length",
Classes: new[] { "text", "medium", "tokenized" },
Description: T("The maximum length allowed.")),
_CustomValidationMessage: shape.Textbox(
Id: "CustomValidationMessage",
Name: "CustomValidationMessage",
Title: "Custom Validation Message",
Classes: new[] { "text", "large", "tokenized" },
Description: T("Optionally provide a custom validation message.")),
_ShowValidationMessage: shape.Checkbox(
Id: "ShowValidationMessage",
Name: "ShowValidationMessage",
Title: "Show Validation Message",
Value: "true",
Description: T("Autogenerate a validation message when a validation error occurs for the current field. Alternatively, to control the placement of the validation message you can use the ValidationMessage element instead.")));
return form;
});
}
protected override void OnDisplaying(TextField element, ElementDisplayContext context) {
context.ElementShape.TokenizedValue = _tokenizer.Replace(element.RuntimeValue, null);
}
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.DynamicForms.Elements;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class UserNameFieldDriver : ElementDriver<UserNameField> { }
}

View File

@@ -0,0 +1,94 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using Orchard.DynamicForms.Elements;
//using Orchard.DynamicForms.Helpers;
//using Orchard.DynamicForms.Services;
//using Orchard.DynamicForms.Services.Models;
//using Orchard.DynamicForms.ViewModels;
//using Orchard.Forms.Services;
//using Orchard.Layouts.Framework.Display;
//using Orchard.Layouts.Framework.Drivers;
//using Orchard.Layouts.Helpers;
//namespace Orchard.DynamicForms.Drivers {
// public class ValidationElementDriver : ElementDriver<FormElement> {
// private readonly IValidationManager _validationManager;
// private readonly IFormManager _formManager;
// public ValidationElementDriver(IValidationManager validationManager, IFormManager formManager) {
// _validationManager = validationManager;
// _formManager = formManager;
// }
// protected override EditorResult OnBuildEditor(FormElement element, ElementEditorContext context) {
// var validatorNames = element.ValidatorNames.ToArray();
// var validators = new FieldValidationSettingsViewModel {
// Validators = _validationManager.GetValidatorsByNames(validatorNames).Select(x => new FieldValidationSettingViewModel() {
// Name = x.Name,
// SettingsEditor = BuildSettingsEditor(context, x)
// }).ToList()
// };
// if (context.Updater != null) {
// var viewModel = new FieldValidationSettingsViewModel();
// if (context.Updater.TryUpdateModel(viewModel, null, null, null)) {
// if (viewModel.Validators != null) {
// foreach (var validatorModel in viewModel.Validators) {
// var validator = validators.Validators.SingleOrDefault(x => x.Name == validatorModel.Name);
// if (validator == null)
// continue;
// validator.Enabled = validatorModel.Enabled;
// validator.CustomValidationMessage = validatorModel.CustomValidationMessage;
// }
// }
// validators.ShowValidationMessage = viewModel.ShowValidationMessage;
// }
// }
// // Fetch validation descriptors.
// foreach (var validator in validators.Validators) {
// validator.Descriptor = _validationManager.GetValidatorByName(validator.Name);
// }
// var validatorsEditor = context.ShapeFactory.EditorTemplate(TemplateName: "Validators", Model: validators);
// validatorsEditor.Metadata.Position = "Validation:10";
// return Editor(context, validatorsEditor);
// }
// protected override void OnDisplaying(FormElement element, ElementDisplayContext context) {
// if (context.DisplayType == "Design" || element.Form == null)
// return;
// if (element.Form.EnableClientValidation != true) {
// context.ElementShape.ClientValidationAttributes = new Dictionary<string, string>();
// return;
// }
// var clientAttributes = new Dictionary<string, string> {
// {"data-val", "true"}
// };
// foreach (var validatorSetting in element.ValidationSettings.Validators.Enabled()) {
// var validatorDescriptor = _validationManager.GetValidatorByName(validatorSetting.Name);
// var clientValidationRegistrationContext = new ClientValidationRegistrationContext(element, validatorSetting, validatorDescriptor);
// validatorDescriptor.ClientAttributes(clientValidationRegistrationContext);
// clientAttributes.Combine(clientValidationRegistrationContext.ClientAttributes);
// }
// context.ElementShape.ClientValidationAttributes = clientAttributes;
// }
// private dynamic BuildSettingsEditor(ElementEditorContext context, ValidatorDescriptor validatorDescriptor) {
// if (String.IsNullOrWhiteSpace(validatorDescriptor.SettingsFormName))
// return null;
// return _formManager.Bind(_formManager.Build(validatorDescriptor.SettingsFormName), context.ValueProvider);
// }
// }
//}

View File

@@ -0,0 +1,30 @@
using System.Collections.Generic;
using Orchard.DynamicForms.Elements;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class ValidationMessageDriver : FormsElementDriver<ValidationMessage> {
public ValidationMessageDriver(IFormManager formManager) : base(formManager) {}
protected override IEnumerable<string> FormNames {
get { yield return "ValidationMessage"; }
}
protected override void DescribeForm(DescribeContext context) {
context.Form("ValidationMessage", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "ValidationMessage",
_ValidationMessageFor: shape.Textbox(
Id: "ValidationMessageFor",
Name: "ValidationMessageFor",
Title: "For",
Classes: new[] { "text", "large" },
Description: T("The name of the field this validation message is for.")));
return form;
});
}
}
}

View File

@@ -0,0 +1,7 @@
using Orchard.DynamicForms.Elements;
using Orchard.Layouts.Framework.Drivers;
namespace Orchard.DynamicForms.Drivers {
public class ValidationSummaryDriver : ElementDriver<ValidationSummary> {
}
}

View File

@@ -0,0 +1,14 @@
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class Button : FormElement {
public override bool HasEditor {
get { return true; }
}
public string Text {
get { return State.Get("ButtonText", "Submit"); }
set { State["ButtonText"] = value; }
}
}
}

View File

@@ -0,0 +1,9 @@
using Orchard.DynamicForms.Validators.Settings;
namespace Orchard.DynamicForms.Elements {
public class CheckBox : LabeledFormElement {
public CheckBoxValidationSettings ValidationSettings {
get { return State.GetModel<CheckBoxValidationSettings>(""); }
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class Enumeration : LabeledFormElement {
private readonly Lazy<IEnumerable<SelectListItem>> _options;
public Enumeration() {
_options = new Lazy<IEnumerable<SelectListItem>>(GetOptions);
}
public IEnumerable<SelectListItem> Options {
get { return _options.Value; }
}
public string InputType {
get { return State.Get("InputType", "SelectList"); }
set { State["InputType"] = value; }
}
private IEnumerable<SelectListItem> GetOptions() {
return ParseOptionsText();
}
private IEnumerable<SelectListItem> ParseOptionsText() {
var data = State.Get("Options");
var lines = Regex.Split(data, @"(?:\r\n|[\r\n])", RegexOptions.Multiline);
return lines.Select(ParseLine).Where(x => x != null);
}
private static SelectListItem ParseLine(string line) {
if (String.IsNullOrWhiteSpace(line))
return null;
var parts = line.Split(':');
if (parts.Length == 1) {
var value = parts[0].Trim();
return new SelectListItem {
Text = value,
Value = value
};
}
else {
var text = parts[0].Trim();
var value = String.Join(":", parts.Skip(1)).Trim();
return new SelectListItem {
Text = text,
Value = value
};
}
}
}
}

View File

@@ -0,0 +1,60 @@
using Orchard.Layouts.Elements;
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class Form : Container {
public override string Category {
get { return "Form"; }
}
public string Name {
get { return State.Get("FormName"); }
set { State["FormName"] = value; }
}
public bool? EnableClientValidation {
get { return State.Get("EnableClientValidation").ToBoolean(); }
set { State["EnableClientValidation"] = value.ToString(); }
}
public string Action {
get { return State.Get("FormAction"); }
set { State["FormAction"] = value; }
}
public string Method {
get { return State.Get("FormMethod"); }
set { State["FormMethod"] = value; }
}
public bool? StoreSubmission {
get { return State.Get("StoreSubmission").ToBoolean(); }
set { State["StoreSubmission"] = value != null ? value.Value.ToString() : null; }
}
public bool? CreateContent {
get { return State.Get("CreateContent").ToBoolean(); }
set { State["CreateContent"] = value != null ? value.Value.ToString() : null; }
}
public string ContentType {
get { return State.Get("CreateContentType"); }
set { State["CreateContentType"] = value; }
}
public string Publication {
get { return State.Get("Publication"); }
set { State["Publication"] = value; }
}
public string Notification {
get { return State.Get("Notification"); }
set { State["Notification"] = value; }
}
public string RedirectUrl {
get { return State.Get("RedirectUrl"); }
set { State["RedirectUrl"] = value; }
}
}
}

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Framework.Harvesters;
namespace Orchard.DynamicForms.Elements {
public class FormCategoryProvider : Component, ICategoryProvider {
public IEnumerable<Category> GetCategories() {
yield return new Category("Form", T("Form"), T("Contains elements that help building forms."), 10);
}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public abstract class FormElement : Element {
private Lazy<string> _runtimeValue;
protected FormElement() {
_runtimeValue = new Lazy<string>(() => Value);
}
public override string Category {
get { return "Form"; }
}
public override bool HasEditor {
get { return true; }
}
public virtual string Name {
get { return State.Get("InputName"); }
}
public string Value {
get { return State.Get("Value"); }
}
public string RuntimeValue {
get { return _runtimeValue.Value; }
set { _runtimeValue = new Lazy<string>(() => value); }
}
public string FormBindingContentType {
get { return State.Get("FormBindingContentType"); }
set { State["FormBindingContentType"] = value; }
}
public Form Form {
get {
var parent = Container;
while (parent != null) {
var form = parent as Form;
if (form != null)
return form;
parent = parent.Container;
}
return null;
}
}
}
}

View File

@@ -0,0 +1,4 @@
namespace Orchard.DynamicForms.Elements {
public class HiddenField : FormElement {
}
}

View File

@@ -0,0 +1,11 @@
namespace Orchard.DynamicForms.Elements {
public class IpAddressField : FormElement {
public override bool HasEditor {
get { return false; }
}
public override string Name {
get { return "IPAddress"; }
}
}
}

View File

@@ -0,0 +1,24 @@
using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class Label : Element {
public override string Category {
get { return "Form"; }
}
public override bool HasEditor {
get { return true; }
}
public string Text {
get { return State.Get("LabelText"); }
set { State["LabelText"] = value; }
}
public string For {
get { return State.Get("LabelFor"); }
set { State["LabelFor"] = value; }
}
}
}

View File

@@ -0,0 +1,15 @@
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public abstract class LabeledFormElement : FormElement {
public string Label {
get { return State.Get("Label"); }
set { State["Label"] = value; }
}
public bool ShowLabel {
get { return State.Get("ShowLabel").ToBoolean().GetValueOrDefault(); }
set { State["ShowLabel"] = value.ToString(); }
}
}
}

View File

@@ -0,0 +1,4 @@
namespace Orchard.DynamicForms.Elements {
public class RadioButton : LabeledFormElement {
}
}

View File

@@ -0,0 +1,30 @@
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class Taxonomy : LabeledFormElement {
public string InputType {
get { return State.Get("InputType", "SelectList"); }
set { State["InputType"] = value; }
}
public int? TaxonomyId {
get { return State.Get("TaxonomyId").ToInt32(); }
set { State["TaxonomyId"] = value.ToString(); }
}
public string SortOrder {
get { return State.Get("SortOrder"); }
set { State["SortOrder"] = value; }
}
public string OptionLabel {
get { return State.Get("OptionLabel"); }
set { State["OptionLabel"] = value; }
}
public bool UseTermId {
get { return State.Get("ValueType") == "TermId"; }
}
}
}

View File

@@ -0,0 +1,15 @@
using Orchard.Layouts.Helpers;
namespace Orchard.DynamicForms.Elements {
public class TextArea : LabeledFormElement {
public int? Rows {
get { return State.Get("Rows").ToInt32(); }
set { State["Rows"] = value.ToString(); }
}
public int? Columns {
get { return State.Get("Columns").ToInt32(); }
set { State["Columns"] = value.ToString(); }
}
}
}

View File

@@ -0,0 +1,9 @@
using Orchard.DynamicForms.Validators.Settings;
namespace Orchard.DynamicForms.Elements {
public class TextField : LabeledFormElement {
public TextFieldValidationSettings ValidationSettings {
get { return State.GetModel<TextFieldValidationSettings>(""); }
}
}
}

View File

@@ -0,0 +1,11 @@
namespace Orchard.DynamicForms.Elements {
public class UserNameField : FormElement {
public override bool HasEditor {
get { return false; }
}
public override string Name {
get { return "UserName"; }
}
}
}

View File

@@ -0,0 +1,13 @@
using Orchard.Layouts.Framework.Elements;
namespace Orchard.DynamicForms.Elements {
public class ValidationMessage : Element {
public override string Category {
get { return "Form"; }
}
public override bool HasEditor {
get { return true; }
}
}
}

View File

@@ -0,0 +1,13 @@
using Orchard.Layouts.Framework.Elements;
namespace Orchard.DynamicForms.Elements {
public class ValidationSummary : Element {
public override string Category {
get { return "Form"; }
}
public override bool HasEditor {
get { return false; }
}
}
}

View File

@@ -0,0 +1,30 @@
using Orchard.Forms.Services;
using DescribeContext = Orchard.Forms.Services.DescribeContext;
namespace Orchard.DynamicForms.Forms {
public class AutoLabelForm : Component, IFormProvider {
public void Describe(DescribeContext context) {
context.Form("AutoLabel", factory => {
var shape = (dynamic)factory;
var form = shape.Fieldset(
Id: "AutoLabel",
_ShowLabel: shape.Checkbox(
Id: "ShowLabel",
Name: "ShowLabel",
Title: "Show Label",
Value: "true",
Description: T("Check this to show a label for this text field.")),
_Label: shape.Textbox(
Id: "Label",
Name: "Label",
Title: "Label",
Classes: new[] { "text", "large", "tokenized" },
Description: T("The label text to render."),
EnabledBy: "ShowLabel"));
return form;
});
}
}
}

View File

@@ -0,0 +1,45 @@
using System.Linq;
using Orchard.DynamicForms.Elements;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Services;
namespace Orchard.DynamicForms.Handlers {
public class ClientValidationRegistrationCoordinator : IFormElementEventHandler, IElementEventHandler {
private readonly IFormService _formService;
public ClientValidationRegistrationCoordinator(IFormService formService) {
_formService = formService;
}
void IFormElementEventHandler.RegisterClientValidation(RegisterClientValidationAttributesEventContext context) {
var validators = _formService.GetValidators(context.Element).ToArray();
foreach (var validator in validators) {
validator.RegisterClientValidation(context);
}
}
void IElementEventHandler.Displaying(ElementDisplayContext context) {
var element = context.Element as FormElement;
if (element == null)
return;
var registrationContext = new RegisterClientValidationAttributesEventContext { Element = element };
if (element.Form.EnableClientValidation == true) {
_formService.RegisterClientValidationAttributes(registrationContext);
}
context.ElementShape.ClientValidationAttributes = registrationContext.ClientAttributes;
}
void IFormElementEventHandler.GetElementValue(FormElement element, ReadElementValuesContext context) { }
void IElementEventHandler.Creating(ElementCreatingContext context) {}
void IElementEventHandler.Created(ElementCreatedContext context) {}
void IElementEventHandler.BuildEditor(ElementEditorContext context) {}
void IElementEventHandler.UpdateEditor(ElementEditorContext context) {}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.DynamicForms.Activities;
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
using Orchard.Layouts.Helpers;
using Orchard.UI.Notify;
using Orchard.Workflows.Services;
namespace Orchard.DynamicForms.Handlers {
public class FormSubmissionCoordinator : FormEventHandlerBase {
private readonly INotifier _notifier;
private readonly IWorkflowManager _workflowManager;
public FormSubmissionCoordinator(INotifier notifier, IWorkflowManager workflowManager) {
_notifier = notifier;
_workflowManager = workflowManager;
}
public override void Validated(FormValidatedEventContext context) {
if (!context.ModelState.IsValid)
return;
var form = context.Form;
var formName = form.Name;
var values = context.Values;
var formService = context.FormService;
// Store the submission.
if (form.StoreSubmission == true) {
formService.CreateSubmission(formName, values);
}
// Create content item.
var contentItem = default(ContentItem);
if (form.CreateContent == true && !String.IsNullOrWhiteSpace(form.ContentType)) {
contentItem = formService.CreateContentItem(form, context.ValueProvider);
}
// Notifiy.
if (!String.IsNullOrWhiteSpace(form.Notification))
_notifier.Information(T(form.Notification));
// Trigger workflow event.
var formValuesDictionary = values.ToTokenDictionary();
_workflowManager.TriggerEvent(FormSubmittedActivity.EventName, contentItem, () => new Dictionary<string, object>(formValuesDictionary) {
{"DynamicForm", form}
});
}
}
}

View File

@@ -0,0 +1,23 @@
using Orchard.AuditTrail.Services;
using Orchard.DynamicForms.Elements;
using Orchard.DynamicForms.Services;
namespace Orchard.DynamicForms.Handlers {
public class IpAddressFieldHandler : FormElementEventHandlerBase {
private readonly IClientIpAddressProvider _clientIpAddressProvider;
public IpAddressFieldHandler(IClientIpAddressProvider clientIpAddressProvider) {
_clientIpAddressProvider = clientIpAddressProvider;
}
public override void GetElementValue(FormElement element, ReadElementValuesContext context) {
var ipAddressField = element as IpAddressField;
if (ipAddressField == null)
return;
var key = ipAddressField.Name;
context.Output[key] = _clientIpAddressProvider.GetClientIpAddress();
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using Orchard.DynamicForms.Elements;
using Orchard.DynamicForms.Services;
namespace Orchard.DynamicForms.Handlers {
public class ReadFormValuesHandler : FormElementEventHandlerBase {
public override void GetElementValue(FormElement element, ReadElementValuesContext context) {
if (String.IsNullOrWhiteSpace(element.Name))
return;
var key = element.Name;
var valueProviderResult = context.ValueProvider.GetValue(key);
if (String.IsNullOrWhiteSpace(key) || valueProviderResult == null)
return;
var items = valueProviderResult.RawValue as string[];
if (items == null)
return;
foreach (var item in items) {
context.Output[key] = item;
}
element.RuntimeValue = String.Join(",", items);
}
}
}

View File

@@ -0,0 +1,22 @@
using Orchard.DynamicForms.Elements;
using Orchard.DynamicForms.Services;
namespace Orchard.DynamicForms.Handlers {
public class UserNameFieldHandler : FormElementEventHandlerBase {
private readonly IWorkContextAccessor _wca;
public UserNameFieldHandler(IWorkContextAccessor wca) {
_wca = wca;
}
public override void GetElementValue(FormElement element, ReadElementValuesContext context) {
var userNameField = element as UserNameField;
if (userNameField == null)
return;
var key = userNameField.Name;
var currentUser = _wca.GetContext().CurrentUser;
context.Output[key] = currentUser != null ? currentUser.UserName : null;
}
}
}

View File

@@ -0,0 +1,30 @@
using Orchard.DynamicForms.Services;
using Orchard.DynamicForms.Services.Models;
namespace Orchard.DynamicForms.Handlers {
public class ValidatorsCoordinator : FormEventHandlerBase {
public override void Validating(FormValidatingEventContext context) {
var form = context.Form;
var values = context.Values;
var formService = context.FormService;
var formElements = formService.GetFormElements(form);
var modelState = context.ModelState;
// Get the validators for each element and validate its submitted values.
foreach (var element in formElements) {
var validators = formService.GetValidators(element);
var attemptedValue = values[element.Name];
foreach (var validator in validators) {
var validateContext = new ValidateInputContext {
Element = element,
ModelState = modelState,
AttemptedValue = attemptedValue,
FieldName = element.Name
};
validator.Validate(validateContext);
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.DynamicForms.Helpers {
public static class ContentTypeDefinitionExtensions {
public static string Stereotype(this ContentTypeDefinition contentTypeDefinition) {
return contentTypeDefinition.Settings.ContainsKey("Stereotype") ? contentTypeDefinition.Settings["Stereotype"] : null;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Data;
using System.IO;
using System.Linq;
namespace Orchard.DynamicForms.Helpers {
public static class DataTableExtensions {
public static string ToCsv(this DataTable table, string delimiter = ",", bool includeHeader = true) {
using (var writer = new StringWriter()) {
ToCsv(table, writer, delimiter, includeHeader);
return writer.GetStringBuilder().ToString();
}
}
public static Stream ToCsv(this DataTable table, Stream output, string delimiter = ",", bool includeHeader = true) {
var writer = new StreamWriter(output);
ToCsv(table, writer, delimiter, includeHeader);
return output;
}
public static TextWriter ToCsv(this DataTable table, TextWriter writer, string delimiter = ",", bool includeHeader = true) {
if (includeHeader) {
var columnNames = table.Columns.Cast<DataColumn>().Select(column => column.ColumnName);
writer.WriteLine(String.Join(",", columnNames));
}
var projection =
from DataRow row in table.Rows
select row.ItemArray.Select(field => String.Concat("\"", field.ToString().Replace("\"", "\"\""), "\""));
foreach (var fields in projection) {
writer.WriteLine(String.Join(",", fields));
}
writer.Flush();
return writer;
}
}
}

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using Orchard.DynamicForms.Services.Models;
namespace Orchard.DynamicForms.Helpers {
public static class FieldValidatorsExtensions {
public static IEnumerable<FieldValidatorSetting> Enabled(this IEnumerable<FieldValidatorSetting> list) {
return list.Where(x => x.Enabled);
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web.Mvc;
using Orchard.DynamicForms.Elements;
namespace Orchard.DynamicForms.Helpers {
internal static class FormControllerExtensions {
internal static void TransferFormSubmission(this Controller controller, Form form, NameValueCollection values) {
controller.TempData[String.Format("Form_ModelState_{0}", form.Name)] = controller.ModelState;
controller.TempData[String.Format("Form_Values_{0}", form.Name)] = values;
}
internal static ModelStateDictionary FetchModelState(this Controller controller, Form form) {
return (ModelStateDictionary)controller.TempData[String.Format("Form_ModelState_{0}", form.Name)];
}
internal static NameValueCollection FetchPostedValues(this Controller controller, Form form) {
return (NameValueCollection)controller.TempData[String.Format("Form_Values_{0}", form.Name)] ?? new NameValueCollection();
}
internal static void ApplyAnyModelErrors(this Controller controller, Form form, ModelStateDictionary modelState) {
var hasErrors = modelState != null && !modelState.IsValid;
if (hasErrors) {
foreach (var state in modelState) {
if (state.Value.Errors.Any()) {
foreach (var error in state.Value.Errors) {
controller.ModelState.AddModelError(state.Key, error.ErrorMessage);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
namespace Orchard.DynamicForms.Helpers {
public static class NameValueCollectionExtensions {
public static string ToQueryString(this NameValueCollection nameValues) {
return String.Join("&", (from string name in nameValues select String.Concat(name, "=", HttpUtility.UrlEncode(nameValues[name]))).ToArray());
}
}
}

View File

@@ -0,0 +1,10 @@
using System.IO;
namespace Orchard.DynamicForms.Helpers {
public static class StreamExtensions {
public static T Reset<T>(this T stream) where T:Stream {
stream.Position = 0;
return stream;
}
}
}

Some files were not shown because too many files have changed in this diff Show More