properly cleanup views/masterpages when changing the type of a template
This commit is contained in:
@@ -58,6 +58,16 @@ namespace umbraco.cms.businesslogic.template
|
||||
return SaveTemplateToFile(t, currentAlias);
|
||||
}
|
||||
|
||||
internal static void RemoveMasterPageFile(string alias)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(alias))
|
||||
{
|
||||
string file = IOHelper.MapPath(SystemDirectories.Masterpages + "/" + alias.Replace(" ", "") + ".master");
|
||||
if (System.IO.File.Exists(file))
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SaveTemplateToFile(Template template, string currentAlias)
|
||||
{
|
||||
var masterPageContent = template.Design;
|
||||
|
||||
@@ -270,10 +270,18 @@ namespace umbraco.cms.businesslogic.template
|
||||
|
||||
|
||||
//we only switch to MVC View editing if the template has a view file, and MVC editing is enabled
|
||||
if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && !MasterPageHelper.IsMasterPageSyntax(_design))
|
||||
if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc && !MasterPageHelper.IsMasterPageSyntax(_design))
|
||||
{
|
||||
MasterPageHelper.RemoveMasterPageFile(this.Alias);
|
||||
MasterPageHelper.RemoveMasterPageFile(_oldAlias);
|
||||
_design = ViewHelper.UpdateViewFile(this, _oldAlias);
|
||||
else if (UmbracoSettings.UseAspNetMasterPages)
|
||||
_design = MasterPageHelper.UpdateMasterPageFile(this, _oldAlias);
|
||||
}
|
||||
else if (UmbracoSettings.UseAspNetMasterPages)
|
||||
{
|
||||
ViewHelper.RemoveViewFile(this.Alias);
|
||||
ViewHelper.RemoveViewFile(_oldAlias);
|
||||
_design = MasterPageHelper.UpdateMasterPageFile(this, _oldAlias);
|
||||
}
|
||||
|
||||
|
||||
SqlHelper.ExecuteNonQuery("Update cmsTemplate set design = @design where NodeId = @id",
|
||||
|
||||
@@ -86,6 +86,16 @@ namespace umbraco.cms.businesslogic.template
|
||||
return t.Design;
|
||||
}
|
||||
|
||||
internal static void RemoveViewFile(string alias)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(alias))
|
||||
{
|
||||
var file = IOHelper.MapPath(ViewPath(alias));
|
||||
if (System.IO.File.Exists(file))
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ViewPath(string alias)
|
||||
{
|
||||
return Umbraco.Core.IO.SystemDirectories.MvcViews + "/" + alias.Replace(" ", "") + ".cshtml";
|
||||
|
||||
Reference in New Issue
Block a user