Kill legacy, get rid of warnings
This commit is contained in:
@@ -1189,9 +1189,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\helper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\item.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -1206,9 +1203,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\template.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbracoPageHolder.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -1590,4 +1584,4 @@
|
||||
<Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" />
|
||||
</SGen>
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -62,9 +62,21 @@ namespace umbraco
|
||||
FireBeforeRequestInit(args);
|
||||
|
||||
//if we are cancelling then return and don't proceed
|
||||
if (args.Cancel) return;
|
||||
|
||||
this.MasterPageFile = template.GetMasterPageName(_upage.Template);
|
||||
if (args.Cancel) return;
|
||||
|
||||
var template = Current.Services.FileService.GetTemplate(_upage.Template);
|
||||
if (template != null)
|
||||
{
|
||||
var alias = template.MasterTemplateAlias;
|
||||
var file = alias.Replace(" ", "") + ".master";
|
||||
var path = SystemDirectories.Masterpages + "/" + file;
|
||||
|
||||
|
||||
if (File.Exists(IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path))))
|
||||
this.MasterPageFile = path;
|
||||
else
|
||||
this.MasterPageFile = SystemDirectories.Umbraco + "/masterPages/default.master";
|
||||
}
|
||||
|
||||
// reset the friendly path so it's used by forms, etc.
|
||||
Context.RewritePath(UmbracoContext.Current.OriginalRequestUrl.PathAndQuery);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for helper.
|
||||
/// </summary>
|
||||
[Obsolete("This needs to be removed, do not use")]
|
||||
public class helper
|
||||
{
|
||||
public static bool IsNumeric(string number)
|
||||
{
|
||||
int result;
|
||||
return int.TryParse(number, out result);
|
||||
}
|
||||
|
||||
public static string FindAttribute(IDictionary attributes, string key)
|
||||
{
|
||||
return FindAttribute(null, attributes, key);
|
||||
}
|
||||
|
||||
public static string FindAttribute(IDictionary pageElements, IDictionary attributes, string key)
|
||||
{
|
||||
// fix for issue 14862: lowercase for case insensitive matching
|
||||
key = key.ToLower();
|
||||
|
||||
var attributeValue = string.Empty;
|
||||
if (attributes[key] != null)
|
||||
attributeValue = attributes[key].ToString();
|
||||
|
||||
attributeValue = MacroRenderer.ParseAttribute(pageElements, attributeValue);
|
||||
return attributeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ using Umbraco.Web;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
@@ -55,7 +56,7 @@ namespace umbraco
|
||||
/// </remarks>
|
||||
internal item(IPublishedContent publishedContent, IDictionary elements, IDictionary attributes)
|
||||
{
|
||||
_fieldName = helper.FindAttribute(attributes, "field");
|
||||
_fieldName = FindAttribute(attributes, "field");
|
||||
|
||||
if (_fieldName.StartsWith("#"))
|
||||
{
|
||||
@@ -64,7 +65,7 @@ namespace umbraco
|
||||
else
|
||||
{
|
||||
// Loop through XML children we need to find the fields recursive
|
||||
var recursive = helper.FindAttribute(attributes, "recursive") == "true";
|
||||
var recursive = FindAttribute(attributes, "recursive") == "true";
|
||||
|
||||
if (publishedContent == null)
|
||||
{
|
||||
@@ -90,7 +91,7 @@ namespace umbraco
|
||||
//now we check if the value is still empty and if so we'll check useIfEmpty
|
||||
if (string.IsNullOrEmpty(_fieldContent))
|
||||
{
|
||||
var altFieldName = helper.FindAttribute(attributes, "useIfEmpty");
|
||||
var altFieldName = FindAttribute(attributes, "useIfEmpty");
|
||||
if (string.IsNullOrEmpty(altFieldName) == false)
|
||||
{
|
||||
if (publishedContent != null && (publishedContent.HasProperty(altFieldName) || recursive))
|
||||
@@ -114,6 +115,13 @@ namespace umbraco
|
||||
ParseItem(attributes);
|
||||
}
|
||||
|
||||
static string FindAttribute(IDictionary attributes, string key)
|
||||
{
|
||||
key = key.ToLowerInvariant();
|
||||
var attributeValue = attributes.Contains(key) ? attributes[key].ToString() : string.Empty;
|
||||
return MacroRenderer.ParseAttribute(null, attributeValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the recursive value using a legacy strategy of looking at the xml cache and the splitPath in the elements collection
|
||||
/// </summary>
|
||||
@@ -160,21 +168,21 @@ namespace umbraco
|
||||
using (Current.ProfilingLogger.DebugDuration<item>("Start parsing " + _fieldName))
|
||||
{
|
||||
HttpContext.Current.Trace.Write("item", "Start parsing '" + _fieldName + "'");
|
||||
if (helper.FindAttribute(attributes, "textIfEmpty") != "" && _fieldContent == "")
|
||||
_fieldContent = helper.FindAttribute(attributes, "textIfEmpty");
|
||||
if (FindAttribute(attributes, "textIfEmpty") != "" && _fieldContent == "")
|
||||
_fieldContent = FindAttribute(attributes, "textIfEmpty");
|
||||
|
||||
_fieldContent = _fieldContent.Trim();
|
||||
|
||||
// DATE FORMATTING FUNCTIONS
|
||||
if (helper.FindAttribute(attributes, "formatAsDateWithTime") == "true")
|
||||
if (FindAttribute(attributes, "formatAsDateWithTime") == "true")
|
||||
{
|
||||
if (_fieldContent == "")
|
||||
_fieldContent = DateTime.Now.ToString();
|
||||
_fieldContent = Convert.ToDateTime(_fieldContent).ToLongDateString() +
|
||||
helper.FindAttribute(attributes, "formatAsDateWithTimeSeparator") +
|
||||
FindAttribute(attributes, "formatAsDateWithTimeSeparator") +
|
||||
Convert.ToDateTime(_fieldContent).ToShortTimeString();
|
||||
}
|
||||
else if (helper.FindAttribute(attributes, "formatAsDate") == "true")
|
||||
else if (FindAttribute(attributes, "formatAsDate") == "true")
|
||||
{
|
||||
if (_fieldContent == "")
|
||||
_fieldContent = DateTime.Now.ToString();
|
||||
@@ -183,7 +191,7 @@ namespace umbraco
|
||||
|
||||
|
||||
// TODO: Needs revision to check if parameter-tags has attributes
|
||||
if (helper.FindAttribute(attributes, "stripParagraph") == "true" && _fieldContent.Length > 5)
|
||||
if (FindAttribute(attributes, "stripParagraph") == "true" && _fieldContent.Length > 5)
|
||||
{
|
||||
_fieldContent = _fieldContent.Trim();
|
||||
string fieldContentLower = _fieldContent.ToLower();
|
||||
@@ -200,20 +208,20 @@ namespace umbraco
|
||||
}
|
||||
|
||||
// CASING
|
||||
if (helper.FindAttribute(attributes, "case") == "lower")
|
||||
if (FindAttribute(attributes, "case") == "lower")
|
||||
_fieldContent = _fieldContent.ToLower();
|
||||
else if (helper.FindAttribute(attributes, "case") == "upper")
|
||||
else if (FindAttribute(attributes, "case") == "upper")
|
||||
_fieldContent = _fieldContent.ToUpper();
|
||||
else if (helper.FindAttribute(attributes, "case") == "title")
|
||||
else if (FindAttribute(attributes, "case") == "title")
|
||||
_fieldContent = _fieldContent.ToCleanString(CleanStringType.Ascii | CleanStringType.Alias | CleanStringType.PascalCase);
|
||||
|
||||
// OTHER FORMATTING FUNCTIONS
|
||||
|
||||
if (helper.FindAttribute(attributes, "urlEncode") == "true")
|
||||
if (FindAttribute(attributes, "urlEncode") == "true")
|
||||
_fieldContent = HttpUtility.UrlEncode(_fieldContent);
|
||||
if (helper.FindAttribute(attributes, "htmlEncode") == "true")
|
||||
if (FindAttribute(attributes, "htmlEncode") == "true")
|
||||
_fieldContent = HttpUtility.HtmlEncode(_fieldContent);
|
||||
if (helper.FindAttribute(attributes, "convertLineBreaks") == "true")
|
||||
if (FindAttribute(attributes, "convertLineBreaks") == "true")
|
||||
_fieldContent = _fieldContent.Replace("\n", "<br/>\n");
|
||||
|
||||
HttpContext.Current.Trace.Write("item", "Done parsing '" + _fieldName + "'");
|
||||
|
||||
@@ -1,391 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.UI;
|
||||
using System.Collections;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Core.IO;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds methods for parsing and building umbraco templates
|
||||
/// </summary>
|
||||
[Obsolete("Do not use this class, use Umbraco.Core.Service.IFileService to work with templates")]
|
||||
public class template
|
||||
{
|
||||
#region private variables
|
||||
|
||||
readonly StringBuilder _templateOutput = new StringBuilder();
|
||||
|
||||
private string _templateDesign = "";
|
||||
int _masterTemplate = -1;
|
||||
private string _templateName = "";
|
||||
private string _templateAlias = "";
|
||||
|
||||
#endregion
|
||||
|
||||
#region public properties
|
||||
public string TemplateContent
|
||||
{
|
||||
set
|
||||
{
|
||||
_templateOutput.Append(value);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _templateOutput.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public int MasterTemplate
|
||||
{
|
||||
get { return _masterTemplate; }
|
||||
}
|
||||
|
||||
//added fallback to the default template to avoid nasty .net errors.
|
||||
//This is referenced in /default.aspx.cs during page rendering.
|
||||
public string MasterPageFile
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
string file = TemplateAlias.Replace(" ", "") + ".master";
|
||||
string path = SystemDirectories.Masterpages + "/" + file;
|
||||
|
||||
|
||||
if (System.IO.File.Exists(IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path))))
|
||||
return path;
|
||||
else
|
||||
return SystemDirectories.Umbraco + "/masterPages/default.master";
|
||||
}
|
||||
}
|
||||
|
||||
//Support for template folders, if a alternative skin folder is requested
|
||||
//we will try to look for template files in another folder
|
||||
public string AlternateMasterPageFile(string templateFolder)
|
||||
{
|
||||
string file = TemplateAlias.Replace(" ", "") + ".master";
|
||||
string path = SystemDirectories.Masterpages + "/" + templateFolder + "/" + file;
|
||||
|
||||
//if it doesn't exists then we return the normal file
|
||||
if (!System.IO.File.Exists(IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path))))
|
||||
{
|
||||
|
||||
string originalPath = IOHelper.MapPath(VirtualPathUtility.ToAbsolute(MasterPageFile));
|
||||
string copyPath = IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path));
|
||||
|
||||
string newFile;
|
||||
using (var fs = new FileStream(originalPath, FileMode.Open, FileAccess.ReadWrite))
|
||||
using (var f = new StreamReader(fs))
|
||||
{
|
||||
newFile = f.ReadToEnd();
|
||||
}
|
||||
|
||||
newFile = newFile.Replace("MasterPageFile=\"~/masterpages/", "MasterPageFile=\"");
|
||||
|
||||
using (var fs = new FileStream(copyPath, FileMode.Create, FileAccess.Write))
|
||||
using (var replacement = new StreamWriter(fs))
|
||||
{
|
||||
replacement.Write(newFile);
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string TemplateAlias
|
||||
{
|
||||
get { return _templateAlias; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region public methods
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this._templateName;
|
||||
}
|
||||
|
||||
public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
|
||||
{
|
||||
|
||||
Control pageContent = new Control();
|
||||
|
||||
bool stop = false;
|
||||
bool debugMode = UmbracoContext.Current.HttpContext.IsDebuggingEnabled;
|
||||
|
||||
while (!stop)
|
||||
{
|
||||
System.Web.HttpContext.Current.Trace.Write("template", "Begining of parsing rutine...");
|
||||
int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
|
||||
if (tagIndex > -1)
|
||||
{
|
||||
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);
|
||||
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)) + ">";
|
||||
// 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
|
||||
// umbraco_macro tag
|
||||
if (tempOutput.ToString().IndexOf(closingTag) > -1)
|
||||
{
|
||||
tempOutput.Remove(0, tempOutput.ToString().IndexOf(closingTag));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.Web.HttpContext.Current.Trace.Write("umbTemplate", "Outputting item: " + tag);
|
||||
|
||||
// Handle umbraco macro tags
|
||||
if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
|
||||
{
|
||||
if (debugMode)
|
||||
pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));
|
||||
|
||||
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>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
|
||||
{
|
||||
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);
|
||||
tempOutput.Insert(0, tempElementContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
pageContent.Controls.Add(new LiteralControl(tempOutput.ToString()));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return pageContent;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Parses the content of the templateOutput stringbuilder, and matches any tags given in the
|
||||
/// XML-file /umbraco/config/umbracoTemplateTags.xml.
|
||||
/// Replaces the found tags in the StringBuilder object, with "real content"
|
||||
/// </summary>
|
||||
/// <param name="umbPage"></param>
|
||||
public void Parse(page umbPage)
|
||||
{
|
||||
System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Start parsing");
|
||||
|
||||
// First parse for known umbraco tags
|
||||
// <?UMBRACO_MACRO/> - macros
|
||||
// <?UMBRACO_GETITEM/> - print item from page, level, or recursive
|
||||
MatchCollection tags = Regex.Matches(_templateOutput.ToString(), "<\\?UMBRACO_MACRO[^>]*/>|<\\?UMBRACO_GETITEM[^>]*/>|<\\?(?<tagName>[\\S]*)[^>]*/>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
foreach (Match tag in tags)
|
||||
{
|
||||
Hashtable attributes = new Hashtable(XmlHelper.GetAttributesFromElement(tag.Value));
|
||||
|
||||
|
||||
if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
|
||||
{
|
||||
var macroId = helper.FindAttribute(attributes, "macroid");
|
||||
if (macroId != "")
|
||||
_templateOutput.Replace(tag.Value, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tag.ToString().ToLower().IndexOf("umbraco_getitem") > -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tempElementContent = umbPage.Elements[helper.FindAttribute(attributes, "field")].ToString();
|
||||
var tempMacros = Regex.Matches(tempElementContent, "<\\?UMBRACO_MACRO(?<attributes>[^>]*)><img[^>]*><\\/\\?UMBRACO_MACRO>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
foreach (Match tempMacro in tempMacros)
|
||||
{
|
||||
var tempAttributes = new Hashtable(XmlHelper.GetAttributesFromElement(tempMacro.Groups["attributes"].Value));
|
||||
var macroId = helper.FindAttribute(tempAttributes, "macroid");
|
||||
if (Convert.ToInt32(macroId) > 0)
|
||||
_templateOutput.Replace(tag.Value, string.Empty);
|
||||
}
|
||||
|
||||
_templateOutput.Replace(tag.Value, tempElementContent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.Web.HttpContext.Current.Trace.Write("umbracoTemplate", "Done parsing");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods
|
||||
|
||||
private static MacroModel GetMacro(string macroId)
|
||||
{
|
||||
HttpContext.Current.Trace.Write("umbracoTemplate", "Starting macro (" + macroId + ")");
|
||||
// it's all obsolete anyways...
|
||||
var macro = Current.Services.MacroService.GetByAlias(macroId);
|
||||
return macro == null ? null : new MacroModel(macro);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region constructors
|
||||
|
||||
public static string GetMasterPageName(int templateID)
|
||||
{
|
||||
return GetMasterPageName(templateID, null);
|
||||
}
|
||||
|
||||
public static string GetMasterPageName(int templateID, string templateFolder)
|
||||
{
|
||||
var t = new template(templateID);
|
||||
|
||||
return !string.IsNullOrEmpty(templateFolder)
|
||||
? t.AlternateMasterPageFile(templateFolder)
|
||||
: t.MasterPageFile;
|
||||
}
|
||||
|
||||
public template(int templateID)
|
||||
{
|
||||
var tId = templateID;
|
||||
|
||||
var t = Current.ApplicationCache.RuntimeCache.GetCacheItem<template>(
|
||||
string.Format("{0}{1}", CacheKeys.TemplateFrontEndCacheKey, tId), () =>
|
||||
{
|
||||
dynamic templateData;
|
||||
using (var scope = Current.ScopeProvider.CreateScope())
|
||||
{
|
||||
templateData = scope.Database.FirstOrDefault<dynamic>(
|
||||
@"select nodeId, alias, node.parentID as master, text, design
|
||||
from cmsTemplate
|
||||
inner join umbracoNode node on (node.id = cmsTemplate.nodeId)
|
||||
where nodeId = @templateID",
|
||||
new { templateID = templateID });
|
||||
}
|
||||
if (templateData != null)
|
||||
{
|
||||
// Get template master and replace content where the template
|
||||
if (templateData.master != null)
|
||||
_masterTemplate = templateData.master;
|
||||
if (templateData.alias != null)
|
||||
_templateAlias = templateData.alias;
|
||||
if (templateData.text != null)
|
||||
_templateName = templateData.text;
|
||||
if (templateData.design != null)
|
||||
_templateDesign = templateData.design;
|
||||
}
|
||||
|
||||
return this;
|
||||
});
|
||||
|
||||
if (t == null)
|
||||
throw new InvalidOperationException("Could not find a tempalte with id " + templateID);
|
||||
|
||||
this._masterTemplate = t._masterTemplate;
|
||||
this._templateAlias = t._templateAlias;
|
||||
this._templateDesign = t._templateDesign;
|
||||
this._masterTemplate = t._masterTemplate;
|
||||
this._templateName = t._templateName;
|
||||
|
||||
}
|
||||
|
||||
private void checkForMaster(int templateID) {
|
||||
// Get template design
|
||||
if (_masterTemplate != 0 && _masterTemplate != templateID) {
|
||||
template masterTemplateDesign = new template(_masterTemplate);
|
||||
if (masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD/>") > -1
|
||||
|| masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD />") > -1) {
|
||||
_templateOutput.Append(
|
||||
masterTemplateDesign.TemplateContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>",
|
||||
_templateDesign).Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", _templateDesign)
|
||||
);
|
||||
} else
|
||||
_templateOutput.Append(_templateDesign);
|
||||
} else {
|
||||
if (_masterTemplate == templateID)
|
||||
{
|
||||
var t = Current.Services.FileService.GetTemplate(templateID);
|
||||
var text = t.Name;
|
||||
if (text.StartsWith("#"))
|
||||
{
|
||||
var lang = Current.Services.LocalizationService.GetLanguageByIsoCode(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null && Current.Services.LocalizationService.DictionaryItemExists(text.Substring(1)))
|
||||
{
|
||||
var di = Current.Services.LocalizationService.GetDictionaryItemByKey(text.Substring(1));
|
||||
text = di.GetTranslatedValue(lang.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "[" + text + "]";
|
||||
}
|
||||
}
|
||||
string templateName = (t != null) ? text : string.Format("'Template with id: '{0}", templateID);
|
||||
System.Web.HttpContext.Current.Trace.Warn("template",
|
||||
String.Format("Master template is the same as the current template. It would cause an endless loop! Make sure that the current template '{0}' has another Master Template than itself. You can change this in the template editor under 'Settings'", templateName));
|
||||
_templateOutput.Append(_templateDesign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate instead")]
|
||||
public static void ClearCachedTemplate(int templateID)
|
||||
{
|
||||
Current.DistributedCache.RefreshTemplateCache(templateID);
|
||||
}
|
||||
|
||||
public template(string templateContent)
|
||||
{
|
||||
_templateOutput.Append(templateContent);
|
||||
_masterTemplate = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -240,13 +240,20 @@ namespace umbraco.presentation.templateControls
|
||||
|
||||
#region Field Information Functions
|
||||
|
||||
static string FindAttribute(IDictionary attributes, string key)
|
||||
{
|
||||
key = key.ToLowerInvariant();
|
||||
var attributeValue = attributes.Contains(key) ? attributes[key].ToString() : string.Empty;
|
||||
return MacroRenderer.ParseAttribute(null, attributeValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the field is a dictionary item.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if the field is a dictionary item; otherwise, <c>false</c>.</returns>
|
||||
protected virtual bool FieldIsDictionaryItem()
|
||||
{
|
||||
return helper.FindAttribute(new AttributeCollectionAdapter(Attributes), "field").StartsWith("#");
|
||||
return FindAttribute(new AttributeCollectionAdapter(Attributes), "field").StartsWith("#");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -255,7 +262,7 @@ namespace umbraco.presentation.templateControls
|
||||
/// <returns><c>true</c> if the field is recursive; otherwise, <c>false</c>.</returns>
|
||||
protected virtual bool FieldIsRercursive()
|
||||
{
|
||||
return helper.FindAttribute(new AttributeCollectionAdapter(Attributes), "recursive") == "true";
|
||||
return FindAttribute(new AttributeCollectionAdapter(Attributes), "recursive") == "true";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -9,6 +10,7 @@ using System.Xml;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Web.Templates;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco.presentation.templateControls
|
||||
{
|
||||
@@ -58,7 +60,7 @@ namespace umbraco.presentation.templateControls
|
||||
string renderOutput = renderOutputWriter.ToString();
|
||||
renderOutput = renderOutput.Trim().Length == 0 ? string.Empty : renderOutput;
|
||||
// handle text before/after
|
||||
renderOutput = AddBeforeAfterText(renderOutput, helper.FindAttribute(item.LegacyAttributes, "insertTextBefore"), helper.FindAttribute(item.LegacyAttributes, "insertTextAfter"));
|
||||
renderOutput = AddBeforeAfterText(renderOutput, FindAttribute(item.LegacyAttributes, "insertTextBefore"), FindAttribute(item.LegacyAttributes, "insertTextAfter"));
|
||||
string finalResult = renderOutput.Trim().Length > 0 ? renderOutput : GetEmptyText(item);
|
||||
|
||||
//Don't parse urls if a content item is assigned since that is taken care
|
||||
@@ -86,6 +88,13 @@ namespace umbraco.presentation.templateControls
|
||||
}
|
||||
}
|
||||
|
||||
static string FindAttribute(IDictionary attributes, string key)
|
||||
{
|
||||
key = key.ToLowerInvariant();
|
||||
var attributeValue = attributes.Contains(key) ? attributes[key].ToString() : string.Empty;
|
||||
return MacroRenderer.ParseAttribute(null, attributeValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the field contents.
|
||||
/// Checks via the NodeId attribute whether to fetch data from another page than the current one.
|
||||
|
||||
Reference in New Issue
Block a user