From 3d7a6a517b019688776fff0cce8355a06c344d89 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 3 Mar 2010 11:32:00 -0800 Subject: [PATCH 1/8] Adding a Futures project to hold Widget concept Conceptual implementation of Widget and HasWidgets parts Adds "HtmlWidget" content type and "Widget" display type WidgetFilter adds widget display view models to named zones (for non-admin requests) --HG-- branch : dev --- .../Controllers/AdminController.cs | 68 ++++++++ .../Controllers/WidgetDriver.cs | 20 +++ .../Controllers/WidgetHandler.cs | 50 ++++++ .../Futures.Widgets/Futures.Widgets.csproj | 118 ++++++++++++++ .../Futures.Widgets/Models/HasWidgets.cs | 14 ++ .../Modules/Futures.Widgets/Models/Widget.cs | 13 ++ .../Modules/Futures.Widgets/Module.txt | 1 + .../Properties/AssemblyInfo.cs | 35 ++++ .../ViewModels/WidgetEditViewModel.cs | 8 + .../Futures.Widgets/Views/Admin/Edit.ascx | 12 ++ .../Modules/Futures.Widgets/Views/Web.config | 34 ++++ .../Modules/Futures.Widgets/Web.config | 154 ++++++++++++++++++ .../Modules/Futures.Widgets/WidgetFilter.cs | 43 +++++ .../Parts/DevTools.ShowDebugLink.ascx | 2 +- src/Orchard.Web/Orchard.Web.csproj | 4 + src/Orchard.sln | 9 + .../UI/Zones/ContentItemDisplayZoneItem.cs | 3 +- .../UI/Zones/ContentPartDisplayZoneItem.cs | 4 +- 18 files changed, 588 insertions(+), 4 deletions(-) create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Controllers/AdminController.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetDriver.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetHandler.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Models/HasWidgets.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Models/Widget.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Module.txt create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Properties/AssemblyInfo.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/ViewModels/WidgetEditViewModel.cs create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Views/Admin/Edit.ascx create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Views/Web.config create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/Web.config create mode 100644 src/Orchard.Web/Modules/Futures.Widgets/WidgetFilter.cs diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/AdminController.cs new file mode 100644 index 000000000..6706ed689 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/AdminController.cs @@ -0,0 +1,68 @@ +using System; +using System.Web.Mvc; +using Futures.Widgets.Models; +using Futures.Widgets.ViewModels; +using Orchard; +using Orchard.ContentManagement; +using Orchard.Core.Common.Models; +using Orchard.Localization; +using Orchard.Settings; + +namespace Futures.Widgets.Controllers { + [ValidateInput(false)] + public class AdminController : Controller, IUpdateModel { + public AdminController(IOrchardServices services) { + Services = services; + } + + private IOrchardServices Services { get; set; } + protected virtual ISite CurrentSite { get; set; } + + public ActionResult AddWidget() { + var hasWidgetsRecord = CurrentSite.As().Record; + + var widget = Services.ContentManager.Create("HtmlWidget", init => { + init.Record.Scope = hasWidgetsRecord; + init.Record.Zone = "content"; + init.Record.Position = "after"; + init.As().Text = "Hello world!"; + }); + + return RedirectToAction("Edit", new {widget.ContentItem.Id }); + } + + public ActionResult Edit(int id, string returnUrl) { + var widget = Services.ContentManager.Get(id); + var viewModel = new WidgetEditViewModel { + Widget = Services.ContentManager.BuildEditorModel(widget), + ReturnUrl = returnUrl, + }; + return View(viewModel); + } + + [HttpPost, ActionName("Edit")] + public ActionResult EditPOST(int id, string returnUrl) { + var widget = Services.ContentManager.Get(id); + var viewModel = new WidgetEditViewModel { + Widget = Services.ContentManager.UpdateEditorModel(widget, this), + ReturnUrl = returnUrl, + }; + if (ModelState.IsValid == false) { + return View(viewModel); + } + if (string.IsNullOrEmpty(returnUrl)) { + return RedirectToAction("Edit", new { id }); + } + return Redirect(returnUrl); + } + + + bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { + return TryUpdateModel(model, prefix, includeProperties, excludeProperties); + } + + void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) { + ModelState.AddModelError(key, errorMessage.ToString()); + } + } +} diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetDriver.cs b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetDriver.cs new file mode 100644 index 000000000..226c08f12 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetDriver.cs @@ -0,0 +1,20 @@ +using System.Web.Routing; +using Futures.Widgets.Models; +using Orchard.ContentManagement.Drivers; + +namespace Futures.Widgets.Controllers { + public class WidgetDriver : ContentItemDriver { + protected override RouteValueDictionary GetEditorRouteValues(Widget item) { + return new RouteValueDictionary { + {"Area", "Futures.Widgets"}, + {"Controller", "Admin"}, + {"Action", "Edit"}, + {"Id", item.ContentItem.Id} + }; + } + + protected override bool UseDefaultTemplate { + get { return true; } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetHandler.cs b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetHandler.cs new file mode 100644 index 000000000..84ffd1181 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetHandler.cs @@ -0,0 +1,50 @@ +using System.Linq; +using System.Web.Routing; +using Futures.Widgets.Models; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Core.Common.Models; +using Orchard.Data; + +namespace Futures.Widgets.Controllers { + public class WidgetHandler : ContentHandler { + public WidgetHandler( + IRepository hasWidgetRepository, + IRepository widgetRepository) { + + // marking the "site" content type as a widget container + Filters.Add(new ActivatingFilter("site")); + + // adding parts to the "HtmlWidget" content type + Filters.Add(new ActivatingFilter("HtmlWidget")); + Filters.Add(new ActivatingFilter("HtmlWidget")); + + // providing standard storage support for widget records + Filters.Add(StorageFilter.For(hasWidgetRepository)); + Filters.Add(StorageFilter.For(widgetRepository)); + + OnLoaded( + (ctx, part) => part.WidgetField.Loader( + () => ctx.ContentManager + .Query() + .Where(x => x.Scope == part.Record) + .List().ToList())); + } + } + + public class WidgetDriver : ContentItemDriver { + protected override RouteValueDictionary GetEditorRouteValues(Widget item) { + return new RouteValueDictionary { + {"Area", "Futures.Widgets"}, + {"Controller", "Admin"}, + {"Action", "Edit"}, + {"Id", item.ContentItem.Id} + }; + } + + protected override bool UseDefaultTemplate { + get { return true; } + } + } +} diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj new file mode 100644 index 000000000..8ee420c90 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj @@ -0,0 +1,118 @@ + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {E65E5633-C0FF-453C-A906-481C14F969D6} + {F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Futures.Widgets + Futures.Widgets + v3.5 + false + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + False + ..\..\..\..\..\..\Program Files\Microsoft ASP.NET\ASP.NET MVC 2\\Assemblies\System.Web.Mvc.dll + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} + Orchard + + + {9916839C-39FC-4CEB-A5AF-89CA7E87119F} + Orchard.Core + + + + + + + + + + + + + + + + False + True + 17593 + / + + + False + True + http://orchard.codeplex.com + False + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Models/HasWidgets.cs b/src/Orchard.Web/Modules/Futures.Widgets/Models/HasWidgets.cs new file mode 100644 index 000000000..b30dde572 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Models/HasWidgets.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Records; +using Orchard.Core.Common.Utilities; + +namespace Futures.Widgets.Models { + public class HasWidgets : ContentPart { + public LazyField> WidgetField = new LazyField>(); + public IList Widgets { get { return WidgetField.Value; } set { WidgetField.Value = value; } } + } + + public class HasWidgetsRecord : ContentPartRecord { + } +} diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Models/Widget.cs b/src/Orchard.Web/Modules/Futures.Widgets/Models/Widget.cs new file mode 100644 index 000000000..c2c693eec --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Models/Widget.cs @@ -0,0 +1,13 @@ +using Orchard.ContentManagement; +using Orchard.ContentManagement.Records; + +namespace Futures.Widgets.Models { + public class Widget : ContentPart { + } + + public class WidgetRecord : ContentPartRecord { + public virtual HasWidgetsRecord Scope { get; set; } + public virtual string Zone { get; set; } + public virtual string Position { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Module.txt b/src/Orchard.Web/Modules/Futures.Widgets/Module.txt new file mode 100644 index 000000000..b38d568c2 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Module.txt @@ -0,0 +1 @@ +name: Widgets diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Properties/AssemblyInfo.cs b/src/Orchard.Web/Modules/Futures.Widgets/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..b0a50137d --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Futures.Widgets")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft IT")] +[assembly: AssemblyProduct("Futures.Widgets")] +[assembly: AssemblyCopyright("Copyright © Microsoft IT 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8c179868-e814-4277-a0af-b71707c3bff4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Orchard.Web/Modules/Futures.Widgets/ViewModels/WidgetEditViewModel.cs b/src/Orchard.Web/Modules/Futures.Widgets/ViewModels/WidgetEditViewModel.cs new file mode 100644 index 000000000..1f288285e --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/ViewModels/WidgetEditViewModel.cs @@ -0,0 +1,8 @@ +using Orchard.Mvc.ViewModels; + +namespace Futures.Widgets.ViewModels { + public class WidgetEditViewModel : BaseViewModel { + public ContentItemViewModel Widget { get; set; } + public string ReturnUrl { get; set;} + } +} diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Views/Admin/Edit.ascx b/src/Orchard.Web/Modules/Futures.Widgets/Views/Admin/Edit.ascx new file mode 100644 index 000000000..f42d7c0cf --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Views/Admin/Edit.ascx @@ -0,0 +1,12 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Futures.Widgets.ViewModels" %> +<%@ Import Namespace="Orchard.Mvc.Html" %> +

<%=Html.TitleForPage(T("Edit Widget").ToString()) %>

+<% using (Html.BeginFormAntiForgeryPost()) { %> + <%= Html.ValidationSummary() %> + <%= Html.EditorForItem(m => m.Widget) %> +
+ <%= Html.HiddenFor(m => m.ReturnUrl) %> + +
+<%} %> diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Views/Web.config b/src/Orchard.Web/Modules/Futures.Widgets/Views/Web.config new file mode 100644 index 000000000..7022197d4 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Views/Web.config @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Web.config b/src/Orchard.Web/Modules/Futures.Widgets/Web.config new file mode 100644 index 000000000..b1c399e16 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/Web.config @@ -0,0 +1,154 @@ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Futures.Widgets/WidgetFilter.cs b/src/Orchard.Web/Modules/Futures.Widgets/WidgetFilter.cs new file mode 100644 index 000000000..dd6f14fc3 --- /dev/null +++ b/src/Orchard.Web/Modules/Futures.Widgets/WidgetFilter.cs @@ -0,0 +1,43 @@ +using System; +using System.Linq; +using System.Web.Mvc; +using Futures.Widgets.Models; +using Orchard.ContentManagement; +using Orchard.Mvc.Filters; +using Orchard.Mvc.ViewModels; +using Orchard.Settings; +using Orchard.UI.Admin; + +namespace Futures.Widgets { + public class WidgetFilter : FilterProvider, IActionFilter { + private readonly IContentManager _contentManager; + + public WidgetFilter(IContentManager contentManager) { + _contentManager = contentManager; + } + + public virtual ISite CurrentSite { get; set; } + + public void OnActionExecuting(ActionExecutingContext filterContext) { + } + + public void OnActionExecuted(ActionExecutedContext filterContext) { + var model = BaseViewModel.From(filterContext.Result); + if (model == null || AdminFilter.IsApplied(filterContext.RequestContext)) { + return; + } + + var siteWidgets = CurrentSite.As(); + if (siteWidgets == null) { + return; + } + + var zones = model.Zones; + foreach (var widget in siteWidgets.Widgets) { + zones.AddDisplayItem( + widget.Record.Zone + ":" + widget.Record.Position, + _contentManager.BuildDisplayModel(widget, "Widget")); + } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Views/DisplayTemplates/Parts/DevTools.ShowDebugLink.ascx b/src/Orchard.Web/Modules/Orchard.DevTools/Views/DisplayTemplates/Parts/DevTools.ShowDebugLink.ascx index b5ced4224..0ff4e2ef6 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Views/DisplayTemplates/Parts/DevTools.ShowDebugLink.ascx +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Views/DisplayTemplates/Parts/DevTools.ShowDebugLink.ascx @@ -1,6 +1,6 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.DevTools.Models" %>
<%=T( - "DevTools: editing {0}", + "DevTools: displaying {0}", Html.ActionLink(T("{0} #{1} v{2}", Model.ContentItem.ContentType, Model.ContentItem.Id, Model.ContentItem.Version).ToString(), "details", "content", new { area = "Orchard.DevTools", Model.ContentItem.Id, Model.ContentItem.Version }, new { }) ) %>
diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 184187747..260d326dd 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -102,6 +102,10 @@ {9916839C-39FC-4CEB-A5AF-89CA7E87119F} Orchard.Core + + {E65E5633-C0FF-453C-A906-481C14F969D6} + Futures.Widgets + {63FBD4D9-E1DA-4A7B-AA6A-D6074FE50867} Orchard.Blogs diff --git a/src/Orchard.sln b/src/Orchard.sln index f0297539d..6035c7e86 100644 --- a/src/Orchard.sln +++ b/src/Orchard.sln @@ -47,6 +47,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuild.Orchard.Tasks", "To EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuild.Orchard.Tasks.Tests", "Tools\MSBuild.Orchard.Tasks.Tests\MSBuild.Orchard.Tasks.Tests.csproj", "{4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Futures", "Futures", "{E75A4CE4-CAA6-41E4-B951-33ACC60DC77C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Futures.Widgets", "Orchard.Web\Modules\Futures.Widgets\Futures.Widgets.csproj", "{E65E5633-C0FF-453C-A906-481C14F969D6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -133,6 +137,10 @@ Global {4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56}.Debug|Any CPU.Build.0 = Debug|Any CPU {4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56}.Release|Any CPU.ActiveCfg = Release|Any CPU {4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56}.Release|Any CPU.Build.0 = Release|Any CPU + {E65E5633-C0FF-453C-A906-481C14F969D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E65E5633-C0FF-453C-A906-481C14F969D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E65E5633-C0FF-453C-A906-481C14F969D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E65E5633-C0FF-453C-A906-481C14F969D6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -155,5 +163,6 @@ Global {8C7FCBC2-E6E1-405E-BFB5-D8D9E67A09C4} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5} {5E5E7A21-C7B2-44D8-8593-2F9541AE041D} = {383DBA32-4A3E-48D1-AAC3-75377A694452} {4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56} = {383DBA32-4A3E-48D1-AAC3-75377A694452} + {E65E5633-C0FF-453C-A906-481C14F969D6} = {E75A4CE4-CAA6-41E4-B951-33ACC60DC77C} EndGlobalSection EndGlobal diff --git a/src/Orchard/UI/Zones/ContentItemDisplayZoneItem.cs b/src/Orchard/UI/Zones/ContentItemDisplayZoneItem.cs index 604b3aba6..5e5857f84 100644 --- a/src/Orchard/UI/Zones/ContentItemDisplayZoneItem.cs +++ b/src/Orchard/UI/Zones/ContentItemDisplayZoneItem.cs @@ -7,7 +7,8 @@ namespace Orchard.UI.Zones { public ContentItemViewModel ViewModel { get; set; } public override void Execute(HtmlHelper html) { - html.DisplayForItem(ViewModel); + var htmlString = html.DisplayForItem(ViewModel); + html.ViewContext.Writer.Write(htmlString); } } } \ No newline at end of file diff --git a/src/Orchard/UI/Zones/ContentPartDisplayZoneItem.cs b/src/Orchard/UI/Zones/ContentPartDisplayZoneItem.cs index 91f587c41..f9e8ea408 100644 --- a/src/Orchard/UI/Zones/ContentPartDisplayZoneItem.cs +++ b/src/Orchard/UI/Zones/ContentPartDisplayZoneItem.cs @@ -8,8 +8,8 @@ namespace Orchard.UI.Zones { public string Prefix { get; set; } public override void Execute(HtmlHelper html) { - html.ViewContext.Writer.Write( - html.DisplayFor(m => Model, TemplateName, Prefix)); + var htmlString = html.DisplayFor(m => Model, TemplateName, Prefix); + html.ViewContext.Writer.Write(htmlString); } } } \ No newline at end of file From f812a4d3731b38c773f42f9cea7292e4d3976fd1 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Wed, 3 Mar 2010 14:55:22 -0800 Subject: [PATCH 2/8] Adding an AddMedia TinyMCE plugin, that doesn't yet do anything --HG-- branch : dev --- .../Scripts/plugins/addmedia/addmedia.htm | 36 ++++++++++ .../Scripts/plugins/addmedia/editor_plugin.js | 68 ++++++++++++++++++ .../plugins/addmedia/img/picture_add.png | Bin 0 -> 750 bytes .../Scripts/plugins/addmedia/js/addmedia.js | 1 + .../Scripts/plugins/addmedia/langs/en_dlg.js | 4 ++ .../Modules/TinyMce/TinyMce.csproj | 11 +++ .../EditorTemplates/TinyMceTextEditor.ascx | 4 +- 7 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm create mode 100644 src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/editor_plugin.js create mode 100644 src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/img/picture_add.png create mode 100644 src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/js/addmedia.js create mode 100644 src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/langs/en_dlg.js diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm new file mode 100644 index 000000000..4d8ff00a1 --- /dev/null +++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm @@ -0,0 +1,36 @@ + + + + {#addmedia_dlg.title} + + + + +
+ +
+ + + + + +
+ + +
+
+
+ + +
+
+ +
+
+
+ + diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/editor_plugin.js b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/editor_plugin.js new file mode 100644 index 000000000..9ce4962e2 --- /dev/null +++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/editor_plugin.js @@ -0,0 +1,68 @@ +(function() { + // Load plugin specific language pack + tinymce.PluginManager.requireLangPack('dlg'); + + tinymce.create('tinymce.plugins.Orchard.AddMedia', { + /** + * Initializes the plugin, this will be executed after the plugin has been created. + * This call is done before the editor instance has finished it's initialization so use the onInit event + * of the editor instance to intercept that event. + * + * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. + * @param {string} url Absolute URL to where the plugin is located. + */ + init: function(ed, url) { + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); + ed.addCommand('mceAddMedia', function() { + ed.windowManager.open({ + file: url + '/addmedia.htm', + width: 480 + parseInt(ed.getLang('addmedia.delta_width', 0)), + height: 110 + parseInt(ed.getLang('addmedia.delta_height', 0)), + inline: 1 + }, { + plugin_url: url, // Plugin absolute URL + }); + }); + + // Register example button + ed.addButton('addmedia', { + title: 'addmedia_desc', + cmd: 'mceAddMedia', + image: url + '/img/picture_add.png' + }); + }, + + /** + * Creates control instances based in the incomming name. This method is normally not + * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons + * but you sometimes need to create more complex controls like listboxes, split buttons etc then this + * method can be used to create those. + * + * @param {String} n Name of the control to create. + * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. + * @return {tinymce.ui.Control} New control instance or null if no control was created. + */ + createControl: function(n, cm) { + return null; + }, + + /** + * Returns information about the plugin as a name/value array. + * The current keys are longname, author, authorurl, infourl and version. + * + * @return {Object} Name/value array containing information about the plugin. + */ + getInfo: function() { + return { + longname: 'Orchard AddMedia Plugin', + author: 'Nathan Heskew', + authorurl: 'http://orchardproject.net', + infourl: 'http://orchardproject.net', + version: '0.1' + }; + } + }); + + // Register plugin + tinymce.PluginManager.add('addmedia', tinymce.plugins.Orchard.AddMedia); +})(); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/img/picture_add.png b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/img/picture_add.png new file mode 100644 index 0000000000000000000000000000000000000000..9e9d5da9d1e5c3fbd108265e178c5d1ea779b5b9 GIT binary patch literal 750 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQa%*9TgAsieWw;%dHU|?WW3-AeX z{r~^JPqpE~&FAK z-M0(Rb{)F2|M1OSM=!76c4f|%D^pLNn6v6)%Zf`S%Pur6JTrO0+1iDBU(7s{Hh=f? z87H%*pGcm)Wd-Z!G>h=WHZ(ewLe#pi7A?=&;TbAFc*-+86 z?0D^>n-#0(H?B^sUY%XL=xEja>s71#%I97yo_n}tnOEk#Sy?leW=&hXzRf;;mP5+q ziCNRUbEkyIPwHv!c8r_Qnbzmu&>S|a+O(`GE}_dKyk9rCMa>QWe}Xi&D$;i?WLqoP$l+HeFr-RCm(T#W6%;YI4E?-h`y*4_X-c z(pD%~+w=2$;4E-pwX85HJ)5esG_+=q&Ci6UIX1J@jDkLSbye+q*TmtNYMiMWnk(BY zpx&aee$&=9tNK<>O_b<39Ez>4mdQo&kQ2+FB+ihb}Tj zUO0T%`qHs$_6iynHhqF>8ag^US_}1(o+#<12pnz_U}?-KEX=EIcG;jHZLiOAq`R=V zxZ9a!W~8Npg5&)ew + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/TinyMce/Views/EditorTemplates/TinyMceTextEditor.ascx b/src/Orchard.Web/Modules/TinyMce/Views/EditorTemplates/TinyMceTextEditor.ascx index 662a464b6..8b9f14733 100644 --- a/src/Orchard.Web/Modules/TinyMce/Views/EditorTemplates/TinyMceTextEditor.ascx +++ b/src/Orchard.Web/Modules/TinyMce/Views/EditorTemplates/TinyMceTextEditor.ascx @@ -7,10 +7,10 @@ theme: "advanced", mode: "specific_textareas", editor_selector: "html", - plugins: "fullscreen,autoresize,searchreplace", + plugins: "fullscreen,autoresize,searchreplace,addmedia", theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", - theme_advanced_buttons1: "search,replace,|,cut,copy,paste,|,undo,redo,|,image,|,link,unlink,charmap,emoticon,codeblock,|,bold,italic,|,numlist,bullist,formatselect,|,code,fullscreen", + theme_advanced_buttons1: "search,replace,|,cut,copy,paste,|,undo,redo,|,image,addmedia,|,link,unlink,charmap,emoticon,codeblock,|,bold,italic,|,numlist,bullist,formatselect,|,code,fullscreen", theme_advanced_buttons2: "", theme_advanced_buttons3: "" }); From cdf6568453a3ac3eb2503c20ae6fe67bfc5f6671 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Wed, 3 Mar 2010 15:01:53 -0800 Subject: [PATCH 3/8] Fixing the (currently hard-coded) form action to add media from tinymce --HG-- branch : dev --- .../Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm index 4d8ff00a1..273f7cd8d 100644 --- a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm +++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/addmedia/addmedia.htm @@ -6,7 +6,7 @@ -
+
  • {#addmedia_dlg.title}
  • From d62256251535ed216f2205834c76be34ae807a4f Mon Sep 17 00:00:00 2001 From: jowall Date: Wed, 3 Mar 2010 16:40:49 -0800 Subject: [PATCH 4/8] Removed "published by" text from CMS pages in the classic and green themes. --HG-- branch : dev --- src/Orchard.Web/Orchard.Web.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 184187747..f0b379d8e 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -174,6 +174,7 @@ + @@ -191,6 +192,7 @@ + From 7d7afd670359d59c05d64dd0875059d894c6a399 Mon Sep 17 00:00:00 2001 From: jowall Date: Wed, 3 Mar 2010 16:41:38 -0800 Subject: [PATCH 5/8] Adding pages.page.ascx files to classic and green themes. --HG-- branch : dev --- .../Classic/Views/DisplayTemplates/Items/Pages.Page.ascx | 6 ++++++ .../Green/Views/DisplayTemplates/Items/Pages.Page.ascx | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Pages.Page.ascx create mode 100644 src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Pages.Page.ascx diff --git a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Pages.Page.ascx b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Pages.Page.ascx new file mode 100644 index 000000000..68ebacdac --- /dev/null +++ b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Pages.Page.ascx @@ -0,0 +1,6 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> +<%@ Import Namespace="Orchard.Mvc.Html"%> +<%@ Import Namespace="Orchard.Mvc.ViewModels"%> +

    <%=Html.TitleForPage(Model.Item.Title)%>

    +<% Html.Zone("primary"); + Html.ZonesAny(); %> \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Pages.Page.ascx b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Pages.Page.ascx new file mode 100644 index 000000000..68ebacdac --- /dev/null +++ b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Pages.Page.ascx @@ -0,0 +1,6 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> +<%@ Import Namespace="Orchard.Mvc.Html"%> +<%@ Import Namespace="Orchard.Mvc.ViewModels"%> +

    <%=Html.TitleForPage(Model.Item.Title)%>

    +<% Html.Zone("primary"); + Html.ZonesAny(); %> \ No newline at end of file From bcaa4462ec7eda8a0b77f1c1320969c664382821 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 3 Mar 2010 17:35:25 -0800 Subject: [PATCH 6/8] Changing the MVC hint path Invalid hint path causes problems on some machines --HG-- branch : dev --- src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj index 8ee420c90..547e232f9 100644 --- a/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj +++ b/src/Orchard.Web/Modules/Futures.Widgets/Futures.Widgets.csproj @@ -44,7 +44,7 @@ False - ..\..\..\..\..\..\Program Files\Microsoft ASP.NET\ASP.NET MVC 2\\Assemblies\System.Web.Mvc.dll + ..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll 3.5 From a238d0e0d076a2df586a039f9d34b8e86f6f4a38 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 3 Mar 2010 17:36:54 -0800 Subject: [PATCH 7/8] Relocating the default role/permission assignments Now that there is a SetupController that is a more appropriate place to simulate one-time-only module activation. This avoids a problem where default permissions would be re-applied when the app domain restarted. --HG-- branch : dev --- .../Controllers/SetupController.cs | 7 ++++++- src/Orchard/Environment/DefaultOrchardHost.cs | 19 ------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index ce6d56d6a..ce8779a2f 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -8,6 +8,7 @@ using Orchard.Core.Settings.Models; using Orchard.Data; using Orchard.Environment; using Orchard.Environment.Configuration; +using Orchard.Extensions; using Orchard.Security; using Orchard.Settings; using Orchard.Setup.ViewModels; @@ -101,7 +102,11 @@ namespace Orchard.Setup.Controllers { themeService.SetSiteTheme("Classic"); var contentManager = finiteEnvironment.Resolve(); - + + // simulate installation-time module activation events + var hackInstallationGenerator = finiteEnvironment.Resolve(); + hackInstallationGenerator.GenerateInstallEvents(); + // create home page as a CMS page var page = contentManager.Create("page", VersionOptions.Draft); page.As().Text = "

    Welcome to Orchard!

    Congratulations, you've successfully set-up your Orchard site.

    This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

    One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

    You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site. We have installed a few themes already, but you'll also be able to browse through an online gallery of themes created by other users of Orchard.

    Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

    Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

    --The Orchard Crew

    "; diff --git a/src/Orchard/Environment/DefaultOrchardHost.cs b/src/Orchard/Environment/DefaultOrchardHost.cs index ac5c021ca..d63ee1f85 100644 --- a/src/Orchard/Environment/DefaultOrchardHost.cs +++ b/src/Orchard/Environment/DefaultOrchardHost.cs @@ -75,9 +75,6 @@ namespace Orchard.Environment { shell.Activate(); _current = shell; - // Fire off one-time install events on an alternate container - HackInstallSimulation(); - // Activate extensions inside shell container HackSimulateExtensionActivation(shellContainer); } @@ -119,22 +116,6 @@ namespace Orchard.Environment { return null; } - private void HackInstallSimulation() { - var tempContainer = CreateShellContainer(); - var containerProvider = new FiniteContainerProvider(tempContainer); - try { - var requestContainer = containerProvider.RequestContainer; - - var hackInstallationGenerator = requestContainer.Resolve(); - hackInstallationGenerator.GenerateInstallEvents(); - } - finally { - // shut everything down again - containerProvider.DisposeRequestContainer(); - tempContainer.Dispose(); - } - } - private void HackSimulateExtensionActivation(IContainer shellContainer) { var containerProvider = new FiniteContainerProvider(shellContainer); try { From ca477238f1f5402e40fdf8873b057c6c3a5e12f4 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Wed, 3 Mar 2010 17:39:24 -0800 Subject: [PATCH 8/8] - Add Area scenario is now working. Areas added via MVC 2 RC 2 VS Tooling are discovered/loaded as Orchard modules. - Html.AddRenderAction to permit controller actions to display views in zones. - Disabling the always on AntiForgery filter (will make it optional probably). --HG-- branch : dev --- src/Orchard.Web/Orchard.Web.csproj | 2 +- src/Orchard/Data/SessionFactoryHolder.cs | 2 +- .../AntiForgeryAuthorizationFilter.cs | 2 ++ src/Orchard/Mvc/Html/HtmlHelperExtensions.cs | 34 +++++++++++++++++++ src/Orchard/Orchard.csproj | 2 ++ src/Orchard/UI/Zones/RenderActionZoneItem.cs | 15 ++++++++ src/Orchard/UI/Zones/RenderStaticZoneItem.cs | 13 +++++++ src/Orchard/UI/Zones/ZoneCollection.cs | 25 ++++++++++++++ 8 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/Orchard/UI/Zones/RenderActionZoneItem.cs create mode 100644 src/Orchard/UI/Zones/RenderStaticZoneItem.cs diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 695eff9fc..792805441 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -5,7 +5,7 @@ 9.0.30729 2.0 {50B779EA-EC00-4699-84C0-03B395C365D2} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + {F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Orchard.Web diff --git a/src/Orchard/Data/SessionFactoryHolder.cs b/src/Orchard/Data/SessionFactoryHolder.cs index 6b64a600a..70c4fe60e 100644 --- a/src/Orchard/Data/SessionFactoryHolder.cs +++ b/src/Orchard/Data/SessionFactoryHolder.cs @@ -60,7 +60,7 @@ namespace Orchard.Data { public ISessionFactory GetSessionFactory() { lock (this) { if (_sessionFactory == null) { - _sessionFactory = BuildSessionFactory(false /*createDatabase*/, false /*updateSchema*/); + _sessionFactory = BuildSessionFactory(false /*createDatabase*/, true /*updateSchema*/); } } return _sessionFactory; diff --git a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs index aa9e084cb..bd0370281 100644 --- a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs +++ b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs @@ -18,6 +18,7 @@ namespace Orchard.Mvc.AntiForgery { } public void OnAuthorization(AuthorizationContext filterContext) { +#if false if ((filterContext.HttpContext.Request.HttpMethod != "POST" || _authenticationService.GetAuthenticatedUser() == null) && !ShouldValidateGet(filterContext)) { return; @@ -29,6 +30,7 @@ namespace Orchard.Mvc.AntiForgery { if (filterContext.HttpContext is HackHttpContext) filterContext.HttpContext = ((HackHttpContext)filterContext.HttpContext).OriginalHttpContextBase; +#endif } private static bool ShouldValidateGet(AuthorizationContext context) { diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs index 01edf2374..6f8605355 100644 --- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs +++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs @@ -8,6 +8,7 @@ using System.Web.Mvc; using System.Web.Mvc.Html; using System.Web.Routing; using Orchard.Extensions; +using Orchard.Mvc.ViewModels; using Orchard.Services; using Orchard.Settings; using Orchard.Utility; @@ -297,5 +298,38 @@ namespace Orchard.Mvc.Html { } #endregion + + #region AddRenderAction + + public static void AddRenderAction(this HtmlHelper html, string location, string actionName) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, null); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, object routeValues) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, new RouteValueDictionary(routeValues)); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, RouteValueDictionary routeValues) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, routeValues); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName) { + AddRenderActionHelper(html, location, actionName, controllerName, null/*RouteValueDictionary*/); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, object routeValues) { + AddRenderActionHelper(html, location, actionName, controllerName, new RouteValueDictionary(routeValues)); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + AddRenderActionHelper(html, location, actionName, controllerName, routeValues); + } + + private static void AddRenderActionHelper(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + // Retrieve the "BaseViewModel" for zones if we have one + var baseViewModel = BaseViewModel.From(html.ViewData); + if (baseViewModel == null) + return; + + baseViewModel.Zones.AddRenderAction(location, actionName, controllerName, routeValues); + } + + #endregion + } } \ No newline at end of file diff --git a/src/Orchard/Orchard.csproj b/src/Orchard/Orchard.csproj index 1c9875f90..ebe7bd44e 100644 --- a/src/Orchard/Orchard.csproj +++ b/src/Orchard/Orchard.csproj @@ -310,7 +310,9 @@ + + diff --git a/src/Orchard/UI/Zones/RenderActionZoneItem.cs b/src/Orchard/UI/Zones/RenderActionZoneItem.cs new file mode 100644 index 000000000..18bb3bf72 --- /dev/null +++ b/src/Orchard/UI/Zones/RenderActionZoneItem.cs @@ -0,0 +1,15 @@ +using System.Web.Mvc; +using System.Web.Mvc.Html; +using System.Web.Routing; + +namespace Orchard.UI.Zones { + public class RenderActionZoneItem : ZoneItem { + public string ActionName { get; set; } + public string ControllerName { get; set; } + public RouteValueDictionary RouteValues { get; set; } + + public override void Execute(HtmlHelper html) { + html.RenderAction(ActionName, ControllerName, RouteValues); + } + } +} diff --git a/src/Orchard/UI/Zones/RenderStaticZoneItem.cs b/src/Orchard/UI/Zones/RenderStaticZoneItem.cs new file mode 100644 index 000000000..3965908c0 --- /dev/null +++ b/src/Orchard/UI/Zones/RenderStaticZoneItem.cs @@ -0,0 +1,13 @@ +using System.Web.Mvc; +using System.Web.Mvc.Html; + +namespace Orchard.UI.Zones { + public class RenderStaticZoneItem : ZoneItem { + public object Model { get; set; } + public string TemplateName { get; set; } + + public override void Execute(HtmlHelper html) { + html.RenderPartial(TemplateName, Model); + } + } +} diff --git a/src/Orchard/UI/Zones/ZoneCollection.cs b/src/Orchard/UI/Zones/ZoneCollection.cs index 3dfbf8e1a..c843f29b7 100644 --- a/src/Orchard/UI/Zones/ZoneCollection.cs +++ b/src/Orchard/UI/Zones/ZoneCollection.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Web.Mvc; +using System.Web.Routing; using Orchard.Mvc.ViewModels; namespace Orchard.UI.Zones { @@ -15,6 +16,11 @@ namespace Orchard.UI.Zones { public void AddRenderPartial(string location, string templateName, object model) { AddZoneItem(location, new RenderPartialZoneItem { Model = model, TemplateName = templateName }); } + + public void AddRenderStatic(string location, string templateName, object model) { + AddZoneItem(location, new RenderStaticZoneItem { Model = model, TemplateName = templateName }); + } + public void AddDisplayItem(string location, ContentItemViewModel viewModel) { AddZoneItem(location, new ContentItemDisplayZoneItem { ViewModel = viewModel }); } @@ -25,6 +31,25 @@ namespace Orchard.UI.Zones { AddZoneItem(location, new ContentPartEditorZoneItem { Model = model, TemplateName = templateName, Prefix = prefix }); } + public void AddRenderAction(string location, string actionName) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName }); + } + public void AddRenderAction(string location, string actionName, object routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, RouteValues = new RouteValueDictionary(routeValues) }); + } + public void AddRenderAction(string location, string actionName, RouteValueDictionary routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, RouteValues = routeValues }); + } + public void AddRenderAction(string location, string actionName, string controllerName) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName }); + } + public void AddRenderAction(string location, string actionName, string controllerName, object routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName, RouteValues = new RouteValueDictionary(routeValues) }); + } + public void AddRenderAction(string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName, RouteValues = routeValues }); + } + private void AddZoneItem(string location, ZoneItem item) { string zoneName; var position = string.Empty;