Imported pull request by Michiel van Oosterhout (consistent line endings)
Removed some commented out code Pull: http://umbraco.codeplex.com/SourceControl/network/forks/michielvoo/UmbracoU4451/contribution/3482
This commit is contained in:
@@ -263,11 +263,6 @@ namespace umbraco.cms.businesslogic.template
|
||||
FlushCache();
|
||||
|
||||
_design = value.Trim(Environment.NewLine.ToCharArray());
|
||||
// NH: Removing an generating the directive can mess up code behind
|
||||
// We don't store the masterpage directive in the design value
|
||||
// if (_design.StartsWith("<%@"))
|
||||
// _design = _design.Substring(_design.IndexOf("%>") + 3).Trim(Environment.NewLine.ToCharArray());
|
||||
|
||||
|
||||
//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))
|
||||
@@ -549,26 +544,7 @@ namespace umbraco.cms.businesslogic.template
|
||||
// NH: Changed this; if you delete a template we'll remove all references instead of
|
||||
// throwing an exception
|
||||
if (DocumentType.GetAllAsList().Where(x => x.allowedTemplates.Select(t => t.Id).Contains(this.Id)).Count() > 0)
|
||||
{
|
||||
// the uncommented code below have been refactored into removeAllReferences method that clears template
|
||||
// from documenttypes, subtemplates and documents.
|
||||
RemoveAllReferences();
|
||||
/*
|
||||
|
||||
// Added to remove template doctype relationship
|
||||
SqlHelper.ExecuteNonQuery("delete from cmsDocumentType where templateNodeId =" + this.Id);
|
||||
|
||||
// Need to update any other template that references this one as it's master to NULL
|
||||
SqlHelper.ExecuteNonQuery("update cmsTemplate set [master] = NULL where [master] = " + this.Id);
|
||||
*/
|
||||
|
||||
// don't allow template deletion if it is in use
|
||||
// (get all doc types and filter based on any that have the template id of this one)
|
||||
/*
|
||||
Log.Add(LogTypes.Error, this.Id, "Can't delete a template that is assigned to existing content");
|
||||
throw new InvalidOperationException("Can't delete a template that is assigned to existing content");
|
||||
*/
|
||||
}
|
||||
|
||||
DeleteEventArgs e = new DeleteEventArgs();
|
||||
FireBeforeDelete(e);
|
||||
@@ -645,7 +621,7 @@ namespace umbraco.cms.businesslogic.template
|
||||
|
||||
public string ConvertToMasterPageSyntax(string templateDesign)
|
||||
{
|
||||
string masterPageContent = GetMasterContentElement(MasterTemplate) + "\n";
|
||||
string masterPageContent = GetMasterContentElement(MasterTemplate) + Environment.NewLine;
|
||||
|
||||
masterPageContent += templateDesign;
|
||||
|
||||
@@ -653,7 +629,9 @@ namespace umbraco.cms.businesslogic.template
|
||||
masterPageContent = EnsureMasterPageSyntax(masterPageContent);
|
||||
|
||||
// append ending asp:content element
|
||||
masterPageContent += "\n</asp:Content>" + Environment.NewLine;
|
||||
masterPageContent += Environment.NewLine
|
||||
+ "</asp:Content>"
|
||||
+ Environment.NewLine;
|
||||
|
||||
return masterPageContent;
|
||||
}
|
||||
@@ -683,98 +661,14 @@ namespace umbraco.cms.businesslogic.template
|
||||
public void ImportDesign(string design)
|
||||
{
|
||||
Design = design;
|
||||
|
||||
/*
|
||||
if (!isMasterPageSyntax(design))
|
||||
{
|
||||
Design = ConvertToMasterPageSyntax(design);
|
||||
}
|
||||
else
|
||||
{
|
||||
Design = design;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public void SaveMasterPageFile(string masterPageContent)
|
||||
{
|
||||
//this will trigger the helper and store everything
|
||||
this.Design = masterPageContent;
|
||||
|
||||
/*
|
||||
|
||||
// Add header to master page if it doesn't exist
|
||||
if (!masterPageContent.StartsWith("<%@"))
|
||||
{
|
||||
masterPageContent = getMasterPageHeader() + "\n" + masterPageContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
// verify that the masterpage attribute is the same as the masterpage
|
||||
string masterHeader = masterPageContent.Substring(0, masterPageContent.IndexOf("%>") + 2).Trim(Environment.NewLine.ToCharArray());
|
||||
// find the masterpagefile attribute
|
||||
MatchCollection m = Regex.Matches(masterHeader, "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"",
|
||||
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
foreach (Match attributeSet in m)
|
||||
{
|
||||
if (attributeSet.Groups["attributeName"].Value.ToLower() == "masterpagefile")
|
||||
{
|
||||
// validate the masterpagefile
|
||||
string currentMasterPageFile = attributeSet.Groups["attributeValue"].Value;
|
||||
string currentMasterTemplateFile = currentMasterTemplateFileName();
|
||||
if (currentMasterPageFile != currentMasterTemplateFile)
|
||||
{
|
||||
masterPageContent =
|
||||
masterPageContent.Replace(
|
||||
attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
|
||||
attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile + "\"");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//we have a Old Alias if the alias and therefor the masterpage file name has changed...
|
||||
//so before we save the new masterfile, we'll clear the old one, so we don't up with
|
||||
//Unused masterpage files
|
||||
if (!string.IsNullOrEmpty(_oldAlias) && _oldAlias != _alias)
|
||||
{
|
||||
|
||||
//Ensure that child templates have the right master masterpage file name
|
||||
if (HasChildren)
|
||||
{
|
||||
//store children array here because iterating over an Array property object is very inneficient.
|
||||
var c = Children;
|
||||
foreach (CMSNode cmn in c)
|
||||
{
|
||||
Template t = new Template(cmn.Id);
|
||||
t.SaveAsMasterPage();
|
||||
t.Save();
|
||||
}
|
||||
}
|
||||
|
||||
//then kill the old file..
|
||||
string _oldFile = IOHelper.MapPath(SystemDirectories.Masterpages + "/" + _oldAlias.Replace(" ", "") + ".master");
|
||||
|
||||
if (System.IO.File.Exists(_oldFile))
|
||||
System.IO.File.Delete(_oldFile);
|
||||
}
|
||||
|
||||
// save the file in UTF-8
|
||||
|
||||
File.WriteAllText(MasterPageFile, masterPageContent, System.Text.Encoding.UTF8);
|
||||
* */
|
||||
}
|
||||
|
||||
private string CurrentMasterTemplateFileName()
|
||||
{
|
||||
if (MasterTemplate != 0)
|
||||
return SystemDirectories.Masterpages + "/" + new Template(MasterTemplate).Alias.Replace(" ", "") + ".master";
|
||||
else
|
||||
return UmbracoMasterTemplate;
|
||||
}
|
||||
|
||||
|
||||
private void GetAspNetMasterPageForm(ref string design)
|
||||
{
|
||||
Match formElement = Regex.Match(design, GetElementRegExp("?ASPNET_FORM", false), RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
Reference in New Issue
Block a user