/// <summary> /// Creation of new tree folder node. /// </summary> /// <param name="dirInfo">Folder information</param> /// <param name="index">Index in tree to check if max number of item isn't exceeded</param> /// <returns>Created node</returns> protected TreeNode CreateNode(DirectoryInfo dirInfo, int index) { if (dirInfo == null) { return(null); } string fullName = dirInfo.FullName; string lowerFullName = fullName.ToLowerCSafe(); TreeNode newNode = null; if (IsAllowed(lowerFullName) && !IsExcluded(lowerFullName)) { newNode = new TreeNode(); string name = dirInfo.Name; DirectoryInfo parent = dirInfo.Parent; // Check if node is part of preselected path string preselectedPath = DefaultPath; if (!DefaultPath.ToLowerCSafe().StartsWithCSafe(FullStartingPath.ToLowerCSafe().TrimEnd('\\'))) { preselectedPath = DirectoryHelper.CombinePath(FullStartingPath, DefaultPath); } if (index == MaxTreeNodes) { newNode.Value = ""; newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", ((parent == null) ? "" : parent.FullName.Replace("\\", "\\\\").Replace("'", "\\'"))); newNode.NavigateUrl = mBasePath + "#"; } else if ((index < MaxTreeNodes) || preselectedPath.ToLowerCSafe().StartsWithCSafe(lowerFullName)) { newNode.Value = fullName; newNode.NavigateUrl = mBasePath + "#"; string nodeName = HttpUtility.HtmlEncode(name); string nodeNameJava = ScriptHelper.GetString(nodeName); string preSel = FullStartingPath.TrimEnd('\\').ToLowerCSafe(); if (DefaultPath.ToLowerCSafe().StartsWithCSafe(FullStartingPath.ToLowerCSafe().TrimEnd('\\'))) { preSel = DefaultPath.ToLowerCSafe(); } else if (!String.IsNullOrEmpty(DefaultPath)) { preSel = DirectoryHelper.CombinePath(preSel, DefaultPath.ToLowerCSafe()); } if ((preSel != "") && (newNode.Value.ToLowerCSafe() == preSel)) { newNode.Text = SelectedNodeTextTemplate.Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", "").Replace("##NODEID##", newNode.Value.Replace("\\", "\\\\").Replace("'", "\\'")); } else { newNode.Text = NodeTextTemplate.Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", "").Replace("##NODEID##", newNode.Value.Replace("\\", "\\\\").Replace("'", "\\'")); } int childNodesCount = 0; try { childNodesCount = ValidationHelper.GetInteger(GetAllowedChildNumber(dirInfo), 0); if (childNodesCount == 0) { newNode.PopulateOnDemand = false; newNode.Expanded = true; } else { newNode.PopulateOnDemand = true; newNode.Expanded = false; } } catch { // Access error newNode.PopulateOnDemand = false; newNode.Expanded = true; } finally { newNode.Text = newNode.Text.Replace("##NODECHILDNODESCOUNT##", childNodesCount.ToString()); } } } return(newNode); }
/// <summary> /// Creation of new tree folder node. /// </summary> /// <param name="dirInfo">Folder information</param> /// <param name="index">Index in tree to check if max number of item isn't exceeded</param> /// <returns></returns> protected TreeNode CreateNode(DirectoryInfo dirInfo, int index) { if ((dirInfo != null) && (this.IsAllowed(dirInfo.FullName.ToLower())) && (!this.IsExcluded(dirInfo.FullName.ToLower()))) { System.Web.UI.WebControls.TreeNode newNode = new System.Web.UI.WebControls.TreeNode(); // Check if node is part of preselected path string preselectedPath = this.DefaultPath; if (!this.DefaultPath.ToLower().StartsWith(this.FullStartingPath.ToLower().TrimEnd('\\'))) { preselectedPath = DirectoryHelper.CombinePath(this.FullStartingPath, this.DefaultPath); } if (index == MaxTreeNodes) { newNode.Value = ""; newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", dirInfo.Parent == null ? "" : dirInfo.Parent.FullName.Replace("\\", "\\\\").Replace("'", "\\'")); newNode.NavigateUrl = mBasePath + "#"; } else if ((index < MaxTreeNodes) || (preselectedPath.ToLower().StartsWith(dirInfo.FullName.ToLower()))) { newNode.Value = dirInfo.FullName; newNode.NavigateUrl = mBasePath + "#"; string imageUrl = ""; string tooltip = ""; imageUrl = treeFileSystem.LineImagesFolder + "/folder.gif"; string imageTag = "<img src=\"" + imageUrl + "\" alt=\"\" style=\"border:0px;vertical-align:middle;\" onclick=\"return false;\"" + tooltip + "/>"; string nodeName = HttpUtility.HtmlEncode(dirInfo.Name); string nodeNameJava = ScriptHelper.GetString(nodeName); string preSel = this.FullStartingPath.TrimEnd('\\').ToLower(); if (this.DefaultPath.ToLower().StartsWith(this.FullStartingPath.ToLower().TrimEnd('\\'))) { preSel = this.DefaultPath.ToLower(); } else if (!String.IsNullOrEmpty(this.DefaultPath)) { preSel = DirectoryHelper.CombinePath(preSel, this.DefaultPath.ToLower()); } if ((preSel != "") && (newNode.Value.ToLower() == preSel)) { newNode.Text = SelectedNodeTextTemplate.Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", imageTag).Replace("##NODEID##", newNode.Value.Replace("\\", "\\\\").Replace("'", "\\'")); } else { newNode.Text = NodeTextTemplate.Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", imageTag).Replace("##NODEID##", newNode.Value.Replace("\\", "\\\\").Replace("'", "\\'")); } int childNodesCount = 0; try { childNodesCount = ValidationHelper.GetInteger(GetAllowedChildNumber(dirInfo), 0); if (childNodesCount == 0) { newNode.PopulateOnDemand = false; newNode.Expanded = true; } else { newNode.PopulateOnDemand = true; newNode.Expanded = false; } } catch { // Access error newNode.PopulateOnDemand = false; newNode.Expanded = true; } finally { newNode.Text = newNode.Text.Replace("##NODECHILDNODESCOUNT##", childNodesCount.ToString()); } } else { return(null); } return(newNode); } return(null); }
/// <summary> /// Creates the tree node. /// </summary> /// <param name="sourceNode">Source node</param> /// <param name="index">Node index</param> /// <param name="childNode">True if the node is child node</param> protected System.Web.UI.WebControls.TreeNode CreateNode(TreeSiteMapNode sourceNode, int index, bool childNode) { System.Web.UI.WebControls.TreeNode newNode = new System.Web.UI.WebControls.TreeNode(); ISimpleDataContainer container = sourceNode; int sourceNodeId = (int)container.GetValue("NodeID"); int nodeLevel = (int)container.GetValue("NodeLevel"); if (sourceNodeId < 0) { newNode.SelectAction = TreeNodeSelectAction.None; newNode.Text = GetString("ContentTree.ReadDocumentDenied"); newNode.NavigateUrl = (DeniedNodePostback ? mBasePath + "#" : ""); return(newNode); } if ((index < MaxTreeNodes) || (nodeLevel <= MapProvider.RootNodeLevel + 1)) { allNodes[sourceNodeId] = newNode; // Set the base data newNode.Value = sourceNodeId.ToString(); newNode.NavigateUrl = "javascript:void(0);"; int classId = ValidationHelper.GetInteger(container.GetValue("NodeClassID"), 0); DataClassInfo ci = DataClassInfoProvider.GetDataClass(classId); if (ci == null) { throw new Exception("[ContentTree.CreateNode]: Node class not found."); } string className = ci.ClassName.ToLower(SqlHelperClass.EnglishCulture); string imageUrl = string.Empty; string tooltip = string.Empty; // Use file type icons for cms.file if (UseCMSFileIcons && (className == "cms.file")) { string extension = ValidationHelper.GetString(container.GetValue("DocumentType"), ""); imageUrl = GetFileIconUrl(extension, CMSFileIconSet); tooltip = " title=\"" + extension.ToLower().TrimStart('.') + "\" "; } // Use class icons else { imageUrl = ResolveUrl(GetDocumentTypeIconUrl(className)); } StringBuilder sb = new StringBuilder(); sb.Append("<img src=\"", imageUrl, "\" alt=\"\" style=\"border:0px;vertical-align:middle;\" onclick=\"return false;\"", tooltip, " class=\"", (className == "cms.root" ? "Image20" : "Image16"), "\" />"); string imageTag = sb.ToString(); string nodeName = HttpUtility.HtmlEncode(ValidationHelper.GetString(container.GetValue("DocumentName"), "")); string nodeNameJava = ScriptHelper.GetString(nodeName); // Render special marks only if allowed if (AllowMarks) { string siteName = SiteName; int workflowStepId = ValidationHelper.GetInteger(container.GetValue("DocumentWorkflowStepID"), 0); string stepName = null; if (workflowStepId > 0) { WorkflowStepInfo stepInfo = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowStepId); if (stepInfo != null) { stepName = stepInfo.StepName; } } // Add icons nodeName += UIHelper.GetDocumentMarks(Page, SiteName, PreferredCulture, stepName, sourceNode); } // Prepare the node text if ((NodeID > 0) && (sourceNodeId == NodeID)) { newNode.Text = SelectedNodeTextTemplate.Replace("##NODEID##", sourceNodeId.ToString()).Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", imageTag); //.DocumentName selectedRendered = true; } else { newNode.Text = NodeTextTemplate.Replace("##NODEID##", sourceNodeId.ToString()).Replace("##NODENAMEJAVA##", nodeNameJava).Replace("##NODENAME##", nodeName).Replace("##ICON##", imageTag); //.DocumentName } int childNodesCount = ValidationHelper.GetInteger(container.GetValue("NodeChildNodesCount"), 0); newNode.Text = newNode.Text.Replace("##NODECHILDNODESCOUNT##", childNodesCount.ToString()); // Drag and drop envelope if (AllowDragAndDrop) { sb.Length = 0; if (childNode) { sb.Append("<span id=\"target_", sourceNodeId, "\"><span class=\"DDItem\" id=\"node_", sourceNodeId, "\"><span class=\"DDHandle\" id=\"handle_", sourceNodeId, "\" onmousedown=\"return false;\" onclick=\"return false;\">", newNode.Text, "</span></span></span>"); } else { sb.Append("<span id=\"target_", sourceNodeId, "\" class=\"RootNode\"><span class=\"DDItem\" id=\"node_", sourceNodeId, "\">", newNode.Text, "</span></span>"); } newNode.Text = sb.ToString(); } // Check if can expand if (childNodesCount == 0) { newNode.PopulateOnDemand = false; newNode.Expanded = true; } else { if ((sourceNode.ChildNodes.Count > 0) || !sourceNode.ChildNodesLoaded) { newNode.PopulateOnDemand = true; } } // Set expanded status string aliasPath = ValidationHelper.GetString(container.GetValue("NodeAliasPath"), ""); if ((aliasPath.ToLower() != MapProvider.UsedPath.ToLower()) && (!expandNodes.Contains(sourceNodeId))) { newNode.Expanded = false; } else { newNode.Expanded = true; } } else { string parentNodeId = ValidationHelper.GetString(container.GetValue("NodeParentID"), ""); newNode.Value = sourceNodeId.ToString(); newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId); newNode.NavigateUrl = "#"; } return(newNode); }