Exemplo n.º 1
0
		private void Init()
		{
            m_JSSerializer = new JSONSerializer { MaxJsonLength = int.MaxValue };

			switch (m_TreeType)
			{
				case SerializedTreeType.XmlTree:
					break;
				case SerializedTreeType.JSONTree:
					m_JSSerializer.RegisterConverters(new List<JavaScriptConverter>() 
					{ 
						new JSONTreeConverter(),
						new JSONTreeNodeConverter()
					});
					break;
				case SerializedTreeType.JsTree:
					m_JSSerializer.RegisterConverters(new List<JavaScriptConverter>() 
					{ 	
						new JsTreeNodeConverter()
					});
					break;
			}


		}
Exemplo n.º 2
0
		public string RenderJSONMenu()
		{

			JSONSerializer jSSerializer = new JSONSerializer();

			jSSerializer.RegisterConverters(new List<JavaScriptConverter>() 
					{ 	
						new JTreeContextMenuItem()
					});

			List<IAction> allActions = new List<IAction>();
			foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
			{
                // NH: Added a try/catch block to this as an error in a 3rd party action can crash the whole menu initialization
                try
                {
                    if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
                    {
                        // if the action is using invalid javascript we need to do something about this
                        if (!umbraco.BusinessLogic.Actions.Action.ValidateActionJs(a))
                        {
                            // Make new Iaction
                            PlaceboAction pa = new PlaceboAction(a);
                            pa.JsFunctionName = "IActionProxy_" + umbraco.cms.helpers.Casing.SafeAlias(pa.Alias) + "()";
                            allActions.Add(pa);

                        }
                        else
                        {
                            allActions.Add(a);
                        }
                    }
                }
                catch (Exception ee)
                {
	                LogHelper.Error<JTreeContextMenu>("Error initializing tree action", ee);
                }

			}


			return jSSerializer.Serialize(allActions);
		}