Fixes U4-864 also fixes similar issues for:
Xslt Javascript Stylesheets Scripting Files Macros If file exists, will redirect to existing file instead of cretaing new
This commit is contained in:
@@ -77,32 +77,34 @@ namespace umbraco
|
||||
templateFile.Close();
|
||||
}
|
||||
|
||||
string abFileName = IOHelper.MapPath(SystemDirectories.MacroScripts + "/" + fileName);
|
||||
|
||||
if (fileName.Contains("/")) //if there's a / create the folder structure for it
|
||||
{
|
||||
string[] folders = fileName.Split("/".ToCharArray());
|
||||
string basePath = IOHelper.MapPath(SystemDirectories.MacroScripts);
|
||||
for (int i = 0; i < folders.Length - 1; i++)
|
||||
{
|
||||
basePath = System.IO.Path.Combine(basePath, folders[i]);
|
||||
System.IO.Directory.CreateDirectory(basePath);
|
||||
}
|
||||
}
|
||||
if (!System.IO.File.Exists(abFileName))
|
||||
{
|
||||
if (fileName.Contains("/")) //if there's a / create the folder structure for it
|
||||
{
|
||||
string[] folders = fileName.Split("/".ToCharArray());
|
||||
string basePath = IOHelper.MapPath(SystemDirectories.MacroScripts);
|
||||
for (int i = 0; i < folders.Length - 1; i++)
|
||||
{
|
||||
basePath = System.IO.Path.Combine(basePath, folders[i]);
|
||||
System.IO.Directory.CreateDirectory(basePath);
|
||||
}
|
||||
}
|
||||
|
||||
string abFileName = IOHelper.MapPath(SystemDirectories.MacroScripts + "/" + fileName);
|
||||
|
||||
System.IO.StreamWriter scriptWriter = System.IO.File.CreateText(abFileName);
|
||||
scriptWriter.Write(scriptContent);
|
||||
scriptWriter.Flush();
|
||||
scriptWriter.Close();
|
||||
System.IO.StreamWriter scriptWriter = System.IO.File.CreateText(abFileName);
|
||||
scriptWriter.Write(scriptContent);
|
||||
scriptWriter.Flush();
|
||||
scriptWriter.Close();
|
||||
|
||||
|
||||
if (ParentID == 1)
|
||||
{
|
||||
cms.businesslogic.macro.Macro m = cms.businesslogic.macro.Macro.MakeNew(
|
||||
helper.SpaceCamelCasing(fileName.Substring(0, (fileName.LastIndexOf('.') + 1)).Trim('.')));
|
||||
m.ScriptingFile = fileName;
|
||||
}
|
||||
if (ParentID == 1)
|
||||
{
|
||||
cms.businesslogic.macro.Macro m = cms.businesslogic.macro.Macro.MakeNew(
|
||||
helper.SpaceCamelCasing(fileName.Substring(0, (fileName.LastIndexOf('.') + 1)).Trim('.')));
|
||||
m.ScriptingFile = fileName;
|
||||
}
|
||||
}
|
||||
|
||||
m_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/python/editPython.aspx?file={0}", fileName);
|
||||
return true;
|
||||
|
||||
@@ -52,15 +52,23 @@ namespace umbraco
|
||||
int createFolder = ParentID;
|
||||
|
||||
string basePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + relPath + fileName);
|
||||
|
||||
if (createFolder == 1)
|
||||
if (System.IO.File.Exists(basePath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(basePath);
|
||||
m_returnUrl = string.Format("settings/scripts/editScript.aspx?file={0}{1}.{2}", relPath, fileName, fileType);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.File.Create(basePath + "." + fileType).Close();
|
||||
m_returnUrl = string.Format("settings/scripts/editScript.aspx?file={0}{1}.{2}", relPath, fileName, fileType);
|
||||
if (createFolder == 1)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(basePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.File.Create(basePath + "." + fileType).Close();
|
||||
m_returnUrl = string.Format("settings/scripts/editScript.aspx?file={0}{1}.{2}", relPath, fileName,
|
||||
fileType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,12 @@ namespace umbraco
|
||||
public bool Save()
|
||||
{
|
||||
|
||||
int id = cms.businesslogic.web.StyleSheet.MakeNew(BusinessLogic.User.GetUser(_userID), Alias, "", "").Id;
|
||||
int id = -1;
|
||||
umbraco.cms.businesslogic.web.StyleSheet checkingSheet =umbraco.cms.businesslogic.web.StyleSheet.GetByName(Alias);
|
||||
if (checkingSheet != null)
|
||||
id = checkingSheet.Id;
|
||||
else
|
||||
id =cms.businesslogic.web.StyleSheet.MakeNew(BusinessLogic.User.GetUser(_userID), Alias, "", "").Id;
|
||||
m_returnUrl = string.Format("settings/stylesheet/editStylesheet.aspx?id={0}", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,40 +54,44 @@ namespace umbraco
|
||||
string xsltTemplateSource = IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/" + template);
|
||||
string xsltNewFilename = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName + ".xslt");
|
||||
|
||||
if (fileName.Contains("/")) //if there's a / create the folder structure for it
|
||||
{
|
||||
string[] folders = fileName.Split("/".ToCharArray());
|
||||
string xsltBasePath = IOHelper.MapPath(SystemDirectories.Xslt);
|
||||
for (int i = 0; i < folders.Length - 1; i++)
|
||||
{
|
||||
xsltBasePath = System.IO.Path.Combine(xsltBasePath, folders[i]);
|
||||
System.IO.Directory.CreateDirectory(xsltBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
// System.IO.File.Copy(xsltTemplateSource, xsltNewFilename, false);
|
||||
if (!System.IO.File.Exists(xsltNewFilename))
|
||||
{
|
||||
if (fileName.Contains("/")) //if there's a / create the folder structure for it
|
||||
{
|
||||
string[] folders = fileName.Split("/".ToCharArray());
|
||||
string xsltBasePath = IOHelper.MapPath(SystemDirectories.Xslt);
|
||||
for (int i = 0; i < folders.Length - 1; i++)
|
||||
{
|
||||
xsltBasePath = System.IO.Path.Combine(xsltBasePath, folders[i]);
|
||||
System.IO.Directory.CreateDirectory(xsltBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
// update with xslt references
|
||||
string xslt = "";
|
||||
System.IO.StreamReader xsltFile = System.IO.File.OpenText(xsltTemplateSource);
|
||||
xslt = xsltFile.ReadToEnd();
|
||||
xsltFile.Close();
|
||||
// System.IO.File.Copy(xsltTemplateSource, xsltNewFilename, false);
|
||||
|
||||
// prepare support for XSLT extensions
|
||||
xslt = macro.AddXsltExtensionsToHeader(xslt);
|
||||
System.IO.StreamWriter xsltWriter = System.IO.File.CreateText(xsltNewFilename);
|
||||
xsltWriter.Write(xslt);
|
||||
xsltWriter.Flush();
|
||||
xsltWriter.Close();
|
||||
// update with xslt references
|
||||
string xslt = "";
|
||||
System.IO.StreamReader xsltFile = System.IO.File.OpenText(xsltTemplateSource);
|
||||
xslt = xsltFile.ReadToEnd();
|
||||
xsltFile.Close();
|
||||
|
||||
// Create macro?
|
||||
if (ParentID == 1)
|
||||
{
|
||||
cms.businesslogic.macro.Macro m =
|
||||
cms.businesslogic.macro.Macro.MakeNew(
|
||||
helper.SpaceCamelCasing(_alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3)));
|
||||
m.Xslt = fileName + ".xslt";
|
||||
}
|
||||
// prepare support for XSLT extensions
|
||||
xslt = macro.AddXsltExtensionsToHeader(xslt);
|
||||
System.IO.StreamWriter xsltWriter = System.IO.File.CreateText(xsltNewFilename);
|
||||
xsltWriter.Write(xslt);
|
||||
xsltWriter.Flush();
|
||||
xsltWriter.Close();
|
||||
|
||||
// Create macro?
|
||||
if (ParentID == 1)
|
||||
{
|
||||
cms.businesslogic.macro.Macro m =
|
||||
cms.businesslogic.macro.Macro.MakeNew(
|
||||
helper.SpaceCamelCasing(_alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3)));
|
||||
m.Xslt = fileName + ".xslt";
|
||||
}
|
||||
}
|
||||
|
||||
m_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}.xslt", fileName);
|
||||
|
||||
|
||||
@@ -49,7 +49,12 @@ namespace umbraco
|
||||
|
||||
public bool Save()
|
||||
{
|
||||
int id = umbraco.cms.businesslogic.macro.Macro.MakeNew(_alias).Id;
|
||||
int id = -1;
|
||||
umbraco.cms.businesslogic.macro.Macro checkingMacro =umbraco.cms.businesslogic.macro.Macro.GetByAlias(_alias);
|
||||
if (checkingMacro!=null)
|
||||
id =checkingMacro.Id;
|
||||
else
|
||||
id = umbraco.cms.businesslogic.macro.Macro.MakeNew(_alias).Id;
|
||||
m_returnUrl = string.Format("developer/Macros/editMacro.aspx?macroID={0}", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user