From c3b2d8e6f602aa19ce760e7e548da4b3abdc9325 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 24 Jun 2010 16:11:10 -0700 Subject: [PATCH] Shifting ContentType editing into dedicated module Orchard.ContentTypes module added Updating actionlink strings in views Adjusting actionview names in contenttypes/admin controller EditType to Edit, and CreateType to Create --HG-- branch : dev --- src/Orchard.Web/Core/Contents/AdminMenu.cs | 4 +- .../Contents/Controllers/AdminController.cs | 248 +--------------- .../Core/Contents/Views/Admin/Types.ascx | 9 - src/Orchard.Web/Core/Orchard.Core.csproj | 22 +- .../Modules/Orchard.ContentTypes/AdminMenu.cs | 16 + .../Controllers/AdminController.cs | 277 ++++++++++++++++++ .../Modules/Orchard.ContentTypes/Module.txt | 10 + .../Orchard.ContentTypes.csproj | 146 +++++++++ .../Orchard.ContentTypes}/Permissions.cs | 2 +- .../Properties/AssemblyInfo.cs | 35 +++ .../Services/ContentDefinitionService.cs | 2 +- .../Services/IContentDefinitionService.cs | 2 +- .../ViewModels/AddFieldViewModel.cs | 2 +- .../ViewModels/CreateTypeViewModel.cs | 2 +- .../ViewModels/EditTypeViewModel.cs | 2 +- .../ViewModels/ListContentTypesViewModel.cs | 9 + .../ViewModels/ListContentsViewModel.cs | 17 ++ .../Views/Admin/AddFieldTo.ascx | 4 +- .../Views/Admin/Create.ascx} | 4 +- .../Views/Admin/Edit.ascx} | 4 +- .../Views/Admin/EditPart.ascx | 6 +- .../Views/Admin/List.ascx | 11 + .../ContentTypeDefinition.ascx | 4 +- .../Views/DisplayTemplates/Field.ascx | 2 +- .../Views/DisplayTemplates/Fields.ascx | 2 +- .../Views/DisplayTemplates/Settings.ascx | 0 .../EditorTemplates/ContentTypePart.ascx | 13 + .../Views/EditorTemplates/Field.ascx | 4 +- .../Views/EditorTemplates/Fields.ascx | 2 +- .../Views/EditorTemplates/Part.ascx | 4 +- .../Views/EditorTemplates/Parts.ascx | 2 +- .../Views/EditorTemplates/Settings.ascx | 0 .../Orchard.ContentTypes/Views/Web.config | 35 +++ .../Orchard.ContentTypes/Web.Debug.config | 30 ++ .../Orchard.ContentTypes/Web.Release.config | 31 ++ .../Modules/Orchard.ContentTypes/Web.config | 80 +++++ src/Orchard.Web/Orchard.Web.csproj | 4 + src/Orchard.sln | 7 + 38 files changed, 753 insertions(+), 301 deletions(-) delete mode 100644 src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Module.txt create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Permissions.cs (94%) create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Properties/AssemblyInfo.cs rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Services/ContentDefinitionService.cs (96%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Services/IContentDefinitionService.cs (93%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/ViewModels/AddFieldViewModel.cs (88%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/ViewModels/CreateTypeViewModel.cs (73%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/ViewModels/EditTypeViewModel.cs (96%) create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentTypesViewModel.cs create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentsViewModel.cs rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/Admin/AddFieldTo.ascx (88%) rename src/Orchard.Web/{Core/Contents/Views/Admin/CreateType.ascx => Modules/Orchard.ContentTypes/Views/Admin/Create.ascx} (84%) rename src/Orchard.Web/{Core/Contents/Views/Admin/EditType.ascx => Modules/Orchard.ContentTypes/Views/Admin/Edit.ascx} (88%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/Admin/EditPart.ascx (80%) create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/List.ascx rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/DisplayTemplates/ContentTypeDefinition.ascx (73%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/DisplayTemplates/Field.ascx (80%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/DisplayTemplates/Fields.ascx (78%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/DisplayTemplates/Settings.ascx (100%) create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/ContentTypePart.ascx rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/EditorTemplates/Field.ascx (85%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/EditorTemplates/Fields.ascx (82%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/EditorTemplates/Part.ascx (88%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/EditorTemplates/Parts.ascx (82%) rename src/Orchard.Web/{Core/Contents => Modules/Orchard.ContentTypes}/Views/EditorTemplates/Settings.ascx (100%) create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Web.config create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Debug.config create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Release.config create mode 100644 src/Orchard.Web/Modules/Orchard.ContentTypes/Web.config diff --git a/src/Orchard.Web/Core/Contents/AdminMenu.cs b/src/Orchard.Web/Core/Contents/AdminMenu.cs index bd1a122fa..0851117cf 100644 --- a/src/Orchard.Web/Core/Contents/AdminMenu.cs +++ b/src/Orchard.Web/Core/Contents/AdminMenu.cs @@ -21,7 +21,7 @@ namespace Orchard.Core.Contents { var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name); builder.Add(T("Content"), "1", menu => { - menu.Add(T("Manage Content"), "1.2", item => item.Action("List", "Admin", new {area = "Contents"})); + menu.Add(T("Manage Content"), "1.2", item => item.Action("List", "Admin", new {area = "Orchard.ContentTypes"})); //foreach (var contentTypeDefinition in contentTypeDefinitions) { // var ci = _contentManager.New(contentTypeDefinition.Name); // var cim = _contentManager.GetItemMetadata(ci); @@ -30,8 +30,6 @@ namespace Orchard.Core.Contents { // menu.Add(T("Create New {0}", contentTypeDefinition.DisplayName), "1.3", item => item.Action(cim.CreateRouteValues["Action"] as string, cim.CreateRouteValues["Controller"] as string, cim.CreateRouteValues)); //} }); - builder.Add(T("Site Configuration"), "11", - menu => menu.Add(T("Content Types"), "3", item => item.Action("Index", "Admin", new { area = "Contents" }))); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index ab096c256..c595901b8 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -4,8 +4,8 @@ using System.Linq; using System.Web.Mvc; using System.Web.Routing; using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData.Models; -using Orchard.Core.Contents.Services; using Orchard.Core.Contents.ViewModels; using Orchard.Data; using Orchard.Localization; @@ -18,20 +18,20 @@ namespace Orchard.Core.Contents.Controllers { [ValidateInput(false)] public class AdminController : Controller, IUpdateModel { private readonly INotifier _notifier; - private readonly IContentDefinitionService _contentDefinitionService; private readonly IContentManager _contentManager; + private readonly IContentDefinitionManager _contentDefinitionManager; private readonly ITransactionManager _transactionManager; public AdminController( IOrchardServices orchardServices, INotifier notifier, - IContentDefinitionService contentDefinitionService, IContentManager contentManager, + IContentDefinitionManager contentDefinitionManager, ITransactionManager transactionManager) { Services = orchardServices; _notifier = notifier; - _contentDefinitionService = contentDefinitionService; _contentManager = contentManager; + _contentDefinitionManager = contentDefinitionManager; _transactionManager = transactionManager; T = NullLocalizer.Instance; Logger = NullLogger.Instance; @@ -41,244 +41,6 @@ namespace Orchard.Core.Contents.Controllers { public Localizer T { get; set; } public ILogger Logger { get; set; } - #region Types - - public ActionResult Index() { - return Types(); - } - - public ActionResult Types() { - return View("Types", new ListContentTypesViewModel { - Types = _contentDefinitionService.GetTypeDefinitions() - }); - } - - public ActionResult CreateType() { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type."))) - return new HttpUnauthorizedResult(); - - return View(new CreateTypeViewModel()); - } - - [HttpPost, ActionName("CreateType")] - public ActionResult CreateTypePOST(CreateTypeViewModel viewModel) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type."))) - return new HttpUnauthorizedResult(); - - var model = new ContentTypeDefinition(""); - TryUpdateModel(model); - - if (!ModelState.IsValid) { - Services.TransactionManager.Cancel(); - return View(viewModel); - } - - _contentDefinitionService.AddTypeDefinition(model); - - return RedirectToAction("Index"); - } - - public ActionResult EditType(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type."))) - return new HttpUnauthorizedResult(); - - var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); - - if (contentTypeDefinition == null) - return new NotFoundResult(); - - return View(new EditTypeViewModel(contentTypeDefinition)); - } - - [HttpPost, ActionName("EditType")] - public ActionResult EditTypePOST(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type."))) - return new HttpUnauthorizedResult(); - - var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); - - if (contentTypeDefinition == null) - return new NotFoundResult(); - - var viewModel = new EditTypeViewModel(); - TryUpdateModel(viewModel); - - if (!ModelState.IsValid) - return EditType(id); - - var contentTypeDefinitionParts = viewModel.Parts.Select(GenerateTypePart).ToList(); - if (viewModel.Fields.Any()) - contentTypeDefinitionParts.Add(GenerateTypePart(viewModel)); - - //todo: apply the changes along the lines of but definately not resembling - // for now this _might_ just get a little messy -> - _contentDefinitionService.AlterTypeDefinition( - new ContentTypeDefinition( - viewModel.Name, - viewModel.DisplayName, - contentTypeDefinitionParts, - viewModel.Settings - ) - ); - - return RedirectToAction("Index"); - } - - private static ContentTypeDefinition.Part GenerateTypePart(EditTypePartViewModel viewModel) { - return new ContentTypeDefinition.Part( - new ContentPartDefinition( - viewModel.PartDefinition.Name, - viewModel.PartDefinition.Fields.Select( - f => new ContentPartDefinition.Field( - new ContentFieldDefinition(f.FieldDefinition.Name), - f.Name, - f.Settings - ) - ), - viewModel.PartDefinition.Settings - ), - viewModel.Settings - ); - } - - private static ContentTypeDefinition.Part GenerateTypePart(EditTypeViewModel viewModel) { - return new ContentTypeDefinition.Part( - new ContentPartDefinition( - viewModel.Name, - viewModel.Fields.Select( - f => new ContentPartDefinition.Field( - new ContentFieldDefinition(f.FieldDefinition.Name), - f.Name, - f.Settings - ) - ), - null - ), - null - ); - } - - #endregion - - #region Parts - - public ActionResult EditPart(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) - return new HttpUnauthorizedResult(); - - var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); - - if (contentPartDefinition == null) - return new NotFoundResult(); - - return View(new EditPartViewModel(contentPartDefinition)); - } - - [HttpPost, ActionName("EditPart")] - public ActionResult EditPartPOST(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) - return new HttpUnauthorizedResult(); - - var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); - - if (contentPartDefinition == null) - return new NotFoundResult(); - - var viewModel = new EditPartViewModel(); - TryUpdateModel(viewModel); - - if (!ModelState.IsValid) - return EditPart(id); - - //todo: apply the changes along the lines of but definately not resembling - // for now this _might_ just get a little messy -> - _contentDefinitionService.AlterPartDefinition(GeneratePart(viewModel)); - - return RedirectToAction("Index"); - } - - public ActionResult AddFieldTo(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) - return new HttpUnauthorizedResult(); - - var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); - - if (contentPartDefinition == null) { - //id passed in might be that of a type w/ no implicit field - var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); - if (contentTypeDefinition != null) - contentPartDefinition = new ContentPartDefinition(id); - else - return new NotFoundResult(); - } - - var viewModel = new AddFieldViewModel { - Part = new EditPartViewModel(contentPartDefinition), - Fields = _contentDefinitionService.GetFieldDefinitions() - }; - - return View(viewModel); - } - - [HttpPost, ActionName("AddFieldTo")] - public ActionResult AddFieldToPOST(string id) { - if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) - return new HttpUnauthorizedResult(); - - var viewModel = new AddFieldViewModel(); - TryUpdateModel(viewModel); - - var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); - var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); - - if (!ModelState.IsValid) - return AddFieldTo(id); - - if (contentPartDefinition == null) { - //id passed in might be that of a type w/ no implicit field - if (contentTypeDefinition != null) { - contentPartDefinition = new ContentPartDefinition(id); - var contentTypeDefinitionParts = contentTypeDefinition.Parts.ToList(); - contentTypeDefinitionParts.Add(new ContentTypeDefinition.Part(contentPartDefinition, null)); - _contentDefinitionService.AlterTypeDefinition( - new ContentTypeDefinition( - contentTypeDefinition.Name, - contentTypeDefinition.DisplayName, - contentTypeDefinitionParts, - contentTypeDefinition.Settings - ) - ); - } - else { - return new NotFoundResult(); - } - } - - var contentPartFields = contentPartDefinition.Fields.ToList(); - contentPartFields.Add(new ContentPartDefinition.Field(new ContentFieldDefinition(viewModel.FieldTypeName), viewModel.DisplayName, null)); - _contentDefinitionService.AlterPartDefinition(new ContentPartDefinition(contentPartDefinition.Name, contentPartFields, contentPartDefinition.Settings)); - - if (contentTypeDefinition != null) - return RedirectToAction("EditType", new { id }); - - return RedirectToAction("EditPart", new {id}); - } - - private static ContentPartDefinition GeneratePart(EditPartViewModel viewModel) { - return new ContentPartDefinition( - viewModel.Name, - viewModel.Fields.Select( - f => new ContentPartDefinition.Field( - new ContentFieldDefinition(f.FieldDefinition.Name), - f.Name, - f.Settings - ) - ), - viewModel.Settings - ); - } - - #endregion #region Content @@ -321,7 +83,7 @@ namespace Orchard.Core.Contents.Controllers { ActionResult CreatableTypeList() { var model = new ListContentTypesViewModel { - Types = _contentDefinitionService.GetTypeDefinitions() + Types = _contentDefinitionManager.ListTypeDefinitions() }; return View("CreatableTypeList", model); diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx b/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx deleted file mode 100644 index c6fe6cc60..000000000 --- a/src/Orchard.Web/Core/Contents/Views/Admin/Types.ascx +++ /dev/null @@ -1,9 +0,0 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> -

<%:Html.TitleForPage(T("Content Types").ToString())%>

-
<%: Html.ActionLink(T("Create new type").ToString(), "CreateType", null, new { @class = "button primaryAction" })%>
-<%:Html.UnorderedList( - Model.Types, - (t,i) => Html.DisplayFor(m => t), - "contentItems" - ) %> \ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 8997fb84e..e01c2e49b 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -73,12 +73,7 @@ - - - - - - + @@ -108,7 +103,6 @@ - @@ -208,25 +202,11 @@ - - - - - - - - - - - - - - diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs new file mode 100644 index 000000000..d8ac11b16 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs @@ -0,0 +1,16 @@ +using Orchard.Localization; +using Orchard.UI.Navigation; + +namespace Orchard.ContentTypes { + public class AdminMenu : INavigationProvider { + + public Localizer T { get; set; } + public string MenuName { get { return "admin"; } } + + public void GetNavigation(NavigationBuilder builder) { + + builder.Add(T("Site Configuration"), "11", + menu => menu.Add(T("Content Types"), "3", item => item.Action("Index", "Admin", new { area = "Orchard.ContentTypes" }))); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs new file mode 100644 index 000000000..1781e039c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs @@ -0,0 +1,277 @@ +using System.Linq; +using System.Web.Mvc; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentTypes.Services; +using Orchard.ContentTypes.ViewModels; +using Orchard.Data; +using Orchard.Localization; +using Orchard.Logging; +using Orchard.Mvc.Results; +using Orchard.UI.Notify; + +namespace Orchard.ContentTypes.Controllers { + public class AdminController : Controller { + private readonly INotifier _notifier; + private readonly IContentDefinitionService _contentDefinitionService; + private readonly IContentManager _contentManager; + private readonly ITransactionManager _transactionManager; + + public AdminController( + IOrchardServices orchardServices, + INotifier notifier, + IContentDefinitionService contentDefinitionService, + IContentManager contentManager, + ITransactionManager transactionManager) { + Services = orchardServices; + _notifier = notifier; + _contentDefinitionService = contentDefinitionService; + _contentManager = contentManager; + _transactionManager = transactionManager; + T = NullLocalizer.Instance; + Logger = NullLogger.Instance; + } + + public IOrchardServices Services { get; private set; } + public Localizer T { get; set; } + public ILogger Logger { get; set; } + public ActionResult Index() { + return List(); + } + + #region Types + + public ActionResult List() { + return View("List", new ListContentTypesViewModel { + Types = _contentDefinitionService.GetTypeDefinitions() + }); + } + + public ActionResult Create() { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type."))) + return new HttpUnauthorizedResult(); + + return View(new CreateTypeViewModel()); + } + + [HttpPost, ActionName("Create")] + public ActionResult CreatePOST(CreateTypeViewModel viewModel) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type."))) + return new HttpUnauthorizedResult(); + + var model = new ContentTypeDefinition(""); + TryUpdateModel(model); + + if (!ModelState.IsValid) { + Services.TransactionManager.Cancel(); + return View(viewModel); + } + + _contentDefinitionService.AddTypeDefinition(model); + + return RedirectToAction("Index"); + } + + public ActionResult Edit(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type."))) + return new HttpUnauthorizedResult(); + + var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); + + if (contentTypeDefinition == null) + return new NotFoundResult(); + + return View(new EditTypeViewModel(contentTypeDefinition)); + } + + [HttpPost, ActionName("Edit")] + public ActionResult EditPOST(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content type."))) + return new HttpUnauthorizedResult(); + + var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); + + if (contentTypeDefinition == null) + return new NotFoundResult(); + + var viewModel = new EditTypeViewModel(); + TryUpdateModel(viewModel); + + if (!ModelState.IsValid) + return Edit(id); + + var contentTypeDefinitionParts = viewModel.Parts.Select(GenerateTypePart).ToList(); + if (viewModel.Fields.Any()) + contentTypeDefinitionParts.Add(GenerateTypePart(viewModel)); + + //todo: apply the changes along the lines of but definately not resembling + // for now this _might_ just get a little messy -> + _contentDefinitionService.AlterTypeDefinition( + new ContentTypeDefinition( + viewModel.Name, + viewModel.DisplayName, + contentTypeDefinitionParts, + viewModel.Settings + ) + ); + + return RedirectToAction("Index"); + } + + private static ContentTypeDefinition.Part GenerateTypePart(EditTypePartViewModel viewModel) { + return new ContentTypeDefinition.Part( + new ContentPartDefinition( + viewModel.PartDefinition.Name, + viewModel.PartDefinition.Fields.Select( + f => new ContentPartDefinition.Field( + new ContentFieldDefinition(f.FieldDefinition.Name), + f.Name, + f.Settings + ) + ), + viewModel.PartDefinition.Settings + ), + viewModel.Settings + ); + } + + private static ContentTypeDefinition.Part GenerateTypePart(EditTypeViewModel viewModel) { + return new ContentTypeDefinition.Part( + new ContentPartDefinition( + viewModel.Name, + viewModel.Fields.Select( + f => new ContentPartDefinition.Field( + new ContentFieldDefinition(f.FieldDefinition.Name), + f.Name, + f.Settings + ) + ), + null + ), + null + ); + } + #endregion + + #region Parts + + public ActionResult EditPart(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) + return new HttpUnauthorizedResult(); + + var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); + + if (contentPartDefinition == null) + return new NotFoundResult(); + + return View(new EditPartViewModel(contentPartDefinition)); + } + + [HttpPost, ActionName("EditPart")] + public ActionResult EditPartPOST(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) + return new HttpUnauthorizedResult(); + + var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); + + if (contentPartDefinition == null) + return new NotFoundResult(); + + var viewModel = new EditPartViewModel(); + TryUpdateModel(viewModel); + + if (!ModelState.IsValid) + return EditPart(id); + + //todo: apply the changes along the lines of but definately not resembling + // for now this _might_ just get a little messy -> + _contentDefinitionService.AlterPartDefinition(GeneratePart(viewModel)); + + return RedirectToAction("Index"); + } + + public ActionResult AddFieldTo(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) + return new HttpUnauthorizedResult(); + + var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); + + if (contentPartDefinition == null) { + //id passed in might be that of a type w/ no implicit field + var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); + if (contentTypeDefinition != null) + contentPartDefinition = new ContentPartDefinition(id); + else + return new NotFoundResult(); + } + + var viewModel = new AddFieldViewModel { + Part = new EditPartViewModel(contentPartDefinition), + Fields = _contentDefinitionService.GetFieldDefinitions() + }; + + return View(viewModel); + } + + [HttpPost, ActionName("AddFieldTo")] + public ActionResult AddFieldToPOST(string id) { + if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part."))) + return new HttpUnauthorizedResult(); + + var viewModel = new AddFieldViewModel(); + TryUpdateModel(viewModel); + + var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id); + var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id); + + if (!ModelState.IsValid) + return AddFieldTo(id); + + if (contentPartDefinition == null) { + //id passed in might be that of a type w/ no implicit field + if (contentTypeDefinition != null) { + contentPartDefinition = new ContentPartDefinition(id); + var contentTypeDefinitionParts = contentTypeDefinition.Parts.ToList(); + contentTypeDefinitionParts.Add(new ContentTypeDefinition.Part(contentPartDefinition, null)); + _contentDefinitionService.AlterTypeDefinition( + new ContentTypeDefinition( + contentTypeDefinition.Name, + contentTypeDefinition.DisplayName, + contentTypeDefinitionParts, + contentTypeDefinition.Settings + ) + ); + } + else { + return new NotFoundResult(); + } + } + + var contentPartFields = contentPartDefinition.Fields.ToList(); + contentPartFields.Add(new ContentPartDefinition.Field(new ContentFieldDefinition(viewModel.FieldTypeName), viewModel.DisplayName, null)); + _contentDefinitionService.AlterPartDefinition(new ContentPartDefinition(contentPartDefinition.Name, contentPartFields, contentPartDefinition.Settings)); + + if (contentTypeDefinition != null) + return RedirectToAction("Edit", new { id }); + + return RedirectToAction("EditPart", new { id }); + } + + private static ContentPartDefinition GeneratePart(EditPartViewModel viewModel) { + return new ContentPartDefinition( + viewModel.Name, + viewModel.Fields.Select( + f => new ContentPartDefinition.Field( + new ContentFieldDefinition(f.FieldDefinition.Name), + f.Name, + f.Settings + ) + ), + viewModel.Settings + ); + } + + #endregion + + } +} diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Module.txt b/src/Orchard.Web/Modules/Orchard.ContentTypes/Module.txt new file mode 100644 index 000000000..417c9d7d8 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Module.txt @@ -0,0 +1,10 @@ +name: ContentTypes +antiforgery: enabled +author: The Orchard Team +website: http://orchardproject.net +version: 0.1 +orchardversion: 0.1.2010.0312 +features: + Orchard.ContentTypes: + Description: ContentTypes modules enables the creation and alteration of content types not based on code. + Category: Developer diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj b/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj new file mode 100644 index 000000000..52587c273 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj @@ -0,0 +1,146 @@ + + + + Debug + AnyCPU + + + 2.0 + {0E7646E8-FE8F-43C1-8799-D97860925EC4} + {F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Orchard.ContentTypes + Orchard.ContentTypes + v4.0 + false + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + False + ..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll + + + 3.5 + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + + {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} + Orchard.Framework + + + + + + + + + + + + + False + True + 9983 + / + + + False + False + + + False + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Permissions.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Permissions.cs similarity index 94% rename from src/Orchard.Web/Core/Contents/Permissions.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Permissions.cs index ccc2c9641..9b0620aed 100644 --- a/src/Orchard.Web/Core/Contents/Permissions.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Permissions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Orchard.Security.Permissions; -namespace Orchard.Core.Contents { +namespace Orchard.ContentTypes { public class Permissions : IPermissionProvider { public static readonly Permission CreateContentTypes = new Permission { Name = "CreateContentTypes", Description = "Create custom content types." }; public static readonly Permission EditContentTypes = new Permission { Name = "EditContentTypes", Description = "Edit content types." }; diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Properties/AssemblyInfo.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9df4b96b9 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/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("Orchard.ContentTypes")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Orchard.ContentTypes")] +[assembly: AssemblyCopyright("Copyright © Microsoft 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("984154ba-5cb9-4728-9551-535c8773fd83")] + +// 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/Core/Contents/Services/ContentDefinitionService.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs similarity index 96% rename from src/Orchard.Web/Core/Contents/Services/ContentDefinitionService.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs index a3f833085..89959b5bf 100644 --- a/src/Orchard.Web/Core/Contents/Services/ContentDefinitionService.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs @@ -8,7 +8,7 @@ using Orchard.ContentManagement.MetaData.Models; using Orchard.Localization; using Orchard.UI.Notify; -namespace Orchard.Core.Contents.Services { +namespace Orchard.ContentTypes.Services { public class ContentDefinitionService : IContentDefinitionService { private readonly IContentDefinitionManager _contentDefinitionManager; private readonly IEnumerable _contentFieldDrivers; diff --git a/src/Orchard.Web/Core/Contents/Services/IContentDefinitionService.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IContentDefinitionService.cs similarity index 93% rename from src/Orchard.Web/Core/Contents/Services/IContentDefinitionService.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IContentDefinitionService.cs index 53793e78c..575c8fd4e 100644 --- a/src/Orchard.Web/Core/Contents/Services/IContentDefinitionService.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IContentDefinitionService.cs @@ -2,7 +2,7 @@ using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData.Models; -namespace Orchard.Core.Contents.Services { +namespace Orchard.ContentTypes.Services { public interface IContentDefinitionService : IDependency { IEnumerable GetTypeDefinitions(); ContentTypeDefinition GetTypeDefinition(string name); diff --git a/src/Orchard.Web/Core/Contents/ViewModels/AddFieldViewModel.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/AddFieldViewModel.cs similarity index 88% rename from src/Orchard.Web/Core/Contents/ViewModels/AddFieldViewModel.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/AddFieldViewModel.cs index f26912f63..404985813 100644 --- a/src/Orchard.Web/Core/Contents/ViewModels/AddFieldViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/AddFieldViewModel.cs @@ -2,7 +2,7 @@ using Orchard.ContentManagement.MetaData; using Orchard.Mvc.ViewModels; -namespace Orchard.Core.Contents.ViewModels { +namespace Orchard.ContentTypes.ViewModels { public class AddFieldViewModel : BaseViewModel { public AddFieldViewModel() { Fields = new List(); diff --git a/src/Orchard.Web/Core/Contents/ViewModels/CreateTypeViewModel.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/CreateTypeViewModel.cs similarity index 73% rename from src/Orchard.Web/Core/Contents/ViewModels/CreateTypeViewModel.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/CreateTypeViewModel.cs index 611ec7bb6..ad93e49ba 100644 --- a/src/Orchard.Web/Core/Contents/ViewModels/CreateTypeViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/CreateTypeViewModel.cs @@ -1,6 +1,6 @@ using Orchard.Mvc.ViewModels; -namespace Orchard.Core.Contents.ViewModels { +namespace Orchard.ContentTypes.ViewModels { public class CreateTypeViewModel : BaseViewModel { public string DisplayName { get; set; } } diff --git a/src/Orchard.Web/Core/Contents/ViewModels/EditTypeViewModel.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/EditTypeViewModel.cs similarity index 96% rename from src/Orchard.Web/Core/Contents/ViewModels/EditTypeViewModel.cs rename to src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/EditTypeViewModel.cs index 20bbb4772..5ff54a160 100644 --- a/src/Orchard.Web/Core/Contents/ViewModels/EditTypeViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/EditTypeViewModel.cs @@ -3,7 +3,7 @@ using System.Linq; using Orchard.ContentManagement.MetaData.Models; using Orchard.Mvc.ViewModels; -namespace Orchard.Core.Contents.ViewModels { +namespace Orchard.ContentTypes.ViewModels { public class EditTypeViewModel : BaseViewModel { public EditTypeViewModel() { Settings = new SettingsDictionary(); diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentTypesViewModel.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentTypesViewModel.cs new file mode 100644 index 000000000..df9bce874 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentTypesViewModel.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.Mvc.ViewModels; + +namespace Orchard.ContentTypes.ViewModels { + public class ListContentTypesViewModel : BaseViewModel { + public IEnumerable Types { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentsViewModel.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentsViewModel.cs new file mode 100644 index 000000000..ada84e833 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/ViewModels/ListContentsViewModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.Mvc.ViewModels; + +namespace Orchard.ContentTypes.ViewModels { + public class ListContentsViewModel : BaseViewModel { + public string Id { get; set; } + public int? Page { get; set; } + public IList Entries { get; set; } + + public class Entry { + public ContentItem ContentItem { get; set; } + public ContentItemMetadata ContentItemMetadata { get; set; } + public ContentItemViewModel ViewModel { get; set; } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/AddFieldTo.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddFieldTo.ascx similarity index 88% rename from src/Orchard.Web/Core/Contents/Views/Admin/AddFieldTo.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddFieldTo.ascx index 79a562468..df62568da 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/AddFieldTo.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddFieldTo.ascx @@ -1,5 +1,5 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<% Html.RegisterStyle("admin.css"); %>

<%:Html.TitleForPage(T("Add a new field to {0}", Model.Part.Name).ToString())%>

<% using (Html.BeginFormAntiForgeryPost()) { %> diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/CreateType.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Create.ascx similarity index 84% rename from src/Orchard.Web/Core/Contents/Views/Admin/CreateType.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Create.ascx index ca466aa3d..01c72136a 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/CreateType.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Create.ascx @@ -1,5 +1,5 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +

<%:Html.TitleForPage(T("New Content Type").ToString())%>

<% using (Html.BeginFormAntiForgeryPost()) { %> <%:Html.ValidationSummary() %> diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/EditType.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Edit.ascx similarity index 88% rename from src/Orchard.Web/Core/Contents/Views/Admin/EditType.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Edit.ascx index 79fc9d4e4..e32d26d0c 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/EditType.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/Edit.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% Html.RegisterStyle("admin.css"); %>

<%:Html.TitleForPage(T("Edit Content Type").ToString())%>

@@ -18,7 +18,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%: Html.ActionLink(T("Add").Text, "AddPart", new { }, new { @class = "button" }) %>
<%:Html.EditorFor(m => m.Parts, "Parts", "") %>

<%:T("Fields") %>

-
<%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Contents", id = Model.Name }, new { @class = "button" }) %>
+
<%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %>
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/EditPart.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/EditPart.ascx similarity index 80% rename from src/Orchard.Web/Core/Contents/Views/Admin/EditPart.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/EditPart.ascx index c3f6642c5..34901350b 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/EditPart.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/EditPart.ascx @@ -1,5 +1,5 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<% Html.RegisterStyle("admin.css"); %>

<%:Html.TitleForPage(T("Edit Part").ToString()) %>

<% using (Html.BeginFormAntiForgeryPost()) { %> @@ -11,7 +11,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>

<%:T("Fields") %>

-
<%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Contents", id = Model.Name }, new { @class = "button" }) %>
+
<%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %>
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/List.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/List.ascx new file mode 100644 index 000000000..362ac9697 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/List.ascx @@ -0,0 +1,11 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> + +

+ <%:Html.TitleForPage(T("Content Types").ToString())%>

+
+ <%: Html.ActionLink(T("Create new type").ToString(), "Create", new{Controller="Admin",Area="Orchard.ContentTypes"}, new { @class = "button primaryAction" })%>
+<%:Html.UnorderedList( + Model.Types, + (t,i) => Html.DisplayFor(m => t), + "contentItems" + ) %> diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/ContentTypeDefinition.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/ContentTypeDefinition.ascx similarity index 73% rename from src/Orchard.Web/Core/Contents/Views/DisplayTemplates/ContentTypeDefinition.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/ContentTypeDefinition.ascx index 15dfd2ca4..355388283 100644 --- a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/ContentTypeDefinition.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/ContentTypeDefinition.ascx @@ -7,8 +7,8 @@ diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Field.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Field.ascx similarity index 80% rename from src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Field.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Field.ascx index 08660099b..bab26afb7 100644 --- a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Field.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Field.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
<%:Model.Name %> (<%:Model.FieldDefinition.Name %>)
diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Fields.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Fields.ascx similarity index 78% rename from src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Fields.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Fields.ascx index 164e32511..c98cfb107 100644 --- a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Fields.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Fields.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% if (Model.Any()) { %>
<% diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Settings.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Settings.ascx similarity index 100% rename from src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Settings.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/Settings.ascx diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/ContentTypePart.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/ContentTypePart.ascx new file mode 100644 index 000000000..2cb7e4dc6 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/ContentTypePart.ascx @@ -0,0 +1,13 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Orchard.ContentManagement.MetaData.Models" %> +
+

<%:Model.PartDefinition.Name %>

+
+ <%--// these inline forms can't be here. should probably have some JavaScript in here to build up the forms and add the "remove" link. + // get the antiforgery token from the edit type form and mark up the part in a semantic way so I can get some info from the DOM --%> + <% using (Html.BeginFormAntiForgeryPost(Url.Action("RemovePart", new { area = "Contents" }), FormMethod.Post, new {@class = "inline link"})) { %> + <%=Html.Hidden("name", Model.PartDefinition.Name, new { id = "" }) %> + + <% } %> +
+
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Field.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.ascx similarity index 85% rename from src/Orchard.Web/Core/Contents/Views/EditorTemplates/Field.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.ascx index 4ca058cba..45ab564bd 100644 --- a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Field.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>

<%:Model.Name %> (<%:Model.FieldDefinition.Name %>)

@@ -6,7 +6,7 @@ <%--// these inline forms can't be here. should probably have some JavaScript in here to build up the forms and add the "remove" link. // get the antiforgery token from the edit type form and mark up the part in a semantic way so I can get some info from the DOM --%> <%:Html.Link("[remove]", "#forshowonlyandnotintendedtowork!") %> -<%-- <% using (Html.BeginFormAntiForgeryPost(Url.Action("RemovePart", new { area = "Contents" }), FormMethod.Post, new {@class = "inline link"})) { %> +<%-- <% using (Html.BeginFormAntiForgeryPost(Url.Action("RemovePart", new { area = "Orchard.ContentTypes" }), FormMethod.Post, new {@class = "inline link"})) { %> <%:Html.Hidden("name", Model.PartDefinition.Name, new { id = "" }) %> <% } %> --%> diff --git a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Fields.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Fields.ascx similarity index 82% rename from src/Orchard.Web/Core/Contents/Views/EditorTemplates/Fields.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Fields.ascx index c22a4f3bb..6fcb47ed5 100644 --- a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Fields.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Fields.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% if (Model.Any()) { %>
<% diff --git a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Part.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Part.ascx similarity index 88% rename from src/Orchard.Web/Core/Contents/Views/EditorTemplates/Part.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Part.ascx index 8ae5b99ad..b50b43632 100644 --- a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Part.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Part.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>

<%:Model.PartDefinition.Name %>

@@ -13,7 +13,7 @@ <%:Html.EditorFor(m => m.Settings, "Settings", "") %>

<%:T("Global configuration") %>

-
<%:Html.ActionLink(T("Edit").Text, "EditPart", new { area = "Contents", id = Model.PartDefinition.Name }) %>
+
<%:Html.ActionLink(T("Edit").Text, "EditPart", new { area = "Orchard.ContentTypes", id = Model.PartDefinition.Name }) %>
<%:Html.DisplayFor(m => m.PartDefinition.Settings, "Settings", "PartDefinition") %> <%:Html.DisplayFor(m => m.PartDefinition.Fields, "Fields") %> <%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %> diff --git a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Parts.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Parts.ascx similarity index 82% rename from src/Orchard.Web/Core/Contents/Views/EditorTemplates/Parts.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Parts.ascx index 13d0904af..b0158b24b 100644 --- a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Parts.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Parts.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><% if (Model.Any()) { %>
<% diff --git a/src/Orchard.Web/Core/Contents/Views/EditorTemplates/Settings.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Settings.ascx similarity index 100% rename from src/Orchard.Web/Core/Contents/Views/EditorTemplates/Settings.ascx rename to src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Settings.ascx diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Web.config b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Web.config new file mode 100644 index 000000000..c397ca482 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Web.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Debug.config b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Debug.config new file mode 100644 index 000000000..962e6b73a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Release.config b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Release.config new file mode 100644 index 000000000..141832ba7 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.config b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.config new file mode 100644 index 000000000..f1065d171 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Web.config @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 91ecbb3a2..8b22c45bb 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -127,6 +127,10 @@ {14C049FD-B35B-415A-A824-87F26B26E7FD} Orchard.Comments + + {0E7646E8-FE8F-43C1-8799-D97860925EC4} + Orchard.ContentTypes + {67C1D3AF-A0EC-46B2-BAE1-DF1DA8E0B890} Orchard.DevTools diff --git a/src/Orchard.sln b/src/Orchard.sln index a9604af83..e18c0dcd4 100644 --- a/src/Orchard.sln +++ b/src/Orchard.sln @@ -69,6 +69,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Search", "Orchard.W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Indexing", "Orchard.Web\Modules\Orchard.Indexing\Orchard.Indexing.csproj", "{EA2B9121-EF54-40A6-A53E-6593C86EE696}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.ContentTypes", "Orchard.Web\Modules\Orchard.ContentTypes\Orchard.ContentTypes.csproj", "{0E7646E8-FE8F-43C1-8799-D97860925EC4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -195,6 +197,10 @@ Global {EA2B9121-EF54-40A6-A53E-6593C86EE696}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA2B9121-EF54-40A6-A53E-6593C86EE696}.Release|Any CPU.ActiveCfg = Release|Any CPU {EA2B9121-EF54-40A6-A53E-6593C86EE696}.Release|Any CPU.Build.0 = Release|Any CPU + {0E7646E8-FE8F-43C1-8799-D97860925EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E7646E8-FE8F-43C1-8799-D97860925EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E7646E8-FE8F-43C1-8799-D97860925EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E7646E8-FE8F-43C1-8799-D97860925EC4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -217,6 +223,7 @@ Global {23E04990-2A8D-41B8-9908-6DDB71EA3B23} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5} {4BE4EB01-AC56-4048-924E-2CA77F509ABA} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5} {EA2B9121-EF54-40A6-A53E-6593C86EE696} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5} + {0E7646E8-FE8F-43C1-8799-D97860925EC4} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5} {ABC826D4-2FA1-4F2F-87DE-E6095F653810} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA} {F112851D-B023-4746-B6B1-8D2E5AD8F7AA} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA} {6CB3EB30-F725-45C0-9742-42599BA8E8D2} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}