Removes more xslt, more very old code and configurations that aren't used anymore

This commit is contained in:
Shannon
2018-05-01 01:15:43 +10:00
parent 310a31b03e
commit c8d2ea141b
18 changed files with 68 additions and 439 deletions

View File

@@ -372,8 +372,6 @@
Write-Host "Add web.config transforms to NuGet package"
mv "$($this.BuildTemp)\WebApp\Views\Web.config" "$($this.BuildTemp)\WebApp\Views\Web.config.transform"
# fixme - that one does not exist in .bat build either?
#mv "$($this.BuildTemp)\WebApp\Xslt\Web.config" "$($this.BuildTemp)\WebApp\Xslt\Web.config.transform"
})
$ubuild.DefineMethod("RestoreNuGet",

View File

@@ -4,13 +4,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface ITemplatesSection : IUmbracoConfigurationSection
{
bool UseAspNetMasterPages { get; }
bool EnableSkinSupport { get; }
RenderingEngine DefaultRenderingEngine { get; }
[Obsolete("This has no affect and will be removed in future versions")]
bool EnableTemplateFolders { get; }
}
}

View File

@@ -5,50 +5,16 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class TemplatesElement : UmbracoConfigurationElement, ITemplatesSection
{
[ConfigurationProperty("useAspNetMasterPages")]
internal InnerTextConfigurationElement<bool> UseAspNetMasterPages
{
get { return GetOptionalTextElement("useAspNetMasterPages", true); }
}
[ConfigurationProperty("enableSkinSupport")]
internal InnerTextConfigurationElement<bool> EnableSkinSupport
{
get { return GetOptionalTextElement("enableSkinSupport", true); }
}
[ConfigurationProperty("defaultRenderingEngine", IsRequired = true)]
internal InnerTextConfigurationElement<RenderingEngine> DefaultRenderingEngine
{
get { return GetOptionalTextElement("defaultRenderingEngine", RenderingEngine.Mvc); }
}
[Obsolete("This has no affect and will be removed in future versions")]
[ConfigurationProperty("enableTemplateFolders")]
internal InnerTextConfigurationElement<bool> EnableTemplateFolders
{
get { return GetOptionalTextElement("enableTemplateFolders", false); }
}
bool ITemplatesSection.UseAspNetMasterPages
{
get { return UseAspNetMasterPages; }
}
bool ITemplatesSection.EnableSkinSupport
{
get { return EnableSkinSupport; }
}
RenderingEngine ITemplatesSection.DefaultRenderingEngine
{
get { return DefaultRenderingEngine; }
}
[Obsolete("This has no affect and will be removed in future versions")]
bool ITemplatesSection.EnableTemplateFolders
{
get { return EnableTemplateFolders; }
}
}
}

View File

@@ -776,7 +776,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
else
{
validExts.Add(_templateConfig.UseAspNetMasterPages ? "master" : "aspx");
validExts.Add("master");
}
// validate path and extension

View File

@@ -6,25 +6,11 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[TestFixture]
public class TemplateElementTests : UmbracoSettingsTests
{
[Test]
public void UseAspNetMasterPages()
{
Assert.IsTrue(SettingsSection.Templates.UseAspNetMasterPages == true);
}
[Test]
public void EnableSkinSupport()
{
Assert.IsTrue(SettingsSection.Templates.EnableSkinSupport);
}
[Test]
public void DefaultRenderingEngine()
{
Assert.IsTrue(SettingsSection.Templates.DefaultRenderingEngine == RenderingEngine.Mvc);
}
[Test]
public void EnableTemplateFolders()
{
Assert.IsTrue(SettingsSection.Templates.EnableTemplateFolders == false);
}
}
}

View File

@@ -160,7 +160,6 @@ angular.module('umbraco.mocks').
{ name: "Data types", childNodesUrl: dataTypeChildrenUrl, id: -1, icon: "icon-folder-close", children: [], expanded: false, hasChildren: true, level: 1, menuUrl: dataTypeMenuUrl, metaData: { treeAlias: "dataTypes" } },
{ name: "Macros", childNodesUrl: url, id: -1, icon: "icon-folder-close", children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl, metaData: { treeAlias: "macros" } },
{ name: "Packages", childNodesUrl: url, id: -1, icon: "icon-folder-close", children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl, metaData: { treeAlias: "packager" } },
{ name: "XSLT Files", childNodesUrl: url, id: -1, icon: "icon-folder-close", children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl, metaData: { treeAlias: "xslt" } },
{ name: "Partial View Macros", childNodesUrl: url, id: -1, icon: "icon-folder-close", children: [], expanded: false, hasChildren: true, level: 1, menuUrl: menuUrl, metaData: { treeAlias: "partialViewMacros" } }
],
expanded: true,
@@ -240,4 +239,4 @@ angular.module('umbraco.mocks').
}
};
}]);
}]);

View File

@@ -260,8 +260,6 @@ angular.module('umbraco.mocks').
"errors_stylesNoStylesOnPage": "No active styles available",
"errors_tableColMergeLeft": "Please place cursor at the left of the two cells you wish to merge",
"errors_tableSplitNotSplittable": "You cannot split a cell that hasn't been merged.",
"errors_xsltErrorHeader": "Error in XSLT source",
"errors_xsltErrorText": "The XSLT has not been saved, because it contained error(s)",
"general_about": "About",
"general_action": "Action",
"general_add": "Add",
@@ -598,11 +596,6 @@ angular.module('umbraco.mocks').
"speechBubbles_templateErrorText": "Please make sure that you do not have 2 templates with the same alias",
"speechBubbles_templateSavedHeader": "Template saved",
"speechBubbles_templateSavedText": "Template saved without any errors!",
"speechBubbles_xsltErrorHeader": "XSLT not saved",
"speechBubbles_xsltErrorText": "XSLT contained an error",
"speechBubbles_xsltPermissionErrorText": "XSLT could not be saved, check file permissions",
"speechBubbles_xsltSavedHeader": "XSLT saved",
"speechBubbles_xsltSavedText": "No errors in XSLT",
"speechBubbles_contentUnpublished": "Content unpublished",
"speechBubbles_partialViewSavedHeader": "Partial view saved",
"speechBubbles_partialViewSavedText": "Partial view saved without any errors!",
@@ -703,7 +696,6 @@ angular.module('umbraco.mocks').
"treeHeaders_scripts": "Scripts",
"treeHeaders_stylesheets": "Stylesheets",
"treeHeaders_templates": "Templates",
"treeHeaders_xslt": "XSLT Files",
"update_updateAvailable": "New update ready",
"update_updateDownloadText": "%0% is ready, click here for download",
"update_updateNoServer": "No connection to server",
@@ -760,4 +752,4 @@ angular.module('umbraco.mocks').
.respond(getLanguageResource);
}
};
}]);
}]);

View File

@@ -145,12 +145,7 @@ namespace Umbraco.Web.Macros
var key = member?.ProviderUserKey;
if (key == null) return;
}
// scripts and xslt can be cached as strings but not controls
// as page events (Page_Load) wouldn't be hit -- yet caching
// controls is a bad idea, it can lead to plenty of issues ?!
// eg with IDs...
// this is legacy and I'm not sure what exactly it is supposed to do
if (macroContent.Control != null)
macroContent.ControlId = macroContent.Control.ID;

View File

@@ -42,9 +42,7 @@ namespace Umbraco.Web._Legacy.PackageActions
string value = XmlHelper.GetNodeValue(xmlData);
var tmp = Current.Services.FileService.GetTemplate(templateAlias);
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
//value = tmp.EnsureMasterPageSyntax(value);
value = MasterPageHelper.EnsureMasterPageSyntax(templateAlias, value);
value = MasterPageHelper.EnsureMasterPageSyntax(templateAlias, value);
_addStringToHtmlElement(tmp, value, htmlElementId, position);
@@ -65,9 +63,7 @@ namespace Umbraco.Web._Legacy.PackageActions
string value = XmlHelper.GetNodeValue(xmlData);
var tmp = Current.Services.FileService.GetTemplate(templateAlias);
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
//value = tmp.EnsureMasterPageSyntax(value);
value = MasterPageHelper.EnsureMasterPageSyntax(templateAlias, value);
value = MasterPageHelper.EnsureMasterPageSyntax(templateAlias, value);
_removeStringFromHtmlElement(tmp, value, htmlElementId);
return true;

View File

@@ -247,10 +247,6 @@ namespace umbraco.cms.businesslogic.packager
insPack.Data.Url = packUrl;
insPack.Data.IconUrl = iconUrl;
//skinning
insPack.Data.EnableSkins = enableSkins;
insPack.Data.SkinRepoGuid = string.IsNullOrEmpty(skinRepoGuid) ? Guid.Empty : new Guid(skinRepoGuid);
insPack.Data.PackageGuid = guid; //the package unique key.
insPack.Data.RepositoryGuid = repoGuid; //the repository unique key, if the package is a file install, the repository will not get logged.
insPack.Save();

View File

@@ -16,10 +16,6 @@ namespace umbraco.cms.businesslogic.packager
public bool HasUpdate { get; set; }
public bool EnableSkins { get; set; }
public Guid SkinRepoGuid { get; set; }
public string Name { get; set; }
public string Url { get; set; }
@@ -73,7 +69,6 @@ namespace umbraco.cms.businesslogic.packager
public PackageInstance()
{
SkinRepoGuid = Guid.Empty;
Name = string.Empty;
Url = string.Empty;
Folder = string.Empty;
@@ -96,7 +91,6 @@ namespace umbraco.cms.businesslogic.packager
Files = new List<string>();
LoadControl = string.Empty;
DataTypes = new List<string>();
EnableSkins = false;
ContentLoadChildNodes = false;
}
}

View File

@@ -213,12 +213,6 @@ namespace umbraco.cms.businesslogic.packager
retVal.UmbracoVersion = parsedVersion;
}
bool enableSkins = false;
bool.TryParse(SafeAttribute("enableSkins", n), out enableSkins);
retVal.EnableSkins = enableSkins;
retVal.SkinRepoGuid = string.IsNullOrEmpty(SafeAttribute("skinRepoGuid", n)) ? Guid.Empty : new Guid(SafeAttribute("skinRepoGuid", n));
retVal.License = SafeNodeValue(n.SelectSingleNode("license"));
retVal.LicenseUrl = n.SelectSingleNode("license").Attributes.GetNamedItem("url").Value;
@@ -293,8 +287,6 @@ namespace umbraco.cms.businesslogic.packager
XmlHelper.SetAttribute(Source, xmlDef, "repositoryGuid", package.RepositoryGuid);
XmlHelper.SetAttribute(Source, xmlDef, "packageGuid", package.PackageGuid);
XmlHelper.SetAttribute(Source, xmlDef, "hasUpdate", package.HasUpdate.ToString());
XmlHelper.SetAttribute(Source, xmlDef, "enableSkins", package.EnableSkins.ToString());
XmlHelper.SetAttribute(Source, xmlDef, "skinRepoGuid", package.SkinRepoGuid.ToString());
XmlHelper.SetAttribute(Source, xmlDef, "iconUrl", package.IconUrl);
if (package.UmbracoVersion != null)
XmlHelper.SetAttribute(Source, xmlDef, "umbVersion", package.UmbracoVersion.ToString(3));

View File

@@ -53,28 +53,24 @@ namespace umbraco
_frequest = UmbracoContext.Current.PublishedRequest;
_upage = _frequest.UmbracoPage;
//we need to check this for backwards compatibility in case people still arent' using master pages
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
var args = new RequestInitEventArgs()
{
Page = _upage,
PageId = _upage.PageID,
Context = Context
};
FireBeforeRequestInit(args);
//if we are cancelling then return and don't proceed
if (args.Cancel) return;
this.MasterPageFile = template.GetMasterPageName(_upage.Template);
// reset the friendly path so it's used by forms, etc.
Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);
//fire the init finished event
FireAfterRequestInit(args);
}
var args = new RequestInitEventArgs()
{
Page = _upage,
PageId = _upage.PageID,
Context = Context
};
FireBeforeRequestInit(args);
//if we are cancelling then return and don't proceed
if (args.Cancel) return;
this.MasterPageFile = template.GetMasterPageName(_upage.Template);
// reset the friendly path so it's used by forms, etc.
Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);
//fire the init finished event
FireAfterRequestInit(args);
}
}
@@ -95,33 +91,6 @@ namespace umbraco
var ctx = new ControllerContext(new HttpContextWrapper(Context), new RouteData(), new TempDataController());
provider.LoadTempData(ctx);
//This is only here for legacy if people arent' using master pages...
//TODO: We need to test that this still works!! Or do we ??
if (!UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
var args = new RequestInitEventArgs()
{
Page = _upage,
PageId = _upage.PageID,
Context = Context
};
FireBeforeRequestInit(args);
//if we are cancelling then return and don't proceed
if (args.Cancel) return;
var pageHolder = new umbraco.layoutControls.umbracoPageHolder
{
ID = "umbPageHolder"
};
Page.Controls.Add(pageHolder);
_upage.RenderPage(_upage.Template);
var umbPageHolder = (layoutControls.umbracoPageHolder)Page.FindControl("umbPageHolder");
umbPageHolder.Populate(_upage);
//fire the init finished event
FireAfterRequestInit(args);
}
}
}

View File

@@ -19,10 +19,10 @@ namespace umbraco
/// </summary>
public class item
{
private String _fieldContent = "";
private readonly String _fieldName;
private string _fieldContent = "";
private readonly string _fieldName;
public String FieldContent
public string FieldContent
{
get { return _fieldContent; }
}
@@ -131,7 +131,7 @@ namespace umbraco
throw new InvalidOperationException("Unsupported IPublishedContentCache, only the Xml one is supported.");
var umbracoXml = cache.GetXml(umbracoContext.InPreviewMode);
var splitpath = (String[])elements["splitpath"];
var splitpath = (string[])elements["splitpath"];
for (int i = 0; i < splitpath.Length - 1; i++)
{
XmlNode element = umbracoXml.GetElementById(splitpath[splitpath.Length - i - 1]);
@@ -208,15 +208,7 @@ namespace umbraco
_fieldContent = _fieldContent.ToCleanString(CleanStringType.Ascii | CleanStringType.Alias | CleanStringType.PascalCase);
// OTHER FORMATTING FUNCTIONS
// If we use masterpages, this is moved to the ItemRenderer to add support for before/after in inline XSLT
if (!UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
if (_fieldContent != "" && helper.FindAttribute(attributes, "insertTextBefore") != "")
_fieldContent = HttpContext.Current.Server.HtmlDecode(helper.FindAttribute(attributes, "insertTextBefore")) +
_fieldContent;
if (_fieldContent != "" && helper.FindAttribute(attributes, "insertTextAfter") != "")
_fieldContent += HttpContext.Current.Server.HtmlDecode(helper.FindAttribute(attributes, "insertTextAfter"));
}
if (helper.FindAttribute(attributes, "urlEncode") == "true")
_fieldContent = HttpUtility.UrlEncode(_fieldContent);
if (helper.FindAttribute(attributes, "htmlEncode") == "true")

View File

@@ -755,34 +755,6 @@ namespace umbraco
return GetUmbracoHelper().ReplaceLineBreaksForHtml(text);
}
/// <summary>
/// Renders the content of a macro. Uses the normal template umbraco macro markup as input.
/// This only works properly with xslt macros.
/// Python and .ascx based macros will not render properly, as viewstate is not included.
/// </summary>
/// <param name="Text">The macro markup to be rendered.</param>
/// <param name="PageId">The page id.</param>
/// <returns>The rendered macro as a string</returns>
public static string RenderMacroContent(string Text, int PageId)
{
try
{
var p = new page(GetSafeContentCache().GetById(PageId));
template t = new template(p.Template);
Control c = t.parseStringBuilder(new StringBuilder(Text), p);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
c.RenderControl(hw);
return sw.ToString();
}
catch (Exception ee)
{
return string.Format("<!-- Error generating macroContent: '{0}' -->", ee);
}
}
/// <summary>
/// Renders a template.
/// </summary>
@@ -791,37 +763,20 @@ namespace umbraco
/// <returns>The rendered template as a string</returns>
public static string RenderTemplate(int PageId, int TemplateId)
{
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
using (var sw = new StringWriter())
{
try
{
var altTemplate = TemplateId == -1 ? null : (int?)TemplateId;
var templateRenderer = new TemplateRenderer(Umbraco.Web.UmbracoContext.Current, PageId, altTemplate);
templateRenderer.Render(sw);
}
catch (Exception ee)
{
sw.Write("<!-- Error rendering template with id {0}: '{1}' -->", PageId, ee);
}
return sw.ToString();
}
}
else
{
var p = new page(GetSafeContentCache().GetById(PageId));
p.RenderPage(TemplateId);
var c = p.PageContentControl;
using (var sw = new StringWriter())
using(var hw = new HtmlTextWriter(sw))
{
c.RenderControl(hw);
return sw.ToString();
}
using (var sw = new StringWriter())
{
try
{
var altTemplate = TemplateId == -1 ? null : (int?)TemplateId;
var templateRenderer = new TemplateRenderer(Umbraco.Web.UmbracoContext.Current, PageId, altTemplate);
templateRenderer.Render(sw);
}
catch (Exception ee)
{
sw.Write("<!-- Error rendering template with id {0}: '{1}' -->", PageId, ee);
}
return sw.ToString();
}
}

View File

@@ -149,7 +149,7 @@ namespace umbraco
void populatePageData(XmlNode node)
{
String s;
string s;
DateTime dt;
Guid guid;
int i;
@@ -255,21 +255,6 @@ namespace umbraco
#endregion
#region Wtf?
public void RenderPage(int templateId)
{
if (templateId != 0)
{
template templateDesign = new template(templateId);
_pageContentControl = templateDesign.ParseWithControls(this);
_pageContent.Append(templateDesign.TemplateContent);
}
}
#endregion
#region Public properties
public Control PageContentControl

View File

@@ -35,7 +35,7 @@ namespace umbraco
#endregion
#region public properties
public String TemplateContent
public string TemplateContent
{
set
{
@@ -118,103 +118,6 @@ namespace umbraco
return this._templateName;
}
public Control ParseWithControls(page umbPage)
{
System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");
if (System.Web.HttpContext.Current.Items["macrosAdded"] == null)
System.Web.HttpContext.Current.Items.Add("macrosAdded", 0);
StringBuilder tempOutput = _templateOutput;
Control pageLayout = new Control();
Control pageHeader = new Control();
Control pageFooter = new Control();
Control pageContent = new Control();
System.Web.UI.HtmlControls.HtmlForm pageForm = new System.Web.UI.HtmlControls.HtmlForm();
System.Web.UI.HtmlControls.HtmlHead pageAspNetHead = new System.Web.UI.HtmlControls.HtmlHead();
// Find header and footer of page if there is an aspnet-form on page
if (_templateOutput.ToString().ToLower().IndexOf("<?aspnet_form>") > 0 ||
_templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">") > 0)
{
pageForm.Attributes.Add("method", "post");
pageForm.Attributes.Add("action", Convert.ToString(System.Web.HttpContext.Current.Items["VirtualUrl"]));
// Find header and footer from tempOutput
int aspnetFormTagBegin = tempOutput.ToString().ToLower().IndexOf("<?aspnet_form>");
int aspnetFormTagLength = 14;
int aspnetFormTagEnd = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>") + 15;
// check if we should disable the script manager
if (aspnetFormTagBegin == -1)
{
aspnetFormTagBegin =
_templateOutput.ToString().ToLower().IndexOf("<?aspnet_form disablescriptmanager=\"true\">");
aspnetFormTagLength = 42;
}
else
{
ScriptManager sm = new ScriptManager();
sm.ID = "umbracoScriptManager";
pageForm.Controls.Add(sm);
}
StringBuilder header = new StringBuilder(tempOutput.ToString().Substring(0, aspnetFormTagBegin));
// Check if there's an asp.net head element in the header
if (header.ToString().ToLower().Contains("<?aspnet_head>"))
{
StringBuilder beforeHeader = new StringBuilder(header.ToString().Substring(0, header.ToString().ToLower().IndexOf("<?aspnet_head>")));
header.Remove(0, header.ToString().ToLower().IndexOf("<?aspnet_head>") + 14);
StringBuilder afterHeader = new StringBuilder(header.ToString().Substring(header.ToString().ToLower().IndexOf("</?aspnet_head>") + 15, header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>") - 15));
header.Remove(header.ToString().ToLower().IndexOf("</?aspnet_head>"), header.Length - header.ToString().ToLower().IndexOf("</?aspnet_head>"));
// Find the title from head
MatchCollection matches = Regex.Matches(header.ToString(), @"<title>(.*?)</title>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
if (matches.Count > 0)
{
StringBuilder titleText = new StringBuilder();
HtmlTextWriter titleTextTw = new HtmlTextWriter(new System.IO.StringWriter(titleText));
parseStringBuilder(new StringBuilder(matches[0].Groups[1].Value), umbPage).RenderControl(titleTextTw);
pageAspNetHead.Title = titleText.ToString();
header = new StringBuilder(header.ToString().Replace(matches[0].Value, ""));
}
pageAspNetHead.Controls.Add(parseStringBuilder(header, umbPage));
pageAspNetHead.ID = "head1";
// build the whole header part
pageHeader.Controls.Add(parseStringBuilder(beforeHeader, umbPage));
pageHeader.Controls.Add(pageAspNetHead);
pageHeader.Controls.Add(parseStringBuilder(afterHeader, umbPage));
}
else
pageHeader.Controls.Add(parseStringBuilder(header, umbPage));
pageFooter.Controls.Add(parseStringBuilder(new StringBuilder(tempOutput.ToString().Substring(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd)), umbPage));
tempOutput.Remove(0, aspnetFormTagBegin + aspnetFormTagLength);
aspnetFormTagEnd = tempOutput.ToString().ToLower().IndexOf("</?aspnet_form>");
tempOutput.Remove(aspnetFormTagEnd, tempOutput.Length - aspnetFormTagEnd);
//throw new ArgumentException(tempOutput.ToString());
pageForm.Controls.Add(parseStringBuilder(tempOutput, umbPage));
pageContent.Controls.Add(pageHeader);
pageContent.Controls.Add(pageForm);
pageContent.Controls.Add(pageFooter);
return pageContent;
}
else
return parseStringBuilder(tempOutput, umbPage);
}
public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
{
@@ -229,18 +132,18 @@ namespace umbraco
int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
if (tagIndex > -1)
{
String tempElementContent = "";
string tempElementContent = "";
pageContent.Controls.Add(new LiteralControl(tempOutput.ToString().Substring(0, tagIndex)));
tempOutput.Remove(0, tagIndex);
String tag = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
string tag = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
Hashtable attributes = new Hashtable(XmlHelper.GetAttributesFromElement(tag));
// Check whether it's a single tag (<?.../>) or a tag with children (<?..>...</?...>)
if (tag.Substring(tag.Length - 2, 1) != "/" && tag.IndexOf(" ") > -1)
{
String closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
string closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
// Tag with children are only used when a macro is inserted by the umbraco-editor, in the
// following format: "<?UMBRACO_MACRO ...><IMG SRC="..."..></?UMBRACO_MACRO>", so we
// need to delete extra information inserted which is the image-tag and the closing
@@ -261,41 +164,14 @@ namespace umbraco
if (debugMode)
pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));
// NH: Switching to custom controls for macros
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
IDictionaryEnumerator ide = attributes.GetEnumerator();
while (ide.MoveNext())
if (macroControl.Attributes[ide.Key.ToString()] == null)
macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
pageContent.Controls.Add(macroControl);
}
else
{
var macroId = helper.FindAttribute(attributes, "macroid");
if (macroId == string.Empty) macroId = helper.FindAttribute(attributes, "macroalias");
var tempMacro = GetMacro(macroId);
if (tempMacro != null)
{
try
{
var renderer = new MacroRenderer(Current.ProfilingLogger);
var c = renderer.Render(tempMacro, umbPage.Elements, umbPage.PageID, attributes).GetAsControl();
if (c != null)
pageContent.Controls.Add(c);
else
System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");
}
catch (Exception e)
{
System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, e);
}
}
}
umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
IDictionaryEnumerator ide = attributes.GetEnumerator();
while (ide.MoveNext())
if (macroControl.Attributes[ide.Key.ToString()] == null)
macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
pageContent.Controls.Add(macroControl);
if (debugMode)
pageContent.Controls.Add(new LiteralControl("</div>"));
}
@@ -303,60 +179,14 @@ namespace umbraco
{
if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
{
// NH: Switching to custom controls for items
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
itemControl.Field = helper.FindAttribute(attributes, "field");
IDictionaryEnumerator ide = attributes.GetEnumerator();
while (ide.MoveNext())
if (itemControl.Attributes[ide.Key.ToString()] == null)
itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
pageContent.Controls.Add(itemControl);
}
else
{
try
{
//TODO: Make this work again - but let's make sure this whole class is overhauled and useful
//if (helper.FindAttribute(attributes, "nodeId") != "" && int.Parse(helper.FindAttribute(attributes, "nodeId")) != 0)
//{
// cms.businesslogic.Content c = new umbraco.cms.businesslogic.Content(int.Parse(helper.FindAttribute(attributes, "nodeId")));
// item umbItem = new item(c.getProperty(helper.FindAttribute(attributes, "field")).Value.ToString(), attributes);
// tempElementContent = umbItem.FieldContent;
// // Check if the content is published
// if (c.nodeObjectType == cms.businesslogic.web.Document._objectType)
// {
// try
// {
// cms.businesslogic.web.Document d = (cms.businesslogic.web.Document)c;
// if (!d.Published)
// tempElementContent = "";
// }
// catch { }
// }
//}
//else
//{
// // NH adds Live Editing test stuff
// item umbItem = new item(umbPage.Elements, attributes);
// // item umbItem = new item(umbPage.PageElements[helper.FindAttribute(attributes, "field")].ToString(), attributes);
// tempElementContent = umbItem.FieldContent;
//}
if (debugMode)
tempElementContent =
"<div title=\"Field Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #fc6;\">" + tempElementContent + "</div>";
}
catch (Exception e)
{
System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
}
}
umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
itemControl.Field = helper.FindAttribute(attributes, "field");
IDictionaryEnumerator ide = attributes.GetEnumerator();
while (ide.MoveNext())
if (itemControl.Attributes[ide.Key.ToString()] == null)
itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
pageContent.Controls.Add(itemControl);
}
}
tempOutput.Remove(0, tempOutput.ToString().IndexOf(">") + 1);
@@ -504,12 +334,6 @@ where nodeId = @templateID",
this._masterTemplate = t._masterTemplate;
this._templateName = t._templateName;
// Only check for master on legacy templates - can show error when using master pages.
if (!UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
checkForMaster(tId);
}
}
private void checkForMaster(int templateID) {
@@ -556,7 +380,7 @@ where nodeId = @templateID",
Current.DistributedCache.RefreshTemplateCache(templateID);
}
public template(String templateContent)
public template(string templateContent)
{
_templateOutput.Append(templateContent);
_masterTemplate = 0;

View File

@@ -34,10 +34,7 @@ namespace umbraco.dialogs
pp_casing.Text = Services.TextService.Localize("templateEditor/casing");
pp_encode.Text = Services.TextService.Localize("templateEditor/encoding");
if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
{
tagName.Value = "umbraco:Item";
}
tagName.Value = "umbraco:Item";
using (var scope = Current.ScopeProvider.CreateScope())
{