Fixing alternates management in shape tracing

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2011-03-24 22:59:46 -07:00
parent ba36f53374
commit 2626f0393d
2 changed files with 18 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ namespace Orchard.DesignerTools.Controllers
var alternateFilename = Server.MapPath(Path.Combine(currentTheme.Location, currentTheme.Id, "Views", alternate));
// use same extension as template, or ".cshtml" if it's a code template))
if (System.IO.File.Exists(template)) {
if (_webSiteFolder.FileExists(template)) {
alternateFilename += Path.GetExtension(template);
using (var stream = System.IO.File.Create(alternateFilename)) {

View File

@@ -97,7 +97,23 @@ namespace Orchard.DesignerTools.Services {
context.Shape._Dump = sw.ToString();
}
shape.Template = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
shape.Template = null;
foreach (var extension in new[] { ".cshtml", ".aspx" }) {
foreach (var alternate in shapeMetadata.Alternates.Reverse()) {
var alternateFilename = currentTheme.Location + "/" + currentTheme.Id + "/Views/" + alternate.Replace("__", "-").Replace("_", ".") + extension;
if (_webSiteFolder.FileExists(alternateFilename)) {
shape.Template = alternateFilename;
}
}
}
if(shape.Template == null) {
shape.Template = descriptor.BindingSource;
}
if(shape.Template == null) {
shape.Template = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
}
try {
if (_webSiteFolder.FileExists(shape.Template)) {