").append(msg.d.html); //get the full html response wrapped in temp div
+ _this._updateImageFromAjax(rHtml);
+ if (typeof callback == "function") {
+ //build the parameters to pass back to the callback method
+ var params = {
+ hasImage: _this._getContainer().find("img.noimage").length == 0,
+ mediaId: msg.d.mediaId,
+ width: msg.d.width,
+ height: msg.d.height,
+ url: msg.d.url,
+ alt: msg.d.alt
+ };
+ //call the callback method
+ callback.call(_this, params);
+ }
+ }
+ });
+ },
+
+ showImage: function(path) {
+ ///
This will force the image to show the path passed in
+ if (this._style != "ThumbnailPreview") {
+ this._getContainer().find("img").attr("src", path);
+ }
+ else {
+ c = this._getContainer().find(".bgImage");
+ c.css("background-image", "url('" + path + "')");
+ }
+ },
+
+ _getContainer: function() {
+ return $("#" + this._containerId, this._context);
+ },
+
+ _updateImageFromAjax: function(rHtml) {
+ this._getContainer().html(rHtml.find(".imageViewer").html()); //replace the html with the inner html of the image viewer response
+ },
+
+ _showThrobber: function() {
+ var c = null;
+ if (this._style != "ThumbnailPreview") {
+ c = this._getContainer().find("img");
+ c.attr("src", this._umbPath + "/images/throbber.gif");
+ c.css("margin-top", ((c.height() - 15) / 2) + "px");
+ c.css("margin-left", ((c.width() - 15) / 2) + "px");
+ }
+ else {
+ c = this._getContainer().find(".bgImage");
+ c.css("background-image", "");
+ c.html("
![]()
");
+ var img = c.find("img");
+ img.attr("src", this._umbPath + "/images/throbber.gif");
+ img.css("margin-top", "45px");
+ img.css("margin-left", "45px");
+ }
+ }
+ }
+ }
+
+ // instance manager
+ Umbraco.Controls.ImageViewer.cntr = 0;
+ Umbraco.Controls.ImageViewer.inst = {};
+
+})(jQuery);
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx
new file mode 100644
index 0000000000..e5ab3a9652
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="ImageViewerUpdater.asmx.cs" Class="umbraco.controls.Images.ImageViewerUpdater" %>
diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs
new file mode 100644
index 0000000000..b3491211a7
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Services;
+using System.ComponentModel;
+using System.Web.Script.Services;
+using System.Web.UI;
+using umbraco.controls.Images;
+using System.IO;
+using System.Web.Script.Serialization;
+using umbraco.businesslogic.Utils;
+
+namespace umbraco.controls.Images
+{
+ ///
+ /// An ajax service to return the html for an image based on a media id
+ ///
+ [WebService(Namespace = "http://tempuri.org/")]
+ [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
+ [ToolboxItem(false)]
+ [ScriptService]
+ public class ImageViewerUpdater : System.Web.Services.WebService
+ {
+
+ ///
+ /// return the a json object with the properties
+ /// html = the html returned for rendering the image viewer
+ /// mediaId = the media id loaded
+ /// width = the width of the media (0) if not found
+ /// height = the height of the media (0) if not found
+ /// url = the url of the image
+ /// alt = the alt text for the image
+ ///
+ ///
+ [WebMethod]
+ public Dictionary
UpdateImage(int mediaId, string style, string linkTarget)
+ {
+ //load the control with the specified properties and render the output as a string and return it
+ Page page = new Page();
+ string path = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx";
+
+ ImageViewer imageViewer = page.LoadControl(path) as ImageViewer;
+ imageViewer.MediaId = mediaId;
+ ImageViewer.Style _style = (ImageViewer.Style)Enum.Parse(typeof(ImageViewer.Style), style);
+ imageViewer.ViewerStyle = _style;
+ imageViewer.LinkTarget = linkTarget;
+
+ //this adds only the anchor with image to be rendered, not the whole control!
+ page.Controls.Add(imageViewer);
+
+ imageViewer.DataBind();
+
+ StringWriter sw = new StringWriter();
+ HttpContext.Current.Server.Execute(page, sw, false);
+
+ Dictionary rVal = new Dictionary();
+ rVal.Add("html", sw.ToString());
+ rVal.Add("mediaId", imageViewer.MediaId.ToString());
+ rVal.Add("width", imageViewer.FileWidth.ToString());
+ rVal.Add("height", imageViewer.FileHeight.ToString());
+ rVal.Add("url", imageViewer.MediaItemPath);
+ rVal.Add("alt", imageViewer.AltText);
+
+ return rVal;
+ }
+ }
+}
diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx
new file mode 100644
index 0000000000..5c8cfd3257
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx
@@ -0,0 +1,28 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UploadMediaImage.ascx.cs"
+ Inherits="umbraco.controls.Images.UploadMediaImage" %>
+<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
+<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
+<%@ Register TagPrefix="ctl" Namespace="umbraco.controls" Assembly="umbraco" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs
new file mode 100644
index 0000000000..767351fa84
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Web;
+using System.Web.SessionState;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.HtmlControls;
+using System.Linq;
+using System.Xml;
+using umbraco.BasePages;
+using umbraco.uicontrols;
+using umbraco.interfaces;
+using umbraco.cms.businesslogic.media;
+
+namespace umbraco.controls.Images
+{
+
+ ///
+ /// A control to render out the controls to upload a new image to media.
+ /// Includes ability to select where in the media you would like it to upload and also supports client
+ /// callback methods once complete.
+ ///
+ public partial class UploadMediaImage : System.Web.UI.UserControl
+ {
+
+ public UploadMediaImage()
+ {
+ OnClientUpload = "";
+ }
+
+ ///
+ /// The JavaScript method to be invoked once the image is uploaded, the page is rendered and the document is ready.
+ /// The method will receive a JSON object with the following parameters:
+ /// - imagePath
+ /// - thumbnailPath
+ /// - width
+ /// - height
+ /// - id
+ ///
+ public string OnClientUpload { get; set; }
+
+ protected IDataType UploadField = new cms.businesslogic.datatype.controls.Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));
+
+ protected override void OnInit(EventArgs e)
+ {
+
+ base.OnInit(e);
+ // Get upload field from datafield factory
+ UploadControl.Controls.Add((Control)UploadField.DataEditor);
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+
+ ((HtmlInputFile)UploadField.DataEditor).ID = "uploadFile";
+ if (!IsPostBack)
+ {
+ DataBind();
+ }
+
+
+ }
+
+ protected void SubmitButton_Click(object sender, EventArgs e)
+ {
+ Media m = Media.MakeNew(TextBoxTitle.Text, cms.businesslogic.media.MediaType.GetByAlias("image"), BasePage.Current.getUser(), int.Parse(MediaPickerControl.Text));
+ var props = m.getProperties;
+ foreach (cms.businesslogic.property.Property p in props)
+ {
+ if (p.PropertyType.DataTypeDefinition.DataType.Id == UploadField.Id)
+ {
+ UploadField.DataTypeDefinitionId = p.PropertyType.DataTypeDefinition.Id;
+ UploadField.Data.PropertyId = p.Id;
+ }
+ }
+ UploadField.DataEditor.Save();
+
+ // Generate xml on image
+ m.XmlGenerate(new XmlDocument());
+ pane_upload.Visible = false;
+
+ //this seems real ugly since we apparently already have the properties above (props)... but this data layer is insane and undecipherable:)
+ string mainImage = m.getProperty("umbracoFile").Value.ToString();
+ string extension = mainImage.Substring(mainImage.LastIndexOf(".") + 1, mainImage.Length - mainImage.LastIndexOf(".") - 1);
+ var thumbnail = mainImage.Remove(mainImage.Length - extension.Length - 1, extension.Length + 1) + "_thumb.jpg";
+ string width = m.getProperty("umbracoWidth").Value.ToString();
+ string height = m.getProperty("umbracoHeight").Value.ToString();
+ int id = m.Id;
+
+ feedback.Style.Add("margin-top", "8px");
+ feedback.type = uicontrols.Feedback.feedbacktype.success;
+ feedback.Text += "";
+
+ if (!string.IsNullOrEmpty(OnClientUpload))
+ {
+ feedback.Text += @"
+ ";
+ }
+
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+
+ ((HtmlInputFile)UploadField.DataEditor).Attributes.Add("onChange", "uploader_" + this.ClientID + ".validateImage();");
+ }
+ }
+}
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs
new file mode 100644
index 0000000000..0ecc358f57
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs
@@ -0,0 +1,109 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4200
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace umbraco.controls.Images
+{
+
+
+ public partial class UploadMediaImage {
+
+ ///
+ /// JsInclude1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
+
+ ///
+ /// pane_upload control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.Pane pane_upload;
+
+ ///
+ /// pp_name control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.PropertyPanel pp_name;
+
+ ///
+ /// TextBoxTitle control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.TextBox TextBoxTitle;
+
+ ///
+ /// pp_file control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.PropertyPanel pp_file;
+
+ ///
+ /// UploadControl control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.PlaceHolder UploadControl;
+
+ ///
+ /// pp_target control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.PropertyPanel pp_target;
+
+ ///
+ /// pp_button control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.PropertyPanel pp_button;
+
+ ///
+ /// SubmitButton control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Button SubmitButton;
+
+ ///
+ /// feedback control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::umbraco.uicontrols.Feedback feedback;
+
+ protected global::umbraco.controls.ContentPicker MediaPickerControl;
+ }
+}
diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js
new file mode 100644
index 0000000000..fb9f8bcea2
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js
@@ -0,0 +1,33 @@
+///
+
+Umbraco.Sys.registerNamespace("Umbraco.Controls");
+
+(function($) {
+ Umbraco.Controls.UploadMediaImage = function(txtBoxTitleID, btnID, uploadFileID) {
+ return {
+ _txtBoxTitleID: txtBoxTitleID,
+ _btnID: btnID,
+ _uplaodFileID: uploadFileID,
+
+ validateImage: function() {
+ // Disable save button
+ var imageTypes = ",jpeg,jpg,gif,bmp,png,tiff,tif,";
+ var tb_title = document.getElementById(this._txtBoxTitleID);
+ var bt_submit = $("#" + this._btnID);
+ var tb_image = document.getElementById(this._uplaodFileID);
+
+ bt_submit.attr("disabled","disabled").css("color", "gray");
+
+ var imageName = tb_image.value;
+ if (imageName.length > 0) {
+ var extension = imageName.substring(imageName.lastIndexOf(".") + 1, imageName.length);
+ if (imageTypes.indexOf(',' + extension.toLowerCase() + ',') > -1) {
+ bt_submit.removeAttr("disabled").css("color", "#000");
+ if (tb_title.value == "")
+ tb_title.value = imageName.substring(imageName.lastIndexOf("\\") + 1, imageName.length).replace("." + extension, "");
+ }
+ }
+ }
+ };
+ }
+})(jQuery);
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs
new file mode 100644
index 0000000000..d2b362fa8b
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.Script.Serialization;
+using umbraco.interfaces;
+using System.Text.RegularExpressions;
+using umbraco.BusinessLogic.Actions;
+using umbraco.businesslogic.Utils;
+using System.Text;
+using umbraco.cms.presentation.Trees;
+using umbraco.BasePages;
+using System.Web.Services;
+
+namespace umbraco.controls.Tree
+{
+ internal class JTreeContextMenu
+ {
+ public string RenderJSONMenu()
+ {
+
+ JSONSerializer jSSerializer = new JSONSerializer();
+
+ jSSerializer.RegisterConverters(new List()
+ {
+ new JTreeContextMenuItem()
+ });
+
+ List allActions = new List();
+ foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
+ {
+ if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
+ {
+ allActions.Add(a);
+ }
+
+ }
+
+
+ return jSSerializer.Serialize(allActions);
+ }
+ }
+}
diff --git a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs
new file mode 100644
index 0000000000..8b33f22670
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.Script.Serialization;
+using umbraco.interfaces;
+using System.Text.RegularExpressions;
+using umbraco.BusinessLogic.Actions;
+using umbraco.businesslogic.Utils;
+using System.Text;
+using umbraco.cms.presentation.Trees;
+using umbraco.BasePages;
+using System.Web.Services;
+
+namespace umbraco.controls.Tree
+{
+ internal class JTreeContextMenuItem : JavaScriptConverter
+ {
+
+ ///
+ /// Not implemented as we never need to Deserialize
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override IDictionary Serialize(object obj, JavaScriptSerializer serializer)
+ {
+ //{
+ // "id": "L",
+ // "label": "Create",
+ // "icon": "create.png",
+ // "visible": function(NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); },
+ // "action": function(NODE, TREE_OBJ) { TREE_OBJ.create(false, NODE); },
+ //}
+
+
+ IAction a = (IAction)obj;
+ Dictionary data = new Dictionary();
+
+ data.Add("id", a.Letter);
+ data.Add("label", ui.Text(a.Alias));
+
+ if (a.Icon.StartsWith("."))
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(string.Format("");
+ sb.Append("");
+ data["label"] = sb.ToString();
+ }
+ else
+ {
+ 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.
+ //TODO: Check if there is a JSSource
+ data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}"));
+
+ return data;
+
+ }
+
+ ///
+ /// TODO: Find out why we can't just return IAction as one type (JavaScriptSerializer doesn't seem to pick up on it)
+ ///
+ public override IEnumerable SupportedTypes
+ {
+ get
+ {
+ List types = new List();
+ foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
+ {
+ types.Add(a.GetType());
+ }
+ return types;
+ }
+
+
+ }
+ }
+}
diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx
similarity index 60%
rename from umbraco/presentation/umbraco/controls/TreeControl.ascx
rename to umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx
index c7e13eba79..ec45eefdb8 100644
--- a/umbraco/presentation/umbraco/controls/TreeControl.ascx
+++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx
@@ -1,4 +1,4 @@
-<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TreeControl.ascx.cs" Inherits="umbraco.presentation.umbraco.controls.TreeControl" %>
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TreeControl.ascx.cs" Inherits="umbraco.controls.Tree.TreeControl" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
@@ -17,38 +17,49 @@
+
-">
+
+
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs
new file mode 100644
index 0000000000..ec82fbc5cc
--- /dev/null
+++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs
@@ -0,0 +1,390 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.Script.Serialization;
+using umbraco.interfaces;
+using System.Text.RegularExpressions;
+using umbraco.BusinessLogic.Actions;
+using umbraco.businesslogic.Utils;
+using System.Text;
+using umbraco.cms.presentation.Trees;
+using umbraco.BasePages;
+using System.Web.Services;
+using System.Drawing;
+
+namespace umbraco.controls.Tree
+{
+
+ ///
+ /// The Umbraco tree control.
+ /// If this control doesn't exist on an UmbracoEnsuredPage it will not work.
+ ///
+ public partial class TreeControl : System.Web.UI.UserControl, ITreeService
+ {
+
+ ///
+ /// Set the defaults
+ ///
+ public TreeControl()
+ {
+ Width = Unit.Empty;
+ Height = Unit.Empty;
+ BackColor = Color.Empty;
+ CssClass = "";
+ }
+
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+ EnableViewState = false;
+ }
+
+ public enum TreeMode
+ {
+ Standard, Checkbox, InheritedCheckBox
+ }
+
+ ///
+ /// If there is not application or tree specified in a query string then this is the application to load.
+ ///
+ private const string DEFAULT_APP = "content";
+
+ private List
m_ActiveTrees = new List();
+ private List m_AllAppTrees = new List();
+ private List m_ActiveTreeDefs = null;
+ private TreeMode m_TreeType = TreeMode.Standard;
+ private bool m_IsInit = false;
+ private TreeService m_TreeService = new TreeService();
+
+ #region Public Properties
+
+ #region Style Properties
+ public string CssClass { get; set; }
+ public Unit Height { get; set; }
+ public Unit Width { get; set; }
+ public Color BackColor { get; set; }
+ #endregion
+
+ #region TreeService parameters.
+ public string FunctionToCall
+ {
+ get { return m_TreeService.FunctionToCall; }
+ set
+ {
+ m_TreeService.FunctionToCall = value;
+ }
+ }
+
+ public string NodeKey
+ {
+ get { return m_TreeService.NodeKey; }
+ set
+ {
+ m_TreeService.NodeKey = value;
+ }
+ }
+
+ public int StartNodeID
+ {
+ get { return m_TreeService.StartNodeID; }
+ set
+ {
+ m_TreeService.StartNodeID = value;
+ }
+ }
+
+ public string TreeType
+ {
+ get { return m_TreeService.TreeType; }
+ set
+ {
+ m_TreeService.TreeType = value;
+ }
+ }
+
+ public bool ShowContextMenu
+ {
+ get { return m_TreeService.ShowContextMenu; }
+ set
+ {
+ m_TreeService.ShowContextMenu = value;
+ }
+ }
+
+ public bool IsDialog
+ {
+ get { return m_TreeService.IsDialog; }
+ set
+ {
+ m_TreeService.IsDialog = value;
+ }
+ }
+
+ public TreeDialogModes DialogMode
+ {
+ get { return m_TreeService.DialogMode; }
+ set
+ {
+ m_TreeService.DialogMode = value;
+ }
+ }
+
+
+ public string App
+ {
+ get
+ {
+ return GetCurrentApp();
+ }
+ set
+ {
+ m_TreeService.App = value;
+ }
+ }
+ #endregion
+
+ ///
+ /// Allows for checkboxes to be used with the tree. Default is standard.
+ ///
+ public TreeMode Mode
+ {
+ get
+ {
+ return m_TreeType;
+ }
+ set
+ {
+ m_TreeType = value;
+ }
+ }
+
+
+ ///
+ /// Returns the requires JavaScript as a string for the current application
+ ///
+ public string JSCurrApp
+ {
+ get
+ {
+ StringBuilder javascript = new StringBuilder();
+ foreach (BaseTree bTree in m_AllAppTrees)
+ bTree.RenderJS(ref javascript);
+ return javascript.ToString();
+ }
+ }
+ #endregion
+
+ ///
+ /// Can be set explicitly which will override what is in query strings or what has been set by properties.
+ /// Useful for rendering out a tree dynamically with an instance of anoterh TreeService.
+ /// By using this method, it will undo any of the tree service public properties that may be set
+ /// on this object.
+ ///
+ public void SetTreeService(TreeService srv)
+ {
+ m_TreeService = srv;
+ Initialize();
+ }
+
+ ///
+ /// Initializes the control and looks up the tree structures that are required to be rendered.
+ /// Properties of the control (or SetTreeService) need to be set before pre render or calling
+ /// GetJSONContextMenu or GetJSONNode
+ ///
+ protected void Initialize()
+ {
+ //use the query strings if the TreeParams isn't explicitly set
+ if (m_TreeService == null)
+ {
+ m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService();
+ }
+ m_TreeService.App = GetCurrentApp();
+
+ // Validate permissions
+ if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID))
+ return;
+ UmbracoEnsuredPage page = new UmbracoEnsuredPage();
+ if (!page.ValidateUserApp(GetCurrentApp()))
+ throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");
+
+ //find all tree definitions that have the current application alias that are ACTIVE
+ m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp());
+ //find all tree defs that exists for the current application regardless of if they are active
+ List appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp());
+
+ //Create the BaseTree's based on the tree definitions found
+ foreach (TreeDefinition treeDef in appTreeDefs)
+ {
+ //create the tree and initialize it
+ BaseTree bTree = treeDef.CreateInstance();
+ bTree.SetTreeParameters(m_TreeService);
+
+ //store the created tree
+ m_AllAppTrees.Add(bTree);
+ if (treeDef.Tree.Initialize)
+ m_ActiveTrees.Add(bTree);
+ }
+
+ m_IsInit = true;
+ }
+
+ ///
+ /// This calls the databind method to bind the data binding syntax on the front-end.
+ ///
+ /// Databinding was used instead of inline tags in case the tree properties needed to be set
+ /// by other classes at runtime
+ ///
+ ///
+ ///
+ ///
+ /// This will initialize the control so all TreeService properties need to be set before hand
+ ///
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+
+ if (!m_IsInit)
+ Initialize();
+
+ //Render out the JavaScript associated with all of the trees for the application
+ RenderTreeJS();
+
+ //apply the styles
+ if (Width != Unit.Empty)
+ TreeContainer.Style.Add( HtmlTextWriterStyle.Width, Width.ToString());
+ if (Height != Unit.Empty)
+ TreeContainer.Style.Add(HtmlTextWriterStyle.Height, Height.ToString());
+ if (BackColor != Color.Empty)
+ TreeContainer.Style.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(BackColor));
+ if (CssClass != "")
+ {
+ TreeContainer.Attributes.Add("class", CssClass);
+ }
+ else
+ {
+ //add the default class
+ TreeContainer.Attributes.Add("class", "treeContainer");
+ }
+
+
+ DataBind();
+ }
+
+ ///
+ /// Returns the JSON markup for the full context menu
+ ///
+ public string GetJSONContextMenu()
+ {
+ if (ShowContextMenu)
+ {
+ JTreeContextMenu menu = new JTreeContextMenu();
+ return menu.RenderJSONMenu();
+ }
+ else
+ {
+ return "{}";
+ }
+
+ }
+
+ ///
+ /// Returns the JSON markup for one node
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This will initialize the control so all TreeService properties need to be set before hand
+ ///
+ public string GetJSONNode(string nodeId)
+ {
+ if (!m_IsInit)
+ Initialize();
+
+ if (string.IsNullOrEmpty(m_TreeService.TreeType))
+ {
+ throw new ArgumentException("The TreeType is not set on the tree service");
+ }
+
+ BaseTree tree = m_ActiveTrees.Find(
+ delegate(BaseTree t)
+ {
+ return (t.TreeAlias == m_TreeService.TreeType);
+ }
+ );
+ return tree.GetSerializedNodeData(nodeId);
+ }
+
+ ///
+ /// Returns the JSON markup for the first node in the tree
+ ///
+
+ public string GetJSONInitNode()
+ {
+ if (!m_IsInit)
+ Initialize();
+
+ //if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the
+ //stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx
+ if (m_ActiveTrees.Count == 1)
+ {
+ m_TreeService.TreeType = m_ActiveTreeDefs[0].Tree.Alias;
+
+ //convert the menu to a string
+ //string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : "");
+
+ //Since there's only 1 tree, render out the tree's RootNode properties
+ XmlTree xTree = new XmlTree();
+ xTree.Add(m_ActiveTrees[0].RootNode);
+ return xTree.ToString();
+ }
+ else
+ {
+
+ //If there is more than 1 tree for the application than render out a
+ //container node labelled with the current application.
+ XmlTree xTree = new XmlTree();
+ XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(GetCurrentApp()));
+ xNode.Text = ui.Text("sections", GetCurrentApp(), UmbracoEnsuredPage.CurrentUser);
+ xNode.Source = m_TreeService.GetServiceUrl();
+ xNode.Action = ClientTools.Scripts.OpenDashboard(GetCurrentApp());
+ xNode.NodeType = m_TreeService.App.ToLower();
+ xNode.NodeID = "-1";
+ xNode.Icon = ".sprTreeFolder";
+ xTree.Add(xNode);
+ return xTree.ToString();
+ }
+ }
+
+
+
+ private void RenderTreeJS()
+ {
+ Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees_" + GetCurrentApp(), JSCurrApp, true);
+ }
+
+ ///
+ /// Return the current application alias. If neither the TreeType of Application is specified
+ /// than return the default application. If the Application is null but there is a TreeType then
+ /// find the application that the tree type is associated with.
+ ///
+ private string GetCurrentApp()
+ {
+ //if theres an treetype specified but no application
+ if (string.IsNullOrEmpty(m_TreeService.App) &&
+ !string.IsNullOrEmpty(m_TreeService.TreeType))
+ {
+ TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(m_TreeService.TreeType);
+ if (treeDef != null)
+ return treeDef.App.alias;
+ }
+ else if (!string.IsNullOrEmpty(m_TreeService.App))
+ return m_TreeService.App;
+
+ //if everything is null then return the default app
+ return DEFAULT_APP;
+ }
+ }
+}
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs
similarity index 89%
rename from umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs
rename to umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs
index 9c42afc877..c27bd96968 100644
--- a/umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs
+++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs
@@ -1,14 +1,14 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3603
+// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace umbraco.presentation.umbraco.controls {
+namespace umbraco.controls.Tree {
public partial class TreeControl {
@@ -138,5 +138,14 @@ namespace umbraco.presentation.umbraco.controls {
/// To modify move field declaration from designer file to code-behind file.
///
protected global::ClientDependency.Core.Controls.JsInclude JsInclude10;
+
+ ///
+ /// TreeContainer control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.HtmlControls.HtmlGenericControl TreeContainer;
}
}
diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs b/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs
deleted file mode 100644
index ce291ac1d5..0000000000
--- a/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs
+++ /dev/null
@@ -1,383 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.Script.Serialization;
-using umbraco.interfaces;
-using System.Text.RegularExpressions;
-using umbraco.BusinessLogic.Actions;
-using umbraco.businesslogic.Utils;
-using System.Text;
-using umbraco.cms.presentation.Trees;
-using umbraco.BasePages;
-using System.Web.Services;
-
-namespace umbraco.presentation.umbraco.controls
-{
-
- ///
- /// The Umbraco tree control.
- /// If this control doesn't exist on an UmbracoEnsuredPage it will not work.
- ///
- public partial class TreeControl : System.Web.UI.UserControl
- {
-
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
- EnableViewState = false;
- }
-
- public enum TreeMode
- {
- Standard, Checkbox, InheritedCheckBox
- }
-
- ///
- /// If there is not application or tree specified in a query string then this is the application to load.
- ///
- private const string DEFAULT_APP = "content";
-
- private List m_ActiveTrees = new List();
- private List m_AllAppTrees = new List();
- private List m_ActiveTreeDefs = null;
- private TreeMode m_TreeType = TreeMode.Standard;
- private bool m_IsInit = false;
- private TreeService m_TreeService = null;
-
- ///
- /// returns the current tree service being used to render the tree
- ///
- public TreeService TreeSvc
- {
- get
- {
- return m_TreeService;
- }
- }
-
- ///
- /// Can be set explicitly which will override what is in query strings.
- /// Useful for rendering out a tree dynamically.
- ///
- public void SetTreeService(TreeService srv)
- {
- m_TreeService = srv;
- Initialize();
- }
-
- ///
- /// Allows for checkboxes to be used with the tree. Default is standard.
- ///
- public TreeMode TreeType
- {
- get
- {
- return m_TreeType;
- }
- set
- {
- m_TreeType = value;
- }
- }
-
- ///
- /// Used to create a different container id for the tree control. This is done so that
- /// there is a way to differentiate between multiple trees if required. This is currently used
- /// to distinguish which tree is the main umbraco tree as opposed to dialog trees.
- ///
- public string CustomContainerId { get; set; }
-
- protected void Initialize()
- {
- //use the query strings if the TreeParams isn't explicitly set
- if (m_TreeService == null)
- {
- TreeRequestParams treeParams = TreeRequestParams.FromQueryStrings();
- m_TreeService = new TreeService()
- {
- ShowContextMenu = treeParams.ShowContextMenu,
- IsDialog = treeParams.IsDialog,
- DialogMode = treeParams.DialogMode,
- App = treeParams.Application,
- TreeType = treeParams.TreeType
- };
- }
-
- //ensure that the application is setup correctly
- m_TreeService.App = CurrentApp;
-
- // Validate permissions
- if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID))
- return;
- UmbracoEnsuredPage page = new UmbracoEnsuredPage();
- if (!page.ValidateUserApp(TreeSvc.App))
- throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");
-
- //find all tree definitions that have the current application alias that are ACTIVE
- m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(TreeSvc.App);
- //find all tree defs that exists for the current application regardless of if they are active
- List appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(TreeSvc.App);
-
- //Create the BaseTree's based on the tree definitions found
- foreach (TreeDefinition treeDef in appTreeDefs)
- {
- //create the tree and initialize it
- BaseTree bTree = treeDef.CreateInstance();
- bTree.SetTreeParameters(TreeSvc);
-
- //store the created tree
- m_AllAppTrees.Add(bTree);
- if (treeDef.Tree.Initialize)
- m_ActiveTrees.Add(bTree);
- }
-
- m_IsInit = true;
- }
-
- ///
- /// This calls the databind method to bind the data binding syntax on the front-end.
- ///
- /// Databinding was used instead of inline tags in case the tree properties needed to be set
- /// by other classes at runtime
- ///
- ///
- ///
- protected override void OnPreRender(EventArgs e)
- {
- base.OnPreRender(e);
-
- if (!m_IsInit)
- Initialize();
-
- //Render out the JavaScript associated with all of the trees for the application
- RenderTreeJS();
-
- DataBind();
- }
-
- ///
- /// Returns the JSON markup for the full context menu
- ///
- public string GetJSONContextMenu()
- {
- JTreeContextMenu menu = new JTreeContextMenu();
- return menu.RenderJSONMenu();
- }
-
- ///
- /// Returns the JSON markup for one node
- ///
- ///
- ///
- ///
- public string GetJSONNode(string nodeId)
- {
- if (!m_IsInit)
- Initialize();
-
- if (string.IsNullOrEmpty(TreeSvc.TreeType))
- {
- throw new ArgumentException("The TreeType is not set on the tree service");
- }
-
- BaseTree tree = m_ActiveTrees.Find(
- delegate(BaseTree t)
- {
- return (t.TreeAlias == TreeSvc.TreeType);
- }
- );
- return tree.GetSerializedNodeData(nodeId);
- }
-
- ///
- /// Returns the JSON markup for the first node in the tree
- ///
- public string GetJSONInitNode()
- {
- if (!m_IsInit)
- Initialize();
-
- //if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the
- //stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx
- if (m_ActiveTrees.Count == 1)
- {
- TreeSvc.TreeType = m_ActiveTreeDefs[0].Tree.Alias;
-
- //convert the menu to a string
- //string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : "");
-
- //Since there's only 1 tree, render out the tree's RootNode properties
- XmlTree xTree = new XmlTree();
- xTree.Add(m_ActiveTrees[0].RootNode);
- return xTree.ToString();
- }
- else
- {
-
- //If there is more than 1 tree for the application than render out a
- //container node labelled with the current application.
- XmlTree xTree = new XmlTree();
- XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(CurrentApp));
- xNode.Text = ui.Text("sections", TreeSvc.App, UmbracoEnsuredPage.CurrentUser);
- xNode.Source = TreeSvc.GetServiceUrl();
- xNode.Action = ClientTools.Scripts.OpenDashboard(TreeSvc.App);
- xNode.NodeType = TreeSvc.App.ToLower();
- xNode.NodeID = "-1";
- xNode.Icon = ".sprTreeFolder";
- xTree.Add(xNode);
- return xTree.ToString();
- }
- }
-
- ///
- /// Returns the requires JavaScript as a string for the current application
- ///
- public string JSCurrApp
- {
- get
- {
- StringBuilder javascript = new StringBuilder();
- foreach (BaseTree bTree in m_AllAppTrees)
- bTree.RenderJS(ref javascript);
- return javascript.ToString();
- }
- }
-
- ///
- /// Return the current application alias. If neither the TreeType of Application is specified
- /// than return the default application. If the Application is null but there is a TreeType then
- /// find the application that the tree type is associated with.
- ///
- protected string CurrentApp
- {
- get
- {
- //if theres an treetype specified but no application
- if (string.IsNullOrEmpty(TreeSvc.App) &&
- !string.IsNullOrEmpty(TreeSvc.TreeType))
- {
- TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(TreeSvc.TreeType);
- if (treeDef != null)
- return treeDef.App.alias;
- }
- else if (!string.IsNullOrEmpty(TreeSvc.App))
- return TreeSvc.App;
-
- //if everything is null then return the default app
- return DEFAULT_APP;
- }
- }
-
- private void RenderTreeJS()
- {
- Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees", JSCurrApp, true);
- }
-
-
- }
-
- internal class JTreeContextMenu
- {
- public string RenderJSONMenu()
- {
-
- JSONSerializer jSSerializer = new JSONSerializer();
-
- jSSerializer.RegisterConverters(new List()
- {
- new JTreeContextMenuItem()
- });
-
- List allActions = new List();
- foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
- {
- if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
- {
- allActions.Add(a);
- }
-
- }
-
-
- return jSSerializer.Serialize(allActions);
- }
- }
-
- internal class JTreeContextMenuItem : JavaScriptConverter
- {
-
- ///
- /// Not implemented as we never need to Deserialize
- ///
- ///
- ///
- ///
- ///
- public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer)
- {
- throw new NotImplementedException();
- }
-
- public override IDictionary Serialize(object obj, JavaScriptSerializer serializer)
- {
- //{
- // "id": "L",
- // "label": "Create",
- // "icon": "create.png",
- // "visible": function(NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); },
- // "action": function(NODE, TREE_OBJ) { TREE_OBJ.create(false, NODE); },
- //}
-
-
- IAction a = (IAction)obj;
- Dictionary data = new Dictionary();
-
- data.Add("id", a.Letter);
- data.Add("label", ui.Text(a.Alias));
-
- if (a.Icon.StartsWith("."))
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(string.Format("");
- sb.Append("");
- data["label"] = sb.ToString();
- }
- else
- {
- 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.
- //TODO: Check if there is a JSSource
- data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}"));
-
- return data;
-
- }
-
- ///
- /// TODO: Find out why we can't just return IAction as one type (JavaScriptSerializer doesn't seem to pick up on it)
- ///
- public override IEnumerable SupportedTypes
- {
- get
- {
- List types = new List();
- foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
- {
- types.Add(a.GetType());
- }
- return types;
- }
-
-
- }
- }
-}
\ No newline at end of file
diff --git a/umbraco/presentation/umbraco/create/content.ascx b/umbraco/presentation/umbraco/create/content.ascx
index 49ae2745b7..da1a385f02 100644
--- a/umbraco/presentation/umbraco/create/content.ascx
+++ b/umbraco/presentation/umbraco/create/content.ascx
@@ -19,7 +19,7 @@