diff --git a/.hgtags b/.hgtags
index 8a944ec680..48a3450e6e 100644
--- a/.hgtags
+++ b/.hgtags
@@ -12,3 +12,4 @@ d03fcffb8834a9583a56813bb44b6abbd9f042cc Release-4.6.0
de73e687ddf6086ed52b6554676c1632865d07f2 Release-4.9.0
8d7d8609e2e4b971da99cd97f72132ce85ce3333 Release-4.9.1
f6da531fbb4c251ff61d314e2a7effb13c71e74a Release-4.10.0
+20e4dff821d8ac2527a5353618fa1a23ea1d8b34 Release-4.11.0
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index 1157175b7d..1891c57e7d 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -99,9 +99,6 @@
False
..\packages\ClientDependency.1.5.1.0\lib\ClientDependency.Core.dll
-
- ..\packages\ClientDependency-Mvc.1.5.1.0\lib\ClientDependency.Core.Mvc.dll
-
False
..\..\lib\CookComputing.XmlRpcV2.dll
diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config
index da972fcd39..58cc730610 100644
--- a/src/Umbraco.Web.UI/web.Template.config
+++ b/src/Umbraco.Web.UI/web.Template.config
@@ -275,11 +275,7 @@
-
-
-
-
-
+
diff --git a/src/Umbraco.Web/umbraco.presentation/install/steps/theend.ascx.cs b/src/Umbraco.Web/umbraco.presentation/install/steps/theend.ascx.cs
index 56a49c13c2..05230b54e8 100644
--- a/src/Umbraco.Web/umbraco.presentation/install/steps/theend.ascx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/install/steps/theend.ascx.cs
@@ -1,3 +1,5 @@
+using System.IO;
+using Umbraco.Core.IO;
using umbraco.BusinessLogic;
namespace umbraco.presentation.install.steps
@@ -32,7 +34,9 @@ namespace umbraco.presentation.install.steps
if (!cms.businesslogic.skinning.Skinning.IsStarterKitInstalled())
customizeSite.Visible = false;
- var initTrees = new ApplicationTreeRegistrar();
+ var tempFolder = IOHelper.MapPath("~/App_Data/TEMP/PluginCache");
+ if(Directory.Exists(tempFolder))
+ Directory.Delete(tempFolder, true);
}
#region Web Form Designer generated code
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/TreeDefinitionCollection.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/TreeDefinitionCollection.cs
index 5d816ce07f..b48c905777 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/TreeDefinitionCollection.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/TreeDefinitionCollection.cs
@@ -15,6 +15,7 @@ using umbraco.interfaces;
using umbraco.BusinessLogic.Utils;
using umbraco.BusinessLogic;
using umbraco.BasePages;
+using TypeFinder = umbraco.BusinessLogic.Utils.TypeFinder;
namespace umbraco.cms.presentation.Trees
{
@@ -151,11 +152,12 @@ namespace umbraco.cms.presentation.Trees
l.UpgradeToWriteLock();
-
- var foundITrees = PluginManager.Current.ResolveTrees();
+ List foundITrees = TypeFinder.FindClassesOfType();
+ //var foundITrees = PluginManager.Current.ResolveTrees();
var objTrees = ApplicationTree.getAll();
- var appTrees = new List();
+ List appTrees = new List();
+ //var appTrees = new List();
appTrees.AddRange(objTrees);
var apps = Application.getAll();
diff --git a/src/umbraco.cms/businesslogic/template/MasterpageHelper.cs b/src/umbraco.cms/businesslogic/template/MasterpageHelper.cs
index 54d8153015..8dc6936d03 100644
--- a/src/umbraco.cms/businesslogic/template/MasterpageHelper.cs
+++ b/src/umbraco.cms/businesslogic/template/MasterpageHelper.cs
@@ -25,15 +25,18 @@ namespace umbraco.cms.businesslogic.template
return IOHelper.MapPath(SystemDirectories.Masterpages + "/" + t.Alias.Replace(" ", "") + ".master");
}
- internal static string CreateMasterPage(Template t, bool overWrite = false)
+ internal static string CreateMasterPage(Template t, bool overWrite = false)
{
string masterpageContent = "";
- if (!File.Exists(GetFilePath(t)) || overWrite)
- masterpageContent = SaveTemplateToFile(t, t.Alias);
+ if (!File.Exists(GetFilePath(t)) || overWrite)
+ {
+ masterpageContent = CreateDefaultMasterPageContent(t, t.Alias);
+ saveDesignToFile(t, null, masterpageContent);
+ }
else
{
- System.IO.TextReader tr = new StreamReader(GetFilePath(t));
+ System.IO.TextReader tr = new StreamReader(GetFilePath(t));
masterpageContent = tr.ReadToEnd();
tr.Close();
}
@@ -56,7 +59,152 @@ namespace umbraco.cms.businesslogic.template
internal static string UpdateMasterPageFile(Template t, string currentAlias)
{
- return SaveTemplateToFile(t, currentAlias);
+ var template = updateMasterPageContent(t, currentAlias);
+ updateChildTemplates(t, currentAlias);
+ saveDesignToFile(t, currentAlias, template);
+
+ return template;
+ }
+
+ internal static string CreateDefaultMasterPageContent(Template template, string currentAlias)
+ {
+ string design = GetMasterPageHeader(template) + "\n";
+
+ if (template.HasMasterTemplate)
+ {
+ var master = new Template(template.MasterTemplate);
+
+ foreach (string cpId in master.contentPlaceholderIds())
+ {
+ design += "\n\t\n\n\n";
+ }
+ }
+ else
+ {
+ design += GetMasterContentElement(template) + "\n";
+ design += template.Design;
+ design += "\n" + Environment.NewLine;
+ }
+
+ return design;
+
+
+ /*
+ var masterPageContent = template.Design;
+
+ if (!IsMasterPageSyntax(masterPageContent))
+ masterPageContent = ConvertToMasterPageSyntax(template);
+
+ // Add header to master page if it doesn't exist
+ if (!masterPageContent.TrimStart().StartsWith("<%@"))
+ {
+ masterPageContent = GetMasterPageHeader(template) + "\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, "(?\\S*)=\"(?[^\"]*)\"",
+ 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 = ParentTemplatePath(template);
+
+ if (currentMasterPageFile != currentMasterTemplateFile)
+ {
+ masterPageContent =
+ masterPageContent.Replace(
+ attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
+ attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile +
+ "\"");
+ }
+ }
+ }
+
+ }
+
+ return masterPageContent;
+ * */
+ }
+
+ internal static string updateMasterPageContent(Template template, string currentAlias)
+ {
+ var masterPageContent = template.Design;
+
+ if (!string.IsNullOrEmpty(currentAlias) && currentAlias != template.Alias)
+ {
+ string masterHeader =
+ masterPageContent.Substring(0, masterPageContent.IndexOf("%>") + 2).Trim(
+ Environment.NewLine.ToCharArray());
+
+ // find the masterpagefile attribute
+ MatchCollection m = Regex.Matches(masterHeader, "(?\\S*)=\"(?[^\"]*)\"",
+ 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 = ParentTemplatePath(template);
+
+ if (currentMasterPageFile != currentMasterTemplateFile)
+ {
+ masterPageContent =
+ masterPageContent.Replace(
+ attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
+ attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile +
+ "\"");
+ }
+ }
+ }
+ }
+
+ return masterPageContent;
+ }
+
+ private static void updateChildTemplates(Template t, string currentAlias)
+ {
+ //if 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(currentAlias) && currentAlias != t.Alias)
+ {
+ //Ensure that child templates have the right master masterpage file name
+ if (t.HasChildren)
+ {
+ var c = t.Children;
+ foreach (CMSNode cmn in c)
+ UpdateMasterPageFile(new Template(cmn.Id), null);
+ }
+ }
+ }
+
+
+ private static void saveDesignToFile(Template t, string currentAlias, string design)
+ {
+ //kill the old file..
+ if (!string.IsNullOrEmpty(currentAlias) && currentAlias != t.Alias)
+ {
+ string _oldFile =
+ IOHelper.MapPath(SystemDirectories.Masterpages + "/" + currentAlias.Replace(" ", "") + ".master");
+ if (System.IO.File.Exists(_oldFile))
+ System.IO.File.Delete(_oldFile);
+ }
+
+ // save the file in UTF-8
+ System.IO.File.WriteAllText(GetFilePath(t), design, System.Text.Encoding.UTF8);
}
internal static void RemoveMasterPageFile(string alias)
diff --git a/src/umbraco.cms/businesslogic/template/Template.cs b/src/umbraco.cms/businesslogic/template/Template.cs
index 9a5e8368bd..f1446d1e63 100644
--- a/src/umbraco.cms/businesslogic/template/Template.cs
+++ b/src/umbraco.cms/businesslogic/template/Template.cs
@@ -383,18 +383,15 @@ namespace umbraco.cms.businesslogic.template
return engine;
}
- public static Template MakeNew(string Name, BusinessLogic.User u, Template master)
- {
- return MakeNew(Name, u, master, null);
- }
-
- private static Template MakeNew(string Name, BusinessLogic.User u, Template master, string design)
+ public static Template MakeNew(string Name, BusinessLogic.User u, Template master)
{
- Template t = MakeNew(Name, u, design);
- t.MasterTemplate = master.Id;
+ return MakeNew(Name, u, master, null);
+ }
- t.Save();
- return t;
+
+ private static Template MakeNew(string name, BusinessLogic.User u, string design)
+ {
+ return MakeNew(name, u, null, design);
}
public static Template MakeNew(string name, BusinessLogic.User u)
@@ -402,7 +399,7 @@ namespace umbraco.cms.businesslogic.template
return MakeNew(name, u, design: null);
}
- private static Template MakeNew(string name, BusinessLogic.User u, string design)
+ private static Template MakeNew(string name, BusinessLogic.User u, Template master, string design)
{
// CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
@@ -418,8 +415,6 @@ namespace umbraco.cms.businesslogic.template
name = name.Substring(0, 95) + "...";
-
-
SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
SqlHelper.CreateParameter("@nodeId", n.Id),
SqlHelper.CreateParameter("@alias", name),
@@ -430,6 +425,9 @@ namespace umbraco.cms.businesslogic.template
NewEventArgs e = new NewEventArgs();
t.OnNew(e);
+ if (master != null)
+ t.MasterTemplate = master.Id;
+
switch (DetermineRenderingEngine(t, design))
{
case RenderingEngine.Mvc: