Ejemplo n.º 1
0
        private bool IsExpandable(TreeNode item)
        {
            if (!Page.IsPostBack)
            {
                if ((item != null) && (item is mojoTreeNode))
                {
                    mojoTreeNode node = item as mojoTreeNode;
                    if (!node.HasVisibleChildren)
                    {
                        return(false);
                    }
                }
            }

            return(HasChildren(item) || ((item != null) && item.PopulateOnDemand));
        }
Ejemplo n.º 2
0
        private void WriteNodeLink(TreeView treeView, TreeNode item, HtmlTextWriter writer)
        {
            writer.WriteBeginTag("a");

            if (renderAnchorCss)
            {
                string anchorCss = GetItemClass(item);
                if (anchorCss.Length > 0)
                {
                    writer.WriteAttribute("class", anchorCss);
                }
            }

            if (!String.IsNullOrEmpty(item.NavigateUrl))
            {
                writer.WriteAttribute("href", Extender.ResolveUrl(item.NavigateUrl));
                if (item is mojoTreeNode)
                {
                    mojoTreeNode node = (mojoTreeNode)item;
                    if (node.OnClientClick.Length > 0)
                    {
                        writer.WriteAttribute("onclick", node.OnClientClick);
                    }
                }
            }
            else
            {
                string codePrefix = "";
                if (item.SelectAction == TreeNodeSelectAction.Select)
                {
                    codePrefix = "s";
                }
                else if (item.SelectAction == TreeNodeSelectAction.SelectExpand)
                {
                    codePrefix = "e";
                }
                else if (item.PopulateOnDemand)
                {
                    codePrefix = "p";
                }
                writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(treeView, codePrefix + (Page.Server.HtmlEncode(item.ValuePath)).Replace("/", "\\"), true));
            }

            WebControlAdapterExtender.WriteTargetAttribute(writer, item.Target);

            if (!useMenuTooltipForCustomCss)
            {
                if (!String.IsNullOrEmpty(item.ToolTip))
                {
                    writer.WriteAttribute("title", item.ToolTip);
                }
                else if (!String.IsNullOrEmpty(treeView.ToolTip))
                {
                    writer.WriteAttribute("title", treeView.ToolTip);
                }
            }
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.Indent++;
            writer.WriteLine();

            switch (extraMarkupMode)
            {
            case "Artisteer":

                if (!suppressCornerDivs)
                {
                    if (item.Depth < 1)
                    {
                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", "l");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.WriteEndTag("span");

                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", "r");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.WriteEndTag("span");

                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", "t");
                        writer.Write(HtmlTextWriter.TagRightChar);
                    }
                }

                break;

            case "":
            case "None":
            default:
                //do nothing
                break;
            }

            if (!suppressImages)
            {
                WriteNodeImage(treeView, item, writer);
            }

            // put a switch here to satisfy this request
            // http://www.mojoportal.com/Forums/Thread.aspx?thread=2824&mid=34&pageid=5&ItemID=4&pagenumber=1#post12578
            if (renderMenuText)
            {
                writer.Write(item.Text);
            }

            switch (extraMarkupMode)
            {
            case "Artisteer":
                if (!suppressCornerDivs)
                {
                    if (item.Depth < 1)
                    {
                        writer.WriteEndTag("span");
                    }
                }

                break;

            case "":
            case "None":
            default:
                //do nothing
                break;
            }

            writer.Indent--;
            writer.WriteEndTag("a");
        }
        private void WriteNodeLink(TreeView treeView, TreeNode item, HtmlTextWriter writer, string nodeClass)
        {
            writer.WriteBeginTag("a");

            if ((useMenuTooltipForCustomCss) && (item.ToolTip.Length > 0))
            {
                if (nodeClass.Contains("active"))
                {
                    writer.WriteAttribute("class", nodeClass + " " + item.ToolTip);
                }
                else
                {
                    writer.WriteAttribute("class", item.ToolTip);
                }
            }
            else
            {
                if (nodeClass.Contains("active"))
                {
                    writer.WriteAttribute("class", nodeClass);
                }
            }

            if (!String.IsNullOrEmpty(item.NavigateUrl))
            {
                writer.WriteAttribute("href", Extender.ResolveUrl(item.NavigateUrl));
                if (item is mojoTreeNode)
                {
                    mojoTreeNode node = (mojoTreeNode)item;
                    if (node.OnClientClick.Length > 0)
                    {
                        writer.WriteAttribute("onclick", node.OnClientClick);
                    }
                }
            }
            else
            {
                string codePrefix = "";
                if (item.SelectAction == TreeNodeSelectAction.Select)
                {
                    codePrefix = "s";
                }
                else if (item.SelectAction == TreeNodeSelectAction.SelectExpand)
                {
                    codePrefix = "e";
                }
                else if (item.PopulateOnDemand)
                {
                    codePrefix = "p";
                }
                writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(treeView, codePrefix + (Page.Server.HtmlEncode(item.ValuePath)).Replace("/", "\\"), true));
            }

            WebControlAdapterExtender.WriteTargetAttribute(writer, item.Target);

            if (!useMenuTooltipForCustomCss)
            {
                if (!String.IsNullOrEmpty(item.ToolTip))
                {
                    writer.WriteAttribute("title", item.ToolTip);
                }
                else if (!String.IsNullOrEmpty(treeView.ToolTip))
                {
                    writer.WriteAttribute("title", treeView.ToolTip);
                }
            }
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.Indent++;
            writer.WriteLine();

            //WriteNodeImage(treeView, item, writer);

            if (item.Depth < 1)
            {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", "l");
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.WriteEndTag("span");

                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", "r");
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.WriteEndTag("span");

                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", "t");
                writer.Write(HtmlTextWriter.TagRightChar);
            }

            if (!String.IsNullOrEmpty(item.ImageUrl))
            {
                writer.WriteBeginTag("img");
                writer.WriteAttribute("src", Page.ResolveClientUrl(item.ImageUrl));
                writer.WriteAttribute("alt", !String.IsNullOrEmpty(item.ToolTip) ? item.ToolTip : (!String.IsNullOrEmpty(treeView.ToolTip) ? treeView.ToolTip : item.Text));
                writer.Write(HtmlTextWriter.SelfClosingTagEnd);
                //writer.Write(HtmlTextWriter.SpaceChar);
            }

            writer.Write(item.Text);

            if (item.Depth < 1)
            {
                writer.WriteEndTag("span");
            }

            //writer.Write(item.Text);

            writer.Indent--;
            writer.WriteEndTag("a");
        }
Ejemplo n.º 4
0
        void menu_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {
            TreeView        menu    = (TreeView)sender;
            mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Node.DataItem;

            if ((useImagesInSiteMap) && (mapNode.MenuImage.Length > 0))
            {
                e.Node.ImageUrl = mapNode.MenuImage;
            }

            if (mapNode.OpenInNewWindow)
            {
                e.Node.Target = "_blank";
            }

            if (useMenuTooltipForCustomCss)
            {
                e.Node.ToolTip = mapNode.MenuCssClass;
            }

            //if (treeViewPopulateOnDemand)
            //{
            if (e.Node is mojoTreeNode)
            {
                mojoTreeNode tn = e.Node as mojoTreeNode;
                tn.HasVisibleChildren = mapNode.HasVisibleChildren();
            }
            // }

            // added this 2007-09-07
            // to solve treeview expand issue when page name is the same
            // as Page Name was used for value if not set explicitly
            e.Node.Value = mapNode.PageGuid.ToString();

            if (resolveFullUrlsForMenuItemProtocolDifferences)
            {
                if (isSecureRequest)
                {
                    if (
                        (!mapNode.UseSsl) &&
                        (!siteSettings.UseSslOnAllPages) &&
                        (mapNode.Url.StartsWith("~/"))
                        )
                    {
                        e.Node.NavigateUrl = insecureSiteRoot + mapNode.Url.Replace("~/", "/");
                    }
                }
                else
                {
                    if ((mapNode.UseSsl) || (siteSettings.UseSslOnAllPages))
                    {
                        if (mapNode.Url.StartsWith("~/"))
                        {
                            e.Node.NavigateUrl = secureSiteRoot + mapNode.Url.Replace("~/", "/");
                        }
                    }
                }
            }


            bool remove = false;

            if (mapNode.Roles == null)
            {
                if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor))
                {
                    remove = true;
                }
            }
            else
            {
                if ((!isAdmin) && (mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins"))
                {
                    remove = true;
                }

                if ((!isAdmin) && (!isContentAdmin) && (!isSiteEditor) && (!WebUser.IsInRoles(mapNode.Roles)))
                {
                    remove = true;
                }
            }

            if (!mapNode.IncludeInSiteMap)
            {
                remove = true;
            }
            //if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) { remove = true; }
            if (mapNode.IsPending)
            {
                if (
                    (!isAdmin) &&
                    (!isContentAdmin) &&
                    (!isSiteEditor) &&
                    (!WebUser.IsInRoles(mapNode.EditRoles)) &&
                    (!WebUser.IsInRoles(mapNode.DraftEditRoles))
                    )
                {
                    remove = true;
                }
            }


            if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated))
            {
                remove = true;
            }

            if (isMobileSkin)
            {
                if (mapNode.PublishMode == webOnly)
                {
                    remove = true;
                }
            }
            else
            {
                if (mapNode.PublishMode == mobileOnly)
                {
                    remove = true;
                }
            }


            if (remove)
            {
                if (e.Node.Depth == 0)
                {
                    menu.Nodes.Remove(e.Node);
                }
                else
                {
                    TreeNode parent = e.Node.Parent;
                    if (parent != null)
                    {
                        parent.ChildNodes.Remove(e.Node);
                    }
                }
            }
            else
            {
                if (mapNode.HasVisibleChildren())
                {
                    //e.Node.PopulateOnDemand = treeViewPopulateOnDemand;
                    e.Node.PopulateOnDemand = menu.PopulateNodesFromClient;
                }

                if (menu.ShowExpandCollapse)
                {
                    e.Node.Expanded = mapNode.ExpandOnSiteMap;
                }
            }
        }