protected void Page_Init(object sender, EventArgs e)
        {
            jsonSerializer=new JavaScriptSerializer();
            TreeDefinition contentTree = TreeDefinitionCollection.Instance.Single(x => x.Tree.Alias.ToUpper() == "CONTENT");

            TreeDefinition filteredContentTree = new TreeDefinition(typeof(ContentPickerTree),
                                                         new umbraco.BusinessLogic.ApplicationTree(true, false, 0,
                                                                   contentTree.Tree.ApplicationAlias,
                                                                   "ContentPickerTree",
                                                                   contentTree.Tree.Title,
                                                                   contentTree.Tree.IconClosed,
                                                                   contentTree.Tree.IconOpened,
                                                                   "umbraco.editorControls",
                                                                   "ContentPicker_FE.ContentPickerTree",
                                                                   contentTree.Tree.Action),
                                                         contentTree.App);

            TreeDefinitionCollection.Instance.Add(filteredContentTree);

            CustomTreeControl treeControl = new CustomTreeControl();
            treeControl.StartNodeID=1937;//does not work
            treeControl.IsDialog=true;
            treeControl.DialogMode=TreeDialogModes.id;
            treeControl.TreeType="ContentPickerTree";
            treeControl.ShowContextMenu=false;

            treePickerDiv.Controls.AddAt(0, treeControl);

            //passing in the saved options to the page for use by jQuery
            ContentPicker_Options savedOptions = jsonSerializer.Deserialize<ContentPicker_Options>(HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["contentPicker"].Value));

            //Log.Add(LogTypes.Debug, 0, "cp=>"+savedOptions.jsPath);

            //add custom js/css if defined
            if (savedOptions.cssPath != "")
            {
                string customCSS = string.Format("<link href=\"{0}\" type=\"text/css\" rel=\"stylesheet\" />", savedOptions.cssPath);

                HtmlGenericControl link = new HtmlGenericControl();
                link.InnerHtml = customCSS;
                head.Controls.Add(link);
            }

            if (savedOptions.jsPath != "")
            {
                string customJS = string.Format("<script src=\"{0}\" ></script>", savedOptions.jsPath);
                HtmlGenericControl script= new HtmlGenericControl();
                script.InnerHtml = customJS;
                head.Controls.Add(script);
            }
            treePickerDiv.Attributes["allowMultiple"] = savedOptions.allowMultiple.ToString().ToLower();
        }
Пример #2
0
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Icon     = "bin_empty.png";
            rootNode.OpenIcon = "bin.png";
            //we made this alias the same as media, so the node name would be media,
            //we need to make it recycle bin
            TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(this);

            rootNode.Text = rootNode.Text = GetTreeHeader(treeDef.Tree.Alias);
            if (new RecycleBin(Media._objectType, RecycleBin.RecycleBinType.Media).Smells())
            {
                rootNode.Icon = "bin.png";
            }
            else
            {
                rootNode.Source = null;
            }
        }
Пример #3
0
		/// <summary>
		/// This adds our filtered tree definition to the TreeDefinitionCollection at runtime
		/// instead of having to declare it in the database 
		/// </summary>
		static MNTP_DataEditor()
		{
			//NOTE: Before we had locking here but static ctors are always threadsafe

			if (TreeDefinitionCollection.Instance.Any(x => x.TreeType == typeof (FilteredContentTree))) 
				return;
			
			
			//need to add our tree definitions to the collection.

			//find the content tree to duplicate
			var contentTree = TreeDefinitionCollection.Instance.Single(x => x.Tree.Alias.ToUpper() == "CONTENT");
			var filteredContentTree = new TreeDefinition(typeof(FilteredContentTree),
			                                             new umbraco.BusinessLogic.ApplicationTree(true, false, 0,
			                                                                                       contentTree.Tree.ApplicationAlias,
			                                                                                       "FilteredContentTree",
			                                                                                       contentTree.Tree.Title,
			                                                                                       contentTree.Tree.IconClosed,
			                                                                                       contentTree.Tree.IconOpened,
			                                                                                       "umbraco.editorControls",
			                                                                                       "MultiNodeTreePicker.FilteredContentTree",
			                                                                                       contentTree.Tree.Action),
			                                             contentTree.App);

			//find the media tree to duplicate
			var mediaTree = TreeDefinitionCollection.Instance.Single(x => x.Tree.Alias.ToUpper() == "MEDIA");
			var filteredMediaTree = new TreeDefinition(typeof(FilteredMediaTree),
			                                           new umbraco.BusinessLogic.ApplicationTree(true, false, 0,
			                                                                                     mediaTree.Tree.ApplicationAlias,
			                                                                                     "FilteredMediaTree",
			                                                                                     contentTree.Tree.Title,
			                                                                                     contentTree.Tree.IconClosed,
			                                                                                     contentTree.Tree.IconOpened,
			                                                                                     "umbraco.editorControls",
			                                                                                     "MultiNodeTreePicker.FilteredMediaTree",
			                                                                                     contentTree.Tree.Action),
			                                           contentTree.App);

			//add it to the collection at runtime
			TreeDefinitionCollection.Instance.Add(filteredContentTree);
			TreeDefinitionCollection.Instance.Add(filteredMediaTree);
		}
        internal static BaseTree GetLegacyTreeForLegacyServices(Core.Models.ApplicationTree appTree)
        {
            if (appTree == null) throw new ArgumentNullException("appTree");

            BaseTree tree;

            var controllerAttempt = appTree.TryGetControllerTree();
            if (controllerAttempt.Success)
            {
                var legacyAtt = controllerAttempt.Result.GetCustomAttribute<LegacyBaseTreeAttribute>(false);
                if (legacyAtt == null)
                {
                    LogHelper.Warn<LegacyTreeDataConverter>("Cannot render tree: " + appTree.Alias + ". Cannot render a " + typeof(TreeController) + " tree type with the legacy web services unless attributed with " + typeof(LegacyBaseTreeAttribute));
                    return null;
                }

                var treeDef = new TreeDefinition(
                    legacyAtt.BaseTreeType,
                    new ApplicationTree(false, true, (byte)appTree.SortOrder, appTree.ApplicationAlias, appTree.Alias, appTree.Title, appTree.IconClosed, appTree.IconOpened, "", legacyAtt.BaseTreeType.GetFullNameWithAssembly(), ""),
                    new Application(appTree.Alias, appTree.Alias, "", 0));

                tree = treeDef.CreateInstance();
                tree.TreeAlias = appTree.Alias;

            }
            else
            {
                //get the tree that we need to render                    
                var treeDef = TreeDefinitionCollection.Instance.FindTree(appTree.Alias);
                if (treeDef == null)
                {
                    return null;
                }
                tree = treeDef.CreateInstance();
            }

            return tree;
        }