private void RenderSiteMapNodes(
            HttpContext context,
            SiteMapNode siteMapNode,
            string pagePrefix)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

            if (!CNode.IsRootNode)
            {
                if (WebUser.IsInRoles(CNode.ViewRoles))
                {
                    if (CNode.ParentId > -1)
                    {
                        pagePrefix += "-";
                    }

                    //context.Response.Write("\t<li class=\"file ext_txt\"><a href=\"#\" rel=\"" + CNode.Url.Replace("~/", "/") + "\">" + pagePrefix + CNode.Title + "</a></li>\n");
                    context.Response.Write("\t<li class=\"file ext_txt\"><a href=\"#\" rel=\"" + page.ResolveUrl(CNode.Url) + "\">" + pagePrefix + CNode.Title + "</a></li>\n");

                    //XmlNode oFileNode = XmlUtil.AppendElement(listNode, "File");
                    //XmlUtil.SetAttribute(oFileNode, "name", pagePrefix + CNode.Title);
                    //XmlUtil.SetAttribute(oFileNode, "size", 1.ToString(CultureInfo.InvariantCulture));

                    //XmlUtil.SetAttribute(oFileNode, "url", Page.ResolveUrl(CNode.Url));
                }
            }


            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                //recurse to populate children
                RenderSiteMapNodes(context, childNode, pagePrefix);
            }
        }
Ejemplo n.º 2
0
        private void PopulatePageDictionary(
            Collection <DictionaryEntry> deCollection,
            SiteMapNode siteMapNode,
            string pagePrefix)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

            if (!CNode.IsRootNode)
            {
                if (CNode.ParentId > -1)
                {
                    pagePrefix += "-";
                }

                deCollection.Add(new DictionaryEntry(
                                     CNode.Title,
                                     CNode.PageId.ToString())
                                 );
            }


            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                //recurse to populate children
                PopulatePageDictionary(deCollection, childNode, pagePrefix);
            }
        }
Ejemplo n.º 3
0
        private void PopulateListControl(
            ListControl listBox,
            SiteMapNode siteMapNode,
            string pagePrefix)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

            if (!CNode.IsRootNode)
            {
                if ((isAdmin) ||
                    ((isContentAdmin) && (CNode.ViewRoles != "Admins;")) ||
                    ((isSiteEditor) && (CNode.ViewRoles != "Admins;")) ||
                    (WebUser.IsInRoles(CNode.CreateChildPageRoles))
                    )
                {
                    if (CNode.ParentId > -1)
                    {
                        pagePrefix += "-";
                    }
                    ListItem listItem = new ListItem();
                    listItem.Text  = pagePrefix + Server.HtmlDecode(CNode.Title);
                    listItem.Value = CNode.PageId.ToInvariantString();

                    listBox.Items.Add(listItem);
                    userCanAddPages = true;
                }
            }


            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                //recurse to populate children
                PopulateListControl(listBox, childNode, pagePrefix);
            }
        }
        private void PopulateListControl(
            ListControl listBox,
            SiteMapNode siteMapNode,
            string pagePrefix)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

            if (!CNode.IsRootNode)
            {
                if (
                    (isAdmin) ||
                    (WebUser.IsInRoles(CNode.EditRoles)) ||
                    (CNode.PageId == module.PageId)
                    )
                {
                    if (CNode.ParentId > -1)
                    {
                        pagePrefix += "-";
                    }
                    ListItem listItem = new ListItem();
                    listItem.Text  = pagePrefix + Server.HtmlDecode(CNode.Title);
                    listItem.Value = CNode.PageId.ToString();

                    listBox.Items.Add(listItem);
                }
            }


            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                //recurse to populate children
                PopulateListControl(listBox, childNode, pagePrefix);
            }
        }
Ejemplo n.º 5
0
        //void breadCrumbsControl_ItemDataBound(object sender, SiteMapNodeItemEventArgs e)
        //{
        //    if (sender == null) return;
        //    if (e == null) return;

        //    Menu menu = (Menu)sender;
        //    CSiteMapNode mapNode = (CSiteMapNode)e.Item.SiteMapNode;

        //    bool remove = false;

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

        //    if (!mapNode.IncludeInMenu) remove = true;
        //    if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor) remove = true;
        //    if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated)) remove = true;

        //    if (remove)
        //    {
        //        //if (e.Item.Depth == 0)
        //        //{
        //        //    breadCrumbsControl.Items.Remove(e.Item);

        //        //}
        //        //else
        //        //{
        //        //    MenuItem parent = e.Item.;
        //        //    if (parent != null)
        //        //    {
        //        //        parent.ChildItems.Remove(e.Item);
        //        //    }
        //        //}
        //    }


        //}

        private void RenderChildPageBreadcrumbs()
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            if (currentPageNode == null)
            {
                currentPageNode = SiteUtils.GetCurrentPageSiteMapNode(siteMapDataSource.Provider.RootNode);
            }
            if (currentPageNode == null)
            {
                return;
            }

            markup = new StringBuilder();
            markup.Append(Server.HtmlEncode(separator));
            separator = string.Empty;

            int addedChildren = 0;

            foreach (SiteMapNode childNode in currentPageNode.ChildNodes)
            {
                if (!(childNode is CSiteMapNode))
                {
                    continue;
                }

                CSiteMapNode node = childNode as CSiteMapNode;

                if (!node.IncludeInMenu)
                {
                    continue;
                }

                if ((isAdmin) ||
                    ((isContentAdmin) && (node.ViewRoles != "Admins;")) ||
                    (WebUser.IsInRoles(node.ViewRoles))
                    )
                {
                    markup.Append(Server.HtmlEncode(separator) + "<a class='"
                                  + this.cssClass + "' href='"
                                  + Page.ResolveUrl(node.Url)
                                  + "'>"
                                  + node.Title + "</a>");

                    separator = " - ";

                    addedChildren += 1;
                }
            }

            // this gets rid of the initial separator between bread crumbs and child crumbs if no children were rendered
            if (addedChildren == 0)
            {
                markup = null;
            }
        }
Ejemplo n.º 6
0
        private bool IsValidUrl(CSiteMapNode CNode)
        {
            bool result = true;

            if (CNode.Url.ToLower().Contains("default.aspx?pageid="))
            {
                result = false;
            }

            if (CNode.Url.Contains("#"))
            {
                result = false;
            }


            return(result);
        }
Ejemplo n.º 7
0
        protected void treeMenu1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            if (e == null)
            {
                return;
            }



            TreeView     menu    = (TreeView)sender;
            CSiteMapNode mapNode = (CSiteMapNode)e.Node.DataItem;

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

            if (treeViewShowExpandCollapse)
            {
                if (e.Node is CTreeNode)
                {
                    CTreeNode tn = e.Node as CTreeNode;
                    tn.HasVisibleChildren = mapNode.HasVisibleChildren();
                }
            }

            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("~/", "/");
                        }
                    }
                }
            }

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



            // 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();

            //log.Info("databound tree node with value path " + e.Node.ValuePath);

            bool remove = false;

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

            if (!mapNode.IncludeInMenu)
            {
                remove = true;
            }
            if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor)
            {
                remove = true;
            }
            if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated))
            {
                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
            {
                //e.Node.PopulateOnDemand = treeViewPopulateOnDemand;

                if (mapNode.HasVisibleChildren())
                {
                    e.Node.PopulateOnDemand = treeViewPopulateOnDemand;
                }
                else
                {
                    e.Node.PopulateOnDemand = false;
                }
            }
        }
Ejemplo n.º 8
0
        void pageMenu_MenuItemDataBound(object sender, MenuEventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            if (e == null)
            {
                return;
            }

            Menu         menu    = (Menu)sender;
            CSiteMapNode mapNode = (CSiteMapNode)e.Item.DataItem;

            if (mapNode.MenuImage.Length > 0)
            {
                e.Item.ImageUrl = mapNode.MenuImage;
            }

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

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

            // 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.Item.Value = mapNode.PageGuid.ToString();

            bool remove = false;

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

            if (!mapNode.IncludeInMenu)
            {
                remove = true;
            }
            if (mapNode.IsPending && !WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor)
            {
                remove = true;
            }
            if ((mapNode.HideAfterLogin) && (Request.IsAuthenticated))
            {
                remove = true;
            }

            if (remove)
            {
                if (e.Item.Depth == 0)
                {
                    menu.Items.Remove(e.Item);
                }
                else
                {
                    MenuItem parent = e.Item.Parent;
                    if (parent != null)
                    {
                        parent.ChildItems.Remove(e.Item);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void RenderNodesToSiteMap(
            HttpContext context,
            Page page,
            XmlTextWriter xmlTextWriter,
            ArrayList alreadyAddedUrls,
            SiteMapNode siteMapNode)
        {
            CSiteMapNode CNode = (CSiteMapNode)siteMapNode;

            if (!CNode.IsRootNode)
            {
                if (
                    ((CNode.Roles == null) || (WebUser.IsInRoles(CNode.Roles))) &&
                    (CNode.IncludeInSearchMap) &&
                    (!CNode.IsPending)
                    )
                {
                    // must use unique urls, google site maps can't have
                    // multiple urls like"
                    // http://SomeSite/Default.aspx?pageid=1
                    // http://SomeSite/Default.aspx?pageid=2
                    // where it only differs by query string
                    // google may stop crawling if it encounters this
                    // in a site map


                    if (IsValidUrl(CNode))
                    {
                        string url;
                        if (CNode.Url.StartsWith("http"))
                        {
                            url = CNode.Url;
                        }
                        else
                        {
                            if (CNode.UseSsl)
                            {
                                url = secureSiteRoot + CNode.Url.Replace("~/", "/");
                            }
                            else
                            {
                                url = insecureSiteRoot + CNode.Url.Replace("~/", "/");
                            }
                        }

                        // no duplicate urls allowed in a google site map
                        if (!alreadyAddedUrls.Contains(url))
                        {
                            alreadyAddedUrls.Add(url);

                            xmlTextWriter.WriteStartElement("url");
                            xmlTextWriter.WriteElementString("loc", url);

                            // this if is only needed because this is a new datapoint
                            // after it has been implemented in the db
                            // this if could be removed
                            if (CNode.LastModifiedUtc > DateTime.MinValue)
                            {
                                xmlTextWriter.WriteElementString(
                                    "lastmod",
                                    CNode.LastModifiedUtc.ToString("u", CultureInfo.InvariantCulture).Replace(" ", "T"));
                            }

                            xmlTextWriter.WriteElementString(
                                "changefreq",
                                CNode.ChangeFrequency.ToString().ToLower());

                            xmlTextWriter.WriteElementString(
                                "priority",
                                CNode.SiteMapPriority);

                            xmlTextWriter.WriteEndElement(); //url
                        }
                    }
                }
            }

            foreach (SiteMapNode childNode in CNode.ChildNodes)
            {
                RenderNodesToSiteMap(
                    context,
                    page,
                    xmlTextWriter,
                    alreadyAddedUrls,
                    childNode);
            }
        }
Ejemplo n.º 10
0
        void SiteMap_MenuItemDataBound(object sender, MenuEventArgs e)
        {
            Menu         menu    = (Menu)sender;
            CSiteMapNode mapNode = (CSiteMapNode)e.Item.DataItem;

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

            bool remove = false;

            if (
                (
                    WebUser.IsAdmin ||
                    (WebUser.IsContentAdmin && (!(mapNode.Roles.Count == 1) && (mapNode.Roles[0].ToString() == "Admins"))) ||
                    (WebUser.IsInRoles(mapNode.Roles))
                )
                )
            {
                remove = false;
            }
            else
            {
                remove = true;
            }

            if ((treatChildPageIndexAsSiteMap) || (hidePagesNotInSiteMap))
            {
                if (!mapNode.IncludeInSiteMap)
                {
                    remove = true;
                }
            }
            else
            {
                if (!mapNode.IncludeInMenu)
                {
                    remove = true;
                }
            }

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


            if (remove)
            {
                if (e.Item.Depth == 0)
                {
                    menu.Items.Remove(e.Item);
                }
                else
                {
                    MenuItem parent = e.Item.Parent;
                    if (parent != null)
                    {
                        parent.ChildItems.Remove(e.Item);
                    }
                }
            }
        }