From 81b93a6699416ae00be874ba941ff962d5d9f119 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 6 Jul 2010 11:25:39 -0700 Subject: [PATCH 01/12] Small refactorings --HG-- branch : dev --- .../ExtensionLoaderCoordinatorTests.cs | 4 ++-- .../Extensions/ExtensionManagerTests.cs | 4 ++-- .../Commands/CommandHostEnvironment.cs | 5 +++++ .../Extensions/ExtensionLoaderCoordinator.cs | 4 ++-- .../Extensions/Loaders/ExtensionLoaderBase.cs | 6 +----- .../Extensions/Loaders/IExtensionLoader.cs | 4 ++-- .../Loaders/PrecompiledExtensionLoader.cs | 19 +++++++++++-------- .../Loaders/ProbingExtensionLoader.cs | 13 +++++++++---- src/Orchard/Environment/IHostEnvironment.cs | 7 +++++++ 9 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/Orchard.Tests/Environment/Extensions/ExtensionLoaderCoordinatorTests.cs b/src/Orchard.Tests/Environment/Extensions/ExtensionLoaderCoordinatorTests.cs index 6e3df715a..f6f6271fd 100644 --- a/src/Orchard.Tests/Environment/Extensions/ExtensionLoaderCoordinatorTests.cs +++ b/src/Orchard.Tests/Environment/Extensions/ExtensionLoaderCoordinatorTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -68,7 +68,7 @@ namespace Orchard.Tests.Environment.Extensions { throw new NotImplementedException(); } - public bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references) { + public bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references) { throw new NotImplementedException(); } diff --git a/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs b/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs index 41ef9dd98..af342a9fb 100644 --- a/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs +++ b/src/Orchard.Tests/Environment/Extensions/ExtensionManagerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -68,7 +68,7 @@ namespace Orchard.Tests.Environment.Extensions { throw new NotImplementedException(); } - public bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references) { + public bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references) { throw new NotImplementedException(); } diff --git a/src/Orchard/Commands/CommandHostEnvironment.cs b/src/Orchard/Commands/CommandHostEnvironment.cs index a44e69bbc..00a3d6dfd 100644 --- a/src/Orchard/Commands/CommandHostEnvironment.cs +++ b/src/Orchard/Commands/CommandHostEnvironment.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Web.Hosting; using Orchard.Environment; @@ -12,6 +13,10 @@ namespace Orchard.Commands { return HostingEnvironment.MapPath(virtualPath); } + public bool IsAssemblyLoaded(string name) { + return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == name); + } + public void RestartAppDomain() { //Don't restart AppDomain in command line environment } diff --git a/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs b/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs index 6041ca598..15ca04ed6 100644 --- a/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs +++ b/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Orchard.Caching; @@ -112,7 +112,7 @@ namespace Orchard.Environment.Extensions { .Select(e => context.ProcessedExtensions[e.Name]); var activatedExtension = extensionProbes - .Where(e => e.Loader.IsCompatibleWithReferences(extension, processedModuleReferences)) + .Where(e => e.Loader.IsCompatibleWithModuleReferences(extension, processedModuleReferences)) .FirstOrDefault(); var previousDependency = context.PreviousDependencies.Where(d => StringComparer.OrdinalIgnoreCase.Equals(d.Name, extension.Name)).FirstOrDefault(); diff --git a/src/Orchard/Environment/Extensions/Loaders/ExtensionLoaderBase.cs b/src/Orchard/Environment/Extensions/Loaders/ExtensionLoaderBase.cs index d17b6926a..70a5f41e2 100644 --- a/src/Orchard/Environment/Extensions/Loaders/ExtensionLoaderBase.cs +++ b/src/Orchard/Environment/Extensions/Loaders/ExtensionLoaderBase.cs @@ -25,7 +25,7 @@ namespace Orchard.Environment.Extensions.Loaders { return null; } - public virtual bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references) { + public virtual bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references) { return true; } @@ -57,9 +57,5 @@ namespace Orchard.Environment.Extensions.Loaders { public virtual IEnumerable GetWebFormVirtualDependencies(DependencyDescriptor dependency) { return Enumerable.Empty(); } - - protected static bool IsAssemblyLoaded(string moduleName) { - return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == moduleName); - } } } \ No newline at end of file diff --git a/src/Orchard/Environment/Extensions/Loaders/IExtensionLoader.cs b/src/Orchard/Environment/Extensions/Loaders/IExtensionLoader.cs index 3fe68678c..2b07e6ff5 100644 --- a/src/Orchard/Environment/Extensions/Loaders/IExtensionLoader.cs +++ b/src/Orchard/Environment/Extensions/Loaders/IExtensionLoader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; using Orchard.Caching; @@ -29,7 +29,7 @@ namespace Orchard.Environment.Extensions.Loaders { Assembly LoadReference(DependencyReferenceDescriptor reference); void ReferenceActivated(ExtensionLoadingContext context, ExtensionReferenceProbeEntry referenceEntry); void ReferenceDeactivated(ExtensionLoadingContext context, ExtensionReferenceProbeEntry referenceEntry); - bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references); + bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references); ExtensionProbeEntry Probe(ExtensionDescriptor descriptor); ExtensionEntry Load(ExtensionDescriptor descriptor); diff --git a/src/Orchard/Environment/Extensions/Loaders/PrecompiledExtensionLoader.cs b/src/Orchard/Environment/Extensions/Loaders/PrecompiledExtensionLoader.cs index e9d767423..987851936 100644 --- a/src/Orchard/Environment/Extensions/Loaders/PrecompiledExtensionLoader.cs +++ b/src/Orchard/Environment/Extensions/Loaders/PrecompiledExtensionLoader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -15,16 +15,19 @@ namespace Orchard.Environment.Extensions.Loaders { /// extension directory. /// public class PrecompiledExtensionLoader : ExtensionLoaderBase { + private readonly IHostEnvironment _hostEnvironment; private readonly IAssemblyProbingFolder _assemblyProbingFolder; private readonly IVirtualPathProvider _virtualPathProvider; private readonly IVirtualPathMonitor _virtualPathMonitor; - public PrecompiledExtensionLoader(IDependenciesFolder dependenciesFolder, + public PrecompiledExtensionLoader( + IHostEnvironment hostEnvironment, + IDependenciesFolder dependenciesFolder, IAssemblyProbingFolder assemblyProbingFolder, IVirtualPathProvider virtualPathProvider, IVirtualPathMonitor virtualPathMonitor) : base(dependenciesFolder) { - + _hostEnvironment = hostEnvironment; _assemblyProbingFolder = assemblyProbingFolder; _virtualPathProvider = virtualPathProvider; _virtualPathMonitor = virtualPathMonitor; @@ -53,7 +56,7 @@ namespace Orchard.Environment.Extensions.Loaders { }); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(dependency.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(dependency.Name)) { Logger.Information("ExtensionRemoved: Module \"{0}\" is removed and its assembly is loaded, forcing AppDomain restart", dependency.Name); ctx.RestartAppDomain = true; } @@ -72,7 +75,7 @@ namespace Orchard.Environment.Extensions.Loaders { ctx.CopyActions.Add(() => _assemblyProbingFolder.StoreAssembly(extension.Name, sourceFileName)); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(extension.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(extension.Name)) { Logger.Information("ExtensionRemoved: Module \"{0}\" is activated with newer file and its assembly is loaded, forcing AppDomain restart", extension.Name); ctx.RestartAppDomain = true; } @@ -88,7 +91,7 @@ namespace Orchard.Environment.Extensions.Loaders { }); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(extension.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(extension.Name)) { Logger.Information("ExtensionDeactivated: Module \"{0}\" is deactivated and its assembly is loaded, forcing AppDomain restart", extension.Name); ctx.RestartAppDomain = true; } @@ -110,7 +113,7 @@ namespace Orchard.Environment.Extensions.Loaders { context.CopyActions.Add(() => _assemblyProbingFolder.StoreAssembly(referenceEntry.Name, sourceFileName)); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(referenceEntry.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(referenceEntry.Name)) { Logger.Information("ReferenceActivated: Reference \"{0}\" is activated with newer file and its assembly is loaded, forcing AppDomain restart", referenceEntry.Name); context.RestartAppDomain = true; } @@ -143,7 +146,7 @@ namespace Orchard.Environment.Extensions.Loaders { } ); } - public override bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references) { + public override bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references) { // A pre-compiled module is _not_ compatible with a dynamically loaded module // because a pre-compiled module usually references a pre-compiled assembly binary // which will have a different identity (i.e. name) from the dynamic module. diff --git a/src/Orchard/Environment/Extensions/Loaders/ProbingExtensionLoader.cs b/src/Orchard/Environment/Extensions/Loaders/ProbingExtensionLoader.cs index 179db141d..95e44dba2 100644 --- a/src/Orchard/Environment/Extensions/Loaders/ProbingExtensionLoader.cs +++ b/src/Orchard/Environment/Extensions/Loaders/ProbingExtensionLoader.cs @@ -10,12 +10,17 @@ namespace Orchard.Environment.Extensions.Loaders { /// file can be found in the "App_Data/Dependencies" folder. /// public class ProbingExtensionLoader : ExtensionLoaderBase { + private readonly IHostEnvironment _hostEnvironment; private readonly IDependenciesFolder _dependenciesFolder; private readonly IAssemblyProbingFolder _assemblyProbingFolder; - public ProbingExtensionLoader(IDependenciesFolder dependenciesFolder, IAssemblyProbingFolder assemblyProbingFolder) + public ProbingExtensionLoader( + IHostEnvironment hostEnvironment, + IDependenciesFolder dependenciesFolder, + IAssemblyProbingFolder assemblyProbingFolder) : base(dependenciesFolder) { + _hostEnvironment = hostEnvironment; _dependenciesFolder = dependenciesFolder; _assemblyProbingFolder = assemblyProbingFolder; Logger = NullLogger.Instance; @@ -42,7 +47,7 @@ namespace Orchard.Environment.Extensions.Loaders { }); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(dependency.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(dependency.Name)) { Logger.Information("ExtensionRemoved: Module \"{0}\" is removed and its assembly is loaded, forcing AppDomain restart", dependency.Name); ctx.RestartAppDomain = true; } @@ -58,14 +63,14 @@ namespace Orchard.Environment.Extensions.Loaders { }); // We need to restart the appDomain if the assembly is loaded - if (IsAssemblyLoaded(extension.Name)) { + if (_hostEnvironment.IsAssemblyLoaded(extension.Name)) { Logger.Information("ExtensionDeactivated: Module \"{0}\" is deactivated and its assembly is loaded, forcing AppDomain restart", extension.Name); ctx.RestartAppDomain = true; } } } - public override bool IsCompatibleWithReferences(ExtensionDescriptor extension, IEnumerable references) { + public override bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable references) { // A pre-compiled module is _not_ compatible with a dynamically loaded module // because a pre-compiled module usually references a pre-compiled assembly binary // which will have a different identity (i.e. name) from the dynamic module. diff --git a/src/Orchard/Environment/IHostEnvironment.cs b/src/Orchard/Environment/IHostEnvironment.cs index 135744917..772ef04fa 100644 --- a/src/Orchard/Environment/IHostEnvironment.cs +++ b/src/Orchard/Environment/IHostEnvironment.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using System.Web; using System.Web.Hosting; using Orchard.Services; @@ -13,6 +14,8 @@ namespace Orchard.Environment { bool IsFullTrust { get; } string MapPath(string virtualPath); + bool IsAssemblyLoaded(string name); + void RestartAppDomain(); void ResetSiteCompilation(); } @@ -32,6 +35,10 @@ namespace Orchard.Environment { return HostingEnvironment.MapPath(virtualPath); } + public bool IsAssemblyLoaded(string name) { + return AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == name); + } + public void RestartAppDomain() { ResetSiteCompilation(); } From c4b6a16122fce6b442047f9a51cbbb2ab8d00d7f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 6 Jul 2010 17:54:05 -0700 Subject: [PATCH 02/12] Make the devtools controller Admin --HG-- branch : dev --- .../Modules/Orchard.DevTools/Controllers/HomeController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs index dff4fe782..f27e317f6 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs @@ -4,9 +4,11 @@ using Orchard.Localization; using Orchard.Mvc.ViewModels; using Orchard.Themes; using Orchard.UI.Notify; +using Orchard.UI.Admin; namespace Orchard.DevTools.Controllers { [Themed] + [Admin] public class HomeController : Controller { private readonly INotifier _notifier; From 0abf6a2374f9a8afcabf0eae13d82234787b0499 Mon Sep 17 00:00:00 2001 From: Jonathan Wall Date: Wed, 7 Jul 2010 15:43:05 -0700 Subject: [PATCH 03/12] Updated Cultures page UI. --HG-- branch : dev --- .../Core/Settings/Styles/admin.css | 5 ++-- .../Core/Settings/Views/Admin/Culture.ascx | 23 ++++++++++--------- .../Themes/TheAdmin/Styles/site.css | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Orchard.Web/Core/Settings/Styles/admin.css b/src/Orchard.Web/Core/Settings/Styles/admin.css index 53fc62882..6da6aeff1 100644 --- a/src/Orchard.Web/Core/Settings/Styles/admin.css +++ b/src/Orchard.Web/Core/Settings/Styles/admin.css @@ -1,5 +1,6 @@ .site-cultures { - font-size:1.2em; + font-size:1.4em; + line-height:1.8em; overflow:auto; } .site-cultures li { @@ -14,5 +15,5 @@ } .site-cultures div { float:left; - width:6em; + width:8em; } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx b/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx index 8d8a70261..b7b42cc34 100644 --- a/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx +++ b/src/Orchard.Web/Core/Settings/Views/Admin/Culture.ascx @@ -1,18 +1,19 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Settings.ViewModels" %><% Html.RegisterStyle("admin.css"); %> -

<%:Html.TitleForPage(T("Supported Cultures").ToString()) %>

+

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

-

<%:T("Cultures this site supports") %>

+

<%:T("Available Cultures") %>

+<% using (Html.BeginFormAntiForgeryPost("AddCulture")) { %> +<%:Html.ValidationSummary() %> +
+ + <%:Html.DropDownList("CultureName", new SelectList(Model.AvailableSystemCultures.OrderBy(s => s), Model.CurrentCulture))%> + +
+<% } %> +

<%:T("Cultures this site supports") %>

<%: Html.UnorderedList( Model.SiteCultures.OrderBy(s => s), (s, i) => Html.DisplayFor(scvm => s, s == Model.CurrentCulture ? "CurrentCulture" : "RemovableCulture", ""), - "site-cultures", "culture", "odd")%> -<% using (Html.BeginFormAntiForgeryPost("AddCulture")) { %> -<%:Html.ValidationSummary() %> -
- - <%:Html.DropDownList("CultureName", new SelectList(Model.AvailableSystemCultures.OrderBy(s => s), Model.CurrentCulture)) %> - -
-<% } %> \ No newline at end of file + "site-cultures", "culture", "odd")%> \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css index a106bbd64..ef5973f6f 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css +++ b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css @@ -397,8 +397,8 @@ label input { } /* todo: (heskew) try to get .text on stuff like .text-box */ select, textarea, input.text, input.textMedium, input.text-box { - padding:2px; - border:1px solid #bdbcbc; + padding:1px; + border:1px solid #bdbcbc; } input.text, input.textMedium, input.text-box { line-height:1.2em; From 322125a33f9a877b9f4cb59bb8097cbf91f4731c Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 15:51:03 -0700 Subject: [PATCH 04/12] Search results are no more filtered by culture by default --HG-- branch : dev --- .../Modules/Orchard.Search/Models/SearchSettingsRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Search/Models/SearchSettingsRecord.cs b/src/Orchard.Web/Modules/Orchard.Search/Models/SearchSettingsRecord.cs index e89f60435..f48178abb 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Models/SearchSettingsRecord.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Models/SearchSettingsRecord.cs @@ -6,7 +6,7 @@ namespace Orchard.Search.Models { public virtual string SearchedFields { get; set; } public SearchSettingsRecord() { - FilterCulture = true; + FilterCulture = false; SearchedFields = "body, title"; } } From d1a4edd34980381ee27f03909d15f4116aafb4f7 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 16:29:58 -0700 Subject: [PATCH 05/12] Implement ContentPartRecord and ContentPartVersionRecord for migration classes, to get rid of the explicit IDs --HG-- branch : dev --- .../Common/DataMigrations/CommonDataMigration.cs | 11 ++++------- .../DataMigrations/LocalizationDataMigration.cs | 2 +- .../DataMigrations/NavigationDataMigration.cs | 4 ++-- .../DataMigrations/SettingsDataMigration.cs | 2 +- .../DataMigrations/WidgetsDataMigration.cs | 2 +- .../DataMigrations/CommentsDataMigration.cs | 6 +++--- .../DataMigrations/MediaDataMigration.cs | 2 +- .../DataMigrations/SandBoxDataMigration.cs | 4 ++-- .../DataMigrations/SearchDataMigration.cs | 2 +- .../DataMigrations/ThemesDataMigration.cs | 4 ++-- .../DataMigrations/UsersDataMigration.cs | 2 +- .../Data/Migration/Schema/CreateTableCommand.cs | 15 +++++++++++---- 12 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs index f1fa72627..5d0077ca3 100644 --- a/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs +++ b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs @@ -7,15 +7,14 @@ namespace Orchard.Core.Common.DataMigrations { public int Create() { //CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("BodyRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartVersionRecord() .Column("Text") .Column("Format") - .Column("ContentItemRecord_id") ); //CREATE TABLE Common_CommonRecord (Id INTEGER not null, OwnerId INTEGER, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, Container_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("CommonRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("OwnerId") .Column("CreatedUtc") .Column("PublishedUtc") @@ -25,20 +24,18 @@ namespace Orchard.Core.Common.DataMigrations { //CREATE TABLE Common_CommonVersionRecord (Id INTEGER not null, CreatedUtc DATETIME, PublishedUtc DATETIME, ModifiedUtc DATETIME, ContentItemRecord_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("CommonVersionRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartVersionRecord() .Column("CreatedUtc") .Column("PublishedUtc") .Column("ModifiedUtc") - .Column("ContentItemRecord_id") ); //CREATE TABLE Common_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("RoutableRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartVersionRecord() .Column("Title") .Column("Slug") .Column("Path") - .Column("ContentItemRecord_id") ); return 0010; diff --git a/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs b/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs index 1eed07b70..baa4b9549 100644 --- a/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs +++ b/src/Orchard.Web/Core/Localization/DataMigrations/LocalizationDataMigration.cs @@ -6,7 +6,7 @@ namespace Orchard.Core.Localization.DataMigrations { public int Create() { //CREATE TABLE Localization_LocalizedRecord (Id INTEGER not null, CultureId INTEGER, MasterContentItemId INTEGER, primary key (Id)); SchemaBuilder.CreateTable("LocalizedRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("CultureId") .Column("MasterContentItemId") ); diff --git a/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs b/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs index 2910c823b..2b956d3e4 100644 --- a/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs +++ b/src/Orchard.Web/Core/Navigation/DataMigrations/NavigationDataMigration.cs @@ -6,13 +6,13 @@ namespace Orchard.Core.Navigation.DataMigrations { public int Create() { //CREATE TABLE Navigation_MenuItemRecord (Id INTEGER not null, Url TEXT, primary key (Id)); SchemaBuilder.CreateTable("MenuItemRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("Url") ); //CREATE TABLE Navigation_MenuPartRecord (Id INTEGER not null, MenuText TEXT, MenuPosition TEXT, OnMainMenu INTEGER, primary key (Id)); SchemaBuilder.CreateTable("MenuPartRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("MenuText") .Column("MenuPosition") .Column("OnMainMenu") diff --git a/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs b/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs index 2116c1ca8..9e6767c87 100644 --- a/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs +++ b/src/Orchard.Web/Core/Settings/DataMigrations/SettingsDataMigration.cs @@ -82,7 +82,7 @@ namespace Orchard.Core.Settings.DataMigrations { //CREATE TABLE Settings_SiteSettingsRecord (Id INTEGER not null, SiteSalt TEXT, SiteName TEXT, SuperUser TEXT, PageTitleSeparator TEXT, HomePage TEXT, SiteCulture TEXT, primary key (Id)); SchemaBuilder.CreateTable("SiteSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("SiteSalt") .Column("SiteName") .Column("SuperUser") diff --git a/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs b/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs index 6e06cd0ae..35a9a8ac0 100644 --- a/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs +++ b/src/Orchard.Web/Modules/Futures.Widgets/DataMigrations/WidgetsDataMigration.cs @@ -11,7 +11,7 @@ namespace Futures.Widgets.DataMigrations { //CREATE TABLE Futures_Widgets_WidgetRecord (Id INTEGER not null, Zone TEXT, Position TEXT, Scope_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("WidgetRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("Zone") .Column("Position") .Column("Scope_id") diff --git a/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs index 7b7f1d689..9fb9882f1 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs @@ -13,7 +13,7 @@ namespace Orchard.Comments.DataMigrations { //CREATE TABLE Orchard_Comments_CommentRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id)); SchemaBuilder.CreateTable("CommentRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("Author") .Column("SiteName") .Column("UserName") @@ -27,7 +27,7 @@ namespace Orchard.Comments.DataMigrations { //CREATE TABLE Orchard_Comments_CommentSettingsRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id)); SchemaBuilder.CreateTable("CommentSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("ModerateComments") .Column("EnableSpamProtection") .Column("AkismetKey") @@ -36,7 +36,7 @@ namespace Orchard.Comments.DataMigrations { //CREATE TABLE Orchard_Comments_HasCommentsRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id)); SchemaBuilder.CreateTable("HasCommentsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("CommentsShown") .Column("CommentsActive") ); diff --git a/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs index e46870480..11b16fb3c 100644 --- a/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Media/DataMigrations/MediaDataMigration.cs @@ -6,7 +6,7 @@ namespace Orchard.Media.DataMigrations { public int Create() { //CREATE TABLE Orchard_Media_MediaSettingsRecord (Id INTEGER not null, RootMediaFolder TEXT, primary key (Id)); SchemaBuilder.CreateTable("MediaSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("RootMediaFolder") ); diff --git a/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs index 88a9aafce..95841485f 100644 --- a/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Sandbox/DataMigrations/SandBoxDataMigration.cs @@ -5,12 +5,12 @@ namespace Orchard.Sandbox.DataMigrations { public int Create() { SchemaBuilder.CreateTable("SandboxPageRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("Name") ); SchemaBuilder.CreateTable("SandboxSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("AllowAnonymousEdits") ); diff --git a/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs index 7c53b4e43..fd77878cb 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/DataMigrations/SearchDataMigration.cs @@ -6,7 +6,7 @@ namespace Orchard.Search.DataMigrations { public int Create() { SchemaBuilder.CreateTable("SearchSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("FilterCulture") .Column("SearchedFields") ); diff --git a/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs index 1b79ca51b..5acbca541 100644 --- a/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Themes/DataMigrations/ThemesDataMigration.cs @@ -6,7 +6,7 @@ namespace Orchard.Themes.DataMigrations { public int Create() { //CREATE TABLE Orchard_Themes_ThemeRecord (Id INTEGER not null, ThemeName TEXT, DisplayName TEXT, Description TEXT, Version TEXT, Author TEXT, HomePage TEXT, Tags TEXT, primary key (Id)); SchemaBuilder.CreateTable("ThemeRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("ThemeName") .Column("DisplayName") .Column("Description") @@ -18,7 +18,7 @@ namespace Orchard.Themes.DataMigrations { //CREATE TABLE Orchard_Themes_ThemeSiteSettingsRecord (Id INTEGER not null, CurrentThemeName TEXT, primary key (Id)); SchemaBuilder.CreateTable("ThemeSiteSettingsRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("CurrentThemeName") ); diff --git a/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs index 89397e04f..f82457c53 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/DataMigrations/UsersDataMigration.cs @@ -6,7 +6,7 @@ namespace Orchard.Users.DataMigrations { public int Create() { //CREATE TABLE Orchard_Users_UserRecord (Id INTEGER not null, UserName TEXT, Email TEXT, NormalizedUserName TEXT, Password TEXT, PasswordFormat TEXT, PasswordSalt TEXT, primary key (Id)); SchemaBuilder.CreateTable("UserRecord", table => table - .Column("Id", column => column.PrimaryKey()) + .ContentPartRecord() .Column("UserName") .Column("Email") .Column("NormalizedUserName") diff --git a/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs b/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs index eefc48aa3..7b745e88e 100644 --- a/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs +++ b/src/Orchard/Data/Migration/Schema/CreateTableCommand.cs @@ -23,16 +23,23 @@ namespace Orchard.Data.Migration.Schema { return Column(columnName, dbType, column); } + /// + /// Defines a primary column as for content parts + /// public CreateTableCommand ContentPartRecord() { - /// TODO: Call Column() with necessary information for content part records + Column("Id", column => column.PrimaryKey()); + return this; } - public CreateTableCommand VersionedContentPartRecord() { - /// TODO: Call Column() with necessary information for content part records + /// + /// Defines a primary column as for versionnable content parts + /// + public CreateTableCommand ContentPartVersionRecord() { + Column("Id", column => column.PrimaryKey()); + Column("ContentItemRecord_id"); return this; } - } } From 7639a18dd47b3133d6fbf3d21a1724a30fdc8be4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 16:59:07 -0700 Subject: [PATCH 06/12] Corrected tests with previous changes --HG-- branch : dev --- src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs b/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs index a0ee24ec7..3e4f14c8a 100644 --- a/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs +++ b/src/Orchard.Tests/DataMigration/SchemaBuilderTests.cs @@ -51,7 +51,7 @@ namespace Orchard.Tests.DataMigration { .Column("Firstname", DbType.String, column => column.WithLength(255)) .Column("Lastname", DbType.String, column => column.WithPrecision(0).WithScale(1))) .CreateTable("Address", table => table - .VersionedContentPartRecord() + .ContentPartVersionRecord() .Column("City", DbType.String) .Column("ZIP", DbType.Int32, column => column.Unique()) .Column("UserId", DbType.Int32, column => column.NotNull())) From cfbea89449c8c20c44f0ce6380538c3a087c800d Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 16:59:49 -0700 Subject: [PATCH 07/12] Scaffold create datamigration should add the file to the .csproj --HG-- branch : dev --- .../Commands/ScaffoldingCommands.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs index 6422474da..976b8c766 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs @@ -32,6 +32,7 @@ namespace Orchard.DevTools.Commands { string dataMigrationsPath = HostingEnvironment.MapPath("~/Modules/" + extension.Name + "/DataMigrations/"); string dataMigrationPath = dataMigrationsPath + extension.DisplayName + "DataMigration.cs"; string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/"); + string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extension.Name)); if ( !Directory.Exists(dataMigrationsPath) ) { Directory.CreateDirectory(dataMigrationsPath); } @@ -55,7 +56,20 @@ namespace Orchard.DevTools.Commands { dataMigrationText = dataMigrationText.Replace("$$ClassName$$", extension.DisplayName); dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString()); File.WriteAllText(dataMigrationPath, dataMigrationText); - Context.Output.WriteLine(T("Data migration created successfully in Module {0}", extension.DisplayName)); + + string projectFileText = File.ReadAllText(moduleCsProjPath); + // The string searches in solution/project files can be made aware of comment lines. + if ( projectFileText.Contains("\r\n ", "DataMigrations\\" + extension.DisplayName + "DataMigration.cs"); + projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("\r\n \r\n \r\n ", "DataMigrations\\" + extension.DisplayName + "DataMigration.cs"); + projectFileText = projectFileText.Insert(projectFileText.LastIndexOf(""), itemGroupReference); + } + File.WriteAllText(moduleCsProjPath, projectFileText); + + Context.Output.WriteLine(T("Data migration created successfully in Module {0}", extension.Name)); return; } } From 0cf950bc83f80e4e157f0a32d60e43a0b32c546f Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 17:11:26 -0700 Subject: [PATCH 08/12] Id columns should not include WithLength() on Data Migration scaffoldin --HG-- branch : dev --- .../Services/ScaffoldingCommandInterpreter.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs index b68ee832f..6704e0417 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs @@ -22,7 +22,7 @@ namespace Orchard.DevTools.Services { var options = new List(); if ( createColumn.IsPrimaryKey ) { - options.Add(string.Format("WithLength({0})", createColumn.Length)); + options.Add("PrimaryKey()"); } if ( createColumn.IsUnique ) { @@ -33,10 +33,6 @@ namespace Orchard.DevTools.Services { options.Add("NotNull()"); } - if ( createColumn.IsPrimaryKey ) { - options.Add("PrimaryKey()"); - } - if ( createColumn.Length.HasValue ) { options.Add(string.Format("WithLength({0})", createColumn.Length )); } From db85727d0aee2219b3c5bb74e6b30538c0405889 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Jul 2010 17:29:06 -0700 Subject: [PATCH 09/12] Table name should not include the prefix: Orchard_Blogs_BlogArchiveRecord during Data Migration scaffolding --HG-- branch : dev --- .../ScaffoldingTemplates/DataMigration.txt | 2 +- .../Services/ScaffoldingCommandInterpreter.cs | 2 +- .../Migration/Generator/SchemaCommandGenerator.cs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/DataMigration.txt b/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/DataMigration.txt index e671bd79a..5755aeb18 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/DataMigration.txt +++ b/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/DataMigration.txt @@ -5,7 +5,7 @@ namespace $$FeatureName$$.DataMigrations { public class $$ClassName$$DataMigration : DataMigrationImpl { public int Create() { - $$Commands$$ +$$Commands$$ return 0100; } diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs index 6704e0417..03603f0c3 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs @@ -13,7 +13,7 @@ namespace Orchard.DevTools.Services { } public override void Visit(CreateTableCommand command) { - _output.WriteLine("// Creating table {0}", command.Name); + _output.WriteLine("\t\t\t// Creating table {0}", command.Name); _output.WriteLine("\t\t\tSchemaBuilder.CreateTable(\"{0}\", table => table", command.Name); foreach ( var createColumn in command.TableCommands.OfType() ) { diff --git a/src/Orchard/Data/Migration/Generator/SchemaCommandGenerator.cs b/src/Orchard/Data/Migration/Generator/SchemaCommandGenerator.cs index 51e1a6353..1c63e242a 100644 --- a/src/Orchard/Data/Migration/Generator/SchemaCommandGenerator.cs +++ b/src/Orchard/Data/Migration/Generator/SchemaCommandGenerator.cs @@ -34,14 +34,20 @@ namespace Orchard.Data.Migration.Generator { // get the tables using reflection var tablesField = typeof(Configuration).GetField("tables", BindingFlags.Instance | BindingFlags.NonPublic); var tables = ((IDictionary) tablesField.GetValue(configuration)).Values; - + + string prefix = feature.Replace(".", "_") + "_"; foreach(var table in tables.Where(t => parameters.RecordDescriptors.Any(rd => rd.Feature.Descriptor.Name == feature && rd.TableName == t.Name))) { - if(drop) { - yield return new DropTableCommand(table.Name); + string tableName = table.Name; + if(tableName.StartsWith(prefix)) { + tableName = tableName.Substring(prefix.Length); } - var command = new CreateTableCommand(table.Name); + if(drop) { + yield return new DropTableCommand(tableName); + } + + var command = new CreateTableCommand(tableName); foreach(var column in table.ColumnIterator) { var table1 = table; From 320019b8c6cb62bebfae446c0f2c9a5105eee07d Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 7 Jul 2010 17:45:59 -0700 Subject: [PATCH 10/12] Display an error message in command line on app domain restart With dynamic compilation, it is sometimes necessary to restart the AppDomain. In the command line scenario, instead of restarting the appdomain, we throw an exception with an descriptive error message. --HG-- branch : dev --- src/Orchard/Commands/CommandHostEnvironment.cs | 11 +++++++++-- .../Extensions/Loaders/ReferencedExtensionLoader.cs | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Orchard/Commands/CommandHostEnvironment.cs b/src/Orchard/Commands/CommandHostEnvironment.cs index 00a3d6dfd..301ccb4b8 100644 --- a/src/Orchard/Commands/CommandHostEnvironment.cs +++ b/src/Orchard/Commands/CommandHostEnvironment.cs @@ -2,9 +2,16 @@ using System; using System.Linq; using System.Web.Hosting; using Orchard.Environment; +using Orchard.Localization; namespace Orchard.Commands { public class CommandHostEnvironment : IHostEnvironment { + public CommandHostEnvironment() { + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + public bool IsFullTrust { get { return AppDomain.CurrentDomain.IsFullyTrusted; } } @@ -18,11 +25,11 @@ namespace Orchard.Commands { } public void RestartAppDomain() { - //Don't restart AppDomain in command line environment + ResetSiteCompilation(); } public void ResetSiteCompilation() { - //Don't restart AppDomain in command line environment + throw new OrchardCoreException(T("A change of configuration requires the application to be restarted. Running the command again usually solves this problem.")); } } } \ No newline at end of file diff --git a/src/Orchard/Environment/Extensions/Loaders/ReferencedExtensionLoader.cs b/src/Orchard/Environment/Extensions/Loaders/ReferencedExtensionLoader.cs index 402ec2cb1..22ccb1848 100644 --- a/src/Orchard/Environment/Extensions/Loaders/ReferencedExtensionLoader.cs +++ b/src/Orchard/Environment/Extensions/Loaders/ReferencedExtensionLoader.cs @@ -45,6 +45,7 @@ namespace Orchard.Environment.Extensions.Loaders { Logger.Information("ExtensionRemoved: Deleting assembly \"{0}\" from bin directory (AppDomain will restart)", moduleName); File.Delete(_virtualPathProvider.MapPath(assemblyPath)); }); + ctx.RestartAppDomain = true; } } From f7803da193885372a7ae8e1ee31937b42e933d2e Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Thu, 8 Jul 2010 10:12:34 -0700 Subject: [PATCH 11/12] Starting to give more attention to generic content management --HG-- branch : dev --- src/Orchard.Web/Core/Contents/AdminMenu.cs | 22 +++++------ .../Contents/Controllers/AdminController.cs | 25 +++++++++++-- .../ViewModels/ListContentsViewModel.cs | 5 ++- .../Views/Admin/CreatableTypeList.ascx | 7 ++++ .../Views/Admin/CreatableTypeList.aspx | 11 ------ .../Core/Contents/Views/Admin/List.ascx | 37 +++++++++++++++++++ .../Core/Contents/Views/Admin/List.aspx | 32 ---------------- src/Orchard.Web/Core/Orchard.Core.csproj | 4 +- 8 files changed, 82 insertions(+), 61 deletions(-) create mode 100644 src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.ascx delete mode 100644 src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.aspx create mode 100644 src/Orchard.Web/Core/Contents/Views/Admin/List.ascx delete mode 100644 src/Orchard.Web/Core/Contents/Views/Admin/List.aspx diff --git a/src/Orchard.Web/Core/Contents/AdminMenu.cs b/src/Orchard.Web/Core/Contents/AdminMenu.cs index 6eefc5d61..f3fd9042c 100644 --- a/src/Orchard.Web/Core/Contents/AdminMenu.cs +++ b/src/Orchard.Web/Core/Contents/AdminMenu.cs @@ -18,18 +18,18 @@ namespace Orchard.Core.Contents { public string MenuName { get { return "admin"; } } public void GetNavigation(NavigationBuilder builder) { - //var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name); + 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 = "Orchard.ContentTypes"})); - //foreach (var contentTypeDefinition in contentTypeDefinitions) { - // var ci = _contentManager.New(contentTypeDefinition.Name); - // var cim = _contentManager.GetItemMetadata(ci); - // var createRouteValues = cim.CreateRouteValues; - // if (createRouteValues.Any()) - // 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("Content"), "1", menu => { + menu.Add(T("Manage Content"), "1.2", item => item.Action("List", "Admin", new { area = "Contents" })); + foreach (var contentTypeDefinition in contentTypeDefinitions) { + var ci = _contentManager.New(contentTypeDefinition.Name); + var cim = _contentManager.GetItemMetadata(ci); + var createRouteValues = cim.CreateRouteValues; + if (createRouteValues.Any()) + 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)); + } + }); } } } \ 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 c595901b8..38a49ec70 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -48,10 +48,17 @@ namespace Orchard.Core.Contents.Controllers { const int pageSize = 20; var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize; - var query = _contentManager.Query(VersionOptions.Latest); + var query = _contentManager.Query(VersionOptions.Latest, _contentDefinitionManager.ListTypeDefinitions().Select(ctd => ctd.Name).ToArray()); - if (!string.IsNullOrEmpty(model.Id)) { - query = query.ForType(model.Id); + if (!string.IsNullOrEmpty(model.TypeName)) { + var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName); + if (contentTypeDefinition == null) + return new NotFoundResult(); + + model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName) + ? contentTypeDefinition.DisplayName + : contentTypeDefinition.Name; + query = query.ForType(model.TypeName); } var contentItems = query.Slice(skip, pageSize); @@ -148,6 +155,18 @@ namespace Orchard.Core.Contents.Controllers { return RedirectToAction("Edit", new RouteValueDictionary { { "Id", contentItem.Id } }); } + [HttpPost, ActionName("Remove")] + public ActionResult RemovePOST(int id, string returnUrl) { + var contentItem = _contentManager.Get(id); + if (contentItem != null) + _contentManager.Remove(contentItem); + + if (!String.IsNullOrEmpty(returnUrl)) + return Redirect(returnUrl); + + return RedirectToAction("List"); + } + private void PrepareEditorViewModel(ContentItemViewModel itemViewModel) { if (string.IsNullOrEmpty(itemViewModel.TemplateName)) { itemViewModel.TemplateName = "Items/Contents.Item"; diff --git a/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs b/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs index c0639640f..84eaaf2c2 100644 --- a/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs +++ b/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs @@ -1,11 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Orchard.ContentManagement; using Orchard.Mvc.ViewModels; namespace Orchard.Core.Contents.ViewModels { public class ListContentsViewModel : BaseViewModel { public string Id { get; set; } + public string TypeName { get { return Id; } } + public string TypeDisplayName { get; set; } public int? Page { get; set; } public IList Entries { get; set; } diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.ascx b/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.ascx new file mode 100644 index 000000000..8af54413a --- /dev/null +++ b/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.ascx @@ -0,0 +1,7 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> +

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

+<%:Html.UnorderedList( + Model.Types, + (ctd, i) => MvcHtmlString.Create(string.Format("

{0}

", Html.ActionLink(ctd.Name, "Create", new { Area = "Contents", Id = ctd.Name }))), + "contentTypes")%> \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.aspx b/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.aspx deleted file mode 100644 index 8aac804bf..000000000 --- a/src/Orchard.Web/Core/Contents/Views/Admin/CreatableTypeList.aspx +++ /dev/null @@ -1,11 +0,0 @@ -<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> -<% Html.AddTitleParts(T("Create Content").ToString()); %> -

- Create content

-
    - <% foreach (var t in Model.Types) {%> -
  • - <%:Html.ActionLink(t.Name, "Create", new RouteValueDictionary{{"Area","Contents"},{"Id",t.Name}}) %>
  • - <%} %> -
diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx b/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx new file mode 100644 index 000000000..61e9aeeeb --- /dev/null +++ b/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx @@ -0,0 +1,37 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Orchard.ContentManagement.Aspects"%> +<%@ Import Namespace="Orchard.ContentManagement"%> +<%@ Import Namespace="Orchard.Utility.Extensions" %> +

<%:Html.TitleForPage(T("Manage {0} Content", !string.IsNullOrEmpty(Model.TypeDisplayName) ? Model.TypeDisplayName : T("all").Text).ToString())%>

+
+ <%:Html.ActionLink(!string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Add new {0} content", Model.TypeDisplayName).Text : T("Add new content").Text, "Create", new { }, new { @class = "button primaryAction" })%> +
+
    <% + foreach (var entry in Model.Entries) { %> +
  • +
    +
    +

    <%:entry.ContentItem.Is() + ? Html.ActionLink(entry.ContentItem.As().Title, "Edit", new { id = entry.ContentItem.Id }) + : MvcHtmlString.Create(string.Format("[title display template needed] (content type == \"{0}\")", entry.ContentItem.TypeDefinition.Name)) %>

    +
      +
    • + <%:T("Last modified: {0}", + entry.ContentItem.Is() && entry.ContentItem.As().ModifiedUtc.HasValue + ? Html.DateTimeRelative(entry.ContentItem.As().ModifiedUtc.Value, T) + : T("unknown"))%> +
    • +
    +
    + +
    +
    +
  • <% + } %> +
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/List.aspx b/src/Orchard.Web/Core/Contents/Views/Admin/List.aspx deleted file mode 100644 index 9ca47e1a4..000000000 --- a/src/Orchard.Web/Core/Contents/Views/Admin/List.aspx +++ /dev/null @@ -1,32 +0,0 @@ -<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage" %> -<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> -<% Html.AddTitleParts(T("Browse Contents").ToString()); %> -

- Browse Contents

- - <% foreach (var t in Model.Entries) {%> - - - - - - - - <%} %> -
- <%:t.ContentItem.Id %>. - - <%:t.ContentItem.ContentType %> - - ver #<%:t.ContentItem.Version %> - - <%if (t.ContentItemMetadata.DisplayRouteValues != null) {%> - <%:Html.ActionLink(t.ContentItemMetadata.DisplayText, t.ContentItemMetadata.DisplayRouteValues["Action"].ToString(), t.ContentItemMetadata.DisplayRouteValues)%> - <%}%> - - <%if (t.ContentItemMetadata.EditorRouteValues != null) {%> - <%:Html.ActionLink("edit", t.ContentItemMetadata.EditorRouteValues["Action"].ToString(), t.ContentItemMetadata.EditorRouteValues)%> - <%}%> -
-

- <%:Html.ActionLink("Create new item", "Create", "Admin", new RouteValueDictionary{{"Area","Contents"},{"Id",Model.Id}}, new Dictionary()) %>

diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 4e2b96d72..0cd261eb9 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -210,10 +210,10 @@ - - + + From 2ceac582a97e3216aae467fbbd81ea82ad5bc860 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 8 Jul 2010 10:45:22 -0700 Subject: [PATCH 12/12] Corrected html for module's homepage --HG-- branch : dev --- src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.ascx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.ascx b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.ascx index e914feb75..c0b3d1b0a 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.ascx +++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.ascx @@ -17,7 +17,7 @@
  • <%:T("Features: {0}", MvcHtmlString.Create(string.Join(", ", module.Features.Select(f => Html.Link(f.Name, string.Format("{0}#{1}", Url.Action("features", new { area = "Orchard.Modules" }), f.Name.AsFeatureId(n => T(n)))).ToString()).OrderBy(s => s).ToArray()))) %>
  •  | <%: T("Author: {0}", !string.IsNullOrEmpty(module.Author) ? module.Author : (new []{"Bradley", "Bertrand", "Renaud", "Suha", "Sebastien", "Jon", "Nathan", "Erik"})[(module.DisplayName.Length + (new Random()).Next()) % 7]) %>
  • <%-- very efficient, I know --%> -
  •  | <%: T("Website: {0}", !string.IsNullOrEmpty(module.HomePage) ? module.HomePage : T("http://orchardproject.net").ToString())%>
  • +
  •  | <%: T("Website: {0}", !string.IsNullOrEmpty(module.HomePage) ? module.HomePage : "http://orchardproject.net")%>