diff --git a/src/Umbraco.Core/Manifest/ManifestBuilder.cs b/src/Umbraco.Core/Manifest/ManifestBuilder.cs
index 50a0af1f39..66610824d7 100644
--- a/src/Umbraco.Core/Manifest/ManifestBuilder.cs
+++ b/src/Umbraco.Core/Manifest/ManifestBuilder.cs
@@ -36,6 +36,27 @@ namespace Umbraco.Core.Manifest
return editors;
});
}
+ }
+
+ ///
+ /// Returns all parameter editors found in the manfifests
+ ///
+ internal static IEnumerable ParameterEditors
+ {
+ get
+ {
+ return (IEnumerable)StaticCache.GetOrAdd(
+ PropertyEditorsKey,
+ s =>
+ {
+ var editors = new List();
+ foreach (var manifest in GetManifests())
+ {
+ editors.AddRange(ManifestParser.GetParameterEditors(manifest.ParameterEditors));
+ }
+ return editors;
+ });
+ }
}
///
diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs
index be3fcb238e..e1489a6d75 100644
--- a/src/Umbraco.Core/Manifest/ManifestParser.cs
+++ b/src/Umbraco.Core/Manifest/ManifestParser.cs
@@ -38,6 +38,18 @@ namespace Umbraco.Core.Manifest
new PropertyEditorConverter(),
new PreValueFieldConverter());
}
+
+ ///
+ /// Parse the property editors from the json array
+ ///
+ ///
+ ///
+ internal static IEnumerable GetParameterEditors(JArray jsonEditors)
+ {
+ return JsonConvert.DeserializeObject>(
+ jsonEditors.ToString(),
+ new ParameterEditorConverter());
+ }
///
/// Get all registered manifests
@@ -143,11 +155,11 @@ namespace Umbraco.Core.Manifest
}
}
-
var manifest = new PackageManifest()
{
JavaScriptInitialize = jConfig,
PropertyEditors = propEditors.Any() ? (JArray)deserialized["propertyEditors"] : new JArray(),
+ ParameterEditors = propEditors.Any() ? (JArray)deserialized["parameterEditors"] : new JArray()
};
result.Add(manifest);
}
diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs
index f70f51644c..7bf4a7c274 100644
--- a/src/Umbraco.Core/Manifest/PackageManifest.cs
+++ b/src/Umbraco.Core/Manifest/PackageManifest.cs
@@ -16,5 +16,10 @@ namespace Umbraco.Core.Manifest
/// The json array of property editors
///
public JArray PropertyEditors { get; set; }
+
+ ///
+ /// The json array of parameter editors
+ ///
+ public JArray ParameterEditors { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Manifest/ParameterEditorConverter.cs b/src/Umbraco.Core/Manifest/ParameterEditorConverter.cs
new file mode 100644
index 0000000000..6d60dd3ab8
--- /dev/null
+++ b/src/Umbraco.Core/Manifest/ParameterEditorConverter.cs
@@ -0,0 +1,31 @@
+using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Umbraco.Core.PropertyEditors;
+using Umbraco.Core.Serialization;
+
+namespace Umbraco.Core.Manifest
+{
+ ///
+ /// Used to convert a parameter editor manifest to a property editor object
+ ///
+ internal class ParameterEditorConverter : JsonCreationConverter
+ {
+ protected override ParameterEditor Create(Type objectType, JObject jObject)
+ {
+ return new ParameterEditor();
+ }
+
+ protected override void Deserialize(JObject jObject, ParameterEditor target, JsonSerializer serializer)
+ {
+ //since it's a manifest editor, we need to create it's instance.
+ //we need to specify the view value for the editor here otherwise we'll get an exception.
+ target.ManifestDefinedParameterValueEditor = new ParameterValueEditor
+ {
+ View = jObject["view"].ToString()
+ };
+
+ base.Deserialize(jObject, target, serializer);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs
index 45a497c68c..0675b4894c 100644
--- a/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs
+++ b/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Newtonsoft.Json;
using Umbraco.Core.IO;
@@ -45,6 +46,18 @@ namespace Umbraco.Core.PropertyEditors
[JsonProperty("name", Required = Required.Always)]
public string Name { get; internal set; }
+ ///
+ /// Allows a parameter editor to be re-used based on the configuration specified.
+ ///
+ [JsonProperty("config")]
+ public virtual IDictionary Configuration { get; set; }
+
+ [JsonIgnore]
+ public ParameterValueEditor ValueEditor
+ {
+ get { return CreateValueEditor(); }
+ }
+
///
/// Creates a value editor instance
///
diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs
new file mode 100644
index 0000000000..212ffefe05
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core.Manifest;
+using Umbraco.Core.ObjectResolution;
+
+namespace Umbraco.Core.PropertyEditors
+{
+ ///
+ /// A resolver to resolve all parameter editors
+ ///
+ ///
+ /// This resolver will contain any property editors defined in manifests as well!
+ ///
+ internal class ParameterEditorResolver : LazyManyObjectsResolverBase
+ {
+ public ParameterEditorResolver(Func> typeListProducerList)
+ : base(typeListProducerList, ObjectLifetimeScope.Application)
+ {
+ }
+
+ ///
+ /// Returns the property editors
+ ///
+ public IEnumerable ParameterEditors
+ {
+ get { return Values.Union(ManifestBuilder.ParameterEditors); }
+ }
+
+ ///
+ /// Returns a property editor by alias
+ ///
+ ///
+ ///
+ public ParameterEditor GetByAlias(string alias)
+ {
+ return ParameterEditors.SingleOrDefault(x => x.Alias == alias);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 3c1f628283..e2f9310ac2 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -278,6 +278,7 @@
+
@@ -716,6 +717,7 @@
+
diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
index bfc8dc4b5f..b26daff668 100644
--- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
+++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
@@ -110,6 +110,36 @@ namespace Umbraco.Tests.Manifest
Assert.AreEqual("some default pre val", parser.ElementAt(1).DefaultPreValues["key1"]);
}
+ [Test]
+ public void Parse_Parameter_Editors()
+ {
+
+ var a = JsonConvert.DeserializeObject(@"[
+ {
+ alias: 'parameter1',
+ name: 'My Parameter',
+ view: '~/App_Plugins/MyPackage/PropertyEditors/MyEditor.html'
+ },
+ {
+ alias: 'parameter2',
+ name: 'Another parameter',
+ config: { key1: 'some config val' },
+ view: '~/App_Plugins/MyPackage/PropertyEditors/CsvEditor.html'
+ }
+]");
+ var parser = ManifestParser.GetParameterEditors(a);
+
+ Assert.AreEqual(2, parser.Count());
+ Assert.AreEqual("parameter1", parser.ElementAt(0).Alias);
+ Assert.AreEqual("My Parameter", parser.ElementAt(0).Name);
+ Assert.AreEqual("/App_Plugins/MyPackage/PropertyEditors/MyEditor.html", parser.ElementAt(0).ValueEditor.View);
+
+ Assert.AreEqual("parameter2", parser.ElementAt(1).Alias);
+ Assert.AreEqual("Another parameter", parser.ElementAt(1).Name);
+ Assert.IsTrue(parser.ElementAt(1).Configuration.ContainsKey("key1"));
+ Assert.AreEqual("some config val", parser.ElementAt(1).Configuration["key1"]);
+ }
+
[Test]
public void Merge_JArrays()
{
@@ -166,7 +196,6 @@ namespace Umbraco.Tests.Manifest
Assert.AreEqual(5, obj1.Properties().Count());
Assert.AreEqual("Value3", obj1.Properties().ElementAt(2).Value.Value());
}
-
[TestCase("C:\\Test", "C:\\Test\\MyFolder\\AnotherFolder", 2)]
diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs
index ffc6c4ac2e..3653098d07 100644
--- a/src/Umbraco.Web/umbraco.presentation/macro.cs
+++ b/src/Umbraco.Web/umbraco.presentation/macro.cs
@@ -1120,6 +1120,9 @@ namespace umbraco
TraceInfo("umbracoMacro",
"Xslt node adding search start (" + macroPropertyAlias + ",'" +
macroPropertyValue + "')");
+
+ //TODO: WE need to fix this so that we give control of this stuff over to the actual parameter editors!
+
switch (macroPropertyType)
{
case "contentTree":
@@ -1149,13 +1152,7 @@ namespace umbraco
macroXmlNode.AppendChild(currentNode);
- break;
-
- case "contentSubs": // disable that one, it does not work anyway...
- //x.LoadXml("");
- //x.FirstChild.AppendChild(x.ImportNode(umbracoXml.GetElementById(contentId), true));
- //macroXmlNode.InnerXml = TransformMacroXml(x, "macroGetSubs.xsl");
- break;
+ break;
case "contentAll":
macroXmlNode.AppendChild(macroXml.ImportNode(umbracoXml.DocumentElement, true));
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
index bfcccaeb4f..06583d71c0 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using Umbraco.Core.IO;
+using Umbraco.Core.PropertyEditors;
using umbraco.BasePages;
using umbraco.uicontrols;
using umbraco.DataLayer;
@@ -74,9 +76,7 @@ namespace umbraco.cms.presentation.developer
}
else
{
- int macroID = Convert.ToInt32(Request.QueryString["macroID"]);
-
- ClientTools
+ ClientTools
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree().Tree.Alias)
.SyncTree("-1,init," + m_macro.Id.ToString(), true); //true forces the reload
@@ -98,7 +98,6 @@ namespace umbraco.cms.presentation.developer
HtmlInputHidden macroPropertyID = (HtmlInputHidden)item.FindControl("macroPropertyID");
TextBox macroElementName = (TextBox)item.FindControl("macroPropertyName");
TextBox macroElementAlias = (TextBox)item.FindControl("macroPropertyAlias");
- CheckBox macroElementShow = (CheckBox)item.FindControl("macroPropertyHidden");
DropDownList macroElementType = (DropDownList)item.FindControl("macroPropertyType");
MacroProperty mp = new MacroProperty(int.Parse(macroPropertyID.Value));
@@ -247,11 +246,16 @@ namespace umbraco.cms.presentation.developer
return test;
}
+ [Obsolete("No longer used and will be removed in the future.")]
public IRecordsReader GetMacroPropertyTypes()
- {
- // Load dataChildTypes
- return SqlHelper.ExecuteReader("select id, macroPropertyTypeAlias from cmsMacroPropertyType order by macroPropertyTypeAlias");
- }
+ {
+ return null;
+ }
+
+ protected IEnumerable GetMacroParameterEditors()
+ {
+ return ParameterEditorResolver.Current.ParameterEditors;
+ }
public void macroPropertyCreate(object sender, EventArgs e)
{