Merge branch 'MangoPieface-dev-v8' into dev-v8
Conflicts: src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
@@ -1629,7 +1629,6 @@
|
||||
</Compile>
|
||||
<Compile Include="WebServices\XmlDataIntegrityController.cs" />
|
||||
<Compile Include="WebViewPageExtensions.cs" />
|
||||
<Compile Include="_Legacy\Utils\JSONSerializer.cs" />
|
||||
<None Include="..\Umbraco.Web.UI\Views\web.config">
|
||||
<Link>Mvc\web.config</Link>
|
||||
</None>
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace Umbraco.Web._Legacy.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// The built in JavaScriptSerializer does not allow you to export real JavaScript
|
||||
/// objects, functions, etc... only string values which isn't always what you want.
|
||||
/// See <see cref="example"/>
|
||||
///
|
||||
/// Override the JavaScriptSerializer serialization process and look for any
|
||||
/// custom "tags" strings such as a @ symbol which depicts that the string value
|
||||
/// should really be a JSON value, therefore the output removes the double quotes.
|
||||
///
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you want to output:
|
||||
/// {"myFunction": function() {alert('hello');}}
|
||||
/// The JavaScriptSerializer will not let you do this, it will render:
|
||||
/// {"myFunction": "function() {alert('hello');}"}
|
||||
/// which means that JavaScript will interpret it as a string.
|
||||
/// This class allows you to output JavaScript objects, amongst other things.
|
||||
/// </example>
|
||||
[Obsolete("Remove this for v8")]
|
||||
internal class JSONSerializer : JavaScriptSerializer
|
||||
{
|
||||
|
||||
public new string Serialize(object obj)
|
||||
{
|
||||
string output = base.Serialize(obj);
|
||||
|
||||
//replaces all strings beginning with this prefix to have no double quotes
|
||||
Regex regex1 = new Regex(string.Format("(\"{0}(.*?)\")+", PrefixJavaScriptObject),
|
||||
RegexOptions.Multiline
|
||||
| RegexOptions.CultureInvariant
|
||||
| RegexOptions.Compiled
|
||||
);
|
||||
string result = regex1.Replace(output, "$2");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private const string PrefixJavaScriptObject = "@@@@";
|
||||
|
||||
/// <summary>
|
||||
/// method for a string to be converted to a json object.
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns>A string formatted with a special prefix</returns>
|
||||
/// <remarks>
|
||||
/// This essentially just prefixes the string with a special key that we will use
|
||||
/// to parse with later during serialization.
|
||||
/// </remarks>
|
||||
public static string ToJSONObject(string s)
|
||||
{
|
||||
return PrefixJavaScriptObject + s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Web.Script.Serialization;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Web._Legacy.Utils;
|
||||
using Action = Umbraco.Web._Legacy.Actions.Action;
|
||||
|
||||
namespace umbraco.cms.presentation.Trees
|
||||
@@ -48,7 +47,7 @@ namespace umbraco.cms.presentation.Trees
|
||||
|
||||
private void Init()
|
||||
{
|
||||
m_JSSerializer = new JSONSerializer { MaxJsonLength = int.MaxValue };
|
||||
m_JSSerializer = new JavaScriptSerializer { MaxJsonLength = int.MaxValue };
|
||||
|
||||
switch (m_TreeType)
|
||||
{
|
||||
@@ -70,7 +69,7 @@ namespace umbraco.cms.presentation.Trees
|
||||
|
||||
}
|
||||
|
||||
private JSONSerializer m_JSSerializer;
|
||||
private JavaScriptSerializer m_JSSerializer;
|
||||
private SerializedTreeType m_TreeType;
|
||||
|
||||
/// <summary>
|
||||
@@ -717,7 +716,7 @@ namespace umbraco.cms.presentation.Trees
|
||||
metadata.Add("source", node.Source);
|
||||
|
||||
//the metadata/jsTree requires this property to be in a quoted JSON syntax
|
||||
JSONSerializer jsSerializer = new JSONSerializer();
|
||||
JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
|
||||
string strMetaData = jsSerializer.Serialize(metadata).Replace("\"", "'");
|
||||
dataAttributes.Add("umb:nodedata", strMetaData);
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Web.Script.Serialization;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Web._Legacy.Utils;
|
||||
using Action = Umbraco.Web._Legacy.Actions.Action;
|
||||
|
||||
namespace umbraco.controls.Tree
|
||||
@@ -14,7 +13,7 @@ namespace umbraco.controls.Tree
|
||||
public string RenderJSONMenu()
|
||||
{
|
||||
|
||||
JSONSerializer jSSerializer = new JSONSerializer();
|
||||
JavaScriptSerializer jSSerializer = new JavaScriptSerializer();
|
||||
|
||||
jSSerializer.RegisterConverters(new List<JavaScriptConverter>()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Text;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Web._Legacy.Utils;
|
||||
|
||||
namespace umbraco.controls.Tree
|
||||
{
|
||||
@@ -56,12 +55,6 @@ namespace umbraco.controls.Tree
|
||||
data.Add("icon", a.Icon);
|
||||
}
|
||||
|
||||
//required by jsTree
|
||||
data.Add("visible", JSONSerializer.ToJSONObject("function() {return true;}"));
|
||||
|
||||
//The action handler is what is assigned to the IAction, but for flexibility, we'll call our onContextMenuSelect method which will need to return true if the function is to execute.
|
||||
data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}"));
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user