mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Work on Migrations.
Fixing view counter to check for pattern instead of pattern name since it can be empty.
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Orchard.Autoroute.Settings {
|
||||
}
|
||||
}
|
||||
|
||||
//Adding null Patterns for the ability to add another Pattern in the UI
|
||||
//Adding Patterns for the UI
|
||||
List<RoutePattern> newPatterns = new List<RoutePattern>();
|
||||
int current = 0;
|
||||
foreach (string culture in settings.SiteCultures) {
|
||||
@@ -58,10 +58,24 @@ namespace Orchard.Autoroute.Settings {
|
||||
}
|
||||
current++;
|
||||
}
|
||||
|
||||
//We add a pattern for each culture if there is none
|
||||
if (!settings.Patterns.Where(x => x.Culture == culture).Any()) {
|
||||
//We add the default pattern from migrations
|
||||
if (settings.Patterns.Where(x => x.Culture == "").Any()) {
|
||||
//we add the RoutePattern and we set the culture since there is none defined
|
||||
RoutePattern migrationRoutePattern = settings.Patterns.Where(x => x.Culture == "").First();
|
||||
newPatterns.Add(new RoutePattern { Culture = culture, Name = migrationRoutePattern.Name, Description = migrationRoutePattern.Description, Pattern = migrationRoutePattern.Pattern });
|
||||
} else {
|
||||
//we add the default pattern for custom content types or modules that don't define it in their migration
|
||||
newPatterns.Add(new RoutePattern { Culture = culture, Name = "Title", Description = "my-title", Pattern = "{Content.Slug}" });
|
||||
}
|
||||
}
|
||||
|
||||
//we add a new empty line for each culture
|
||||
newPatterns.Add(new RoutePattern { Culture = culture, Name = null, Description = null, Pattern = null });
|
||||
|
||||
// if the content type has no defaultPattern for autoroute, then use a default one
|
||||
// if the content type has no defaultPattern for autoroute, then assign a the first one we just created
|
||||
if (!settings.DefaultPatterns.Any(x => x.Culture == culture)) {
|
||||
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = culture });
|
||||
}
|
||||
@@ -84,6 +98,7 @@ namespace Orchard.Autoroute.Settings {
|
||||
settings.SiteCultures = _cultureManager.ListCultures().ToList();
|
||||
|
||||
if (updateModel.TryUpdateModel(settings, "AutorouteSettings", null, null)) {
|
||||
//TODO need to add validations client and/or server side here
|
||||
// remove empty patterns
|
||||
var patterns = settings.Patterns;
|
||||
patterns.RemoveAll(p => String.IsNullOrWhiteSpace(p.Name) && String.IsNullOrWhiteSpace(p.Pattern) && String.IsNullOrWhiteSpace(p.Description));
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Description, new { @class = "text" })</td>
|
||||
<td>@Html.HiddenFor(m => m.Patterns[patternCount].Culture) </td>
|
||||
</tr>
|
||||
if (Model.Patterns[patternCount].Name != null) { patternCultureCount++; } else { patternCultureCount = 0; }
|
||||
if (Model.Patterns[patternCount].Pattern != null) { patternCultureCount++; } else { patternCultureCount = 0; }
|
||||
patternCount++;
|
||||
}
|
||||
<tr></tr>
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Orchard.Blogs {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-blog\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-blog\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2"))
|
||||
);
|
||||
@@ -58,8 +58,8 @@ namespace Orchard.Blogs {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Blog and Title\",\"Pattern\":\"{Content.Container.Path}/{Content.Slug}\",\"Description\":\"my-blog/my-post\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Blog and Title\",\"Pattern\":\"{Content.Container.Path}/{Content.Slug}\",\"Description\":\"my-blog/my-post\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("BodyPart")
|
||||
.Draftable()
|
||||
);
|
||||
@@ -133,23 +133,5 @@ namespace Orchard.Blogs {
|
||||
|
||||
return 6;
|
||||
}
|
||||
|
||||
public int UpdateFrom6() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Blog",
|
||||
cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-blog\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
|
||||
cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Blog and Title\",\"Pattern\":\"{Content.Container.Path}/{Content.Slug}\",\"Description\":\"my-blog/my-post\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ namespace Orchard.CustomForms {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-form\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-form\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("CustomFormPart")
|
||||
.DisplayedAs("Custom Form")
|
||||
@@ -59,17 +59,6 @@ namespace Orchard.CustomForms {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom4() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("CustomForm",
|
||||
cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-form\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
public void Uninstall() {
|
||||
ContentDefinitionManager.DeleteTypeDefinition("CustomForm");
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ namespace Orchard.DynamicForms {
|
||||
public int UpdateFrom1() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Form", type => type
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-form\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-form\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
);
|
||||
|
||||
return 2;
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace Orchard.Lists {
|
||||
.WithPart("ContainerPart")
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-list\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0")));
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-list\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]")));
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -35,15 +35,5 @@ namespace Orchard.Lists {
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom4() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("List", type => type
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-list\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Orchard.Pages {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-page\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-page\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("LayoutPart")
|
||||
.Creatable()
|
||||
.Listable()
|
||||
@@ -28,16 +28,5 @@ namespace Orchard.Pages {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.WithPart("CommonPart", p => p.WithSetting("DateEditorSettings.ShowDateEditor", "True")));
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int UpdateFrom2() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Page",
|
||||
cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-page\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,8 +190,8 @@ namespace Orchard.Projections {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-projections\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-projections\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("ProjectionPart")
|
||||
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "5"))
|
||||
@@ -274,16 +274,5 @@ namespace Orchard.Projections {
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int UpdateFrom3() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("ProjectionPage",
|
||||
cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-projections\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,8 @@ namespace Orchard.Taxonomies {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "True")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "False")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-taxonomy\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-taxonomy\",\"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("TermsPartRecord", table => table
|
||||
@@ -78,15 +78,5 @@ namespace Orchard.Taxonomies {
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int UpdateFrom4() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Taxonomy", cfg => cfg
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{\"Name\":\"Title\",\"Pattern\":\"{Content.Slug}\",\"Description\":\"my-taxonomy\",\"Culture\":\"en-US\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"en-US\"}]"))
|
||||
);
|
||||
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,8 +105,8 @@ namespace Orchard.Taxonomies.Services {
|
||||
.WithPart("AutoroutePart", builder => builder
|
||||
.WithSetting("AutorouteSettings.AllowCustomPattern", "true")
|
||||
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Taxonomy and Title', Pattern: '{Content.Container.Path}/{Content.Slug}', Description: 'my-taxonomy/my-term/sub-term'}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
|
||||
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Taxonomy and Title', Pattern: '{Content.Container.Path}/{Content.Slug}', Description: 'my-taxonomy/my-term/sub-term', \"Culture\":\"\"}]")
|
||||
.WithSetting("AutorouteSettings.DefaultPatternDefinitions", "[{\"PatternIndex\":\"0\",\"Culture\":\"\"}]"))
|
||||
.WithPart("CommonPart")
|
||||
.DisplayedAs(taxonomy.Name + " Term")
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user