mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,8 +1,21 @@
|
||||
<div class="sections">
|
||||
<div class="primary">
|
||||
@Display(Model.Content)
|
||||
<div class="edit-item">
|
||||
<div class="edit-item-primary">
|
||||
@if (Model.Content != null) {
|
||||
<div class="edit-item-content">
|
||||
@Display(Model.Content)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="secondary">
|
||||
@Display(Model.Sidebar)
|
||||
<div class="edit-item-secondary">
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
@if (Model.Sidebar != null) {
|
||||
<div class="edit-item-sidebar">
|
||||
@Display(Model.Sidebar)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
@@ -7,7 +8,7 @@ using Orchard.Core.Contents.Extensions;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace $$FeatureName$$.DataMigrations {
|
||||
public class Migration : DataMigrationImpl {
|
||||
public class Migrations : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
$$Commands$$
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{$$ModuleProjectGuid$$}</ProjectGuid>
|
||||
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>$$ModuleName$$</RootNamespace>
|
||||
@@ -39,6 +39,7 @@
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
|
@@ -61,7 +61,7 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
}
|
||||
|
||||
string dataMigrationFolderPath = HostingEnvironment.MapPath("~/Modules/" + extensionDescriptor.Name + "/");
|
||||
string dataMigrationFilePath = dataMigrationFolderPath + "Migration.cs";
|
||||
string dataMigrationFilePath = dataMigrationFolderPath + "Migrations.cs";
|
||||
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
|
||||
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extensionDescriptor.Name));
|
||||
|
||||
@@ -93,11 +93,11 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
|
||||
// The string searches in solution/project files can be made aware of comment lines.
|
||||
if ( projectFileText.Contains("<Compile Include") ) {
|
||||
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extensionDescriptor.DisplayName + "DataMigration.cs");
|
||||
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "Migrations.cs");
|
||||
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
|
||||
}
|
||||
else {
|
||||
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "DataMigrations\\" + extensionDescriptor.DisplayName + "DataMigration.cs");
|
||||
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "Migrations.cs");
|
||||
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
|
||||
}
|
||||
|
||||
@@ -302,6 +302,7 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
// include in solution but dont create a project: just add the references to Orchard.Themes project
|
||||
var itemGroup = CreateProjectItemGroup(HostingEnvironment.MapPath("~/Themes/"), createdFiles, createdFolders);
|
||||
AddFilesToOrchardThemesProject(output, itemGroup);
|
||||
TouchSolution(output);
|
||||
}
|
||||
else {
|
||||
// create a project (already done) and add it to the solution
|
||||
|
@@ -7,7 +7,6 @@ using Orchard.Core.Contents.Controllers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.UI.Widgets;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
using Orchard.Widgets.ViewModels;
|
||||
@@ -20,16 +19,13 @@ namespace Orchard.Widgets.Controllers {
|
||||
private const string NotAuthorizedManageWidgetsLabel = "Not authorized to manage widgets";
|
||||
|
||||
private readonly IWidgetsService _widgetsService;
|
||||
private readonly IRuleManager _ruleManager;
|
||||
|
||||
public AdminController(
|
||||
IOrchardServices services,
|
||||
IWidgetsService widgetsService,
|
||||
IRuleManager ruleManager) {
|
||||
IWidgetsService widgetsService) {
|
||||
|
||||
Services = services;
|
||||
_widgetsService = widgetsService;
|
||||
_ruleManager = ruleManager;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -179,8 +175,6 @@ namespace Orchard.Widgets.Controllers {
|
||||
|
||||
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
||||
|
||||
ValidateLayer(layerPart);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(model);
|
||||
@@ -227,8 +221,6 @@ namespace Orchard.Widgets.Controllers {
|
||||
|
||||
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
||||
|
||||
ValidateLayer(layerPart);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(model);
|
||||
@@ -339,27 +331,6 @@ namespace Orchard.Widgets.Controllers {
|
||||
RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public bool ValidateLayer(LayerPart layer) {
|
||||
if ( String.IsNullOrWhiteSpace(layer.LayerRule) ) {
|
||||
layer.LayerRule = "true";
|
||||
}
|
||||
|
||||
if(_widgetsService.GetLayers().Count(l => String.Equals(l.Name, layer.Name, StringComparison.InvariantCultureIgnoreCase)) > 1) { // the current layer counts for 1
|
||||
ModelState.AddModelError("Name", T("A Layer with the same name already exists").Text);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
_ruleManager.Matches(layer.LayerRule);
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
ModelState.AddModelError("Description", T("The rule is not valid: {0}", e.Message).Text);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return base.TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
@@ -1,12 +1,31 @@
|
||||
using JetBrains.Annotations;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Widgets;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Widgets.Drivers {
|
||||
|
||||
[UsedImplicitly]
|
||||
public class LayerPartDriver : ContentPartDriver<LayerPart> {
|
||||
private readonly IRuleManager _ruleManager;
|
||||
private readonly IWidgetsService _widgetsService;
|
||||
|
||||
public LayerPartDriver(
|
||||
IRuleManager ruleManager,
|
||||
IWidgetsService widgetsService) {
|
||||
|
||||
_ruleManager = ruleManager;
|
||||
_widgetsService = widgetsService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Widgets_LayerPart",
|
||||
@@ -14,7 +33,23 @@ namespace Orchard.Widgets.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(layerPart, Prefix, null, null);
|
||||
if(updater.TryUpdateModel(layerPart, Prefix, null, null)) {
|
||||
if ( String.IsNullOrWhiteSpace(layerPart.LayerRule) ) {
|
||||
layerPart.LayerRule = "true";
|
||||
}
|
||||
|
||||
if ( _widgetsService.GetLayers().Any(l => String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
|
||||
updater.AddModelError("Name", T("A Layer with the same name already exists"));
|
||||
}
|
||||
|
||||
try {
|
||||
_ruleManager.Matches(layerPart.LayerRule);
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
updater.AddModelError("Description", T("The rule is not valid: {0}", e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
return Editor(layerPart, shapeHelper);
|
||||
}
|
||||
}
|
||||
|
@@ -47,9 +47,8 @@ namespace Orchard.Widgets.Filters {
|
||||
IEnumerable<WidgetPart> widgetParts = _contentManager.Query<WidgetPart, WidgetPartRecord>().List();
|
||||
IEnumerable<LayerPart> activeLayers = _contentManager.Query<LayerPart, LayerPartRecord>().List();
|
||||
|
||||
List<int> activeLayerIds = new List<int>();
|
||||
var activeLayerIds = new List<int>();
|
||||
foreach (var activeLayer in activeLayers) {
|
||||
var context = workContext.HttpContext;
|
||||
// ignore the rule if it fails to execute
|
||||
try {
|
||||
if (_ruleManager.Matches(activeLayer.Record.LayerRule)) {
|
||||
@@ -57,7 +56,7 @@ namespace Orchard.Widgets.Filters {
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.Debug(e, T("An error occured during layer evaluation on: {0}", activeLayer.Name).Text);
|
||||
Logger.Warning(e, T("An error occured during layer evaluation on: {0}", activeLayer.Name).Text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -120,7 +120,7 @@ body {
|
||||
h1,h2,h3,h4,h5,h6 { font-weight: normal;}
|
||||
|
||||
h1 { font-size: 1.692em }
|
||||
h2, h2 span { font-size: 1.538em; }
|
||||
h2 { font-size: 1.538em; }
|
||||
h3 { font-size: 1.231em; }
|
||||
h4 { font-size: 1.154em; }
|
||||
h5 { font-size: 1.077em; }
|
||||
@@ -482,7 +482,6 @@ label {
|
||||
}
|
||||
label.forcheckbox {
|
||||
display:inline;
|
||||
line-height:1.8em;
|
||||
}
|
||||
.bulk-actions label, .bulk-items h3, label.sub {
|
||||
display:inline;
|
||||
@@ -618,7 +617,7 @@ input[type="submit"]:hover,input[type="reset"]:hover, input[type="button"]:hover
|
||||
background: -webkit-gradient(linear, 0 0, 0 100%, from(#ffac40), to(#f9760d));
|
||||
background: -moz-linear-gradient(top, #ffac40, #f9760d);
|
||||
}
|
||||
input[type="submit"]:active, input[type="reset"]:active, input[type="button"]:active, button:active {
|
||||
input[type="submit"]:active, input[type="reset"]:active, input[type="button"]:active, button:active, .buton:active, .button.primaryAction:active {
|
||||
text-decoration:none;
|
||||
background: #62a9e2;
|
||||
color:#fff;
|
||||
@@ -872,7 +871,7 @@ table .button {
|
||||
padding:1em;
|
||||
}
|
||||
.orchard-media fieldset div, .settings fieldset div, .settings .button {
|
||||
margin:1em 0 .5em;
|
||||
margin:.5em 0;
|
||||
}
|
||||
.settings legend {
|
||||
margin:0 0 -.4em;
|
||||
@@ -890,7 +889,7 @@ fieldset.publish-later-datetime {
|
||||
min-width:13.6em;
|
||||
padding-left:6px;
|
||||
padding-right:0;
|
||||
width:68%;
|
||||
width:50%;
|
||||
}
|
||||
fieldset.publish-later-datetime legend {
|
||||
display:none;
|
||||
|
@@ -188,7 +188,7 @@ namespace Orchard.Data.Migration {
|
||||
.ToList();
|
||||
|
||||
foreach (var migration in migrations.OfType<DataMigrationImpl>()) {
|
||||
migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Name.Replace(".", "_") + "_");
|
||||
migration.SchemaBuilder = new SchemaBuilder(_interpreter, migration.Feature.Descriptor.Name, (s) => s.Replace(".", "_") + "_");
|
||||
migration.ContentDefinitionManager = _contentDefinitionManager;
|
||||
}
|
||||
|
||||
|
@@ -5,28 +5,30 @@ namespace Orchard.Data.Migration.Schema {
|
||||
public class SchemaBuilder {
|
||||
private readonly IDataMigrationInterpreter _interpreter;
|
||||
private readonly string _featurePrefix;
|
||||
private readonly Func<string, string> _formatPrefix;
|
||||
|
||||
public SchemaBuilder(IDataMigrationInterpreter interpreter, string featurePrefix = null) {
|
||||
public SchemaBuilder(IDataMigrationInterpreter interpreter, string featurePrefix = null, Func<string, string> formatPrefix = null) {
|
||||
_interpreter = interpreter;
|
||||
_featurePrefix = featurePrefix;
|
||||
_featurePrefix = featurePrefix ?? String.Empty;
|
||||
_formatPrefix = formatPrefix ?? (s => s ?? String.Empty);
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateTable(string name, Action<CreateTableCommand> table) {
|
||||
var createTable = new CreateTableCommand(String.Concat(_featurePrefix, name));
|
||||
var createTable = new CreateTableCommand(String.Concat(_formatPrefix(_featurePrefix), name));
|
||||
table(createTable);
|
||||
Run(createTable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder AlterTable(string name, Action<AlterTableCommand> table) {
|
||||
var alterTable = new AlterTableCommand(String.Concat(_featurePrefix, name));
|
||||
var alterTable = new AlterTableCommand(String.Concat(_formatPrefix(_featurePrefix), name));
|
||||
table(alterTable);
|
||||
Run(alterTable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder DropTable(string name) {
|
||||
var deleteTable = new DropTableCommand(String.Concat(_featurePrefix, name));
|
||||
var deleteTable = new DropTableCommand(String.Concat(_formatPrefix(_featurePrefix), name));
|
||||
Run(deleteTable);
|
||||
return this;
|
||||
}
|
||||
@@ -45,13 +47,37 @@ namespace Orchard.Data.Migration.Schema {
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateForeignKey(string name, string srcTable, string[] srcColumns, string destTable, string[] destColumns) {
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_featurePrefix, srcTable), srcColumns, String.Concat(_featurePrefix, destTable), destColumns);
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_formatPrefix(_featurePrefix), srcTable), srcColumns, String.Concat(_formatPrefix(_featurePrefix), destTable), destColumns);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateForeignKey(string name, string srcModule, string srcTable, string[] srcColumns, string destTable, string[] destColumns) {
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_formatPrefix(srcModule), srcTable), srcColumns, String.Concat(_formatPrefix(_featurePrefix), destTable), destColumns);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateForeignKey(string name, string srcTable, string[] srcColumns, string destModule, string destTable, string[] destColumns) {
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_formatPrefix(_featurePrefix), srcTable), srcColumns, String.Concat(_formatPrefix(destModule), destTable), destColumns);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder CreateForeignKey(string name, string srcModule, string srcTable, string[] srcColumns, string destModule, string destTable, string[] destColumns) {
|
||||
var command = new CreateForeignKeyCommand(name, String.Concat(_formatPrefix(srcModule), srcTable), srcColumns, String.Concat(_formatPrefix(destModule), destTable), destColumns);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder DropForeignKey(string srcTable, string name) {
|
||||
var command = new DropForeignKeyCommand(String.Concat(_featurePrefix, srcTable), name);
|
||||
var command = new DropForeignKeyCommand(String.Concat(_formatPrefix(_featurePrefix), srcTable), name);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemaBuilder DropForeignKey(string srcModule, string srcTable, string name) {
|
||||
var command = new DropForeignKeyCommand(String.Concat(_formatPrefix(srcModule), srcTable), name);
|
||||
Run(command);
|
||||
return this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user