More xslt removal
This commit is contained in:
@@ -179,7 +179,7 @@ namespace Umbraco.Core.Macros
|
||||
// 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
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace Umbraco.Core.Macros
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates what an xslt extension object is when used for macros
|
||||
/// </summary>
|
||||
internal sealed class XsltExtension
|
||||
{
|
||||
public XsltExtension(string ns, object extensionObject)
|
||||
{
|
||||
Namespace = ns;
|
||||
ExtensionObject = extensionObject;
|
||||
}
|
||||
|
||||
public string Namespace { get; private set; }
|
||||
public object ExtensionObject { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Web;
|
||||
|
||||
namespace Umbraco.Core.Macros
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows App_Code XSLT extensions to be declared using the [XsltExtension] class attribute.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An optional XML namespace can be specified using [XsltExtension("MyNamespace")].
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class XsltExtensionAttribute : Attribute
|
||||
{
|
||||
public XsltExtensionAttribute()
|
||||
{
|
||||
Namespace = String.Empty;
|
||||
}
|
||||
|
||||
public XsltExtensionAttribute(string ns)
|
||||
{
|
||||
Namespace = ns;
|
||||
}
|
||||
|
||||
public string Namespace { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Namespace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Macros
|
||||
{
|
||||
internal class XsltExtensionCollection : BuilderCollectionBase<XsltExtension>
|
||||
{
|
||||
public XsltExtensionCollection(IEnumerable<XsltExtension> items)
|
||||
: base(items)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.Macros
|
||||
{
|
||||
// that one is special since it's not initialized with XsltExtension types, but with Xslt extension object types,
|
||||
// which are then wrapped in an XsltExtension object when the collection is created. so, cannot really inherit
|
||||
// from (Lazy)CollectionBuilderBase and have to re-implement it. but almost everything is copied from CollectionBuilderBase.
|
||||
|
||||
internal class XsltExtensionCollectionBuilder : ICollectionBuilder<XsltExtensionCollection, XsltExtension>
|
||||
{
|
||||
private readonly IServiceContainer _container;
|
||||
private readonly List<Func<IEnumerable<Type>>> _producers = new List<Func<IEnumerable<Type>>>();
|
||||
private readonly object _locker = new object();
|
||||
private ServiceRegistration[] _registrations;
|
||||
|
||||
public XsltExtensionCollectionBuilder(IServiceContainer container)
|
||||
{
|
||||
_container = container;
|
||||
|
||||
// register the collection
|
||||
container.Register(_ => CreateCollection(), new PerContainerLifetime());
|
||||
}
|
||||
|
||||
public static XsltExtensionCollectionBuilder Register(IServiceContainer container)
|
||||
{
|
||||
// register the builder - per container
|
||||
var builderLifetime = new PerContainerLifetime();
|
||||
container.Register<XsltExtensionCollectionBuilder>(builderLifetime);
|
||||
return container.GetInstance<XsltExtensionCollectionBuilder>();
|
||||
}
|
||||
|
||||
public XsltExtensionCollectionBuilder AddExtensionObjectProducer(Func<IEnumerable<Type>> producer)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_registrations != null)
|
||||
throw new InvalidOperationException("Cannot configure a collection builder after its types have been resolved.");
|
||||
_producers.Add(producer);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void RegisterTypes()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_registrations != null) return;
|
||||
|
||||
var prefix = GetType().FullName + "_";
|
||||
var i = 0;
|
||||
foreach (var type in _producers.SelectMany(x => x()).Distinct())
|
||||
{
|
||||
var name = $"{prefix}{i++:00000}";
|
||||
_container.Register(type, type, name);
|
||||
}
|
||||
|
||||
_registrations = _container.AvailableServices
|
||||
.Where(x => x.ServiceName.StartsWith(prefix))
|
||||
.OrderBy(x => x.ServiceName)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public XsltExtensionCollection CreateCollection()
|
||||
{
|
||||
RegisterTypes(); // will do it only once
|
||||
|
||||
var exts = _registrations.SelectMany(r => r.ServiceType.GetCustomAttributes<XsltExtensionAttribute>(true)
|
||||
.Select(a => new XsltExtension(a.Namespace.IfNullOrWhiteSpace(r.ServiceType.FullName), _container.GetInstance(r.ServiceType, r.ServiceName))));
|
||||
|
||||
return new XsltExtensionCollection(exts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,29 +57,14 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
string ControlType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the assembly, which should be used by the Macro
|
||||
/// </summary>
|
||||
/// <remarks>Will usually only be filled if the ScriptFile is a Usercontrol</remarks>
|
||||
[DataMember]
|
||||
[Obsolete("This is no longer used, we should remove it in v8, CustomControl macros are gone")]
|
||||
string ControlAssembly { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the path to the Python file in use
|
||||
/// </summary>
|
||||
/// <remarks>Optional: Can only be one of three Script, Python or Xslt</remarks>
|
||||
[DataMember]
|
||||
string ScriptPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the Xslt file in use
|
||||
/// </summary>
|
||||
/// <remarks>Optional: Can only be one of three Script, Python or Xslt</remarks>
|
||||
[DataMember]
|
||||
string XsltPath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of Macro Properties
|
||||
/// </summary>
|
||||
|
||||
@@ -35,13 +35,11 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="controlType"></param>
|
||||
/// <param name="controlAssembly"></param>
|
||||
/// <param name="xsltPath"></param>
|
||||
/// <param name="cacheByPage"></param>
|
||||
/// <param name="cacheByMember"></param>
|
||||
/// <param name="dontRender"></param>
|
||||
/// <param name="scriptPath"></param>
|
||||
public Macro(int id, Guid key, bool useInEditor, int cacheDuration, string @alias, string name, string controlType, string controlAssembly, string xsltPath, bool cacheByPage, bool cacheByMember, bool dontRender, string scriptPath)
|
||||
public Macro(int id, Guid key, bool useInEditor, int cacheDuration, string @alias, string name, string controlType, bool cacheByPage, bool cacheByMember, bool dontRender, string scriptPath)
|
||||
: this()
|
||||
{
|
||||
Id = id;
|
||||
@@ -51,8 +49,6 @@ namespace Umbraco.Core.Models
|
||||
Alias = alias.ToCleanString(CleanStringType.Alias);
|
||||
Name = name;
|
||||
ControlType = controlType;
|
||||
ControlAssembly = controlAssembly;
|
||||
XsltPath = xsltPath;
|
||||
CacheByPage = cacheByPage;
|
||||
CacheByMember = cacheByMember;
|
||||
DontRender = dontRender;
|
||||
@@ -67,16 +63,12 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="alias"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="controlType"></param>
|
||||
/// <param name="controlAssembly"></param>
|
||||
/// <param name="xsltPath"></param>
|
||||
/// <param name="cacheByPage"></param>
|
||||
/// <param name="cacheByMember"></param>
|
||||
/// <param name="dontRender"></param>
|
||||
/// <param name="scriptPath"></param>
|
||||
public Macro(string @alias, string name,
|
||||
string controlType = "",
|
||||
string controlAssembly = "",
|
||||
string xsltPath = "",
|
||||
string scriptPath = "",
|
||||
bool cacheByPage = false,
|
||||
bool cacheByMember = false,
|
||||
@@ -90,8 +82,6 @@ namespace Umbraco.Core.Models
|
||||
Alias = alias.ToCleanString(CleanStringType.Alias);
|
||||
Name = name;
|
||||
ControlType = controlType;
|
||||
ControlAssembly = controlAssembly;
|
||||
XsltPath = xsltPath;
|
||||
CacheByPage = cacheByPage;
|
||||
CacheByMember = cacheByMember;
|
||||
DontRender = dontRender;
|
||||
@@ -125,9 +115,7 @@ namespace Umbraco.Core.Models
|
||||
public readonly PropertyInfo CacheByMemberSelector = ExpressionHelper.GetPropertyInfo<Macro, bool>(x => x.CacheByMember);
|
||||
public readonly PropertyInfo DontRenderSelector = ExpressionHelper.GetPropertyInfo<Macro, bool>(x => x.DontRender);
|
||||
public readonly PropertyInfo ControlPathSelector = ExpressionHelper.GetPropertyInfo<Macro, string>(x => x.ControlType);
|
||||
public readonly PropertyInfo ControlAssemblySelector = ExpressionHelper.GetPropertyInfo<Macro, string>(x => x.ControlAssembly);
|
||||
public readonly PropertyInfo ScriptPathSelector = ExpressionHelper.GetPropertyInfo<Macro, string>(x => x.ScriptPath);
|
||||
public readonly PropertyInfo XsltPathSelector = ExpressionHelper.GetPropertyInfo<Macro, string>(x => x.XsltPath);
|
||||
public readonly PropertyInfo PropertiesSelector = ExpressionHelper.GetPropertyInfo<Macro, MacroPropertyCollection>(x => x.Properties);
|
||||
}
|
||||
|
||||
@@ -281,17 +269,6 @@ namespace Umbraco.Core.Models
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _scriptFile, Ps.Value.ControlPathSelector); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the assembly, which should be used by the Macro
|
||||
/// </summary>
|
||||
/// <remarks>Will usually only be filled if the ControlType is a Usercontrol</remarks>
|
||||
[DataMember]
|
||||
public string ControlAssembly
|
||||
{
|
||||
get { return _scriptAssembly; }
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _scriptAssembly, Ps.Value.ControlAssemblySelector); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the path to the Python file in use
|
||||
/// </summary>
|
||||
@@ -303,17 +280,6 @@ namespace Umbraco.Core.Models
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _scriptPath, Ps.Value.ScriptPathSelector); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the Xslt file in use
|
||||
/// </summary>
|
||||
/// <remarks>Optional: Can only be one of three Script, Python or Xslt</remarks>
|
||||
[DataMember]
|
||||
public string XsltPath
|
||||
{
|
||||
get { return _xslt; }
|
||||
set { SetPropertyValueAndDetectChanges(value, ref _xslt, Ps.Value.XsltPathSelector); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of Macro Properties
|
||||
/// </summary>
|
||||
|
||||
@@ -10,15 +10,11 @@ namespace Umbraco.Core.Models
|
||||
[DataContract(IsReference = true)]
|
||||
public enum MacroTypes
|
||||
{
|
||||
[EnumMember]
|
||||
Xslt = 1,
|
||||
[EnumMember]
|
||||
UserControl = 3,
|
||||
[EnumMember]
|
||||
Unknown = 4,
|
||||
[EnumMember]
|
||||
Script = 6,
|
||||
[EnumMember]
|
||||
PartialView = 7
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,7 @@ namespace Umbraco.Core.Persistence.Dtos
|
||||
[Column("macroScriptType")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string ScriptType { get; set; }
|
||||
|
||||
[Column("macroScriptAssembly")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string ScriptAssembly { get; set; }
|
||||
|
||||
[Column("macroXSLT")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string Xslt { get; set; }
|
||||
|
||||
|
||||
[Column("macroCacheByPage")]
|
||||
[Constraint(Default = "1")]
|
||||
public bool CacheByPage { get; set; }
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
public IMacro BuildEntity(MacroDto dto)
|
||||
{
|
||||
var model = new Macro(dto.Id, dto.UniqueId, dto.UseInEditor, dto.RefreshRate, dto.Alias, dto.Name, dto.ScriptType, dto.ScriptAssembly, dto.Xslt, dto.CacheByPage, dto.CachePersonalized, dto.DontRender, dto.MacroFilePath);
|
||||
var model = new Macro(dto.Id, dto.UniqueId, dto.UseInEditor, dto.RefreshRate, dto.Alias, dto.Name, dto.ScriptType, dto.CacheByPage, dto.CachePersonalized, dto.DontRender, dto.MacroFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -42,10 +42,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Name = entity.Name,
|
||||
MacroFilePath = entity.ScriptPath,
|
||||
RefreshRate = entity.CacheDuration,
|
||||
ScriptAssembly = entity.ControlAssembly,
|
||||
ScriptType = entity.ControlType,
|
||||
UseInEditor = entity.UseInEditor,
|
||||
Xslt = entity.XsltPath,
|
||||
MacroPropertyDtos = BuildPropertyDtos(entity)
|
||||
};
|
||||
|
||||
|
||||
@@ -18,14 +18,12 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<Macro, MacroDto>(src => src.Alias, dto => dto.Alias);
|
||||
CacheMap<Macro, MacroDto>(src => src.CacheByPage, dto => dto.CacheByPage);
|
||||
CacheMap<Macro, MacroDto>(src => src.CacheByMember, dto => dto.CachePersonalized);
|
||||
CacheMap<Macro, MacroDto>(src => src.ControlAssembly, dto => dto.ScriptAssembly);
|
||||
CacheMap<Macro, MacroDto>(src => src.ControlType, dto => dto.ScriptType);
|
||||
CacheMap<Macro, MacroDto>(src => src.DontRender, dto => dto.DontRender);
|
||||
CacheMap<Macro, MacroDto>(src => src.Name, dto => dto.Name);
|
||||
CacheMap<Macro, MacroDto>(src => src.CacheDuration, dto => dto.RefreshRate);
|
||||
CacheMap<Macro, MacroDto>(src => src.ScriptPath, dto => dto.MacroFilePath);
|
||||
CacheMap<Macro, MacroDto>(src => src.UseInEditor, dto => dto.UseInEditor);
|
||||
CacheMap<Macro, MacroDto>(src => src.XsltPath, dto => dto.Xslt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,9 +296,7 @@ namespace Umbraco.Core.Services
|
||||
xml.Add(new XElement("name", macro.Name));
|
||||
xml.Add(new XElement("alias", macro.Alias));
|
||||
xml.Add(new XElement("scriptType", macro.ControlType));
|
||||
xml.Add(new XElement("scriptAssembly", macro.ControlAssembly));
|
||||
xml.Add(new XElement("scriptingFile", macro.ScriptPath));
|
||||
xml.Add(new XElement("xslt", macro.XsltPath));
|
||||
xml.Add(new XElement("useInEditor", macro.UseInEditor.ToString()));
|
||||
xml.Add(new XElement("dontRender", macro.DontRender.ToString()));
|
||||
xml.Add(new XElement("refreshRate", macro.CacheDuration.ToString(CultureInfo.InvariantCulture)));
|
||||
|
||||
@@ -31,9 +31,6 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <returns><see cref="MacroTypes"/></returns>
|
||||
internal static MacroTypes GetMacroType(IMacro macro)
|
||||
{
|
||||
if (string.IsNullOrEmpty(macro.XsltPath) == false)
|
||||
return MacroTypes.Xslt;
|
||||
|
||||
if (string.IsNullOrEmpty(macro.ScriptPath) == false)
|
||||
return MacroTypes.PartialView;
|
||||
|
||||
|
||||
@@ -1271,8 +1271,6 @@ namespace Umbraco.Core.Services.Implement
|
||||
var macroName = macroElement.Element("name").Value;
|
||||
var macroAlias = macroElement.Element("alias").Value;
|
||||
var controlType = macroElement.Element("scriptType").Value;
|
||||
var controlAssembly = macroElement.Element("scriptAssembly").Value;
|
||||
var xsltPath = macroElement.Element("xslt").Value;
|
||||
var scriptPath = macroElement.Element("scriptingFile").Value;
|
||||
|
||||
//Following xml elements are treated as nullable properties
|
||||
@@ -1308,7 +1306,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
var existingMacro = _macroService.GetByAlias(macroAlias) as Macro;
|
||||
var macro = existingMacro ?? new Macro(macroAlias, macroName, controlType, controlAssembly, xsltPath, scriptPath,
|
||||
var macro = existingMacro ?? new Macro(macroAlias, macroName, controlType, scriptPath,
|
||||
cacheByPage, cacheByMember, dontRender, useInEditor, cacheDuration);
|
||||
|
||||
var properties = macroElement.Element("properties");
|
||||
|
||||
@@ -562,10 +562,6 @@
|
||||
<Compile Include="Logging\WebProfilerProvider.cs" />
|
||||
<Compile Include="Macros\MacroErrorBehaviour.cs" />
|
||||
<Compile Include="Macros\MacroTagParser.cs" />
|
||||
<Compile Include="Macros\XsltExtension.cs" />
|
||||
<Compile Include="Macros\XsltExtensionAttribute.cs" />
|
||||
<Compile Include="Macros\XsltExtensionCollection.cs" />
|
||||
<Compile Include="Macros\XsltExtensionCollectionBuilder.cs" />
|
||||
<Compile Include="MainDom.cs" />
|
||||
<Compile Include="Manifest\ManifestParser.cs" />
|
||||
<Compile Include="Manifest\ValueValidatorConverter.cs" />
|
||||
|
||||
@@ -100,70 +100,6 @@ namespace Umbraco.Tests.Composing
|
||||
return new ProfilingLogger(logger, profiler);
|
||||
}
|
||||
|
||||
[Ignore("fixme - ignored test")]
|
||||
[Test]
|
||||
public void Benchmark_Original_Finder()
|
||||
{
|
||||
var profilingLogger = GetTestProfilingLogger();
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting test", "Finished test"))
|
||||
{
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesOfType", "Finished FindClassesOfType"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinderOriginal.FindClassesOfType<DisposableObject>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesOfTypeWithAttribute", "Finished FindClassesOfTypeWithAttribute"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinderOriginal.FindClassesOfTypeWithAttribute<TestEditor, MyTestAttribute>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesWithAttribute", "Finished FindClassesWithAttribute"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinderOriginal.FindClassesWithAttribute<XsltExtensionAttribute>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Ignore("fixme - ignored test")]
|
||||
[Test]
|
||||
public void Benchmark_New_Finder()
|
||||
{
|
||||
var profilingLogger = GetTestProfilingLogger();
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting test", "Finished test"))
|
||||
{
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesOfType", "Finished FindClassesOfType"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinder.FindClassesOfType<DisposableObject>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesOfTypeWithAttribute", "Finished FindClassesOfTypeWithAttribute"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinder.FindClassesOfTypeWithAttribute<TestEditor, MyTestAttribute>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
using (profilingLogger.TraceDuration<TypeFinderTests>("Starting FindClassesWithAttribute", "Finished FindClassesWithAttribute"))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Assert.Greater(TypeFinder.FindClassesWithAttribute<XsltExtensionAttribute>(_assemblies).Count(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public class MyTestAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -288,14 +288,7 @@ AnotherContentFinder
|
||||
var types = _typeLoader.GetDataEditors();
|
||||
Assert.AreEqual(43, types.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Resolves_XsltExtensions()
|
||||
{
|
||||
var types = _typeLoader.GetXsltExtensions();
|
||||
Assert.AreEqual(3, types.Count());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This demonstrates this issue: http://issues.umbraco.org/issue/U4-3505 - the TypeList was returning a list of assignable types
|
||||
/// not explicit types which is sort of ideal but is confusing so we'll do it the less confusing way.
|
||||
@@ -319,12 +312,6 @@ AnotherContentFinder
|
||||
Assert.IsNull(shouldNotFind);
|
||||
}
|
||||
|
||||
[XsltExtension("Blah.Blah")]
|
||||
public class MyXsltExtension
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface IFindMe : IDiscoverable
|
||||
{
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.Linq;
|
||||
using LightInject;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.Tests.Composing
|
||||
{
|
||||
[TestFixture]
|
||||
public class XsltExtensionCollectionTests : ComposingTestBase
|
||||
{
|
||||
[Test]
|
||||
public void XsltExtensionsCollectionBuilderWorks()
|
||||
{
|
||||
var container = new ServiceContainer();
|
||||
var builder = new XsltExtensionCollectionBuilder(container);
|
||||
builder.AddExtensionObjectProducer(() => TypeLoader.GetXsltExtensions());
|
||||
var extensions = builder.CreateCollection();
|
||||
|
||||
Assert.AreEqual(3, extensions.Count());
|
||||
|
||||
Assert.IsTrue(extensions.Select(x => x.ExtensionObject.GetType()).Contains(typeof (XsltEx1)));
|
||||
Assert.IsTrue(extensions.Select(x => x.ExtensionObject.GetType()).Contains(typeof(XsltEx2)));
|
||||
Assert.AreEqual("test1", extensions.Single(x => x.ExtensionObject.GetType() == typeof(XsltEx1)).Namespace);
|
||||
Assert.AreEqual("test2", extensions.Single(x => x.ExtensionObject.GetType() == typeof(XsltEx2)).Namespace);
|
||||
}
|
||||
|
||||
#region Test Objects
|
||||
|
||||
[XsltExtension("test1")]
|
||||
public class XsltEx1
|
||||
{ }
|
||||
|
||||
//test with legacy one
|
||||
[umbraco.XsltExtension("test2")]
|
||||
public class XsltEx2
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,6 @@ namespace Umbraco.Tests.Macros
|
||||
var model = new MacroModel
|
||||
{
|
||||
MacroType = macroType,
|
||||
Xslt = "anything",
|
||||
ScriptName = "anything",
|
||||
TypeName = "anything"
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Tests.Models
|
||||
[Test]
|
||||
public void Can_Deep_Clone()
|
||||
{
|
||||
var macro = new Macro(1, Guid.NewGuid(), true, 3, "test", "Test", "blah", "blah", "xslt", false, true, true, "script");
|
||||
var macro = new Macro(1, Guid.NewGuid(), true, 3, "test", "Test", "blah", false, true, true, "script");
|
||||
macro.Properties.Add(new MacroProperty(6, Guid.NewGuid(), "rewq", "REWQ", 1, "asdfasdf"));
|
||||
|
||||
var clone = (Macro)macro.DeepClone();
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
var macro = new Macro("test1", "Test", "~/usercontrol/blah.ascx", "MyAssembly", "test.xslt", "~/views/macropartials/test.cshtml");
|
||||
var macro = new Macro("test1", "Test", "~/usercontrol/blah.ascx", "~/views/macropartials/test.cshtml");
|
||||
;
|
||||
|
||||
Assert.Throws<SqlCeException>(() => repository.Save(macro));
|
||||
@@ -94,14 +94,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.That(macro.Alias, Is.EqualTo("test1"));
|
||||
Assert.That(macro.CacheByPage, Is.EqualTo(false));
|
||||
Assert.That(macro.CacheByMember, Is.EqualTo(false));
|
||||
Assert.That(macro.ControlAssembly, Is.EqualTo("MyAssembly1"));
|
||||
Assert.That(macro.ControlType, Is.EqualTo("~/usercontrol/test1.ascx"));
|
||||
Assert.That(macro.DontRender, Is.EqualTo(true));
|
||||
Assert.That(macro.Name, Is.EqualTo("Test1"));
|
||||
Assert.That(macro.CacheDuration, Is.EqualTo(0));
|
||||
Assert.That(macro.ScriptPath, Is.EqualTo("~/views/macropartials/test1.cshtml"));
|
||||
Assert.That(macro.UseInEditor, Is.EqualTo(false));
|
||||
Assert.That(macro.XsltPath, Is.EqualTo("test1.xslt"));
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +169,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
// Act
|
||||
var macro = new Macro("test", "Test", "~/usercontrol/blah.ascx", "MyAssembly", "test.xslt", "~/views/macropartials/test.cshtml");
|
||||
var macro = new Macro("test", "Test", "~/usercontrol/blah.ascx", "~/views/macropartials/test.cshtml");
|
||||
macro.Properties.Add(new MacroProperty("test", "Test", 0, "test"));
|
||||
repository.Save(macro);
|
||||
|
||||
@@ -197,12 +195,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
macro.CacheDuration = 1234;
|
||||
macro.CacheByPage = true;
|
||||
macro.CacheByMember = true;
|
||||
macro.ControlAssembly = "";
|
||||
macro.ControlType = "";
|
||||
macro.DontRender = false;
|
||||
macro.ScriptPath = "~/newpath.cshtml";
|
||||
macro.UseInEditor = true;
|
||||
macro.XsltPath = "";
|
||||
|
||||
repository.Save(macro);
|
||||
|
||||
@@ -214,12 +210,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.That(macroUpdated.CacheDuration, Is.EqualTo(1234));
|
||||
Assert.That(macroUpdated.CacheByPage, Is.EqualTo(true));
|
||||
Assert.That(macroUpdated.CacheByMember, Is.EqualTo(true));
|
||||
Assert.That(macroUpdated.ControlAssembly, Is.EqualTo(""));
|
||||
Assert.That(macroUpdated.ControlType, Is.EqualTo(""));
|
||||
Assert.That(macroUpdated.DontRender, Is.EqualTo(false));
|
||||
Assert.That(macroUpdated.ScriptPath, Is.EqualTo("~/newpath.cshtml"));
|
||||
Assert.That(macroUpdated.UseInEditor, Is.EqualTo(true));
|
||||
Assert.That(macroUpdated.XsltPath, Is.EqualTo(""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +293,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml");
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "~/views/macropartials/test1.cshtml");
|
||||
macro.Properties.Add(new MacroProperty("blah1", "New1", 4, "test.editor"));
|
||||
|
||||
repository.Save(macro);
|
||||
@@ -324,7 +318,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml");
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "~/views/macropartials/test1.cshtml");
|
||||
macro.Properties.Add(new MacroProperty("blah1", "New1", 4, "test.editor"));
|
||||
repository.Save(macro);
|
||||
|
||||
@@ -348,7 +342,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml");
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "~/views/macropartials/test1.cshtml");
|
||||
var prop1 = new MacroProperty("blah1", "New1", 4, "test.editor");
|
||||
var prop2 = new MacroProperty("blah2", "New2", 3, "test.editor");
|
||||
|
||||
@@ -434,9 +428,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
repository.Save(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml"));
|
||||
repository.Save(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "MyAssembly2", "test2.xslt", "~/views/macropartials/test2.cshtml"));
|
||||
repository.Save(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "MyAssembly3", "test3.xslt", "~/views/macropartials/test3.cshtml"));
|
||||
repository.Save(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "~/views/macropartials/test1.cshtml"));
|
||||
repository.Save(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "~/views/macropartials/test2.cshtml"));
|
||||
repository.Save(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "~/views/macropartials/test3.cshtml"));
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
var repository = new MacroRepository((IScopeAccessor) provider, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>());
|
||||
|
||||
repository.Save(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml"));
|
||||
repository.Save(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "MyAssembly2", "test2.xslt", "~/views/macropartials/test2.cshtml"));
|
||||
repository.Save(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "MyAssembly3", "test3.xslt", "~/views/macropartials/test3.cshtml"));
|
||||
repository.Save(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "~/views/macropartials/test1.cshtml"));
|
||||
repository.Save(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "~/views/macropartials/test2.cshtml"));
|
||||
repository.Save(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "~/views/macropartials/test3.cshtml"));
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Tests.Services
|
||||
public void PackagingService_Can_Export_Macro()
|
||||
{
|
||||
// Arrange
|
||||
var macro = new Macro("test1", "Test", "~/usercontrol/blah.ascx", "MyAssembly", "test.xslt", "~/views/macropartials/test.cshtml");
|
||||
var macro = new Macro("test1", "Test", "~/usercontrol/blah.ascx", "~/views/macropartials/test.cshtml");
|
||||
ServiceContext.MacroService.Save(macro);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace Umbraco.Tests.UI
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(typeof(XsltTasks), Constants.Applications.Developer)]
|
||||
[TestCase(typeof(StylesheetTasks), Constants.Applications.Settings)]
|
||||
[TestCase(typeof(stylesheetPropertyTasks), Constants.Applications.Settings)]
|
||||
[TestCase(typeof(MemberGroupTasks), Constants.Applications.Members)]
|
||||
|
||||
@@ -335,7 +335,6 @@
|
||||
<Compile Include="Services\LocalizedTextServiceTests.cs" />
|
||||
<Compile Include="Services\TagServiceTests.cs" />
|
||||
<Compile Include="Services\LocalizationServiceTests.cs" />
|
||||
<Compile Include="Composing\XsltExtensionCollectionTests.cs" />
|
||||
<Compile Include="Services\MemberServiceTests.cs" />
|
||||
<Compile Include="Services\MediaServiceTests.cs" />
|
||||
<Compile Include="Services\MemberTypeServiceTests.cs" />
|
||||
|
||||
@@ -567,7 +567,6 @@
|
||||
<Content Include="Umbraco\Translation\preview.aspx" />
|
||||
<Content Include="Umbraco\Translation\xml.aspx" />
|
||||
<Content Include="Umbraco\Create\simple.ascx" />
|
||||
<Content Include="Umbraco\Developer\Macros\assemblyBrowser.aspx" />
|
||||
<Content Include="Umbraco\Developer\Macros\editMacro.aspx" />
|
||||
<Content Include="Umbraco\Developer\Xslt\editXslt.aspx" />
|
||||
<Content Include="Umbraco\Developer\Xslt\getXsltStatus.asmx" />
|
||||
|
||||
@@ -378,8 +378,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">讀取使用者控制項 %0% 錯誤</key>
|
||||
<key alias="macroErrorLoadingCustomControl">讀取使用者控制項 %0% 錯誤(組件:%0%,類別:%1%)</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">讀取巨集引擎腳本錯誤(檔案:%0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">分析XSLT檔案錯誤:%0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">讀取XSLT檔案錯誤:%0%</key>
|
||||
<key alias="missingTitle">請輸入標題</key>
|
||||
<key alias="missingType">請選擇類型</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">圖片尺寸大於原始尺寸不會提高圖片品質,您確定要把圖片尺寸變大嗎?</key>
|
||||
@@ -1350,4 +1348,4 @@
|
||||
<key alias="enabledConfirm">轉址追蹤器已開啟。</key>
|
||||
<key alias="enableError">啟動轉址追蹤器錯誤,更多資訊請參閱您的紀錄檔。</key>
|
||||
</area>
|
||||
</language>
|
||||
</language>
|
||||
|
||||
@@ -434,8 +434,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Error loading userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Error loading customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Error loading MacroEngine script (file: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Error parsing XSLT file: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Error reading XSLT file: %0%</key>
|
||||
<key alias="missingTitle">Please enter a title</key>
|
||||
<key alias="missingType">Please choose a type</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">You're about to make the picture larger than the original size. Are you sure that you want to proceed?</key>
|
||||
|
||||
@@ -503,8 +503,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Error loading userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Error loading customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Error loading MacroEngine script (file: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Error parsing XSLT file: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Error reading XSLT file: %0%</key>
|
||||
<key alias="missingTitle">Please enter a title</key>
|
||||
<key alias="missingType">Please choose a type</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">You're about to make the picture larger than the original size. Are you sure that you want to proceed?</key>
|
||||
|
||||
@@ -487,8 +487,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Error cargando userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Error cargandog customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Error cargando MacroEngine script (file: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Error analizando archivo XSLT: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Error leyendo archivo XSLT: %0%</key>
|
||||
<key alias="missingTitle">
|
||||
<![CDATA[Por favor, introduzca un título
|
||||
]]>
|
||||
|
||||
@@ -388,8 +388,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Erreur de chargement du userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Erreur de chargement d'un customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Erreur de chargement d'un script du MacroEngine (fichier : %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Erreur de parsing d'un fichier XSLT : %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Erreur de lecture d'un fichier XSLT : %0%</key>
|
||||
<key alias="missingTitle">Veuillez entrer un titre</key>
|
||||
<key alias="missingType">Veuillez choisir un type</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">Vous allez définir une taille d'image supérieure à sa taille d'origine. Êtes-vous certain(e) de vouloir continuer?</key>
|
||||
|
||||
@@ -370,8 +370,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">userControl の読み込みエラー '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">customControl の読み込みエラー (アセンブリ: %0%, タイプ: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">MacroEngine スクリプトの読み込みエラー (ファイル: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">XSLT ファイル解析エラー: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">XSLT ファイル読み込みエラー: %0%</key>
|
||||
<key alias="missingTitle">タイトルを入力してください</key>
|
||||
<key alias="missingType">型を選択してください</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">元画像より大きくしようとしていますが、本当によろしいのですか?</key>
|
||||
|
||||
@@ -398,8 +398,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Error bij het laden van userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Error bij het laden van customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Error bij het laden van MacroEngine script (file: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Error bij het parsen van XSLT file: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Error bij het laden van XSLT file: %0%</key>
|
||||
<key alias="missingTitle">Vul een titel in</key>
|
||||
<key alias="missingType">Selecteer een type</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">U wilt een afbeelding groter maken dan de originele afmetingen. Weet je zeker dat je wilt doorgaan?</key>
|
||||
|
||||
@@ -487,8 +487,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Wystąpił błąd podczas ładowania userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Wystąpił błąd podczas ładowania customControl (Assembly: %0%, Typ: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Wystąpił błąd podczas ładowania skryptu MacroEngine (plik: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Wystąpił błąd podczas parsowania pliku XSLT: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Wystąpił błąd odczytu pliku XSLT: %0%</key>
|
||||
<key alias="missingTitle">Proszę podać tytuł</key>
|
||||
<key alias="missingType">Proszę wybrać typ</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">Chcesz utworzyć obraz większy niż rozmiar oryginalny. Czy na pewno chcesz kontynuować?</key>
|
||||
|
||||
@@ -512,8 +512,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Ошибка загрузки пользовательского элемента управления '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Ошибка загрузки внешнего типа (сборка: %0%, тип: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Ошибка загрузки макроса (файл: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Ошибка разбора кода XSLT в файле: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Ошибка чтения XSLT-файла: %0%</key>
|
||||
<key alias="missingPropertyEditorErrorMessage">Ошибка в конфигурации типа данных, используемого для свойства, проверьте тип данных</key>
|
||||
<key alias="missingTitle">Укажите заголовок</key>
|
||||
<key alias="missingType">Выберите тип</key>
|
||||
|
||||
@@ -314,8 +314,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">Error loading userControl '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">Error loading customControl (Assembly: %0%, Type: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">Error loading MacroEngine script (Dosya: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"Error parsing XSLT file: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"Error reading XSLT file: %0%</key>
|
||||
<key alias="missingTitle">Lütfen bir başlık girin</key>
|
||||
<key alias="missingType">Lütfen bir tür seçin</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">Orijinal boyutundan daha resmi büyütmek üzereyiz. Devam etmek istediğinizden emin misiniz?</key>
|
||||
|
||||
@@ -393,8 +393,6 @@
|
||||
<key alias="macroErrorLoadingUsercontrol">加载 userControl 时出错 '%0%'</key>
|
||||
<key alias="macroErrorLoadingCustomControl">加载 customControl 时出错(程序集: %0%, 类型: '%1%')</key>
|
||||
<key alias="macroErrorLoadingMacroEngineScript">加载 MacroEngine 脚本时出错 (文件: %0%)</key>
|
||||
<key alias="macroErrorParsingXSLTFile">"解析 xslt 文件时出错: %0%</key>
|
||||
<key alias="macroErrorReadingXSLTFile">"读取 xslt 文件时出错: %0%</key>
|
||||
<key alias="missingTitle">请输入标题</key>
|
||||
<key alias="missingType">请选择类型</key>
|
||||
<key alias="pictureResizeBiggerThanOrg">图片尺寸大于原始尺寸不会提高图片质量,您确定要把图片尺寸变大吗?</key>
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace Umbraco.Web.UI.Umbraco.Developer.Macros
|
||||
/// <param name="macro"> </param>
|
||||
/// <param name="macroAssemblyValue"></param>
|
||||
/// <param name="macroTypeValue"></param>
|
||||
protected override void PopulateFieldsOnLoad(IMacro macro, string macroAssemblyValue, string macroTypeValue)
|
||||
protected override void PopulateFieldsOnLoad(IMacro macro, string macroTypeValue)
|
||||
{
|
||||
base.PopulateFieldsOnLoad(macro, macroAssemblyValue, macroTypeValue);
|
||||
base.PopulateFieldsOnLoad(macro, macroTypeValue);
|
||||
//check if the ScriptingFile property contains the MacroPartials path
|
||||
if (macro.ScriptPath.IsNullOrWhiteSpace() == false &&
|
||||
(macro.ScriptPath.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/")
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Developer.Macros {
|
||||
|
||||
|
||||
|
||||
|
||||
public partial class EditMacro {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// CssInclude1 control.
|
||||
/// </summary>
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Web.UI.Umbraco.Developer.Macros {
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.CssInclude CssInclude1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SelectedPartialView control.
|
||||
/// </summary>
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Web.UI.Umbraco.Developer.Macros {
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox SelectedPartialView;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PartialViewList control.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Title="Assembly Browser" Codebehind="assemblyBrowser.aspx.cs" AutoEventWireup="True"
|
||||
Inherits="umbraco.developer.assemblyBrowser" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<h3 style="MARGIN-LEFT: 0px"><asp:Label id="AssemblyName" runat="server"></asp:Label></h3>
|
||||
<asp:Panel id="ChooseProperties" runat="server">
|
||||
<p class="guiDialogTiny">The following list shows the Public Properties from the
|
||||
Control. By checking the Properties and click the "Save Properties" button at
|
||||
|
||||
the bottom, umbraco will create the corresponding Macro Elements.</p>
|
||||
<asp:CheckBoxList id="MacroProperties" runat="server"></asp:CheckBoxList>
|
||||
<p>
|
||||
<asp:Button id="Button1" runat="server" Text="Save Properties" onclick="Button1_Click"></asp:Button>
|
||||
</p>
|
||||
</asp:Panel>
|
||||
|
||||
<asp:Panel id="ConfigProperties" runat="server" Visible="False">
|
||||
<p class="guiDialogNormal"><strong>The following Macro Parameters was added:</strong><br /></p>
|
||||
<ul class="guiDialogNormal"><asp:Literal ID="resultLiteral" runat="server"></asp:Literal></ul>
|
||||
<p class="guiDialogNormal">
|
||||
<span style="color: Green"><strong>Important:</strong> You might need to reload the macro to see the changes.</span><br /><br />
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
</asp:Panel>
|
||||
|
||||
</asp:Content>
|
||||
@@ -68,27 +68,12 @@
|
||||
<asp:DropDownList ID="PartialViewList" runat="server" >
|
||||
</asp:DropDownList>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="XSLT">
|
||||
<asp:TextBox ID="macroXslt" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
<asp:DropDownList ID="xsltFiles" runat="server">
|
||||
</asp:DropDownList>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
|
||||
<cc1:PropertyPanel runat="server" Text="usercontrol">
|
||||
<asp:TextBox ID="macroUserControl" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
<asp:DropDownList ID="userControlList" runat="server">
|
||||
</asp:DropDownList>
|
||||
<asp:PlaceHolder ID="assemblyBrowserUserControl" runat="server"></asp:PlaceHolder>
|
||||
</cc1:PropertyPanel>
|
||||
|
||||
<asp:PlaceHolder runat="server" Visible="false">
|
||||
<asp:TextBox ID="macroAssembly" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
(Assembly)<br />
|
||||
<asp:TextBox ID="macroType" runat="server" CssClass="guiInputText"></asp:TextBox>
|
||||
(Type)
|
||||
<asp:PlaceHolder ID="assemblyBrowser" runat="server"></asp:PlaceHolder>
|
||||
</asp:PlaceHolder>
|
||||
</cc1:Pane>
|
||||
|
||||
<cc1:Pane ID="Pane1_3" runat="server" Title="Editor settings">
|
||||
|
||||
@@ -124,10 +124,7 @@ namespace Umbraco.Web.Composing
|
||||
|
||||
internal static EditorValidatorCollection EditorValidators
|
||||
=> Container.GetInstance<EditorValidatorCollection>();
|
||||
|
||||
internal static XsltExtensionCollection XsltExtensions
|
||||
=> Container.GetInstance<XsltExtensionCollection>();
|
||||
|
||||
|
||||
internal static UmbracoApiControllerTypeCollection UmbracoApiControllerTypes
|
||||
=> Container.GetInstance<UmbracoApiControllerTypeCollection>();
|
||||
|
||||
@@ -143,9 +140,6 @@ namespace Umbraco.Web.Composing
|
||||
internal static IPublishedSnapshotService PublishedSnapshotService
|
||||
=> Container.GetInstance<IPublishedSnapshotService>();
|
||||
|
||||
public static ThumbnailProviderCollection ThumbnailProviders
|
||||
=> Container.GetInstance<ThumbnailProviderCollection>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Web Constants
|
||||
|
||||
@@ -33,15 +33,7 @@ namespace Umbraco.Core.Components
|
||||
/// <returns></returns>
|
||||
internal static ActionCollectionBuilder Actions(this Composition composition)
|
||||
=> composition.Container.GetInstance<ActionCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content finders collection builder.
|
||||
/// </summary>
|
||||
/// <param name="composition">The composition.</param>
|
||||
/// <returns></returns>
|
||||
internal static XsltExtensionCollectionBuilder XsltExtensions(this Composition composition)
|
||||
=> composition.Container.GetInstance<XsltExtensionCollectionBuilder>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content finders collection builder.
|
||||
/// </summary>
|
||||
@@ -80,13 +72,6 @@ namespace Umbraco.Core.Components
|
||||
internal static ImageUrlProviderCollectionBuilder ImageUrlProviders(this Composition composition)
|
||||
=> composition.Container.GetInstance<ImageUrlProviderCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the thumbnail providers collection builder.
|
||||
/// </summary>
|
||||
/// <param name="composition">The composition.</param>
|
||||
internal static ThumbnailProviderCollectionBuilder ThumbnailProviders(this Composition composition)
|
||||
=> composition.Container.GetInstance<ThumbnailProviderCollectionBuilder>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the url providers collection builder.
|
||||
/// </summary>
|
||||
|
||||
@@ -19,13 +19,8 @@ namespace Umbraco.Web.Macros
|
||||
|
||||
public MacroTypes MacroType { get; set; }
|
||||
|
||||
// that one was for CustomControls which are gone in v8
|
||||
//public string TypeAssembly { get; set; }
|
||||
|
||||
public string TypeName { get; set; }
|
||||
|
||||
public string Xslt { get; set; }
|
||||
|
||||
public string ScriptName { get; set; }
|
||||
|
||||
public string ScriptCode { get; set; }
|
||||
@@ -54,9 +49,7 @@ namespace Umbraco.Web.Macros
|
||||
Id = macro.Id;
|
||||
Name = macro.Name;
|
||||
Alias = macro.Alias;
|
||||
//TypeAssembly = macro.ControlAssembly;
|
||||
TypeName = macro.ControlType;
|
||||
Xslt = macro.XsltPath;
|
||||
ScriptName = macro.ScriptPath;
|
||||
CacheDuration = macro.CacheDuration;
|
||||
CacheByPage = macro.CacheByPage;
|
||||
|
||||
@@ -177,22 +177,12 @@ namespace Umbraco.Web.Macros
|
||||
|
||||
switch (model.MacroType)
|
||||
{
|
||||
case MacroTypes.Xslt:
|
||||
filename = SystemDirectories.Xslt.EnsureEndsWith('/') + model.Xslt;
|
||||
break;
|
||||
//case MacroTypes.Script:
|
||||
// // was "~/macroScripts/"
|
||||
// filename = SystemDirectories.MacroScripts.EnsureEndsWith('/') + model.ScriptName;
|
||||
// break;
|
||||
case MacroTypes.PartialView:
|
||||
filename = model.ScriptName; //partial views are saved with their full virtual path
|
||||
break;
|
||||
case MacroTypes.UserControl:
|
||||
filename = model.TypeName; //user controls are saved with their full virtual path
|
||||
break;
|
||||
//case MacroTypes.Script:
|
||||
//case MacroTypes.CustomControl:
|
||||
//case MacroTypes.Unknown:
|
||||
default:
|
||||
// not file-based, or not supported
|
||||
filename = null;
|
||||
@@ -381,24 +371,7 @@ namespace Umbraco.Web.Macros
|
||||
"Executed PartialView.",
|
||||
() => ExecutePartialView(model),
|
||||
() => textService.Localize("errors/macroErrorLoadingPartialView", new[] { model.ScriptName }));
|
||||
|
||||
//case MacroTypes.Script:
|
||||
// return ExecuteMacroWithErrorWrapper(model,
|
||||
// "Executing Script: " + (string.IsNullOrWhiteSpace(model.ScriptCode)
|
||||
// ? "ScriptName=\"" + model.ScriptName + "\""
|
||||
// : "Inline, Language=\"" + model.ScriptLanguage + "\""),
|
||||
// "Executed Script.",
|
||||
// () => ExecuteScript(model),
|
||||
// () => textService.Localize("errors/macroErrorLoadingMacroEngineScript", new[] { model.ScriptName }));
|
||||
|
||||
case MacroTypes.Xslt:
|
||||
return ExecuteMacroWithErrorWrapper(model,
|
||||
$"Executing Xslt: TypeName=\"{model.TypeName}\", ScriptName=\"{model.Xslt}\".",
|
||||
"Executed Xslt.",
|
||||
() => ExecuteXslt(model, _plogger),
|
||||
// cannot diff. between reading & parsing... bah
|
||||
() => textService.Localize("errors/macroErrorParsingXSLTFile", new[] { model.Xslt }));
|
||||
|
||||
|
||||
case MacroTypes.UserControl:
|
||||
return ExecuteMacroWithErrorWrapper(model,
|
||||
$"Loading UserControl: TypeName=\"{model.TypeName}\".",
|
||||
@@ -447,16 +420,6 @@ namespace Umbraco.Web.Macros
|
||||
return engine.Execute(macro, content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders an Xslt Macro.
|
||||
/// </summary>
|
||||
/// <returns>The text output of the macro execution.</returns>
|
||||
public static MacroContent ExecuteXslt(MacroModel macro, ProfilingLogger plogger)
|
||||
{
|
||||
var engine = new XsltMacroEngine(plogger);
|
||||
return engine.Execute(macro);
|
||||
}
|
||||
|
||||
public static MacroContent ExecuteUserControl(MacroModel macro)
|
||||
{
|
||||
// add tilde for v4 defined macros
|
||||
|
||||
@@ -1,687 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Xml.Xsl;
|
||||
using umbraco;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Xml.XPath;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Templates;
|
||||
|
||||
namespace Umbraco.Web.Macros
|
||||
{
|
||||
/// <summary>
|
||||
/// A macro engine using XSLT to execute.
|
||||
/// </summary>
|
||||
public class XsltMacroEngine
|
||||
{
|
||||
private readonly Func<HttpContextBase> _getHttpContext;
|
||||
private readonly Func<UmbracoContext> _getUmbracoContext;
|
||||
private readonly ProfilingLogger _plogger;
|
||||
|
||||
public XsltMacroEngine(ProfilingLogger plogger)
|
||||
{
|
||||
_plogger = plogger;
|
||||
|
||||
_getHttpContext = () =>
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
throw new InvalidOperationException("The Xslt Macro Engine cannot execute with a null HttpContext.Current reference");
|
||||
return new HttpContextWrapper(HttpContext.Current);
|
||||
};
|
||||
|
||||
_getUmbracoContext = () =>
|
||||
{
|
||||
if (UmbracoContext.Current == null)
|
||||
throw new InvalidOperationException("The Xslt Macro Engine cannot execute with a null UmbracoContext.Current reference");
|
||||
return UmbracoContext.Current;
|
||||
};
|
||||
}
|
||||
|
||||
#region Execute Xslt
|
||||
|
||||
// executes the macro, relying on GetXsltTransform
|
||||
// will pick XmlDocument or Navigator mode depending on the capabilities of the published caches
|
||||
public MacroContent Execute(MacroModel model)
|
||||
{
|
||||
var hasCode = string.IsNullOrWhiteSpace(model.ScriptCode) == false;
|
||||
var hasXslt = string.IsNullOrWhiteSpace(model.Xslt) == false;
|
||||
|
||||
if (hasXslt == false && hasCode == false)
|
||||
{
|
||||
Current.Logger.Warn<XsltMacroEngine>("Xslt is empty");
|
||||
return MacroContent.Empty;
|
||||
}
|
||||
|
||||
if (hasCode && model.ScriptLanguage.InvariantEquals("xslt") == false)
|
||||
{
|
||||
Current.Logger.Warn<XsltMacroEngine>("Unsupported script language \"" + model.ScriptLanguage + "\".");
|
||||
return MacroContent.Empty;
|
||||
}
|
||||
|
||||
var msg = "Executing Xslt: " + (hasCode ? "Inline." : "Xslt=\"" + model.Xslt + "\".");
|
||||
using (_plogger.DebugDuration<XsltMacroEngine>(msg, "ExecutedXslt."))
|
||||
{
|
||||
// need these two here for error reporting
|
||||
MacroNavigator macroNavigator = null;
|
||||
XmlDocument macroXml = null;
|
||||
|
||||
IXPathNavigable macroNavigable;
|
||||
IXPathNavigable contentNavigable;
|
||||
|
||||
var xmlCache = UmbracoContext.Current.ContentCache as PublishedCache.XmlPublishedCache.PublishedContentCache;
|
||||
|
||||
if (xmlCache == null)
|
||||
{
|
||||
// a different cache
|
||||
// inheriting from NavigableNavigator is required
|
||||
|
||||
var contentNavigator = UmbracoContext.Current.ContentCache.CreateNavigator() as NavigableNavigator;
|
||||
var mediaNavigator = UmbracoContext.Current.MediaCache.CreateNavigator() as NavigableNavigator;
|
||||
|
||||
if (contentNavigator == null || mediaNavigator == null)
|
||||
throw new Exception("Published caches XPathNavigator do not inherit from NavigableNavigator.");
|
||||
|
||||
var parameters = new List<MacroNavigator.MacroParameter>();
|
||||
foreach (var prop in model.Properties)
|
||||
AddMacroParameter(parameters, contentNavigator, mediaNavigator, prop.Key, prop.Type, prop.Value);
|
||||
|
||||
macroNavigable = macroNavigator = new MacroNavigator(parameters);
|
||||
contentNavigable = UmbracoContext.Current.ContentCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the original XML cache
|
||||
// render the macro on top of the Xml document
|
||||
|
||||
var umbracoXml = xmlCache.GetXml(UmbracoContext.Current.InPreviewMode);
|
||||
|
||||
macroXml = new XmlDocument();
|
||||
macroXml.LoadXml("<macro/>");
|
||||
|
||||
foreach (var prop in model.Properties)
|
||||
AddMacroXmlNode(umbracoXml, macroXml, prop.Key, prop.Type, prop.Value);
|
||||
|
||||
macroNavigable = macroXml;
|
||||
contentNavigable = umbracoXml;
|
||||
}
|
||||
|
||||
// this is somewhat ugly but eh...
|
||||
var httpContext = _getHttpContext();
|
||||
if (httpContext.Request.QueryString["umbDebug"] != null && GlobalSettings.DebugMode)
|
||||
{
|
||||
var outerXml = macroXml?.OuterXml ?? macroNavigator.OuterXml;
|
||||
var text = $"<div style=\"border: 2px solid green; padding: 5px;\"><b>Debug from {model.Name}<b><br />{HttpUtility.HtmlEncode(outerXml)}</div>";
|
||||
return new MacroContent { Text = text };
|
||||
}
|
||||
|
||||
// get the transform
|
||||
XslCompiledTransform transform;
|
||||
if (hasCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var sreader = new StringReader(model.ScriptCode))
|
||||
using (var xreader = new XmlTextReader(sreader))
|
||||
{
|
||||
transform = GetXsltTransform(xreader, GlobalSettings.DebugMode);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception("Failed to parse inline Xslt.", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
transform = GetCachedXsltTransform(model.Xslt);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Failed to read Xslt file \"{model.Xslt}\".", e);
|
||||
}
|
||||
}
|
||||
|
||||
using (_plogger.DebugDuration<XsltMacroEngine>("Performing transformation.", "Performed transformation."))
|
||||
{
|
||||
try
|
||||
{
|
||||
var transformed = XsltTransform(_plogger, macroNavigable, contentNavigable, transform);
|
||||
var text = TemplateUtilities.ResolveUrlsFromTextString(transformed);
|
||||
return new MacroContent { Text = text };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Failed to exec Xslt file \"{model.Xslt}\".", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the XSLT extension namespaces to the XSLT header using
|
||||
/// {0} as the container for the namespace references and
|
||||
/// {1} as the container for the exclude-result-prefixes
|
||||
/// </summary>
|
||||
/// <param name="xslt">The XSLT</param>
|
||||
/// <returns>The XSLT with {0} and {1} replaced.</returns>
|
||||
/// <remarks>This is done here because it needs the engine's XSLT extensions.</remarks>
|
||||
public static string AddXsltExtensionsToHeader(string xslt)
|
||||
{
|
||||
var namespaceList = new StringBuilder();
|
||||
var namespaceDeclaractions = new StringBuilder();
|
||||
foreach (var extension in GetXsltExtensions())
|
||||
{
|
||||
namespaceList.Append(extension.Key).Append(' ');
|
||||
namespaceDeclaractions.AppendFormat("xmlns:{0}=\"urn:{0}\" ", extension.Key);
|
||||
}
|
||||
|
||||
// parse xslt
|
||||
xslt = xslt.Replace("{0}", namespaceDeclaractions.ToString());
|
||||
xslt = xslt.Replace("{1}", namespaceList.ToString());
|
||||
return xslt;
|
||||
}
|
||||
|
||||
public static string TestXsltTransform(ProfilingLogger plogger, string xsltText, int currentPageId = -1)
|
||||
{
|
||||
IXPathNavigable macroNavigable;
|
||||
IXPathNavigable contentNavigable;
|
||||
|
||||
var xmlCache = UmbracoContext.Current.ContentCache as PublishedCache.XmlPublishedCache.PublishedContentCache;
|
||||
|
||||
var xslParameters = new Dictionary<string, object>();
|
||||
xslParameters["currentPage"] = UmbracoContext.Current.ContentCache
|
||||
.CreateNavigator()
|
||||
.Select(currentPageId > 0 ? ("//* [@id=" + currentPageId + "]") : "//* [@parentID=-1]");
|
||||
|
||||
if (xmlCache == null)
|
||||
{
|
||||
// a different cache
|
||||
// inheriting from NavigableNavigator is required
|
||||
|
||||
var contentNavigator = UmbracoContext.Current.ContentCache.CreateNavigator() as NavigableNavigator;
|
||||
if (contentNavigator == null)
|
||||
throw new Exception("Published caches XPathNavigator do not inherit from NavigableNavigator.");
|
||||
|
||||
var parameters = new List<MacroNavigator.MacroParameter>();
|
||||
macroNavigable = new MacroNavigator(parameters);
|
||||
contentNavigable = UmbracoContext.Current.ContentCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the original XML cache
|
||||
// render the macro on top of the Xml document
|
||||
|
||||
var umbracoXml = xmlCache.GetXml(UmbracoContext.Current.InPreviewMode);
|
||||
|
||||
var macroXml = new XmlDocument();
|
||||
macroXml.LoadXml("<macro/>");
|
||||
|
||||
macroNavigable = macroXml;
|
||||
contentNavigable = umbracoXml;
|
||||
}
|
||||
|
||||
// for a test, do not try...catch
|
||||
// but let the exceptions be thrown
|
||||
|
||||
XslCompiledTransform transform;
|
||||
using (var reader = new XmlTextReader(new StringReader(xsltText)))
|
||||
{
|
||||
transform = GetXsltTransform(reader, true);
|
||||
}
|
||||
var transformed = XsltTransform(plogger, macroNavigable, contentNavigable, transform, xslParameters);
|
||||
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static string ExecuteItemRenderer(ProfilingLogger plogger, XslCompiledTransform transform, string itemData)
|
||||
{
|
||||
IXPathNavigable macroNavigable;
|
||||
IXPathNavigable contentNavigable;
|
||||
|
||||
var xmlCache = UmbracoContext.Current.ContentCache as PublishedCache.XmlPublishedCache.PublishedContentCache;
|
||||
|
||||
if (xmlCache == null)
|
||||
{
|
||||
// a different cache
|
||||
// inheriting from NavigableNavigator is required
|
||||
|
||||
var contentNavigator = UmbracoContext.Current.ContentCache.CreateNavigator() as NavigableNavigator;
|
||||
var mediaNavigator = UmbracoContext.Current.MediaCache.CreateNavigator() as NavigableNavigator;
|
||||
|
||||
if (contentNavigator == null || mediaNavigator == null)
|
||||
throw new Exception("Published caches XPathNavigator do not inherit from NavigableNavigator.");
|
||||
|
||||
var parameters = new List<MacroNavigator.MacroParameter>();
|
||||
|
||||
macroNavigable = new MacroNavigator(parameters);
|
||||
contentNavigable = UmbracoContext.Current.ContentCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the original XML cache
|
||||
// render the macro on top of the Xml document
|
||||
|
||||
var umbracoXml = xmlCache.GetXml(UmbracoContext.Current.InPreviewMode);
|
||||
|
||||
var macroXml = new XmlDocument();
|
||||
macroXml.LoadXml("<macro/>");
|
||||
|
||||
macroNavigable = macroXml;
|
||||
contentNavigable = umbracoXml;
|
||||
}
|
||||
|
||||
var xslParameters = new Dictionary<string, object> { { "itemData", itemData } };
|
||||
return XsltTransform(plogger, macroNavigable, contentNavigable, transform, xslParameters);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region XsltTransform
|
||||
|
||||
// running on the XML cache, document mode
|
||||
// add parameters to the <macro> root node
|
||||
// note: contains legacy dirty code
|
||||
private static void AddMacroXmlNode(XmlDocument umbracoXml, XmlDocument macroXml,
|
||||
string macroPropertyAlias, string macroPropertyType, string macroPropertyValue)
|
||||
{
|
||||
var macroXmlNode = macroXml.CreateNode(XmlNodeType.Element, macroPropertyAlias, string.Empty);
|
||||
|
||||
// if no value is passed, then use the current "pageID" as value
|
||||
var contentId = macroPropertyValue == string.Empty ? UmbracoContext.Current.PageId.ToString() : macroPropertyValue;
|
||||
|
||||
Current.Logger.Info<XsltMacroEngine>($"Xslt node adding search start ({macroPropertyAlias},{macroPropertyValue})");
|
||||
|
||||
switch (macroPropertyType)
|
||||
{
|
||||
case "contentTree":
|
||||
var nodeId = macroXml.CreateAttribute("nodeID");
|
||||
nodeId.Value = contentId;
|
||||
macroXmlNode.Attributes.SetNamedItem(nodeId);
|
||||
|
||||
// Get subs
|
||||
try
|
||||
{
|
||||
macroXmlNode.AppendChild(macroXml.ImportNode(umbracoXml.GetElementById(contentId), true));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
break;
|
||||
|
||||
case "contentCurrent":
|
||||
var importNode = macroPropertyValue == string.Empty
|
||||
? umbracoXml.GetElementById(contentId)
|
||||
: umbracoXml.GetElementById(macroPropertyValue);
|
||||
|
||||
var currentNode = macroXml.ImportNode(importNode, true);
|
||||
|
||||
// remove all sub content nodes
|
||||
foreach (XmlNode n in currentNode.SelectNodes("*[@isDoc]"))
|
||||
currentNode.RemoveChild(n);
|
||||
|
||||
macroXmlNode.AppendChild(currentNode);
|
||||
|
||||
break;
|
||||
|
||||
case "contentSubs": // disable that one, it does not work anyway...
|
||||
//x.LoadXml("<nodes/>");
|
||||
//x.FirstChild.AppendChild(x.ImportNode(umbracoXml.GetElementById(contentId), true));
|
||||
//macroXmlNode.InnerXml = TransformMacroXml(x, "macroGetSubs.xsl");
|
||||
break;
|
||||
|
||||
case "contentAll":
|
||||
macroXmlNode.AppendChild(macroXml.ImportNode(umbracoXml.DocumentElement, true));
|
||||
break;
|
||||
|
||||
case "contentRandom":
|
||||
XmlNode source = umbracoXml.GetElementById(contentId);
|
||||
if (source != null)
|
||||
{
|
||||
var sourceList = source.SelectNodes("*[@isDoc]");
|
||||
if (sourceList.Count > 0)
|
||||
{
|
||||
int rndNumber;
|
||||
var r = library.GetRandom();
|
||||
lock (r)
|
||||
{
|
||||
rndNumber = r.Next(sourceList.Count);
|
||||
}
|
||||
var node = macroXml.ImportNode(sourceList[rndNumber], true);
|
||||
// remove all sub content nodes
|
||||
foreach (XmlNode n in node.SelectNodes("*[@isDoc]"))
|
||||
node.RemoveChild(n);
|
||||
|
||||
macroXmlNode.AppendChild(node);
|
||||
}
|
||||
else
|
||||
Current.Logger.Warn<XsltMacroEngine>("Error adding random node - parent (" + macroPropertyValue + ") doesn't have children!");
|
||||
}
|
||||
else
|
||||
Current.Logger.Warn<XsltMacroEngine>("Error adding random node - parent (" + macroPropertyValue + ") doesn't exists!");
|
||||
break;
|
||||
|
||||
case "mediaCurrent":
|
||||
if (string.IsNullOrEmpty(macroPropertyValue) == false)
|
||||
{
|
||||
//var c = new global::umbraco.cms.businesslogic.Content(int.Parse(macroPropertyValue));
|
||||
//macroXmlNode.AppendChild(macroXml.ImportNode(c.ToXml(global::umbraco.content.Instance.XmlContent, false), true));
|
||||
var nav = UmbracoContext.Current.MediaCache.CreateNodeNavigator(int.Parse(macroPropertyValue), false);
|
||||
if (nav != null)
|
||||
macroXmlNode.AppendChild(macroXml.ReadNode(nav.ReadSubtree()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
macroXmlNode.InnerText = HttpUtility.HtmlDecode(macroPropertyValue);
|
||||
break;
|
||||
}
|
||||
macroXml.FirstChild.AppendChild(macroXmlNode);
|
||||
}
|
||||
|
||||
// running on a navigable cache, navigable mode
|
||||
// add parameters to the macro parameters collection
|
||||
private static void AddMacroParameter(ICollection<MacroNavigator.MacroParameter> parameters,
|
||||
NavigableNavigator contentNavigator, NavigableNavigator mediaNavigator,
|
||||
string macroPropertyAlias, string macroPropertyType, string macroPropertyValue)
|
||||
{
|
||||
// if no value is passed, then use the current "pageID" as value
|
||||
var contentId = macroPropertyValue == string.Empty ? UmbracoContext.Current.PageId.ToString() : macroPropertyValue;
|
||||
|
||||
Current.Logger.Info<XsltMacroEngine>($"Xslt node adding search start ({macroPropertyAlias},{macroPropertyValue})");
|
||||
|
||||
// beware! do not use the raw content- or media- navigators, but clones !!
|
||||
|
||||
switch (macroPropertyType)
|
||||
{
|
||||
case "contentTree":
|
||||
parameters.Add(new MacroNavigator.MacroParameter(
|
||||
macroPropertyAlias,
|
||||
contentNavigator.CloneWithNewRoot(contentId), // null if not found - will be reported as empty
|
||||
attributes: new Dictionary<string, string> { { "nodeID", contentId } }));
|
||||
|
||||
break;
|
||||
|
||||
case "contentPicker":
|
||||
parameters.Add(new MacroNavigator.MacroParameter(
|
||||
macroPropertyAlias,
|
||||
contentNavigator.CloneWithNewRoot(contentId), // null if not found - will be reported as empty
|
||||
0));
|
||||
break;
|
||||
|
||||
case "contentSubs":
|
||||
parameters.Add(new MacroNavigator.MacroParameter(
|
||||
macroPropertyAlias,
|
||||
contentNavigator.CloneWithNewRoot(contentId), // null if not found - will be reported as empty
|
||||
1));
|
||||
break;
|
||||
|
||||
case "contentAll":
|
||||
parameters.Add(new MacroNavigator.MacroParameter(macroPropertyAlias, contentNavigator.Clone()));
|
||||
break;
|
||||
|
||||
case "contentRandom":
|
||||
var nav = contentNavigator.Clone();
|
||||
if (nav.MoveToId(contentId))
|
||||
{
|
||||
var descendantIterator = nav.Select("./* [@isDoc]");
|
||||
if (descendantIterator.MoveNext())
|
||||
{
|
||||
// not empty - and won't change
|
||||
var descendantCount = descendantIterator.Count;
|
||||
|
||||
int index;
|
||||
var r = library.GetRandom();
|
||||
lock (r)
|
||||
{
|
||||
index = r.Next(descendantCount);
|
||||
}
|
||||
|
||||
while (index > 0 && descendantIterator.MoveNext())
|
||||
index--;
|
||||
|
||||
var node = descendantIterator.Current.UnderlyingObject as INavigableContent;
|
||||
if (node != null)
|
||||
{
|
||||
nav = contentNavigator.CloneWithNewRoot(node.Id);
|
||||
parameters.Add(new MacroNavigator.MacroParameter(macroPropertyAlias, nav, 0));
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException("Iterator contains non-INavigableContent elements.");
|
||||
}
|
||||
else
|
||||
Current.Logger.Warn<XsltMacroEngine>("Error adding random node - parent (" + macroPropertyValue + ") doesn't have children!");
|
||||
}
|
||||
else
|
||||
Current.Logger.Warn<XsltMacroEngine>("Error adding random node - parent (" + macroPropertyValue + ") doesn't exists!");
|
||||
break;
|
||||
|
||||
case "mediaCurrent":
|
||||
parameters.Add(new MacroNavigator.MacroParameter(
|
||||
macroPropertyAlias,
|
||||
mediaNavigator.CloneWithNewRoot(contentId), // null if not found - will be reported as empty
|
||||
0));
|
||||
break;
|
||||
|
||||
default:
|
||||
parameters.Add(new MacroNavigator.MacroParameter(macroPropertyAlias, HttpUtility.HtmlDecode(macroPropertyValue)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// gets the result of the xslt transform
|
||||
private static string XsltTransform(ProfilingLogger plogger, IXPathNavigable macroNavigable, IXPathNavigable contentNavigable,
|
||||
XslCompiledTransform xslt, IDictionary<string, object> xslParameters = null)
|
||||
{
|
||||
TextWriter tw = new StringWriter();
|
||||
|
||||
XsltArgumentList xslArgs;
|
||||
using (plogger.DebugDuration<XsltMacroEngine>("Adding Xslt extensions", "Added Xslt extensions"))
|
||||
{
|
||||
xslArgs = GetXsltArgumentListWithExtensions();
|
||||
var lib = new library();
|
||||
xslArgs.AddExtensionObject("urn:umbraco.library", lib);
|
||||
}
|
||||
|
||||
// add parameters
|
||||
if (xslParameters == null || xslParameters.ContainsKey("currentPage") == false)
|
||||
{
|
||||
// note: "PageId" is a legacy stuff that might be != from what's in current PublishedContentRequest
|
||||
var currentPageId = UmbracoContext.Current.PageId;
|
||||
var current = contentNavigable.CreateNavigator().Select("//* [@id=" + currentPageId + "]");
|
||||
xslArgs.AddParam("currentPage", string.Empty, current);
|
||||
}
|
||||
if (xslParameters != null)
|
||||
foreach (var parameter in xslParameters)
|
||||
xslArgs.AddParam(parameter.Key, string.Empty, parameter.Value);
|
||||
|
||||
// transform
|
||||
using (plogger.DebugDuration<XsltMacroEngine>("Executing Xslt transform", "Executed Xslt transform"))
|
||||
{
|
||||
xslt.Transform(macroNavigable, xslArgs, tw);
|
||||
}
|
||||
|
||||
return tw.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manage transforms
|
||||
|
||||
private static XslCompiledTransform GetCachedXsltTransform(string filename)
|
||||
{
|
||||
//TODO: SD: Do we really need to cache this??
|
||||
var filepath = IOHelper.MapPath(SystemDirectories.Xslt.EnsureEndsWith('/') + filename);
|
||||
return Current.ApplicationCache.GetCacheItem(
|
||||
CacheKeys.MacroXsltCacheKey + filename,
|
||||
CacheItemPriority.Default,
|
||||
new CacheDependency(filepath),
|
||||
() =>
|
||||
{
|
||||
using (var xslReader = new XmlTextReader(filepath))
|
||||
{
|
||||
return GetXsltTransform(xslReader, GlobalSettings.DebugMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static XslCompiledTransform GetXsltTransform(XmlTextReader xslReader, bool debugMode)
|
||||
{
|
||||
var transform = new XslCompiledTransform(debugMode);
|
||||
var xslResolver = new XmlUrlResolver
|
||||
{
|
||||
Credentials = CredentialCache.DefaultCredentials
|
||||
};
|
||||
|
||||
xslReader.EntityHandling = EntityHandling.ExpandEntities;
|
||||
xslReader.DtdProcessing = DtdProcessing.Parse;
|
||||
|
||||
try
|
||||
{
|
||||
transform.Load(xslReader, XsltSettings.TrustedXslt, xslResolver);
|
||||
}
|
||||
finally
|
||||
{
|
||||
xslReader.Close();
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manage extensions
|
||||
|
||||
/*
|
||||
private static readonly string XsltExtensionsConfig =
|
||||
IOHelper.MapPath(SystemDirectories.Config + "/xsltExtensions.config");
|
||||
|
||||
private static readonly Func<CacheDependency> XsltExtensionsDependency =
|
||||
() => new CacheDependency(XsltExtensionsConfig);
|
||||
*/
|
||||
|
||||
// creates and return an Xslt argument list with all Xslt extensions.
|
||||
public static XsltArgumentList GetXsltArgumentListWithExtensions()
|
||||
{
|
||||
var xslArgs = new XsltArgumentList();
|
||||
|
||||
foreach (var extension in GetXsltExtensions())
|
||||
{
|
||||
var extensionNamespace = "urn:" + extension.Key;
|
||||
xslArgs.AddExtensionObject(extensionNamespace, extension.Value);
|
||||
Current.Logger.Info<XsltMacroEngine>($"Extension added: {extensionNamespace}, {extension.Value.GetType().Name}");
|
||||
}
|
||||
|
||||
return xslArgs;
|
||||
}
|
||||
|
||||
/*
|
||||
// gets the collection of all XSLT extensions for macros
|
||||
// ie predefined, configured in the config file, and marked with the attribute
|
||||
public static Dictionary<string, object> GetCachedXsltExtensions()
|
||||
{
|
||||
// We could cache the extensions in a static variable but then the cache
|
||||
// would not be refreshed when the .config file is modified. An application
|
||||
// restart would be required. Better use the cache and add a dependency.
|
||||
|
||||
// SD: The only reason the above statement might be true is because the xslt extension .config file is not a
|
||||
// real config file!! if it was, we wouldn't have this issue. Having these in a static variable would be preferred!
|
||||
// If you modify a config file, the app restarts and thus all static variables are reset.
|
||||
// Having this stuff in cache just adds to the gigantic amount of cache data and will cause more cache turnover to happen.
|
||||
|
||||
return ApplicationContext.Current.ApplicationCache.GetCacheItem(
|
||||
"UmbracoXsltExtensions",
|
||||
CacheItemPriority.NotRemovable, // NH 4.7.1, Changing to NotRemovable
|
||||
null, // no refresh action
|
||||
XsltExtensionsDependency(), // depends on the .config file
|
||||
TimeSpan.FromDays(1), // expires in 1 day (?)
|
||||
GetXsltExtensions);
|
||||
}
|
||||
*/
|
||||
|
||||
// actually gets the collection of all XSLT extensions for macros
|
||||
// ie predefined, configured in the config file, and marked with the attribute
|
||||
public static Dictionary<string, object> GetXsltExtensions()
|
||||
{
|
||||
return Current.XsltExtensions
|
||||
.ToDictionary(x => x.Namespace, x => x.ExtensionObject);
|
||||
|
||||
/*
|
||||
// initialize the collection
|
||||
// there is no "predefined" extensions anymore
|
||||
var extensions = new Dictionary<string, object>();
|
||||
|
||||
// Load the XSLT extensions configuration
|
||||
var xsltExt = new XmlDocument();
|
||||
xsltExt.Load(XsltExtensionsConfig);
|
||||
|
||||
// get the configured types
|
||||
var extensionsNode = xsltExt.SelectSingleNode("/XsltExtensions");
|
||||
if (extensionsNode != null)
|
||||
foreach (var attributes in extensionsNode.Cast<XmlNode>()
|
||||
.Where(x => x.NodeType == XmlNodeType.Element)
|
||||
.Select(x => x.Attributes))
|
||||
{
|
||||
Debug.Assert(attributes["assembly"] != null, "Extension attribute 'assembly' not specified.");
|
||||
Debug.Assert(attributes["type"] != null, "Extension attribute 'type' not specified.");
|
||||
Debug.Assert(attributes["alias"] != null, "Extension attribute 'alias' not specified.");
|
||||
|
||||
// load the extension assembly
|
||||
var extensionFile = IOHelper.MapPath(string.Format("{0}/{1}.dll",
|
||||
SystemDirectories.Bin, attributes["assembly"].Value));
|
||||
|
||||
Assembly extensionAssembly;
|
||||
try
|
||||
{
|
||||
extensionAssembly = Assembly.LoadFrom(extensionFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
String.Format("Could not load assembly {0} for XSLT extension {1}. Please check config/xsltExtensions.config.",
|
||||
extensionFile, attributes["alias"].Value), ex);
|
||||
}
|
||||
|
||||
// load the extension type
|
||||
var extensionType = extensionAssembly.GetType(attributes["type"].Value);
|
||||
if (extensionType == null)
|
||||
throw new Exception(
|
||||
String.Format("Could not load type {0} ({1}) for XSLT extension {2}. Please check config/xsltExtensions.config.",
|
||||
attributes["type"].Value, extensionFile, attributes["alias"].Value));
|
||||
|
||||
// create an instance and add it to the extensions list
|
||||
extensions.Add(attributes["alias"].Value, Activator.CreateInstance(extensionType));
|
||||
}
|
||||
|
||||
// get types marked with XsltExtension attribute
|
||||
var foundExtensions = TypeLoader.Current.ResolveXsltExtensions();
|
||||
foreach (var xsltType in foundExtensions)
|
||||
{
|
||||
var attributes = xsltType.GetCustomAttributes<XsltExtensionAttribute>(true);
|
||||
var xsltTypeName = xsltType.FullName;
|
||||
foreach (var ns in attributes
|
||||
.Select(attribute => string.IsNullOrEmpty(attribute.Namespace) ? attribute.Namespace : xsltTypeName))
|
||||
{
|
||||
extensions.Add(ns, Activator.CreateInstance(xsltType));
|
||||
}
|
||||
}
|
||||
|
||||
return extensions;
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.ThumbnailProviders
|
||||
{
|
||||
// fixme - kill entirely in v8 thumbs should be generated by ImageProcessor
|
||||
public class ThumbnailProviderCollection : BuilderCollectionBase<IThumbnailProvider>
|
||||
{
|
||||
public ThumbnailProviderCollection(IEnumerable<IThumbnailProvider> items)
|
||||
: base(items)
|
||||
{ }
|
||||
|
||||
public string GetThumbnailUrl(string fileUrl)
|
||||
{
|
||||
var provider = this.FirstOrDefault(x => x.CanProvideThumbnail(fileUrl));
|
||||
return provider != null ? provider.GetThumbnailUrl(fileUrl) : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using LightInject;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Media;
|
||||
|
||||
namespace Umbraco.Web.Media.ThumbnailProviders
|
||||
{
|
||||
public class ThumbnailProviderCollectionBuilder : WeightedCollectionBuilderBase<ThumbnailProviderCollectionBuilder, ThumbnailProviderCollection, IThumbnailProvider>
|
||||
{
|
||||
public ThumbnailProviderCollectionBuilder(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
protected override ThumbnailProviderCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -121,9 +121,6 @@ namespace Umbraco.Web.Runtime
|
||||
composition.Container.EnableWebApi(GlobalConfiguration.Configuration);
|
||||
composition.Container.RegisterApiControllers(typeLoader, GetType().Assembly);
|
||||
|
||||
XsltExtensionCollectionBuilder.Register(composition.Container)
|
||||
.AddExtensionObjectProducer(() => typeLoader.GetXsltExtensions());
|
||||
|
||||
composition.Container.RegisterCollectionBuilder<SearchableTreeCollectionBuilder>()
|
||||
.Add(() => typeLoader.GetTypes<ISearchableTree>()); // fixme which searchable trees?!
|
||||
|
||||
@@ -179,13 +176,7 @@ namespace Umbraco.Web.Runtime
|
||||
.Append<ContentFinderByRedirectUrl>();
|
||||
|
||||
composition.Container.RegisterSingleton<ISiteDomainHelper, SiteDomainHelper>();
|
||||
|
||||
composition.Container.RegisterCollectionBuilder<ThumbnailProviderCollectionBuilder>()
|
||||
.Add(typeLoader.GetThumbnailProviders());
|
||||
|
||||
composition.Container.RegisterCollectionBuilder<ImageUrlProviderCollectionBuilder>()
|
||||
.Append(typeLoader.GetImageUrlProviders());
|
||||
|
||||
|
||||
composition.Container.RegisterSingleton<ICultureDictionaryFactory, DefaultCultureDictionaryFactory>();
|
||||
|
||||
// register *all* checks, except those marked [HideFromTypeFinder] of course
|
||||
|
||||
@@ -63,36 +63,6 @@ namespace Umbraco.Web
|
||||
{
|
||||
return mgr.GetTypes<ISearchableTree>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all classes attributed with XsltExtensionAttribute attribute
|
||||
/// </summary>
|
||||
/// <param name="mgr"></param>
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<Type> GetXsltExtensions(this TypeLoader mgr)
|
||||
{
|
||||
return mgr.GetAttributedTypes<Core.Macros.XsltExtensionAttribute>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all IThumbnailProvider classes
|
||||
/// </summary>
|
||||
/// <param name="mgr"></param>
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<Type> GetThumbnailProviders(this TypeLoader mgr)
|
||||
{
|
||||
return mgr.GetTypes<IThumbnailProvider>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all IImageUrlProvider classes
|
||||
/// </summary>
|
||||
/// <param name="mgr"></param>
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<Type> GetImageUrlProviders(this TypeLoader mgr)
|
||||
{
|
||||
return mgr.GetTypes<IImageUrlProvider>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,6 @@
|
||||
<Compile Include="HealthCheck\HealthCheck.cs" />
|
||||
<Compile Include="HealthCheck\HealthCheckStatus.cs" />
|
||||
<Compile Include="HealthCheck\Checks\Security\HttpsCheck.cs" />
|
||||
<Compile Include="Macros\XsltMacroEngine.cs" />
|
||||
<Compile Include="HealthCheck\StatusResultType.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DataIntegrity\XmlDataIntegrityHealthCheck.cs" />
|
||||
<Compile Include="Media\ImageUrlProviderCollection.cs" />
|
||||
@@ -217,8 +216,6 @@
|
||||
<Compile Include="Models\ContentEditing\CodeFileDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentRedirectUrl.cs" />
|
||||
<Compile Include="Media\ImageUrlProviderCollectionBuilder.cs" />
|
||||
<Compile Include="Media\ThumbnailProviders\ThumbnailProviderCollection.cs" />
|
||||
<Compile Include="Media\ThumbnailProviders\ThumbnailProviderCollectionBuilder.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentVariation.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentVariationPublish.cs" />
|
||||
<Compile Include="Models\ContentEditing\EditorNavigation.cs" />
|
||||
@@ -443,6 +440,7 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\endPreview.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\XmlTree.cs" />
|
||||
<Compile Include="WebApi\EnableDetailedErrorsAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\AppendUserModifiedHeaderAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\CheckIfUserTicketDataIsStaleAttribute.cs" />
|
||||
@@ -808,9 +806,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\create\Language.ascx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\create\xslt.ascx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadPackager.cs" />
|
||||
<Compile Include="UmbracoComponentRenderer.cs" />
|
||||
<Compile Include="Web References\org.umbraco.our\Reference.cs">
|
||||
@@ -1181,9 +1176,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Macros\editMacro.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\editXslt.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\umbracoField.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@@ -1200,7 +1192,6 @@
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\Image.cs" />
|
||||
<Compile Include="umbraco.presentation\XsltExtensionAttribute.cs" />
|
||||
<Compile Include="UmbracoHelper.cs" />
|
||||
<Compile Include="Mvc\ViewContextExtensions.cs" />
|
||||
<Compile Include="Mvc\ViewDataContainerExtensions.cs" />
|
||||
@@ -1293,7 +1284,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\create\MemberGroupTasks.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create\stylesheetPropertyTasks.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create\StylesheetTasks.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\create\XsltTasks.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1327,13 +1317,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\Preview.aspx.designer.cs">
|
||||
<DependentUpon>Preview.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltVisualize.aspx.cs">
|
||||
<DependentUpon>xsltVisualize.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltVisualize.aspx.designer.cs">
|
||||
<DependentUpon>xsltVisualize.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx.cs">
|
||||
<DependentUpon>insertMasterpageContent.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1374,13 +1357,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\create\languageTasks.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Macros\assemblyBrowser.aspx.cs">
|
||||
<DependentUpon>assemblyBrowser.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Macros\assemblyBrowser.aspx.designer.cs">
|
||||
<DependentUpon>assemblyBrowser.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx.cs">
|
||||
<DependentUpon>editPackage.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1388,24 +1364,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx.designer.cs">
|
||||
<DependentUpon>editPackage.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\getXsltStatus.asmx.cs">
|
||||
<DependentUpon>getXsltStatus.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltChooseExtension.aspx.cs">
|
||||
<DependentUpon>xsltChooseExtension.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltChooseExtension.aspx.designer.cs">
|
||||
<DependentUpon>xsltChooseExtension.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltInsertValueOf.aspx.cs">
|
||||
<DependentUpon>xsltInsertValueOf.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Xslt\xsltInsertValueOf.aspx.designer.cs">
|
||||
<DependentUpon>xsltInsertValueOf.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\exportDocumenttype.aspx.cs">
|
||||
<DependentUpon>exportDocumenttype.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1466,11 +1424,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\ItemRenderer.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\Macro.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\ContentType.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\templateControls\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\translation\default.aspx.cs">
|
||||
<DependentUpon>default.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1506,9 +1459,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\TreeDefinition.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\TreeDialogModes.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\TreeService.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\XmlTree.cs">
|
||||
<DependentUpon>XmlTree.xsd</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\urlRewriter\UrlRewriterFormWriter.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\ajaxHelpers.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\CacheRefresher.asmx.cs">
|
||||
@@ -1519,10 +1469,6 @@
|
||||
<DependentUpon>CheckForUpgrade.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\codeEditorSave.asmx.cs">
|
||||
<DependentUpon>codeEditorSave.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\webservices\legacyAjaxCalls.asmx.cs">
|
||||
<DependentUpon>legacyAjaxCalls.asmx</DependentUpon>
|
||||
<SubType>Component</SubType>
|
||||
@@ -1571,11 +1517,6 @@
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="umbraco.presentation\umbraco\templateControls\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UI\JavaScript\Main.js" />
|
||||
<EmbeddedResource Include="UI\JavaScript\JsInitialize.js" />
|
||||
<EmbeddedResource Include="UI\JavaScript\ServerVariables.js" />
|
||||
@@ -1593,10 +1534,6 @@
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\translation\preview.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\translation\xml.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Macros\assemblyBrowser.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Xslt\getXsltStatus.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Xslt\xsltChooseExtension.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Xslt\xsltInsertValueOf.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\settings\EditDictionaryItem.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
@@ -1604,7 +1541,6 @@
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\CacheRefresher.asmx">
|
||||
<SubType>Form</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\codeEditorSave.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\legacyAjaxCalls.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\webservices\nodeSorter.asmx" />
|
||||
<Content Include="PublishedCache\NuCache\notes.txt" />
|
||||
@@ -1624,7 +1560,6 @@
|
||||
<Content Include="umbraco.presentation\umbraco\controls\ProgressBar.ascx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Xslt\xsltVisualize.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\empty.htm" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1655,11 +1590,6 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="umbraco.presentation\umbraco\Trees\Trees.cd" />
|
||||
<None Include="umbraco.presentation\umbraco\Trees\XmlTree.xsd" />
|
||||
<None Include="umbraco.presentation\umbraco\Trees\XmlTree.xsx">
|
||||
<DependentUpon>XmlTree.xsd</DependentUpon>
|
||||
</None>
|
||||
<None Include="Web References\org.umbraco.update\checkforupgrade.disco" />
|
||||
<None Include="Web References\org.umbraco.update\checkforupgrade.wsdl" />
|
||||
<None Include="Web References\org.umbraco.update\Reference.map">
|
||||
@@ -1685,7 +1615,6 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings1.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="umbraco.presentation\umbraco\templateControls\InlineXslt.xsltTemplate" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WebReferenceUrl Include="http://our.umbraco.org/umbraco/webservices/api/repository.asmx">
|
||||
|
||||
@@ -132,9 +132,6 @@ namespace umbraco.cms.businesslogic.packager
|
||||
|
||||
if (appendFile)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mcr.XsltPath))
|
||||
AppendFileToManifest(IOHelper.ResolveUrl(SystemDirectories.Xslt) + "/" + mcr.XsltPath, packageDirectory, doc);
|
||||
|
||||
//TODO: Clearly the packager hasn't worked very well for packaging Partial Views to date since there is no logic in here for that
|
||||
|
||||
//if (!string.IsNullOrEmpty(mcr.ScriptingFile))
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows App_Code XSLT extensions to be declared using the [XsltExtension] class attribute.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An optional XML namespace can be specified using [XsltExtension("MyNamespace")].
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[Obsolete("Use Umbraco.Core.Macros.XsltExtensionAttribute instead")]
|
||||
public class XsltExtensionAttribute : Umbraco.Core.Macros.XsltExtensionAttribute
|
||||
{
|
||||
public XsltExtensionAttribute() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public XsltExtensionAttribute(string ns) : base(ns)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Font Name="Tahoma" Size="8.25" />
|
||||
<Class Name="umbraco.cms.presentation.Trees.BaseTree">
|
||||
<Position X="3.5" Y="0.5" Width="3.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\BaseTree.cs</FileName>
|
||||
<HashCode>AABUAABAAAQSAQAIAAAAQAAABRBgBEUBWDIAAMKAAyI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.596" />
|
||||
</Class>
|
||||
<Class Name="umbraco.cms.presentation.Trees.BaseContentTree">
|
||||
<Position X="7.25" Y="0.5" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\BaseContentTree.cs</FileName>
|
||||
<HashCode>ACAAAAAIBICAgAIIEAEAAAAAAAAAAAAAgBQAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.loadContent">
|
||||
<Position X="10" Y="0.5" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\loadContent.cs</FileName>
|
||||
<HashCode>AAAAAAAAAQAABAAIAAQAAAAAAABAAAABABAAAEAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.loadMedia">
|
||||
<Position X="4" Y="9.25" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\loadMedia.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAIAAAAAAAAAABAAAABABAAAEAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.cms.presentation.Trees.FileSystemTree">
|
||||
<Position X="7.25" Y="6" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\FileSystemTree.cs</FileName>
|
||||
<HashCode>AAABAAAAAAAAABAAAAAAAAAAAAAAEAABABBAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.loadXslt">
|
||||
<Position X="10" Y="6" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\loadXslt.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAABAAAAAAAAAAAAAAEAABAABAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.loadPython">
|
||||
<Position X="7.25" Y="9.25" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\loadPython.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAABAAAAAAAAAAAAAAEAABAABAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.cms.presentation.Trees.ContentRecycleBin">
|
||||
<Position X="10" Y="3.5" Width="2.25" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\ContentRecycleBin.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAIEAAAAAAAAABAAAABAAIAAEAAAAA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.cms.presentation.Trees.LegacyTree">
|
||||
<Position X="0.75" Y="3" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\LegacyTree.cs</FileName>
|
||||
<HashCode>AAAAAAAAACAAAAAAAAAAAAABACAAAAABABAAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="umbraco.cms.presentation.Trees.NullTree">
|
||||
<Position X="0.75" Y="5.5" Width="2" />
|
||||
<TypeIdentifier>
|
||||
<FileName>umbraco\Trees\NullTree.cs</FileName>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAQAAAAABABAAAAAAAAI=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Interface Name="umbraco.interfaces.ITree">
|
||||
<Position X="0.75" Y="0.5" Width="2" />
|
||||
<TypeIdentifier />
|
||||
</Interface>
|
||||
</ClassDiagram>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
|
||||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="trees">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element minOccurs="0" name="tree">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="menu" type="xs:string" />
|
||||
<xs:attribute name="text" type="xs:string" />
|
||||
<xs:attribute name="action" type="xs:string" />
|
||||
<xs:attribute name="src" type="xs:string" />
|
||||
<xs:attribute name="rootSrc" type="xs:string" />
|
||||
<xs:attribute name="icon" type="xs:string" />
|
||||
<xs:attribute name="iconClass" type="xs:string" />
|
||||
<xs:attribute name="openIcon" type="xs:string" />
|
||||
<xs:attribute name="nodeType" type="xs:string" />
|
||||
<xs:attribute name="nodeID" type="xs:string" />
|
||||
<xs:attribute name="isProtected" type="xs:boolean" />
|
||||
<xs:attribute name="notPublished" type="xs:boolean" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--This file is auto-generated by the XML Schema Designer. It holds layout information for components on the designer surface.-->
|
||||
<XSDDesignerLayout Style="LeftRight" />
|
||||
@@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.UI;
|
||||
using Umbraco.Core.FileResources;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web._Legacy.UI;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for standardTasks.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
public class XsltTasks : LegacyDialogTask
|
||||
{
|
||||
|
||||
public override bool PerformSave()
|
||||
{
|
||||
IOHelper.EnsurePathExists(SystemDirectories.Xslt);
|
||||
IOHelper.EnsureFileExists(Path.Combine(IOHelper.MapPath(SystemDirectories.Xslt), "web.config"), Files.BlockingWebConfig);
|
||||
|
||||
var template = Alias.Substring(0, Alias.IndexOf("|||"));
|
||||
var fileName = Alias.Substring(Alias.IndexOf("|||") + 3, Alias.Length - Alias.IndexOf("|||") - 3).Replace(" ", "");
|
||||
if (fileName.ToLowerInvariant().EndsWith(".xslt") == false)
|
||||
fileName += ".xslt";
|
||||
var xsltTemplateSource = IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/" + template);
|
||||
var xsltNewFilename = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);
|
||||
|
||||
if (File.Exists(xsltNewFilename) == false)
|
||||
{
|
||||
if (fileName.Contains("/")) //if there's a / create the folder structure for it
|
||||
{
|
||||
var folders = fileName.Split("/".ToCharArray());
|
||||
var xsltBasePath = IOHelper.MapPath(SystemDirectories.Xslt);
|
||||
for (var i = 0; i < folders.Length - 1; i++)
|
||||
{
|
||||
xsltBasePath = System.IO.Path.Combine(xsltBasePath, folders[i]);
|
||||
System.IO.Directory.CreateDirectory(xsltBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
// update with xslt references
|
||||
var xslt = "";
|
||||
using (var xsltFile = System.IO.File.OpenText(xsltTemplateSource))
|
||||
{
|
||||
xslt = xsltFile.ReadToEnd();
|
||||
xsltFile.Close();
|
||||
}
|
||||
|
||||
// prepare support for XSLT extensions
|
||||
xslt = Umbraco.Web.Macros.XsltMacroEngine.AddXsltExtensionsToHeader(xslt);
|
||||
var xsltWriter = System.IO.File.CreateText(xsltNewFilename);
|
||||
xsltWriter.Write(xslt);
|
||||
xsltWriter.Flush();
|
||||
xsltWriter.Close();
|
||||
|
||||
// Create macro?
|
||||
if (ParentID == 1)
|
||||
{
|
||||
var name = Alias.Substring(Alias.IndexOf("|||") + 3, Alias.Length - Alias.IndexOf("|||") - 3);
|
||||
if (name.ToLowerInvariant().EndsWith(".xslt"))
|
||||
name = name.Substring(0, name.Length - 5);
|
||||
|
||||
name = name.SplitPascalCasing().ToFirstUpperInvariant();
|
||||
//cms.businesslogic.macro.Macro m =
|
||||
// cms.businesslogic.macro.Macro.MakeNew(name);
|
||||
var m = new Macro
|
||||
{
|
||||
Name = name,
|
||||
Alias = name.Replace(" ", String.Empty)
|
||||
};
|
||||
m.XsltPath = fileName;
|
||||
//m.Save();
|
||||
Current.Services.MacroService.Save(m);
|
||||
}
|
||||
}
|
||||
|
||||
_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}", fileName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool PerformDelete()
|
||||
{
|
||||
var path = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Alias.TrimStart('/'));
|
||||
|
||||
try
|
||||
{
|
||||
if(System.IO.Directory.Exists(path))
|
||||
System.IO.Directory.Delete(path);
|
||||
else if(System.IO.File.Exists(path))
|
||||
System.IO.File.Delete(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Current.Logger.Error<XsltTasks>(string.Format("Could not remove XSLT file {0} - User {1}", Alias, UmbracoContext.Current.Security.GetUserId()), ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private string _returnUrl = "";
|
||||
|
||||
public override string ReturnUrl
|
||||
{
|
||||
get { return _returnUrl; }
|
||||
}
|
||||
|
||||
public override string AssignedApp
|
||||
{
|
||||
get { return Constants.Applications.Developer.ToString(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
using Umbraco.Core.Services;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.UI.Controls;
|
||||
using Umbraco.Web._Legacy.UI;
|
||||
|
||||
namespace umbraco.presentation.create
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for xslt.
|
||||
/// </summary>
|
||||
public partial class xslt : UmbracoUserControl
|
||||
{
|
||||
protected System.Web.UI.WebControls.ListBox nodeType;
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
sbmt.Text = Services.TextService.Localize("create");
|
||||
foreach (string fileName in Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + GetXsltTemplatePath()), "*.xslt"))
|
||||
{
|
||||
FileInfo fi = new FileInfo(fileName);
|
||||
if (fi.Name != "Clean.xslt")
|
||||
{
|
||||
var liText = fi.Name.Replace(".xslt", "").SplitPascalCasing().ToFirstUpperInvariant();
|
||||
xsltTemplate.Items.Add(new ListItem(liText, fi.Name));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static string GetXsltTemplatePath()
|
||||
{
|
||||
return "/xslt/templates/schema2";
|
||||
}
|
||||
|
||||
protected void sbmt_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
var createMacroVal = 0;
|
||||
if (createMacro.Checked)
|
||||
createMacroVal = 1;
|
||||
|
||||
var xsltName = Path.Combine("schema2", xsltTemplate.SelectedValue);
|
||||
|
||||
|
||||
var returnUrl = LegacyDialogHandler.Create(
|
||||
new HttpContextWrapper(Context),
|
||||
Security.CurrentUser,
|
||||
Request.GetItemAsString("nodeType"),
|
||||
createMacroVal,
|
||||
xsltName + "|||" + rename.Text);
|
||||
|
||||
ClientTools
|
||||
.ChangeContentFrameUrl(returnUrl)
|
||||
.ChildNodeCreated()
|
||||
.CloseModalWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rename control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox rename;
|
||||
|
||||
/// <summary>
|
||||
/// RequiredFieldValidator1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
|
||||
|
||||
/// <summary>
|
||||
/// xsltTemplate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ListBox xsltTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// createMacro control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CheckBox createMacro;
|
||||
|
||||
/// <summary>
|
||||
/// Textbox1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox Textbox1;
|
||||
|
||||
/// <summary>
|
||||
/// sbmt control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button sbmt;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoDialog.Master" Title="Assembly Browser" Codebehind="assemblyBrowser.aspx.cs" AutoEventWireup="True"
|
||||
Inherits="umbraco.developer.assemblyBrowser" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<h4><asp:Label id="AssemblyName" runat="server"></asp:Label></h4>
|
||||
|
||||
<asp:Panel id="ChooseProperties" runat="server">
|
||||
<p class="guiDialogTiny">The following list shows the Public Properties from the
|
||||
Control. By checking the Properties and click the "Save Properties" button at
|
||||
|
||||
the bottom, umbraco will create the corresponding Macro Elements.</p>
|
||||
<asp:CheckBoxList id="MacroProperties" runat="server"></asp:CheckBoxList>
|
||||
<p>
|
||||
<asp:Button id="Button1" runat="server" Text="Save Properties" onclick="Button1_Click"></asp:Button>
|
||||
</p>
|
||||
</asp:Panel>
|
||||
|
||||
<asp:Panel id="ConfigProperties" runat="server" Visible="False">
|
||||
<p class="guiDialogNormal"><strong>The following Macro Parameters was added:</strong><br /></p>
|
||||
<ul class="guiDialogNormal"><asp:Literal ID="resultLiteral" runat="server"></asp:Literal></ul>
|
||||
<p class="guiDialogNormal">
|
||||
<span style="color: Green"><strong>Important:</strong> You might need to reload the macro to see the changes.</span><br /><br />
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
</asp:Panel>
|
||||
|
||||
</asp:Content>
|
||||
-204
@@ -1,204 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Reflection;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using UserControl = System.Web.UI.UserControl;
|
||||
|
||||
namespace umbraco.developer
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for assemblyBrowser.
|
||||
/// </summary>
|
||||
public partial class assemblyBrowser : UmbracoEnsuredPage
|
||||
{
|
||||
public assemblyBrowser()
|
||||
{
|
||||
CurrentApp = Constants.Applications.Developer.ToString();
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var isUserControl = false;
|
||||
var errorReadingControl = false;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Type type = null;
|
||||
if (Request.QueryString["type"] == null)
|
||||
{
|
||||
isUserControl = true;
|
||||
var fileName = Request.GetItemAsString("fileName");
|
||||
if (!fileName.StartsWith("~"))
|
||||
{
|
||||
if (fileName.StartsWith("/"))
|
||||
{
|
||||
fileName = "~" + fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = "~/" + fileName;
|
||||
}
|
||||
}
|
||||
IOHelper.ValidateEditPath(fileName, SystemDirectories.UserControls);
|
||||
|
||||
if (System.IO.File.Exists(IOHelper.MapPath(fileName)))
|
||||
{
|
||||
var oControl = (UserControl)LoadControl(fileName);
|
||||
|
||||
type = oControl.GetType();
|
||||
}
|
||||
else
|
||||
{
|
||||
errorReadingControl = true;
|
||||
ChooseProperties.Visible = false;
|
||||
AssemblyName.Text = "<span style=\"color: red;\">User control doesn't exist</span><br /><br />Please verify that you've copied the file to:<br />" + IOHelper.MapPath("~/" + fileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentAss = IOHelper.MapPath(SystemDirectories.Bin + "/" + Request.QueryString["fileName"] + ".dll");
|
||||
var asm = Assembly.LoadFrom(currentAss);
|
||||
type = asm.GetType(Request.QueryString["type"]);
|
||||
}
|
||||
|
||||
if (!errorReadingControl)
|
||||
{
|
||||
string fullControlAssemblyName;
|
||||
if (isUserControl)
|
||||
{
|
||||
AssemblyName.Text = "Choose Properties from " + type.BaseType.Name;
|
||||
fullControlAssemblyName = type.BaseType.Namespace + "." + type.BaseType.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssemblyName.Text = "Choose Properties from " + type.Name;
|
||||
fullControlAssemblyName = type.Namespace + "." + type.Name;
|
||||
}
|
||||
|
||||
|
||||
if (!IsPostBack && type != null)
|
||||
{
|
||||
MacroProperties.Items.Clear();
|
||||
foreach (var pi in type.GetProperties())
|
||||
{
|
||||
if (pi.CanWrite && ((fullControlAssemblyName == pi.DeclaringType.Namespace + "." + pi.DeclaringType.Name) || pi.DeclaringType == type))
|
||||
{
|
||||
MacroProperties.Items.Add(new ListItem(pi.Name + " <span style=\"color: #99CCCC\">(" + pi.PropertyType.Name + ")</span>", pi.PropertyType.Name));
|
||||
}
|
||||
|
||||
foreach (ListItem li in MacroProperties.Items)
|
||||
li.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AssemblyName.Text = "Error reading " + Request.CleanForXss("fileName");
|
||||
Button1.Visible = false;
|
||||
ChooseProperties.Controls.Add(new LiteralControl("<p class=\"guiDialogNormal\" style=\"color: red;\">" + err.ToString() + "</p><p/><p class=\"guiDialogNormal\">"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var result = "";
|
||||
|
||||
// Get the macro object
|
||||
var macroObject = Current.Services.MacroService.GetById(Convert.ToInt32(Request.QueryString["macroID"]));
|
||||
|
||||
//// Load all macroPropertyTypes
|
||||
//var macroPropertyTypes = new Hashtable();
|
||||
//var macroPropertyIds = new Hashtable();
|
||||
|
||||
//var macroPropTypes = ParameterEditorResolver.Current.ParameterEditors.ToArray();
|
||||
|
||||
//foreach (var mpt in macroPropTypes)
|
||||
//{
|
||||
// macroPropertyIds.Add(mpt.Alias, mpt.Id.ToString());
|
||||
// macroPropertyTypes.Add(mpt.Alias, mpt.BaseType);
|
||||
//}
|
||||
var changed = false;
|
||||
|
||||
foreach (ListItem li in MacroProperties.Items)
|
||||
{
|
||||
if (li.Selected && MacroHasProperty(macroObject, li.Text.Substring(0, li.Text.IndexOf(" ", StringComparison.Ordinal)).ToLower()) == false)
|
||||
{
|
||||
result += "<li>Added: " + SpaceCamelCasing(li.Text) + "</li>";
|
||||
var macroPropertyTypeAlias = GetMacroTypeFromClrType(li.Value);
|
||||
|
||||
macroObject.Properties.Add(new Umbraco.Core.Models.MacroProperty
|
||||
{
|
||||
Name = SpaceCamelCasing(li.Text),
|
||||
Alias = li.Text.Substring(0, li.Text.IndexOf(" ", StringComparison.Ordinal)),
|
||||
EditorAlias = macroPropertyTypeAlias
|
||||
});
|
||||
|
||||
changed = true;
|
||||
}
|
||||
else if (li.Selected)
|
||||
{
|
||||
result += "<li>Skipped: " + SpaceCamelCasing(li.Text) + " (already exists as a parameter)</li>";
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
Current.Services.MacroService.Save(macroObject);
|
||||
}
|
||||
|
||||
ChooseProperties.Visible = false;
|
||||
ConfigProperties.Visible = true;
|
||||
resultLiteral.Text = result;
|
||||
}
|
||||
|
||||
private static bool MacroHasProperty(IMacro macroObject, string propertyAlias)
|
||||
{
|
||||
return macroObject.Properties.Any(mp => mp.Alias.ToLower() == propertyAlias);
|
||||
}
|
||||
|
||||
private static string SpaceCamelCasing(string text)
|
||||
{
|
||||
var tempString = text.Substring(0, 1).ToUpper();
|
||||
for (var i = 1; i < text.Length; i++)
|
||||
{
|
||||
if (text.Substring(i, 1) == " ")
|
||||
break;
|
||||
if (text.Substring(i, 1).ToUpper() == text.Substring(i, 1))
|
||||
tempString += " ";
|
||||
tempString += text.Substring(i, 1);
|
||||
}
|
||||
return tempString;
|
||||
}
|
||||
|
||||
private static string GetMacroTypeFromClrType(string baseTypeName)
|
||||
{
|
||||
switch (baseTypeName)
|
||||
{
|
||||
case "Int32":
|
||||
return Constants.PropertyEditors.Aliases.Integer;
|
||||
case "Decimal":
|
||||
//we previously only had an integer editor too! - this would of course
|
||||
// fail if someone enters a real long number
|
||||
return Constants.PropertyEditors.Aliases.Integer;
|
||||
case "Boolean":
|
||||
return Constants.PropertyEditors.Aliases.Boolean;
|
||||
case "String":
|
||||
default:
|
||||
return Constants.PropertyEditors.Aliases.TextBox;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Generated
-69
@@ -1,69 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.developer {
|
||||
|
||||
|
||||
public partial class assemblyBrowser {
|
||||
|
||||
/// <summary>
|
||||
/// AssemblyName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label AssemblyName;
|
||||
|
||||
/// <summary>
|
||||
/// ChooseProperties control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Panel ChooseProperties;
|
||||
|
||||
/// <summary>
|
||||
/// MacroProperties control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CheckBoxList MacroProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Button1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button Button1;
|
||||
|
||||
/// <summary>
|
||||
/// ConfigProperties control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Panel ConfigProperties;
|
||||
|
||||
/// <summary>
|
||||
/// resultLiteral control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal resultLiteral;
|
||||
}
|
||||
}
|
||||
@@ -47,22 +47,9 @@ namespace umbraco.cms.presentation.developer
|
||||
ClientTools
|
||||
.SyncTree("-1," + _macro.Id, false);
|
||||
|
||||
string tempMacroAssembly = _macro.ControlAssembly ?? "";
|
||||
string tempMacroType = _macro.ControlType ?? "";
|
||||
|
||||
PopulateFieldsOnLoad(_macro, tempMacroAssembly, tempMacroType);
|
||||
|
||||
// Check for assemblyBrowser
|
||||
if (tempMacroType.IndexOf(".ascx", StringComparison.Ordinal) > 0)
|
||||
assemblyBrowserUserControl.Controls.Add(
|
||||
new LiteralControl("<br/><button onClick=\"UmbClientMgr.openModalWindow('" + IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/developer/macros/assemblyBrowser.aspx?fileName=" + macroUserControl.Text +
|
||||
"¯oID=" + _macro.Id.ToInvariantString() +
|
||||
"', 'Browse Properties', true, 475,500); return false;\" class=\"guiInputButton\"><img src=\"../../images/editor/propertiesNew.gif\" align=\"absmiddle\" style=\"width: 18px; height: 17px; padding-right: 5px;\"/> Browse properties</button>"));
|
||||
else if (tempMacroType != string.Empty && tempMacroAssembly != string.Empty)
|
||||
assemblyBrowser.Controls.Add(
|
||||
new LiteralControl("<br/><button onClick=\"UmbClientMgr.openModalWindow('" + IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/developer/macros/assemblyBrowser.aspx?fileName=" + macroAssembly.Text +
|
||||
"¯oID=" + _macro.Id.ToInvariantString() + "&type=" + macroType.Text +
|
||||
"', 'Browse Properties', true, 475,500); return false\" class=\"guiInputButton\"><img src=\"../../images/editor/propertiesNew.gif\" align=\"absmiddle\" style=\"width: 18px; height: 17px; padding-right: 5px;\"/> Browse properties</button>"));
|
||||
PopulateFieldsOnLoad(_macro, tempMacroType);
|
||||
|
||||
// Load elements from macro
|
||||
macroPropertyBind();
|
||||
@@ -83,12 +70,11 @@ namespace umbraco.cms.presentation.developer
|
||||
/// <param name="macro"></param>
|
||||
/// <param name="macroAssemblyValue"></param>
|
||||
/// <param name="macroTypeValue"></param>
|
||||
protected virtual void PopulateFieldsOnLoad(IMacro macro, string macroAssemblyValue, string macroTypeValue)
|
||||
protected virtual void PopulateFieldsOnLoad(IMacro macro, string macroTypeValue)
|
||||
{
|
||||
macroName.Text = macro.Name;
|
||||
macroAlias.Text = macro.Alias;
|
||||
macroKey.Text = macro.Key.ToString();
|
||||
macroXslt.Text = macro.XsltPath;
|
||||
cachePeriod.Text = macro.CacheDuration.ToInvariantString();
|
||||
macroRenderContent.Checked = macro.DontRender == false;
|
||||
macroEditor.Checked = macro.UseInEditor;
|
||||
@@ -96,9 +82,8 @@ namespace umbraco.cms.presentation.developer
|
||||
cachePersonalized.Checked = macro.CacheByMember;
|
||||
|
||||
// Populate either user control or custom control
|
||||
if (macroTypeValue != string.Empty && macroAssemblyValue != string.Empty)
|
||||
if (macroTypeValue != string.Empty)
|
||||
{
|
||||
macroAssembly.Text = macroAssemblyValue;
|
||||
macroType.Text = macroTypeValue;
|
||||
}
|
||||
else
|
||||
@@ -119,9 +104,7 @@ namespace umbraco.cms.presentation.developer
|
||||
macro.CacheDuration = macroCachePeriod;
|
||||
macro.Alias = macroAlias.Text;
|
||||
macro.Name = macroName.Text;
|
||||
macro.ControlAssembly = macroAssemblyValue;
|
||||
macro.ControlType = macroTypeValue;
|
||||
macro.XsltPath = macroXslt.Text;
|
||||
}
|
||||
|
||||
private static void GetXsltFilesFromDir(string orgPath, string path, ArrayList files)
|
||||
@@ -229,7 +212,7 @@ namespace umbraco.cms.presentation.developer
|
||||
return Convert.ToBoolean(isChecked);
|
||||
}
|
||||
|
||||
public void AddChooseList(Object sender, EventArgs e)
|
||||
public void AddChooseList(object sender, EventArgs e)
|
||||
{
|
||||
if (IsPostBack == false)
|
||||
{
|
||||
@@ -341,18 +324,6 @@ namespace umbraco.cms.presentation.developer
|
||||
|
||||
ClientTools.ShowSpeechBubble(SpeechBubbleIcon.Save, "Macro saved", "");
|
||||
|
||||
// Check for assemblyBrowser
|
||||
if (tempMacroType.IndexOf(".ascx", StringComparison.Ordinal) > 0)
|
||||
assemblyBrowserUserControl.Controls.Add(
|
||||
new LiteralControl("<br/><button onClick=\"UmbClientMgr.openModalWindow('developer/macros/assemblyBrowser.aspx?fileName=" + macroUserControl.Text +
|
||||
"¯oID=" + Request.QueryString["macroID"] +
|
||||
"', 'Browse Properties', true, 500, 475); return false\" class=\"guiInputButton\"><img src=\"../../images/editor/propertiesNew.gif\" align=\"absmiddle\" style=\"width: 18px; height: 17px; padding-right: 5px;\"/> Browse properties</button>"));
|
||||
else if (tempMacroType != string.Empty && tempMacroAssembly != string.Empty)
|
||||
assemblyBrowser.Controls.Add(
|
||||
new LiteralControl("<br/><button onClick=\"UmbClientMgr.openModalWindow('developer/macros/assemblyBrowser.aspx?fileName=" + macroAssembly.Text +
|
||||
"¯oID=" + Request.QueryString["macroID"] + "&type=" + macroType.Text +
|
||||
"', 'Browse Properties', true, 500, 475); return false\" class=\"guiInputButton\"><img src=\"../../images/editor/propertiesNew.gif\" align=\"absmiddle\" style=\"width: 18px; height: 17px; padding-right: 5px;\"/> Browse properties</button>"));
|
||||
|
||||
macroPropertyBind();
|
||||
}
|
||||
|
||||
@@ -418,16 +389,7 @@ namespace umbraco.cms.presentation.developer
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1_2;
|
||||
|
||||
/// <summary>
|
||||
/// macroXslt control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox macroXslt;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// xsltFiles control.
|
||||
/// </summary>
|
||||
@@ -454,16 +416,7 @@ namespace umbraco.cms.presentation.developer
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList userControlList;
|
||||
|
||||
/// <summary>
|
||||
/// assemblyBrowserUserControl control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder assemblyBrowserUserControl;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// macroAssembly control.
|
||||
/// </summary>
|
||||
@@ -481,16 +434,7 @@ namespace umbraco.cms.presentation.developer
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox macroType;
|
||||
|
||||
/// <summary>
|
||||
/// assemblyBrowser control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder assemblyBrowser;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pane1_3 control.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,198 +0,0 @@
|
||||
using Umbraco.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web._Legacy.Controls;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.cms.presentation.developer
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for editXslt.
|
||||
/// </summary>
|
||||
[WebformsPageTreeAuthorize(Constants.Trees.Xslt)]
|
||||
public partial class editXslt : UmbracoEnsuredPage
|
||||
{
|
||||
|
||||
protected PlaceHolder buttons;
|
||||
|
||||
protected MenuButton SaveButton;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
string file = Request.QueryString["file"];
|
||||
string path = BaseTree.GetTreePathFromFilePath(file, false, true);
|
||||
ClientTools
|
||||
.SyncTree(path, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
|
||||
SaveButton = UmbracoPanel1.Menu.NewButton();
|
||||
SaveButton.ToolTip = "Save Xslt File";
|
||||
SaveButton.Text = Services.TextService.Localize("save");
|
||||
SaveButton.ButtonType = MenuButtonType.Primary;
|
||||
SaveButton.ID = "save";
|
||||
SaveButton.CssClass = "client-side";
|
||||
|
||||
var code = UmbracoPanel1.NewTabPage("xslt");
|
||||
code.Controls.Add(pane1);
|
||||
|
||||
var props = UmbracoPanel1.NewTabPage("properties");
|
||||
props.Controls.Add(pane2);
|
||||
|
||||
var tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/images/editor/insField.GIF";
|
||||
tmp.OnClickCommand = ClientTools.Scripts.OpenModalWindow(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/developer/xslt/xsltinsertvalueof.aspx?objectId=" + editorSource.ClientID, "Insert value", 750, 250);
|
||||
//"umbracoInsertField(document.getElementById('editorSource'), 'xsltInsertValueOf', '','felt', 750, 230, '');";
|
||||
tmp.AltText = "Insert xslt:value-of";
|
||||
|
||||
editorSource.Menu.InsertSplitter();
|
||||
|
||||
tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = SystemDirectories.Umbraco + "/images/editor/insMemberItem.GIF";
|
||||
tmp.OnClickCommand = "UmbEditor.Insert('<xsl:variable name=\"\" select=\"', '\"/>\\n', '" + editorSource.ClientID + "'); return false;";
|
||||
tmp.AltText = "Insert xsl:variable";
|
||||
|
||||
editorSource.Menu.InsertSplitter();
|
||||
|
||||
tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = SystemDirectories.Umbraco + "/images/editor/insChildTemplateNew.GIF";
|
||||
tmp.OnClickCommand = "UmbEditor.Insert('<xsl:if test=\"CONDITION\">\\n', '\\n</xsl:if>\\n', '" + editorSource.ClientID + "'); return false;";
|
||||
tmp.AltText = "Insert xsl:if";
|
||||
|
||||
tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = SystemDirectories.Umbraco + "/images/editor/insChildTemplateNew.GIF";
|
||||
tmp.OnClickCommand = "UmbEditor.Insert('<xsl:for-each select=\"QUERY\">\\n', '\\n</xsl:for-each>\\n', '" + editorSource.ClientID + "'); return false;";
|
||||
tmp.AltText = "Insert xsl:for-each";
|
||||
|
||||
editorSource.Menu.InsertSplitter();
|
||||
|
||||
tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = SystemDirectories.Umbraco + "/images/editor/insFieldByLevel.GIF";
|
||||
tmp.OnClickCommand = "UmbEditor.Insert('<xsl:choose>\\n<xsl:when test=\"CONDITION\">\\n', '\\n</xsl:when>\\n<xsl:otherwise>\\n</xsl:otherwise>\\n</xsl:choose>\\n', '" + editorSource.ClientID + "'); return false;";
|
||||
tmp.AltText = "Insert xsl:choose";
|
||||
|
||||
editorSource.Menu.InsertSplitter();
|
||||
|
||||
tmp = editorSource.Menu.NewIcon();
|
||||
tmp.ImageURL = SystemDirectories.Umbraco + "/images/editor/xslVisualize.GIF";
|
||||
tmp.OnClickCommand = "xsltVisualize();";
|
||||
tmp.AltText = "Visualize XSLT";
|
||||
|
||||
|
||||
// Add source and filename
|
||||
var file = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Request.QueryString["file"]);
|
||||
|
||||
// validate file
|
||||
IOHelper.ValidateEditPath(file, SystemDirectories.Xslt);
|
||||
// validate extension
|
||||
IOHelper.ValidateFileExtension(file, new List<string>() { "xslt", "xsl" });
|
||||
|
||||
|
||||
xsltFileName.Text = file.Replace(IOHelper.MapPath(SystemDirectories.Xslt), "").Substring(1).Replace(@"\", "/");
|
||||
|
||||
StreamReader SR;
|
||||
string S;
|
||||
SR = File.OpenText(file);
|
||||
|
||||
S = SR.ReadToEnd();
|
||||
SR.Close();
|
||||
|
||||
editorSource.Text = S;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
|
||||
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/codeEditorSave.asmx"));
|
||||
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/legacyAjaxCalls.asmx"));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// JsInclude1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
|
||||
|
||||
/// <summary>
|
||||
/// UmbracoPanel1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.TabView UmbracoPanel1;
|
||||
|
||||
/// <summary>
|
||||
/// Pane1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane pane1;
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane pane2;
|
||||
|
||||
/// <summary>
|
||||
/// pp_filename control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_filename;
|
||||
|
||||
/// <summary>
|
||||
/// xsltFileName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox xsltFileName;
|
||||
|
||||
/// <summary>
|
||||
/// pp_errorMsg control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel pp_errorMsg;
|
||||
|
||||
/// <summary>
|
||||
/// editorSource control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.CodeArea editorSource;
|
||||
|
||||
/// <summary>
|
||||
/// editorJs control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal editorJs;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<%@ WebService Language="c#" Codebehind="getXsltStatus.asmx.cs" Class="umbraco.developer.getXsltStatus" %>
|
||||
@@ -1,88 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
using umbraco.presentation.webservices;
|
||||
using Umbraco.Web.WebServices;
|
||||
|
||||
namespace umbraco.developer
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for getXsltStatus.
|
||||
/// </summary>
|
||||
[WebService(Namespace="http://umbraco.org/webservices")]
|
||||
public class getXsltStatus : UmbracoAuthorizedWebService
|
||||
{
|
||||
public getXsltStatus()
|
||||
{
|
||||
//CODEGEN: This call is required by the ASP.NET Web Services Designer
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// TODO: Security-check
|
||||
[WebMethod]
|
||||
public XmlDocument FilesFromDirectory(string dir)
|
||||
{
|
||||
AuthorizeRequest(true);
|
||||
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.LoadXml("<files/>");
|
||||
foreach (string file in System.IO.Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/" + dir), "*.xsl*"))
|
||||
{
|
||||
FileInfo fi = new FileInfo(file);
|
||||
FileAttributes fa = fi.Attributes;
|
||||
XmlElement fileXml = xd.CreateElement("file");
|
||||
fileXml.SetAttribute("name", fi.Name);
|
||||
//fileXml.SetAttribute("created", fi.CreationTimeUtc);
|
||||
fileXml.SetAttribute("modified", fi.LastWriteTimeUtc.ToString());
|
||||
fileXml.SetAttribute("size", fi.Length.ToString());
|
||||
xd.DocumentElement.AppendChild((XmlNode) fileXml);
|
||||
}
|
||||
return xd;
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
//Required by the Web Services Designer
|
||||
private IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if(disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// WEB SERVICE EXAMPLE
|
||||
// The HelloWorld() example service returns the string Hello World
|
||||
// To build, uncomment the following lines then save and build the project
|
||||
// To test this web service, press F5
|
||||
|
||||
// [WebMethod]
|
||||
// public string HelloWorld()
|
||||
// {
|
||||
// return "Hello World";
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<%@ Page Language="c#" Codebehind="xsltChooseExtension.aspx.cs" MasterPageFile="../../masterpages/umbracoDialog.Master" AutoEventWireup="True"
|
||||
Inherits="umbraco.developer.xsltChooseExtension" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script type="text/javascript">
|
||||
function returnResult() {
|
||||
result = document.getElementById('<%= assemblies.ClientID %>').value + ":" + document.getElementById('selectedMethod').value + "(";
|
||||
for (var i = 0; i < document.forms[0].length - 1; i++) {
|
||||
if (document.forms[0][i].name.indexOf('param') > -1)
|
||||
result = result + "'" + document.forms[0][i].value + "', "
|
||||
}
|
||||
if (result.substring(result.length - 1, result.length) == " ")
|
||||
result = result.substring(0, result.length - 2);
|
||||
result = result + ")"
|
||||
|
||||
|
||||
document.location = 'xsltInsertValueOf.aspx?objectId=<%=umbraco.helper.Request("objectId")%>&value=' + result;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
div.code{padding: 7px 0px 7px 0px; font-family: Consolas,courier;}
|
||||
div.code input{border: none; background:#F6F6F9; color: #000; padding: 5px; font-family: Consolas,courier;}
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:Pane runat="server" Text="Choose xslt extension">
|
||||
<cc1:PropertyPanel runat="server">
|
||||
<asp:DropDownList ID="assemblies" runat="server" Width="200px" />
|
||||
<asp:DropDownList ID="methods" runat="server" Width="400px"/>
|
||||
</cc1:PropertyPanel>
|
||||
<cc1:PropertyPanel runat="server">
|
||||
<asp:PlaceHolder ID="PlaceHolderParamters" runat="server"></asp:PlaceHolder>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
<p>
|
||||
<asp:Button ID="bt_insert" OnClientClick="returnResult(); return false;" Enabled="false" runat="server" Text="Insert" /> <em><%= Services.TextService.Localize("or") %></em> <a href="xsltInsertValueOf.aspx"><%= Services.TextService.Localize("cancel") %></a>
|
||||
</p>
|
||||
|
||||
</asp:Content>
|
||||
-164
@@ -1,164 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.developer
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for xsltChooseExtension.
|
||||
/// </summary>
|
||||
[WebformsPageTreeAuthorize(Constants.Trees.Xslt)]
|
||||
public partial class xsltChooseExtension : UmbracoEnsuredPage
|
||||
{
|
||||
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
SortedList<string, List<string>> ht = GetXsltAssembliesAndMethods();
|
||||
if (!IsPostBack)
|
||||
{
|
||||
assemblies.Attributes.Add("onChange", "document.forms[0].submit()");
|
||||
foreach(string s in ht.Keys)
|
||||
assemblies.Items.Add(new ListItem(s));
|
||||
|
||||
// Select the umbraco extensions as default
|
||||
assemblies.Items[0].Selected = true;
|
||||
}
|
||||
|
||||
string selectedMethod = "";
|
||||
if (methods.SelectedValue != "")
|
||||
{
|
||||
selectedMethod = methods.SelectedValue;
|
||||
PlaceHolderParamters.Controls.Clear();
|
||||
PlaceHolderParamters.Controls.Add(new LiteralControl("<div class='code'>" + assemblies.SelectedItem + ":" + methods.SelectedValue.Substring(0, methods.SelectedValue.IndexOf("(")) + "("));
|
||||
PlaceHolderParamters.Controls.Add(new LiteralControl("<input type=\"hidden\" name=\"selectedMethod\" id=\"selectedMethod\" value=\"" + methods.SelectedValue.Substring(0, methods.SelectedValue.IndexOf("(")) + "\"/>"));
|
||||
|
||||
int counter = 0;
|
||||
string[] props = methods.SelectedValue.Substring(methods.SelectedValue.IndexOf("(") + 1, methods.SelectedValue.IndexOf(")") - methods.SelectedValue.IndexOf("(") - 1).Split(',');
|
||||
|
||||
foreach (string s in props)
|
||||
{
|
||||
if (s.Trim() != "")
|
||||
{
|
||||
counter++;
|
||||
TextBox t = new TextBox();
|
||||
t.ID = "param" + Guid.NewGuid().ToString();
|
||||
t.Text = s.Trim();
|
||||
t.TabIndex = (short) counter;
|
||||
t.Attributes.Add("onFocus", "if (this.value == '" + s.Trim() + "') this.value = '';");
|
||||
t.Attributes.Add("onBlur", "if (this.value == '') this.value = '" + s.Trim() + "'");
|
||||
t.Attributes.Add("style", "width:80px;");
|
||||
PlaceHolderParamters.Controls.Add(t);
|
||||
|
||||
if(counter < props.Length)
|
||||
PlaceHolderParamters.Controls.Add(new LiteralControl(","));
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
//PlaceHolderParamters.Controls.Add(new LiteralControl(")</div> <br/><input type=\"button\" style=\"font-size: XX-Small\" tabIndex=\"" + counter.ToString() + "\" value=\"Insert\" onClick=\"returnResult();\"/>"));
|
||||
PlaceHolderParamters.Controls.Add(new LiteralControl(")</div>"));
|
||||
bt_insert.Enabled = true;
|
||||
}
|
||||
else
|
||||
PlaceHolderParamters.Controls.Clear();
|
||||
|
||||
|
||||
if (assemblies.SelectedValue != "")
|
||||
{
|
||||
methods.Items.Clear();
|
||||
methods.Items.Add(new ListItem("Choose method", ""));
|
||||
methods.Attributes.Add("onChange", "document.forms[0].submit()");
|
||||
List<string> methodList = ht[assemblies.SelectedValue];
|
||||
foreach (string method in methodList)
|
||||
{
|
||||
ListItem li = new ListItem(method);
|
||||
if (method == selectedMethod)
|
||||
li.Selected = true;
|
||||
methods.Items.Add(li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XSLT assemblies and their methods.
|
||||
/// </summary>
|
||||
/// <returns>A list of assembly names linked to a list of method signatures.</returns>
|
||||
private SortedList<string, List<string>> GetXsltAssembliesAndMethods()
|
||||
{
|
||||
SortedList<string, List<string>> _tempAssemblies = new SortedList<string, List<string>>();
|
||||
|
||||
// add all extensions definied by macro
|
||||
foreach(KeyValuePair<string, object> extension in Umbraco.Web.Macros.XsltMacroEngine.GetXsltExtensions())
|
||||
_tempAssemblies.Add(extension.Key, GetStaticMethods(extension.Value.GetType()));
|
||||
|
||||
// add the Umbraco library (not included in macro extensions)
|
||||
_tempAssemblies.Add("umbraco.library", GetStaticMethods(typeof(umbraco.library)));
|
||||
|
||||
return _tempAssemblies;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the static methods of the specified type, alphabetically sorted.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>A sortd list with method signatures.</returns>
|
||||
private List<string> GetStaticMethods(Type type)
|
||||
{
|
||||
List<string> methods = new List<string>();
|
||||
foreach (MethodInfo method in type.GetMethods())
|
||||
{
|
||||
if (method.IsStatic)
|
||||
{
|
||||
// add method name to signature
|
||||
StringBuilder methodSignature = new StringBuilder(method.Name);
|
||||
|
||||
// add parameters to signature
|
||||
methodSignature.Append('(');
|
||||
ParameterInfo[] parameters = method.GetParameters();
|
||||
for(int i=0; i<parameters.Length; i++)
|
||||
{
|
||||
ParameterInfo parameter = parameters[i];
|
||||
methodSignature.Append(i == 0 ? String.Empty : ", ")
|
||||
.Append(parameter.ParameterType.Name)
|
||||
.Append(' ')
|
||||
.Append(parameter.Name);
|
||||
}
|
||||
methodSignature.Append(')');
|
||||
|
||||
// add method signature to list
|
||||
methods.Add(methodSignature.ToString());
|
||||
}
|
||||
}
|
||||
methods.Sort();
|
||||
return methods;
|
||||
}
|
||||
|
||||
|
||||
#region Web Form Designer generated code
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Generated
-51
@@ -1,51 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.developer {
|
||||
|
||||
|
||||
public partial class xsltChooseExtension {
|
||||
|
||||
/// <summary>
|
||||
/// assemblies control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList assemblies;
|
||||
|
||||
/// <summary>
|
||||
/// methods control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList methods;
|
||||
|
||||
/// <summary>
|
||||
/// PlaceHolderParamters control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder PlaceHolderParamters;
|
||||
|
||||
/// <summary>
|
||||
/// bt_insert control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button bt_insert;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoDialog.Master" Codebehind="xsltInsertValueOf.aspx.cs" AutoEventWireup="True" Inherits="umbraco.developer.xsltInsertValueOf" %>
|
||||
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script type="text/javascript">
|
||||
function doSubmit() {
|
||||
|
||||
var checked = "";
|
||||
if (document.getElementById('<%= disableOutputEscaping.ClientID %>').checked)
|
||||
checked = ' disable-output-escaping="yes"';
|
||||
|
||||
result = '<xsl:value-of select="' + document.getElementById('<%= valueOf.ClientID %>').value + '"' + checked + '/>';
|
||||
|
||||
UmbClientMgr.contentFrame().focus();
|
||||
UmbClientMgr.contentFrame().UmbEditor.Insert(result, '', '<%=umbraco.helper.Request("objectId")%>');
|
||||
|
||||
UmbClientMgr.closeModalWindow();
|
||||
}
|
||||
|
||||
function getExtensionMethod() {
|
||||
document.location = 'xsltChooseExtension.aspx?objectId=<%=umbraco.helper.Request("objectId")%>';
|
||||
}
|
||||
|
||||
function recieveExtensionMethod(theValue) {
|
||||
document.getElementById('<%= valueOf.ClientID %>').value = theValue;
|
||||
}
|
||||
|
||||
var functionsFrame = this;
|
||||
var tabFrame = this;
|
||||
var isDialog = true;
|
||||
var submitOnEnter = true;
|
||||
|
||||
this.focus();
|
||||
</script>
|
||||
|
||||
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="js/umbracoCheckKeys.js" PathNameAlias="UmbracoRoot" />
|
||||
|
||||
<style type="text/css">
|
||||
body{margin: 0px; padding: 0px;}
|
||||
.propertyItemheader{width: 200px !Important;}
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:Pane runat="server" Text="Insert value">
|
||||
<cc1:PropertyPanel runat="server" Text="Value">
|
||||
<asp:TextBox runat="server" ID="valueOf" Width="250px"></asp:TextBox>
|
||||
<asp:DropDownList ID="preValues" runat="server" Width="150px"></asp:DropDownList>
|
||||
<input type="button" value="Get Extension" onclick="getExtensionMethod();" style="font-size: xx-small">
|
||||
</cc1:PropertyPanel>
|
||||
<cc1:PropertyPanel runat="server" Text="Disable output escaping">
|
||||
<asp:CheckBox runat="server" ID="disableOutputEscaping"></asp:CheckBox>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
<p>
|
||||
<input type="button" value="Insert value" onclick="doSubmit();" /> <em><%= Services.TextService.Localize("or") %></em> <a href="#" onclick="UmbClientMgr.closeModalWindow(); return false;"><%= Services.TextService.Localize("cancel") %></a>
|
||||
</p>
|
||||
</asp:Content>
|
||||
@@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.developer
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for xsltInsertValueOf.
|
||||
/// </summary>
|
||||
[WebformsPageTreeAuthorize(Constants.Trees.Xslt)]
|
||||
public partial class xsltInsertValueOf : UmbracoEnsuredPage
|
||||
{
|
||||
protected void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
ArrayList preValuesSource = new ArrayList();
|
||||
|
||||
// Attributes
|
||||
string[] attributes = {"@id", "@parentID", "@level", "@writerID", "@nodeType", "@template", "@sortOrder", "@createDate", "@creatorName", "@updateDate", "@nodeName", "@urlName", "@writerName", "@nodeTypeAlias", "@path"};
|
||||
foreach (string att in attributes)
|
||||
preValuesSource.Add(att);
|
||||
|
||||
// generic properties
|
||||
string existingGenProps = ",";
|
||||
var exclude = Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray();
|
||||
|
||||
var propertyTypes = Services.ContentTypeService.GetAllPropertyTypeAliases();
|
||||
|
||||
foreach (var ptAlias in propertyTypes.Where(x => exclude.Contains(x) == false))
|
||||
{
|
||||
if (!existingGenProps.Contains("," + ptAlias + ","))
|
||||
{
|
||||
preValuesSource.Add(ptAlias);
|
||||
|
||||
|
||||
existingGenProps += ptAlias + ",";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
preValuesSource.Sort();
|
||||
preValues.DataSource = preValuesSource;
|
||||
preValues.DataBind();
|
||||
preValues.Items.Insert(0, new ListItem("Prevalues...", ""));
|
||||
|
||||
preValues.Attributes.Add("onChange", "if (this.value != '') document.getElementById('" + valueOf.ClientID + "').value = this.value");
|
||||
|
||||
if(!String.IsNullOrEmpty(Request.QueryString["value"]))
|
||||
valueOf.Text = Request.QueryString["value"];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Generated
-51
@@ -1,51 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.developer {
|
||||
|
||||
|
||||
public partial class xsltInsertValueOf {
|
||||
|
||||
/// <summary>
|
||||
/// JsInclude1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
|
||||
|
||||
/// <summary>
|
||||
/// valueOf control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox valueOf;
|
||||
|
||||
/// <summary>
|
||||
/// preValues control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList preValues;
|
||||
|
||||
/// <summary>
|
||||
/// disableOutputEscaping control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CheckBox disableOutputEscaping;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<%@ Page Language="C#" MasterPageFile="../../masterpages/umbracoDialog.Master" AutoEventWireup="true"
|
||||
CodeBehind="xsltVisualize.aspx.cs" ValidateRequest="false" Inherits="umbraco.presentation.umbraco.developer.Xslt.xsltVisualize" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" Assembly="Umbraco.Web" %>
|
||||
<%@ Register TagPrefix="cc2" Namespace="umbraco.controls" Assembly="Umbraco.Web" %>
|
||||
|
||||
<asp:Content runat="server" ContentPlaceHolderID="head">
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
var xsltSelection = jQuery("#<%=xsltSelection.ClientID %>");
|
||||
if (xsltSelection.val() == '') {
|
||||
xsltSelection.val(UmbClientMgr.contentFrame().xsltSnippet);
|
||||
|
||||
// automatically submit if page is chosen
|
||||
var picker = Umbraco.Controls.TreePicker.GetPickerById('<%=contentPicker.ClientID%>');
|
||||
if (picker.GetValue() != '') {
|
||||
jQuery("#<%=visualizeDo.ClientID %>").click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function encodeDecodeResult(isChecked) {
|
||||
var html = jQuery("#result").html();
|
||||
if (isChecked) {
|
||||
jQuery("#result").html(
|
||||
html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,"<br/>").replace(/\r/g,""));
|
||||
} else {
|
||||
jQuery("#result").html(
|
||||
html.replace(/<BR>/g, "\n").replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'));
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</asp:Content>
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
|
||||
<cc1:Pane ID="Pane1" runat="server" Text="Visualize XSLT">
|
||||
<cc1:PropertyPanel ID="PropertyPanel1" runat="server">
|
||||
<input type="hidden" runat="server" id="xsltSelection" />
|
||||
<cc2:ContentPicker ID="contentPicker" runat="server" /><br /><br />
|
||||
<asp:Button ID="visualizeDo" runat="server" Text="Visualize XSLT" OnClick="visualizeDo_Click" />
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
<cc1:Pane ID="visualizeContainer" runat="server" Text="Generated Result" Visible="false">
|
||||
<p style="float: right">
|
||||
<input type="checkbox" id="encodeDecode" onclick="encodeDecodeResult(this.checked)" />
|
||||
<label for="encodeDecode">Encode/Decode result</label></p>
|
||||
<cc1:PropertyPanel ID="visualizePanel" runat="server">
|
||||
<asp:Literal ID="visualizeArea" runat="server"></asp:Literal>
|
||||
</cc1:PropertyPanel>
|
||||
</cc1:Pane>
|
||||
|
||||
</asp:Content>
|
||||
@@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace umbraco.presentation.umbraco.developer.Xslt
|
||||
{
|
||||
[WebformsPageTreeAuthorize(Constants.Trees.Xslt)]
|
||||
public partial class xsltVisualize : UmbracoEnsuredPage
|
||||
{
|
||||
private const string XsltVisualizeCookieName = "UMB_XSLTVISPG";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
// Check if cookie exists in the current request.
|
||||
// zb-00004 #29956 : refactor cookies names & handling
|
||||
if (Request.HasCookieValue(XsltVisualizeCookieName))
|
||||
contentPicker.Value = Request.GetCookieValue(XsltVisualizeCookieName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void visualizeDo_Click(object sender, EventArgs e)
|
||||
{
|
||||
// get xslt file
|
||||
string xslt;
|
||||
if (xsltSelection.Value.Contains("<xsl:stylesheet"))
|
||||
{
|
||||
// assume xslt contains everything we need
|
||||
xslt = xsltSelection.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// read clean xslt, paste selection, and prepare support for XSLT extensions
|
||||
xslt = File.ReadAllText(IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/clean.xslt"));
|
||||
xslt = xslt.Replace("<!-- start writing XSLT -->", xsltSelection.Value);
|
||||
xslt = Umbraco.Web.Macros.XsltMacroEngine.AddXsltExtensionsToHeader(xslt);
|
||||
}
|
||||
|
||||
int pageId;
|
||||
if (int.TryParse(contentPicker.Value, out pageId) == false)
|
||||
pageId = -1;
|
||||
|
||||
// transform
|
||||
string xsltResult;
|
||||
try
|
||||
{
|
||||
xsltResult = Umbraco.Web.Macros.XsltMacroEngine.TestXsltTransform(Current.ProfilingLogger, xslt, pageId);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
xsltResult = string.Format(
|
||||
"<div class=\"error\"><h3>Error parsing the XSLT:</h3><p>{0}</p></div>",
|
||||
ee.ToString());
|
||||
}
|
||||
|
||||
visualizeContainer.Visible = true;
|
||||
|
||||
// update output
|
||||
visualizeArea.Text = !String.IsNullOrEmpty(xsltResult) ? "<div id=\"result\">" + xsltResult + "</Div>" : "<div class=\"notice\"><p>The XSLT didn't generate any output</p></div>";
|
||||
|
||||
|
||||
// add cookie with current page
|
||||
// zb-00004 #29956 : refactor cookies names & handling
|
||||
Response.Cookies.Set(new HttpCookie(XsltVisualizeCookieName, contentPicker.Value)
|
||||
{
|
||||
Expires = DateTime.Now + TimeSpan.FromMinutes(20)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Generated
-87
@@ -1,87 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.presentation.umbraco.developer.Xslt {
|
||||
|
||||
|
||||
public partial class xsltVisualize {
|
||||
|
||||
/// <summary>
|
||||
/// Pane1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane Pane1;
|
||||
|
||||
/// <summary>
|
||||
/// PropertyPanel1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel PropertyPanel1;
|
||||
|
||||
/// <summary>
|
||||
/// xsltSelection control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlInputHidden xsltSelection;
|
||||
|
||||
/// <summary>
|
||||
/// contentPicker control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.controls.ContentPicker contentPicker;
|
||||
|
||||
/// <summary>
|
||||
/// visualizeDo control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button visualizeDo;
|
||||
|
||||
/// <summary>
|
||||
/// visualizeContainer control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.Pane visualizeContainer;
|
||||
|
||||
/// <summary>
|
||||
/// visualizePanel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Umbraco.Web._Legacy.Controls.PropertyPanel visualizePanel;
|
||||
|
||||
/// <summary>
|
||||
/// visualizeArea control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal visualizeArea;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:msxml="urn:schemas-microsoft-com:xslt"
|
||||
xmlns:umbraco.library="urn:umbraco.library"
|
||||
{3}
|
||||
exclude-result-prefixes="msxml umbraco.library {2}">
|
||||
<xsl:output method="xml" omit-xml-declaration="yes"/>
|
||||
<xsl:param name="currentPage"/>
|
||||
<xsl:param name="itemData"/>
|
||||
<xsl:template match="/"><xsl:value-of select="{0}" disable-output-escaping="{1}"/></xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -82,42 +82,7 @@ namespace umbraco.presentation.templateControls
|
||||
get { return (string)ViewState["TextIfEmpty"] ?? String.Empty; }
|
||||
set { ViewState["TextIfEmpty"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the XPath expression used for the inline XSLT transformation.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The XPath expression, or an empty string to disable XSLT transformation.
|
||||
/// The code <c>{0}</c> is used as a placeholder for the rendered field contents.
|
||||
/// </value>
|
||||
[Bindable(true)]
|
||||
[Category("Umbraco")]
|
||||
[DefaultValue("")]
|
||||
[Localizable(true)]
|
||||
public string Xslt
|
||||
{
|
||||
get { return (string)ViewState["Xslt"] ?? String.Empty; }
|
||||
set { ViewState["Xslt"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether XML entity escaping of the XSLT transformation output is disabled.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> HTML escaping is disabled; otherwise, <c>false</c> (default).</value>
|
||||
/// <remarks>
|
||||
/// This corresponds value to the <c>disable-output-escaping</c> parameter
|
||||
/// of the XSLT <c>value-of</c> element.
|
||||
/// </remarks>
|
||||
[Bindable(true)]
|
||||
[Category("Umbraco")]
|
||||
[DefaultValue(false)]
|
||||
[Localizable(true)]
|
||||
public bool XsltDisableEscaping
|
||||
{
|
||||
get { return ViewState["XsltEscape"] == null ? false : (bool)ViewState["XsltEscape"]; }
|
||||
set { ViewState["XsltEscape"] = value; }
|
||||
}
|
||||
|
||||
|
||||
[Bindable(true)]
|
||||
[Category("Umbraco")]
|
||||
[DefaultValue("")]
|
||||
|
||||
@@ -56,12 +56,10 @@ namespace umbraco.presentation.templateControls
|
||||
|
||||
// parse macros and execute the XSLT transformation on the result if not empty
|
||||
string renderOutput = renderOutputWriter.ToString();
|
||||
string xsltTransformedOutput = renderOutput.Trim().Length == 0
|
||||
? String.Empty
|
||||
: XsltTransform(item.Xslt, renderOutput, item.XsltDisableEscaping);
|
||||
renderOutput = renderOutput.Trim().Length == 0 ? string.Empty : renderOutput;
|
||||
// handle text before/after
|
||||
xsltTransformedOutput = AddBeforeAfterText(xsltTransformedOutput, helper.FindAttribute(item.LegacyAttributes, "insertTextBefore"), helper.FindAttribute(item.LegacyAttributes, "insertTextAfter"));
|
||||
string finalResult = xsltTransformedOutput.Trim().Length > 0 ? xsltTransformedOutput : GetEmptyText(item);
|
||||
renderOutput = AddBeforeAfterText(renderOutput, helper.FindAttribute(item.LegacyAttributes, "insertTextBefore"), helper.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
|
||||
// of with the value converters
|
||||
@@ -192,48 +190,6 @@ namespace umbraco.presentation.templateControls
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the content using the XSLT attribute, if provided.
|
||||
/// </summary>
|
||||
/// <param name="xpath">The xpath expression.</param>
|
||||
/// <param name="itemData">The item's rendered content.</param>
|
||||
/// <param name="disableEscaping">if set to <c>true</c>, escaping is disabled.</param>
|
||||
/// <returns>The transformed content if the XSLT attribute is present, otherwise the original content.</returns>
|
||||
protected virtual string XsltTransform(string xpath, string itemData, bool disableEscaping)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(xpath))
|
||||
{
|
||||
// XML-encode the expression and add the itemData parameter to it
|
||||
string xpathEscaped = xpath.Replace("<", "<").Replace(">", ">").Replace("\"", """);
|
||||
string xpathExpression = string.Format(xpathEscaped, "$itemData");
|
||||
|
||||
// prepare support for XSLT extensions
|
||||
StringBuilder namespaceList = new StringBuilder();
|
||||
StringBuilder namespaceDeclaractions = new StringBuilder();
|
||||
foreach (KeyValuePair<string, object> extension in Umbraco.Web.Macros.XsltMacroEngine.GetXsltExtensions())
|
||||
{
|
||||
namespaceList.Append(extension.Key).Append(' ');
|
||||
namespaceDeclaractions.AppendFormat("xmlns:{0}=\"urn:{0}\" ", extension.Key);
|
||||
}
|
||||
|
||||
// add the XSLT expression into the full XSLT document, together with the needed parameters
|
||||
string xslt = string.Format(Umbraco.Web.umbraco.presentation.umbraco.templateControls.Resources.InlineXslt, xpathExpression, disableEscaping ? "yes" : "no",
|
||||
namespaceList, namespaceDeclaractions);
|
||||
|
||||
// create the parameter
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>(1);
|
||||
parameters.Add("itemData", itemData);
|
||||
|
||||
// apply the XSLT transformation
|
||||
using (var xslReader = new XmlTextReader(new StringReader(xslt)))
|
||||
{
|
||||
var transform = Umbraco.Web.Macros.XsltMacroEngine.GetXsltTransform(xslReader, false);
|
||||
return Umbraco.Web.Macros.XsltMacroEngine.ExecuteItemRenderer(Current.ProfilingLogger, transform, itemData);
|
||||
}
|
||||
}
|
||||
return itemData;
|
||||
}
|
||||
|
||||
protected string AddBeforeAfterText(string text, string before, string after)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(text))
|
||||
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Umbraco.Web.umbraco.presentation.umbraco.templateControls {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Web.umbraco.presentation.umbraco.templateControls.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-8"?>
|
||||
///<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
|
||||
///<xsl:stylesheet
|
||||
/// version="1.0"
|
||||
/// xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
/// xmlns:msxml="urn:schemas-microsoft-com:xslt"
|
||||
/// xmlns:umbraco.library="urn:umbraco.library"
|
||||
/// {3}
|
||||
/// exclude-result-prefixes="msxml umbraco.library {2}">
|
||||
///<xsl:output method="xml" omit-xml-declaration="yes"/>
|
||||
///<xsl:param name="currentPage"/>
|
||||
///<xsl:param name="itemData"/>
|
||||
///<xsl:template match="/"><xsl:value-of select="{0}" disa [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string InlineXslt {
|
||||
get {
|
||||
return ResourceManager.GetString("InlineXslt", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="InlineXslt" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>inlinexslt.xsltTemplate;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1 +0,0 @@
|
||||
<%@ WebService Language="C#" CodeBehind="codeEditorSave.asmx.cs" Class="umbraco.presentation.webservices.codeEditorSave" %>
|
||||
@@ -1,188 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.WebServices;
|
||||
using Umbraco.Web.Macros;
|
||||
|
||||
namespace umbraco.presentation.webservices
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for codeEditorSave
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[ToolboxItem(false)]
|
||||
[ScriptService]
|
||||
public class codeEditorSave : UmbracoAuthorizedWebService
|
||||
{
|
||||
[WebMethod]
|
||||
public string SaveXslt(string fileName, string oldName, string fileContents, bool ignoreDebugging)
|
||||
{
|
||||
if (AuthorizeRequest(Constants.Applications.Developer.ToString()))
|
||||
{
|
||||
IOHelper.EnsurePathExists(SystemDirectories.Xslt);
|
||||
|
||||
// validate file
|
||||
IOHelper.ValidateEditPath(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
|
||||
SystemDirectories.Xslt);
|
||||
// validate extension
|
||||
IOHelper.ValidateFileExtension(IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName),
|
||||
new List<string>() { "xsl", "xslt" });
|
||||
|
||||
StreamWriter SW;
|
||||
string tempFileName = IOHelper.MapPath(SystemDirectories.Xslt + "/" + DateTime.Now.Ticks + "_temp.xslt");
|
||||
SW = File.CreateText(tempFileName);
|
||||
SW.Write(fileContents);
|
||||
SW.Close();
|
||||
|
||||
// Test the xslt
|
||||
string errorMessage = "";
|
||||
|
||||
if (ignoreDebugging == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UmbracoContext.ContentCache.HasContent())
|
||||
XsltMacroEngine.TestXsltTransform(ProfilingLogger, fileContents);
|
||||
|
||||
/*
|
||||
// Check if there's any documents yet
|
||||
string xpath = "/root/*";
|
||||
if (content.Instance.XmlContent.SelectNodes(xpath).Count > 0)
|
||||
{
|
||||
var macroXML = new XmlDocument();
|
||||
macroXML.LoadXml("<macro/>");
|
||||
|
||||
var macroXSLT = new XslCompiledTransform();
|
||||
var umbPage = new page(content.Instance.XmlContent.SelectSingleNode("//* [@parentID = -1]"));
|
||||
|
||||
var xslArgs = macro.AddMacroXsltExtensions();
|
||||
var lib = new library(umbPage);
|
||||
xslArgs.AddExtensionObject("urn:umbraco.library", lib);
|
||||
HttpContext.Current.Trace.Write("umbracoMacro", "After adding extensions");
|
||||
|
||||
// Add the current node
|
||||
xslArgs.AddParam("currentPage", "", library.GetXmlNodeById(umbPage.PageID.ToString()));
|
||||
|
||||
HttpContext.Current.Trace.Write("umbracoMacro", "Before performing transformation");
|
||||
|
||||
// Create reader and load XSL file
|
||||
// We need to allow custom DTD's, useful for defining an ENTITY
|
||||
var readerSettings = new XmlReaderSettings();
|
||||
readerSettings.ProhibitDtd = false;
|
||||
using (var xmlReader = XmlReader.Create(tempFileName, readerSettings))
|
||||
{
|
||||
var xslResolver = new XmlUrlResolver();
|
||||
xslResolver.Credentials = CredentialCache.DefaultCredentials;
|
||||
macroXSLT.Load(xmlReader, XsltSettings.TrustedXslt, xslResolver);
|
||||
xmlReader.Close();
|
||||
// Try to execute the transformation
|
||||
var macroResult = new HtmlTextWriter(new StringWriter());
|
||||
macroXSLT.Transform(macroXML, xslArgs, macroResult);
|
||||
macroResult.Close();
|
||||
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
//errorMessage = Services.TextService.Localize("developer/xsltErrorNoNodesPublished");
|
||||
File.Delete(tempFileName);
|
||||
//base.speechBubble(speechBubbleIcon.info, Services.TextService.Localize("errors/xsltErrorHeader"), "Unable to validate xslt as no published content nodes exist.");
|
||||
}
|
||||
}
|
||||
catch (Exception errorXslt)
|
||||
{
|
||||
File.Delete(tempFileName);
|
||||
|
||||
errorMessage = (errorXslt.InnerException ?? errorXslt).ToString();
|
||||
|
||||
// Full error message
|
||||
errorMessage = errorMessage.Replace("\n", "<br/>\n");
|
||||
//closeErrorMessage.Visible = true;
|
||||
|
||||
// Find error
|
||||
var m = Regex.Matches(errorMessage, @"\d*[^,],\d[^\)]", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
foreach (Match mm in m)
|
||||
{
|
||||
string[] errorLine = mm.Value.Split(',');
|
||||
|
||||
if (errorLine.Length > 0)
|
||||
{
|
||||
var theErrorLine = int.Parse(errorLine[0]);
|
||||
var theErrorChar = int.Parse(errorLine[1]);
|
||||
|
||||
errorMessage = "Error in XSLT at line " + errorLine[0] + ", char " + errorLine[1] +
|
||||
"<br/>";
|
||||
errorMessage += "<span style=\"font-family: courier; font-size: 11px;\">";
|
||||
|
||||
var xsltText = fileContents.Split("\n".ToCharArray());
|
||||
for (var i = 0; i < xsltText.Length; i++)
|
||||
{
|
||||
if (i >= theErrorLine - 3 && i <= theErrorLine + 1)
|
||||
if (i + 1 == theErrorLine)
|
||||
{
|
||||
errorMessage += "<b>" + (i + 1) + ": >>> " +
|
||||
Server.HtmlEncode(xsltText[i].Substring(0, theErrorChar));
|
||||
errorMessage +=
|
||||
"<span style=\"text-decoration: underline; border-bottom: 1px solid red\">" +
|
||||
Server.HtmlEncode(
|
||||
xsltText[i].Substring(theErrorChar,
|
||||
xsltText[i].Length - theErrorChar)).
|
||||
Trim() + "</span>";
|
||||
errorMessage += " <<<</b><br/>";
|
||||
}
|
||||
else
|
||||
errorMessage += (i + 1) + ": " +
|
||||
Server.HtmlEncode(xsltText[i]) + "<br/>";
|
||||
}
|
||||
errorMessage += "</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage == "" && fileName.ToLower().EndsWith(".xslt"))
|
||||
{
|
||||
//Hardcoded security-check... only allow saving files in xslt directory...
|
||||
var savePath = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName);
|
||||
|
||||
if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Xslt + "/")))
|
||||
{
|
||||
//deletes the old xslt file
|
||||
if (fileName != oldName)
|
||||
{
|
||||
|
||||
var p = IOHelper.MapPath(SystemDirectories.Xslt + "/" + oldName);
|
||||
if (File.Exists(p))
|
||||
File.Delete(p);
|
||||
}
|
||||
|
||||
SW = File.CreateText(savePath);
|
||||
SW.Write(fileContents);
|
||||
SW.Close();
|
||||
errorMessage = "true";
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = "Illegal path";
|
||||
}
|
||||
}
|
||||
|
||||
File.Delete(tempFileName);
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user