mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
HasWidgets -> WidgetsPart; Widget -> WidgetPart
- updating part names to conform to a <name>Part convention --HG-- branch : dev rename : src/Orchard.Web/Modules/Futures.Widgets/Controllers/WidgetHandler.cs => src/Orchard.Web/Modules/Futures.Widgets/Handlers/WidgetsPartHandler.cs rename : src/Orchard.Web/Modules/Futures.Widgets/Models/Widget.cs => src/Orchard.Web/Modules/Futures.Widgets/Models/WidgetPart.cs rename : src/Orchard.Web/Modules/Futures.Widgets/Models/HasWidgets.cs => src/Orchard.Web/Modules/Futures.Widgets/Models/WidgetsPart.cs
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Futures.Widgets.Controllers {
|
||||
public Localizer T{ get; set;}
|
||||
|
||||
public ActionResult AddWidget(string zoneName, string themeName, string returnUrl) {
|
||||
var hasWidgetsRecord = CurrentSite.As<HasWidgets>().Record;
|
||||
var hasWidgetsRecord = CurrentSite.As<WidgetsPart>().Record;
|
||||
|
||||
var virtualPath = "~/Themes/" + themeName + "/Zones/" + zoneName + ".html";
|
||||
var physicalPath = Server.MapPath(virtualPath);
|
||||
@@ -31,7 +31,7 @@ namespace Futures.Widgets.Controllers {
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
|
||||
var widget = Services.ContentManager.Create<Widget>("HtmlWidget", init => {
|
||||
var widget = Services.ContentManager.Create<WidgetPart>("HtmlWidget", init => {
|
||||
init.Record.Scope = hasWidgetsRecord;
|
||||
init.Record.Zone = zoneName;
|
||||
init.Record.Position = "1";
|
||||
|
@@ -1,43 +0,0 @@
|
||||
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<HasWidgetsRecord> hasWidgetRepository,
|
||||
IRepository<WidgetRecord> widgetRepository) {
|
||||
|
||||
// providing standard storage support for widget records
|
||||
Filters.Add(StorageFilter.For(hasWidgetRepository));
|
||||
Filters.Add(StorageFilter.For(widgetRepository));
|
||||
|
||||
OnLoaded<HasWidgets>(
|
||||
(ctx, part) => part.WidgetField.Loader(
|
||||
() => ctx.ContentManager
|
||||
.Query<Widget, WidgetRecord>()
|
||||
.Where(x => x.Scope == part.Record)
|
||||
.List().ToList()));
|
||||
}
|
||||
}
|
||||
|
||||
public class WidgetDriver : ContentItemDriver<Widget> {
|
||||
public 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; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,12 +6,12 @@ namespace Futures.Widgets.DataMigrations {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Futures_Widgets_HasWidgetsRecord (Id INTEGER not null, primary key (Id));
|
||||
SchemaBuilder.CreateTable("HasWidgetsRecord", table => table
|
||||
SchemaBuilder.CreateTable("WidgetsPartRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey())
|
||||
);
|
||||
|
||||
//CREATE TABLE Futures_Widgets_WidgetRecord (Id INTEGER not null, Zone TEXT, Position TEXT, Scope_id INTEGER, primary key (Id));
|
||||
SchemaBuilder.CreateTable("WidgetRecord", table => table
|
||||
SchemaBuilder.CreateTable("WidgetPartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
.Column<string>("Zone")
|
||||
.Column<string>("Position")
|
||||
@@ -22,14 +22,9 @@ namespace Futures.Widgets.DataMigrations {
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Site",
|
||||
cfg => cfg
|
||||
.WithPart("HasWidgets")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
|
||||
cfg => cfg
|
||||
.WithPart("Widget")
|
||||
.WithPart("WidgetPart")
|
||||
.WithPart("BodyPart")
|
||||
);
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -58,10 +58,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\WidgetHandler.cs" />
|
||||
<Compile Include="Drivers\WidgetsPartDriver.cs" />
|
||||
<Compile Include="Handlers\WidgetsPartHandler.cs" />
|
||||
<Compile Include="DataMigrations\WidgetsDataMigration.cs" />
|
||||
<Compile Include="Models\HasWidgets.cs" />
|
||||
<Compile Include="Models\Widget.cs" />
|
||||
<Compile Include="Models\WidgetsPartRecord.cs" />
|
||||
<Compile Include="Models\WidgetsPart.cs" />
|
||||
<Compile Include="Models\WidgetPart.cs" />
|
||||
<Compile Include="Models\WidgetPartRecord.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ViewModels\WidgetEditViewModel.cs" />
|
||||
<Compile Include="WidgetFilter.cs" />
|
||||
|
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using Futures.Widgets.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
|
||||
namespace Futures.Widgets.Handlers {
|
||||
public class WidgetsPartHandler : ContentHandler {
|
||||
public WidgetsPartHandler(
|
||||
IRepository<WidgetsPartRecord> widgetsRepository,
|
||||
IRepository<WidgetPartRecord> widgetRepository) {
|
||||
|
||||
Filters.Add(new ActivatingFilter<WidgetsPart>("Site"));
|
||||
|
||||
// providing standard storage support for widget records
|
||||
Filters.Add(StorageFilter.For(widgetsRepository));
|
||||
Filters.Add(StorageFilter.For(widgetRepository));
|
||||
|
||||
OnLoaded<WidgetsPart>(
|
||||
(ctx, part) => part.WidgetField.Loader(
|
||||
() => ctx.ContentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.Where(x => x.Scope == part.Record)
|
||||
.List().ToList()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Common.Utilities;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class HasWidgets : ContentPart<HasWidgetsRecord> {
|
||||
public LazyField<IList<Widget>> WidgetField = new LazyField<IList<Widget>>();
|
||||
public IList<Widget> Widgets { get { return WidgetField.Value; } set { WidgetField.Value = value; } }
|
||||
}
|
||||
|
||||
public class HasWidgetsRecord : ContentPartRecord {
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class Widget : ContentPart<WidgetRecord> {
|
||||
}
|
||||
|
||||
public class WidgetRecord : ContentPartRecord {
|
||||
public virtual HasWidgetsRecord Scope { get; set; }
|
||||
public virtual string Zone { get; set; }
|
||||
public virtual string Position { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class WidgetPart : ContentPart<WidgetPartRecord> {
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class WidgetPartRecord : ContentPartRecord {
|
||||
public virtual WidgetsPartRecord Scope { get; set; }
|
||||
public virtual string Zone { get; set; }
|
||||
public virtual string Position { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Common.Utilities;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class WidgetsPart : ContentPart<WidgetsPartRecord> {
|
||||
public LazyField<IList<WidgetPart>> WidgetField = new LazyField<IList<WidgetPart>>();
|
||||
public IList<WidgetPart> Widgets { get { return WidgetField.Value; } set { WidgetField.Value = value; } }
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Futures.Widgets.Models {
|
||||
public class WidgetsPartRecord : ContentPartRecord {
|
||||
}
|
||||
}
|
@@ -25,7 +25,7 @@ namespace Futures.Widgets {
|
||||
return;
|
||||
}
|
||||
|
||||
var siteWidgets = CurrentSite.As<HasWidgets>();
|
||||
var siteWidgets = CurrentSite.As<WidgetsPart>();
|
||||
if (siteWidgets == null) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user