mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
SandboxPage -> SandboxPagePart
- updating part names to conform to a <name>Part convention --HG-- branch : dev rename : src/Orchard.Web/Modules/Orchard.Sandbox/Drivers/SandboxPageDriver.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Drivers/SandboxPagePartDriver.cs rename : src/Orchard.Web/Modules/Orchard.Sandbox/Handlers/SandboxContentHandler.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Handlers/SandboxPagePartHandler.cs rename : src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxPage.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxPagePart.cs rename : src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxPageRecord.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxPagePartRecord.cs rename : src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxSettingsRecord.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxSettingsPartRecord.cs
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
public ActionResult Index() {
|
||||
var model = new PageIndexViewModel {
|
||||
Pages = Services.ContentManager.Query<SandboxPage, SandboxPageRecord>()
|
||||
Pages = Services.ContentManager.Query<SandboxPagePart, SandboxPagePartRecord>()
|
||||
.OrderBy(x => x.Name)
|
||||
.List()
|
||||
.Select(x => Services.ContentManager.BuildDisplayModel(x, "SummaryList"))
|
||||
@@ -32,12 +32,12 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
public ActionResult Show(int id) {
|
||||
return View(new PageShowViewModel {
|
||||
Page = Services.ContentManager.BuildDisplayModel<SandboxPage>(id, "Detail")
|
||||
Page = Services.ContentManager.BuildDisplayModel<SandboxPagePart>(id, "Detail")
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsRecord>>();
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsPartRecord>>();
|
||||
if (settings.Record.AllowAnonymousEdits == false && CurrentUser == null) {
|
||||
Services.Notifier.Error(T("Anonymous users can not create pages"));
|
||||
return RedirectToAction("index");
|
||||
@@ -49,13 +49,13 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(PageCreateViewModel model) {
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsRecord>>();
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsPartRecord>>();
|
||||
if (settings.Record.AllowAnonymousEdits == false && CurrentUser == null) {
|
||||
Services.Notifier.Error(T("Anonymous users can not create pages"));
|
||||
return RedirectToAction("index");
|
||||
}
|
||||
|
||||
var page = Services.ContentManager.Create<SandboxPage>(SandboxPageDriver.ContentType.Name, item => {
|
||||
var page = Services.ContentManager.Create<SandboxPagePart>(SandboxPagePartDriver.ContentType.Name, item => {
|
||||
item.Record.Name = model.Name;
|
||||
});
|
||||
return RedirectToAction("show", new { page.ContentItem.Id });
|
||||
@@ -67,7 +67,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
return RedirectToAction("show", new { id });
|
||||
}
|
||||
|
||||
var latest = Services.ContentManager.GetLatest<SandboxPage>(id);
|
||||
var latest = Services.ContentManager.GetLatest<SandboxPagePart>(id);
|
||||
return View(new PageEditViewModel {
|
||||
Page = Services.ContentManager.BuildEditorModel(latest)
|
||||
});
|
||||
@@ -78,7 +78,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
if (IsEditAllowed() == false) {
|
||||
return RedirectToAction("show", new { id });
|
||||
}
|
||||
var latest = Services.ContentManager.GetDraftRequired<SandboxPage>(id);
|
||||
var latest = Services.ContentManager.GetDraftRequired<SandboxPagePart>(id);
|
||||
var model = new PageEditViewModel {
|
||||
Page = Services.ContentManager.UpdateEditorModel(latest, this)
|
||||
};
|
||||
@@ -91,7 +91,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
}
|
||||
|
||||
bool IsEditAllowed() {
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsRecord>>();
|
||||
var settings = CurrentSite.Get<ContentPart<SandboxSettingsPartRecord>>();
|
||||
if (settings.Record.AllowAnonymousEdits == false && CurrentUser == null) {
|
||||
Services.Notifier.Error(T("Anonymous users can not edit pages"));
|
||||
return false;
|
||||
|
@@ -5,12 +5,12 @@ namespace Orchard.Sandbox.DataMigrations {
|
||||
public class SandboxDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
SchemaBuilder.CreateTable("SandboxPageRecord", table => table
|
||||
SchemaBuilder.CreateTable("SandboxPagePartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
.Column<string>("Name")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("SandboxSettingsRecord", table => table
|
||||
SchemaBuilder.CreateTable("SandboxSettingsPartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
.Column<bool>("AllowAnonymousEdits")
|
||||
);
|
||||
@@ -22,7 +22,7 @@ namespace Orchard.Sandbox.DataMigrations {
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("SandboxPage",
|
||||
cfg => cfg
|
||||
.WithPart("SandboxPage")
|
||||
.WithPart("SandboxPagePart")
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("IsRoutable")
|
||||
.WithPart("BodyPart")
|
||||
|
@@ -8,7 +8,7 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class SandboxPageDriver : ContentItemDriver<SandboxPage> {
|
||||
public class SandboxPagePartDriver : ContentItemDriver<SandboxPagePart> {
|
||||
public readonly static ContentType ContentType = new ContentType {
|
||||
Name = "SandboxPage",
|
||||
DisplayName = "Sandbox Page"
|
||||
@@ -17,11 +17,11 @@ namespace Orchard.Sandbox.Drivers {
|
||||
protected override ContentType GetContentType() {
|
||||
return ContentType;
|
||||
}
|
||||
protected override string GetDisplayText(SandboxPage item) {
|
||||
protected override string GetDisplayText(SandboxPagePart item) {
|
||||
return item.Record.Name;
|
||||
}
|
||||
|
||||
public override RouteValueDictionary GetDisplayRouteValues(SandboxPage item) {
|
||||
public override RouteValueDictionary GetDisplayRouteValues(SandboxPagePart item) {
|
||||
return new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Sandbox",
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Sandbox.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
public override RouteValueDictionary GetEditorRouteValues(SandboxPage item) {
|
||||
public override RouteValueDictionary GetEditorRouteValues(SandboxPagePart item) {
|
||||
return new RouteValueDictionary(
|
||||
new {
|
||||
area = "Orchard.Sandbox",
|
||||
@@ -41,17 +41,17 @@ namespace Orchard.Sandbox.Drivers {
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Display(SandboxPage part, string displayType) {
|
||||
protected override DriverResult Display(SandboxPagePart part, string displayType) {
|
||||
return Combined(
|
||||
ContentItemTemplate("Items/Sandbox.Page").LongestMatch(displayType, "Summary"),
|
||||
ContentPartTemplate(part, "Parts/Sandbox.Page.Title").Location("title"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentItemViewModel<SandboxPage> model) {
|
||||
protected override DriverResult Editor(ContentItemViewModel<SandboxPagePart> model) {
|
||||
return ContentItemTemplate("Items/Sandbox.Page");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentItemViewModel<SandboxPage> model, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(ContentItemViewModel<SandboxPagePart> model, IUpdateModel updater) {
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
return ContentItemTemplate("Items/Sandbox.Page");
|
||||
}
|
@@ -6,15 +6,15 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class SandboxContentHandler : ContentHandler {
|
||||
public SandboxContentHandler(IRepository<SandboxPageRecord> pageRepository, IRepository<SandboxSettingsRecord> settingsRepository) {
|
||||
public class SandboxPagePartHandler : ContentHandler {
|
||||
public SandboxPagePartHandler(IRepository<SandboxPagePartRecord> pageRepository, IRepository<SandboxSettingsPartRecord> settingsRepository) {
|
||||
// define the "SandboxPage" content type
|
||||
Filters.Add(StorageFilter.For(pageRepository) );
|
||||
|
||||
// add settings to site, and simple record-template gui
|
||||
Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsRecord>>("Site"));
|
||||
Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsPartRecord>>("Site"));
|
||||
Filters.Add(StorageFilter.For(settingsRepository));
|
||||
Filters.Add(new TemplateFilterForRecord<SandboxSettingsRecord>("SandboxSettings", "Parts/Sandbox.SiteSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<SandboxSettingsPartRecord>("SandboxSettings", "Parts/Sandbox.SiteSettings"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxPage : ContentPart<SandboxPageRecord> {
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxPagePart : ContentPart<SandboxPagePartRecord> {
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxPageRecord : ContentPartRecord {
|
||||
public class SandboxPagePartRecord : ContentPartRecord {
|
||||
public virtual string Name { get; set; }
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Sandbox.Models {
|
||||
public class SandboxSettingsRecord : ContentPartRecord {
|
||||
public class SandboxSettingsPartRecord : ContentPartRecord {
|
||||
public virtual bool AllowAnonymousEdits { get; set; }
|
||||
}
|
||||
}
|
@@ -68,11 +68,11 @@
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\PageController.cs" />
|
||||
<Compile Include="DataMigrations\SandBoxDataMigration.cs" />
|
||||
<Compile Include="Drivers\SandboxPageDriver.cs" />
|
||||
<Compile Include="Models\SandboxPage.cs" />
|
||||
<Compile Include="Handlers\SandboxContentHandler.cs" />
|
||||
<Compile Include="Models\SandboxPageRecord.cs" />
|
||||
<Compile Include="Models\SandboxSettingsRecord.cs" />
|
||||
<Compile Include="Drivers\SandboxPagePartDriver.cs" />
|
||||
<Compile Include="Models\SandboxPagePart.cs" />
|
||||
<Compile Include="Handlers\SandboxPagePartHandler.cs" />
|
||||
<Compile Include="Models\SandboxPagePartRecord.cs" />
|
||||
<Compile Include="Models\SandboxSettingsPartRecord.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ViewModels\PageEditViewModel.cs" />
|
||||
<Compile Include="ViewModels\PageCreateViewModel.cs" />
|
||||
|
@@ -5,6 +5,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageEditViewModel : BaseViewModel {
|
||||
public ContentItemViewModel<SandboxPage> Page { get; set; }
|
||||
public ContentItemViewModel<SandboxPagePart> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageIndexViewModel : BaseViewModel {
|
||||
public IEnumerable<ContentItemViewModel<SandboxPage>> Pages { get; set; }
|
||||
public IEnumerable<ContentItemViewModel<SandboxPagePart>> Pages { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageShowViewModel : BaseViewModel {
|
||||
public ContentItemViewModel<SandboxPage> Page { get; set; }
|
||||
public ContentItemViewModel<SandboxPagePart> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<SandboxPagePart>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<div class="item">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<SandboxPagePart>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<div class="item">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ContentItemViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ContentItemViewModel<SandboxPagePart>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models"%>
|
||||
<fieldset>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SandboxSettingsRecord>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SandboxSettingsPartRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models"%>
|
||||
<fieldset>
|
||||
<legend>Sandbox</legend>
|
||||
|
Reference in New Issue
Block a user