/// <summary>
    /// Sets icon handler.
    /// </summary>
    private string treeElem_OnGetStatusIcons(ForumPostTreeNode node)
    {
        if (node == null)
        {
            return null;
        }

        if (!ValidationHelper.GetBoolean(((DataRow)node.ItemData)["PostApproved"], false))
        {
            return UIHelper.GetAccessibleIconTag("NodeLink icon-circle tn color-red-70", GetString("general.notapproved"));
        }

        return null;
    }
コード例 #2
0
    protected string treeElem_OnGetPostIconUrl(ForumPostTreeNode node)
    {
        if (node == null)
        {
            return(null);
        }

        if (!ValidationHelper.GetBoolean(((DataRow)node.ItemData)["PostApproved"], false))
        {
            return(UIHelper.GetAccessibleIconTag("NodeLink icon-circle tn color-red-70", GetString("general.notapproved")));
        }

        return(null);
    }
コード例 #3
0
    /// <summary>
    /// Sets icon handler.
    /// </summary>
    private string PostTree1_OnGetPostIconUrl(ForumPostTreeNode node)
    {
        string imageUrl = "";

        if (node != null)
        {
            imageUrl = GetImageUrl("CMSModules/CMS_Forums/post16.png");
            if (!ValidationHelper.GetBoolean(((DataRow)node.ItemData)["PostApproved"], false))
            {
                imageUrl = GetImageUrl("CMSModules/CMS_Forums/rejected16.png");
            }
        }

        return(imageUrl);
    }
コード例 #4
0
    /// <summary>
    /// Sets icon handler.
    /// </summary>
    private string PostTree1_OnGetPostIconUrl(ForumPostTreeNode node)
    {
        string imageUrl = "";

        if (node != null)
        {
            imageUrl = GetImageUrl("CMSModules/CMS_Forums/post16.png");
            if (!ValidationHelper.GetBoolean(((DataRow)node.ItemData)["PostApproved"], false))
            {
                imageUrl = GetImageUrl("CMSModules/CMS_Forums/rejected16.png");
            }
        }

        return imageUrl;
    }
コード例 #5
0
ファイル: PostTree.ascx.cs プロジェクト: itymofieiev/Kentico9
    /// <summary>
    /// Creates tree node.
    /// </summary>
    /// <param name="sourceNode">Node with source data</param>
    /// <param name="index">Node index</param>
    protected TreeNode CreateNode(ForumPostTreeNode sourceNode, int index)
    {
        if (sourceNode == null)
        {
            return(null);
        }

        // Create tree node
        TreeNode newNode = new TreeNode();

        DataRow dr = (DataRow)sourceNode.ItemData;

        // Check whether item data are defined, if not it is root node
        if (dr != null)
        {
            int sourceNodeId = (int)dr["PostID"];
            int nodeLevel    = (int)dr["PostLevel"];

            // Check on maximum post in tree
            if (!UseMaxPostNodes || (index < MaxPostNodes) || (MaxPostNodes <= 0))
            {
                #region "Set node values and appearance"

                newNode.Value        = sourceNodeId.ToString();
                newNode.SelectAction = TreeNodeSelectAction.None;

                bool   isApproved  = ValidationHelper.GetBoolean(dr["PostApproved"], false);
                string postSubject = (string)dr["PostSubject"];

                string cssClass = ItemCssClass;

                // Add CSS class for unapproved posts
                if (HighlightUnApprove && !isApproved)
                {
                    cssClass += " PostUnApproved";
                }

                string statusIcons = "";
                if (OnGetStatusIcons != null)
                {
                    statusIcons = OnGetStatusIcons(sourceNode);
                }


                // Set by display mode
                switch (ShowMode)
                {
                // Dynamic detail mode
                case ShowModeEnum.DynamicDetailMode:
                    newNode.Text = CreateDynamicDetailModeNode(dr, cssClass, statusIcons, postSubject);
                    break;

                // Detail mode
                case ShowModeEnum.DetailMode:
                    newNode.Text = CreateDetailModeNode(dr);
                    break;

                // Tree mode
                default:

                    if (Selected == sourceNodeId)
                    {
                        cssClass = SelectedItemCssClass;

                        string spanId = String.Empty;
                        if (AdministrationMode)
                        {
                            spanId = "id=\"treeSelectedNode\"";
                        }

                        newNode.Text = String.Format("<span {0} class=\"{1}\" onclick=\"ShowPost({2}); SelectForumNode(this);\"><span class=\"Name\">{4}{3}</span></span>",
                                                     spanId, cssClass, newNode.Value, statusIcons, HTMLHelper.HTMLEncode(postSubject));
                    }
                    else
                    {
                        newNode.Text = String.Format("<span class=\"{0}\" onclick=\"ShowPost({1}); SelectForumNode(this);\"><span class=\"Name\">{3}{2}</span></span>",
                                                     cssClass, newNode.Value, statusIcons, HTMLHelper.HTMLEncode(postSubject));
                    }
                    break;
                }

                #endregion


                if (!ExpandTree)
                {
                    #region "Populate deeper levels on demand"

                    // Check if can expand
                    string childCountColumn = "PostThreadPosts";

                    // Check if unapproved posts can be included
                    if (AdministrationMode || UserIsModerator)
                    {
                        childCountColumn = "PostThreadPostsAbsolute";
                    }

                    int childNodesCount = ValidationHelper.GetInteger(dr[childCountColumn], 0);

                    // If the post is thread(level = 0) then childnodes count 1 means no real child-post
                    if ((childNodesCount == 0) || ((childNodesCount == 1) && (nodeLevel == 0)))
                    {
                        newNode.PopulateOnDemand = false;

                        // No children -> expand
                        newNode.Expanded = true;
                    }
                    else
                    {
                        if (!sourceNode.ChildNodesLoaded)
                        {
                            newNode.PopulateOnDemand = true;
                            newNode.Expanded         = false;
                        }
                    }

                    #endregion


                    #region "Expand nodes on the current path"

                    // If preselect is set = first load
                    if (RegularLoad)
                    {
                        string currentNodePath     = (string)dr["PostIDPath"];
                        string currentSelectedPath = String.Empty;

                        if (SelectedPost != null)
                        {
                            currentSelectedPath = SelectedPost.PostIDPath;
                        }

                        // Expand if node is on the path
                        if (currentSelectedPath.StartsWithCSafe(currentNodePath))
                        {
                            // Raise OnTreeNodePopulate
                            newNode.PopulateOnDemand = true;
                            newNode.Expanded         = true;
                        }
                        else
                        {
                            newNode.Expanded = false;
                        }
                    }

                    #endregion
                }
                else
                {
                    // Populate will be called on each node
                    newNode.PopulateOnDemand = true;
                    newNode.Expanded         = true;
                }
            }
            else
            {
                string parentNodeId = ValidationHelper.GetString(dr["PostParentID"], "");
                newNode.Value        = sourceNodeId.ToString();
                newNode.Text         = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId);
                newNode.SelectAction = TreeNodeSelectAction.None;
            }
        }
        // Root node populate by default
        else
        {
            // Root node as forum display name
            ForumInfo fi = ForumInfoProvider.GetForumInfo(ForumID);

            if (fi != null)
            {
                newNode.Text         = "<span class=\"" + ItemCssClass + "\" onclick=\"ShowPost('-1'); SelectForumNode(this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(fi.ForumDisplayName) + "</span></span>";
                newNode.Value        = "0";
                newNode.SelectAction = TreeNodeSelectAction.None;
            }

            newNode.PopulateOnDemand = true;
            newNode.Expanded         = true;
        }

        return(newNode);
    }
コード例 #6
0
    /// <summary>
    /// Creates tree node.
    /// </summary>
    /// <param name="sourceNode">Node with source data</param>
    protected TreeNode CreateNode(ForumPostTreeNode sourceNode, int index)
    {
        if (sourceNode == null)
        {
            return null;
        }

        // Create tree node
        TreeNode newNode = new TreeNode();

        DataRow dr = (DataRow)sourceNode.ItemData;

        // Check whether item data are defined, if not it is root node
        if (dr != null)
        {
            int sourceNodeId = (int)dr["PostID"];
            int nodeLevel = (int)dr["PostLevel"];

            // Check on maximum post in tree
            if (!this.UseMaxPostNodes || (index < MaxPostNodes))
            {
                #region "Set node values and appearance"

                newNode.Value = sourceNodeId.ToString();
                newNode.SelectAction = TreeNodeSelectAction.None;

                bool isApproved = ValidationHelper.GetBoolean(dr["PostApproved"], false);
                string postSubject = (string)dr["PostSubject"];

                string cssClass = this.ItemCssClass;

                // Add CSS class for unapproved posts
                if (HighlightUnApprove && !isApproved)
                {
                    cssClass += " PostUnApproved";
                }

                string imageTag = "";
                if (OnGetPostIconUrl != null)
                {
                    string imageUrl = OnGetPostIconUrl(sourceNode);
                    imageTag = "<img src=\"" + imageUrl + "\" alt=\"post\" style=\"border:0px;vertical-align:middle;\" />&nbsp;";
                }

                // Set by display mode
                switch (this.ShowMode)
                {
                    // Dynamic detail mode
                    case ShowModeEnum.DynamicDetailMode:
                        newNode.Text = CreateDynamicDetailModeNode(dr, cssClass, imageTag, postSubject);
                        break;

                    // Detail mode
                    case ShowModeEnum.DetailMode:
                        newNode.Text = CreateDetailModeNode(dr);
                        break;

                    // Tree mode
                    default:

                        if (this.Selected == sourceNodeId)
                        {
                            cssClass = this.SelectedItemCssClass;

                            string spanId = String.Empty;
                            if (this.AdministrationMode)
                            {
                                spanId = "id=\"treeSelectedNode\"";
                            }

                            newNode.Text = String.Format("<span {0} class=\"{1}\" onclick=\"ShowPost({2}); SelectForumNode(this);\">{3}<span class=\"Name\">{4}</span></span>",
                                spanId, cssClass, newNode.Value, imageTag, HTMLHelper.HTMLEncode(postSubject));
                        }
                        else
                        {
                            newNode.Text = String.Format("<span class=\"{0}\" onclick=\"ShowPost({1}); SelectForumNode(this);\">{2}<span class=\"Name\">{3}</span></span>",
                                cssClass, newNode.Value, imageTag, HTMLHelper.HTMLEncode(postSubject));
                        }
                        break;
                }

                #endregion

                if (!this.ExpandTree)
                {
                    #region "Populate deeper levels on demand"

                    // Check if can expand
                    string childCountColumn = "PostThreadPosts";

                    // Check if unapproved posts can be included
                    if (this.AdministrationMode || this.UserIsModerator)
                    {
                        childCountColumn = "PostThreadPostsAbsolute";
                    }

                    int childNodesCount = ValidationHelper.GetInteger(dr[childCountColumn], 0);

                    // If the post is thread(level = 0) then childnodes count 1 means no real child-post
                    if ((childNodesCount == 0) || ((childNodesCount == 1) && (nodeLevel == 0)))
                    {
                        newNode.PopulateOnDemand = false;

                        // No childs -> expand
                        newNode.Expanded = true;
                    }
                    else
                    {
                        if (!sourceNode.ChildNodesLoaded)
                        {
                            newNode.PopulateOnDemand = true;
                            newNode.Expanded = false;
                        }
                    }

                    #endregion

                    #region "Expand nodes on the current path"

                    // If preselect is set = first load
                    if (this.RegularLoad)
                    {
                        string currentNodePath = (string)dr["PostIDPath"];
                        string currentSelectedPath = String.Empty;

                        if (this.SelectedPost != null)
                        {
                            currentSelectedPath = this.SelectedPost.PostIDPath;
                        }

                        // Expand if node is on the path
                        if (currentSelectedPath.StartsWith(currentNodePath))
                        {
                            // Raise OnTreeNodePopulate
                            newNode.PopulateOnDemand = true;
                            newNode.Expanded = true;
                        }
                        else
                        {
                            newNode.Expanded = false;
                        }
                    }

                    #endregion
                }
                else
                {
                    // Populate will be called on each node
                    newNode.PopulateOnDemand = true;
                    newNode.Expanded = true;
                }
            }
            else
            {
                string parentNodeId = ValidationHelper.GetString(dr["PostParentID"], "");
                newNode.Value = sourceNodeId.ToString();
                newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId);
                newNode.SelectAction = TreeNodeSelectAction.None;
            }
        }
        // Root node populate by default
        else
        {
            // Root node as forum display name
            ForumInfo fi = ForumInfoProvider.GetForumInfo(this.ForumID);

            if (fi != null)
            {
                newNode.Text = "<span class=\"" + this.ItemCssClass + "\" onclick=\"ShowPost('-1'); SelectForumNode(this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(fi.ForumDisplayName) + "</span></span>";
                newNode.Value = "0";
                newNode.SelectAction = TreeNodeSelectAction.None;
            }

            newNode.PopulateOnDemand = true;
            newNode.Expanded = true;
        }

        return newNode;
    }