mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Converting Futures.Widgets module
--HG-- branch : dev
This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
using System.Web.Routing;
|
|
||||||
using Futures.Widgets.Models;
|
|
||||||
using Orchard.ContentManagement.Drivers;
|
|
||||||
|
|
||||||
namespace Futures.Widgets.Drivers {
|
|
||||||
public class WidgetsPartDriver : ContentItemDriver<WidgetPart> {
|
|
||||||
public override RouteValueDictionary GetEditorRouteValues(WidgetPart item) {
|
|
||||||
return new RouteValueDictionary {
|
|
||||||
{"Area", "Futures.Widgets"},
|
|
||||||
{"Controller", "Admin"},
|
|
||||||
{"Action", "Edit"},
|
|
||||||
{"Id", item.ContentItem.Id}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool UseDefaultTemplate {
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="System.Web.ApplicationServices" />
|
<Reference Include="System.Web.ApplicationServices" />
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
<Content Include="Views\Admin\Edit.ascx" />
|
<None Include="Views\Admin\Edit.cshtml" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
<Content Include="Views\Web.config" />
|
<Content Include="Views\Web.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using Orchard.Mvc.ViewModels;
|
|
||||||
|
|
||||||
namespace Futures.Widgets.ViewModels {
|
namespace Futures.Widgets.ViewModels {
|
||||||
public class WidgetEditViewModel : BaseViewModel {
|
public class WidgetEditViewModel {
|
||||||
public ContentItemViewModel Widget { get; set; }
|
public dynamic Widget { get; set; }
|
||||||
public string ReturnUrl { get; set;}
|
public string ReturnUrl { get; set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<WidgetEditViewModel>" %>
|
|
||||||
<%@ Import Namespace="Futures.Widgets.ViewModels" %>
|
|
||||||
<h1><%: Html.TitleForPage(T("Edit Widget").ToString()) %></h1>
|
|
||||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
|
||||||
<%: Html.ValidationSummary() %>
|
|
||||||
<%: Html.EditorForItem(m => m.Widget) %>
|
|
||||||
<fieldset>
|
|
||||||
<%: Html.HiddenFor(m => m.ReturnUrl) %>
|
|
||||||
<input class="button primaryAction" type="submit" name="submit.Save" value="Save"/>
|
|
||||||
</fieldset>
|
|
||||||
<%} %>
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@model Futures.Widgets.ViewModels.WidgetEditViewModel
|
||||||
|
|
||||||
|
<h1>@Html.TitleForPage(T("Edit Widget").ToString())</h1>
|
||||||
|
|
||||||
|
@using (Html.BeginFormAntiForgeryPost()) {
|
||||||
|
@Html.ValidationSummary()
|
||||||
|
@Display(Model.Widget)
|
||||||
|
@Html.HiddenFor(m => m.ReturnUrl)
|
||||||
|
}
|
||||||
@@ -1,40 +1,44 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Futures.Widgets.Models;
|
using Futures.Widgets.Models;
|
||||||
|
using Orchard;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Mvc.Filters;
|
using Orchard.Mvc.Filters;
|
||||||
using Orchard.Mvc.ViewModels;
|
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
|
|
||||||
namespace Futures.Widgets {
|
namespace Futures.Widgets {
|
||||||
public class WidgetFilter : FilterProvider, IActionFilter {
|
public class WidgetFilter : FilterProvider, IActionFilter {
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
|
private readonly IWorkContextAccessor _workContextAccessor;
|
||||||
|
|
||||||
public WidgetFilter(IContentManager contentManager) {
|
public WidgetFilter(IContentManager contentManager, IWorkContextAccessor workContextAccessor) {
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
|
_workContextAccessor = workContextAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ISite CurrentSite { get; set; }
|
|
||||||
|
|
||||||
public void OnActionExecuting(ActionExecutingContext filterContext) {
|
public void OnActionExecuting(ActionExecutingContext filterContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnActionExecuted(ActionExecutedContext filterContext) {
|
public void OnActionExecuted(ActionExecutedContext filterContext) {
|
||||||
var model = BaseViewModel.From(filterContext.Result);
|
var workContext = _workContextAccessor.GetContext(filterContext);
|
||||||
if (model == null || AdminFilter.IsApplied(filterContext.RequestContext)) {
|
|
||||||
|
if (workContext == null ||
|
||||||
|
workContext.Page == null ||
|
||||||
|
workContext.CurrentSite == null ||
|
||||||
|
AdminFilter.IsApplied(filterContext.RequestContext)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var siteWidgets = CurrentSite.As<WidgetsPart>();
|
var siteWidgets = workContext.CurrentSite.As<WidgetsPart>();
|
||||||
if (siteWidgets == null) {
|
if (siteWidgets == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var zones = model.Zones;
|
var zones = workContext.Page.Zones;
|
||||||
foreach (var widget in siteWidgets.Widgets) {
|
foreach (var widget in siteWidgets.Widgets) {
|
||||||
zones.AddDisplayItem(
|
var widgetShape = _contentManager.BuildDisplayModel(widget);
|
||||||
widget.Record.Zone + ":" + widget.Record.Position,
|
|
||||||
_contentManager.BuildDisplayModel(widget, "Widget"));
|
zones[widget.Record.Zone].Add(widgetShape, widget.Record.Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ namespace Orchard.Setup.Services {
|
|||||||
"Orchard.Comments",
|
"Orchard.Comments",
|
||||||
"Orchard.Tags",
|
"Orchard.Tags",
|
||||||
"Orchard.Media",
|
"Orchard.Media",
|
||||||
//"Futures.Widgets"
|
"Futures.Widgets",
|
||||||
|
|
||||||
"Orchard.DevTools"
|
"Orchard.DevTools",
|
||||||
};
|
};
|
||||||
|
|
||||||
context.EnabledFeatures = hardcoded;
|
context.EnabledFeatures = hardcoded;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Contents.Item.ascx" />
|
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Contents.Item.ascx" />
|
||||||
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Blogs.BlogPost.Metadata.ascx" />
|
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Blogs.BlogPost.Metadata.ascx" />
|
||||||
<Content Include="Themes\Contoso\Views\Orchard.Search\Search\Index.ascx" />
|
<Content Include="Themes\Contoso\Views\Orchard.Search\Search\Index.ascx" />
|
||||||
|
<Content Include="Themes\Contoso\Zones\Footer.html" />
|
||||||
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Blogs.BlogPost.Metadata.ascx" />
|
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Blogs.BlogPost.Metadata.ascx" />
|
||||||
<Content Include="Themes\Green\Views\Orchard.Search\Search\Index.ascx" />
|
<Content Include="Themes\Green\Views\Orchard.Search\Search\Index.ascx" />
|
||||||
<Content Include="Themes\SafeMode\Views\Zone.ascx" />
|
<Content Include="Themes\SafeMode\Views\Zone.ascx" />
|
||||||
|
|||||||
6
src/Orchard.Web/Themes/Contoso/Zones/Footer.html
Normal file
6
src/Orchard.Web/Themes/Contoso/Zones/Footer.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<h3>
|
||||||
|
MVC Area One</h3>
|
||||||
|
<p>
|
||||||
|
Perfect place to talk about your company. Contoso is a fictious company that provides
|
||||||
|
technology sevices to a varierty of sectors.
|
||||||
|
</p>
|
||||||
@@ -76,6 +76,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Indexing", "Orchard
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Search", "Orchard.Web\Modules\Orchard.Search\Orchard.Search.csproj", "{4BE4EB01-AC56-4048-924E-2CA77F509ABA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Search", "Orchard.Web\Modules\Orchard.Search\Orchard.Search.csproj", "{4BE4EB01-AC56-4048-924E-2CA77F509ABA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Futures.Widgets", "Orchard.Web\Modules\Futures.Widgets\Futures.Widgets.csproj", "{E65E5633-C0FF-453C-A906-481C14F969D6}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||||
@@ -395,6 +397,16 @@ Global
|
|||||||
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||||
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4BE4EB01-AC56-4048-924E-2CA77F509ABA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6}.Coverage|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}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6}.FxCop|Any CPU.Build.0 = Release|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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -428,5 +440,6 @@ Global
|
|||||||
{33B1BC8D-E292-4972-A363-22056B207156} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
{33B1BC8D-E292-4972-A363-22056B207156} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||||
{8A4E42CE-79F8-4BE2-8B1E-A6B83432123B} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
{8A4E42CE-79F8-4BE2-8B1E-A6B83432123B} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||||
{0DFA2E10-96C8-4E05-BC10-B710B97ECCDE} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
{0DFA2E10-96C8-4E05-BC10-B710B97ECCDE} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||||
|
{E65E5633-C0FF-453C-A906-481C14F969D6} = {E75A4CE4-CAA6-41E4-B951-33ACC60DC77C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user