Exemplo n.º 1
0
        private void BindCrumbs()
        {
            if (siteMapDataSource == null)
            {
                return;
            }

            //breadCrumbsControl.ParentLevelsDisplayed = -1;

            if ((!showhome) && (!currentPage.ShowHomeCrumb))
            {
                int currentPageDepth = SiteUtils.GetCurrentPageDepth(siteMapDataSource.Provider.RootNode);
                breadCrumbsControl.ParentLevelsDisplayed = currentPageDepth;
            }

            #region BreadCrumb

            string[] queryParams             = null;
            string[] queryParameters         = null;
            var      queryStringParamsCount  = Request.QueryString.Count;
            bool     playVideoPageURLPresent = false;
            if (queryStringParamsCount > 1)
            {
                string requestURL = Request.Url.OriginalString;
                Uri    requestUri = new Uri(requestURL);
                queryParameters = GetQueryStringData(requestUri.OriginalString);
                queryParams     = requestURL.Split('?');
            }

            currentPageNode = SiteUtils.GetCurrentPageSiteMapNode(siteMapDataSource.Provider.RootNode);

            if (queryParams != null)
            {
                if (currentPageNode.Url.ToString().Split('?')[0] == "~/" + WebConfigSettings.KalturaPlayVideoPageURL)
                {
                    playVideoPageURLPresent = true;
                }
                for (int i = 0; i < queryParameters.Length; i++)
                {
                    if (playVideoPageURLPresent == false)
                    {
                        if (queryParameters[i].Contains("categoryName"))
                        {
                            currentPageNode.Title = "";
                            currentPageNode.Title = Resources.Resource.KalturaDisplayVideosByCategoryBreadcrumb + " - " + HttpUtility.UrlDecode(queryParameters[i].Split('=')[1]);
                        }
                    }
                }
                playVideoPageURLPresent = false;
                currentPageNode.Url     = currentPageNode.Url.Split('?')[0];
                currentPageNode.Url     = currentPageNode.Url + "?" + queryParams[1];
            }
            #endregion

            breadCrumbsControl.OverrideCurrentNode = currentPageNode;
            breadCrumbsControl.PathSeparator       = Separator;

            breadCrumbsControl.Provider = siteMapDataSource.Provider;
            breadCrumbsControl.DataBind();
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        public MenuList()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();

            isAdmin = WebUser.IsAdmin;
            if (!isAdmin)
            {
                isContentAdmin = WebUser.IsContentAdmin;
            }
            if ((!isAdmin) && (!isContentAdmin))
            {
                isSiteEditor = SiteUtils.UserIsSiteEditor();
            }

            resolveFullUrlsForMenuItemProtocolDifferences = WebConfigSettings.ResolveFullUrlsForMenuItemProtocolDifferences;
            if (resolveFullUrlsForMenuItemProtocolDifferences)
            {
                secureSiteRoot   = WebUtils.GetSecureSiteRoot();
                insecureSiteRoot = WebUtils.GetInSecureSiteRoot();
            }

            isSecureRequest = SiteUtils.IsSecureRequest();

            siteMapDataSource = new SiteMapDataSource();
            siteMapDataSource.SiteMapProvider = "mojosite" + siteSettings.SiteId.ToInvariantString();

            rootNode     = siteMapDataSource.Provider.RootNode;
            currentNode  = SiteUtils.GetCurrentPageSiteMapNode(rootNode);
            startingNode = rootNode;

            //if (startingNodePageId > -1)
            //{
            //    startingNode = SiteUtils.GetSiteMapNodeForPage(rootNode, startingNodePageId);
            //}
            //else if (startingNodeOffset > -1)
            //{
            //    startingNode = SiteUtils.GetOffsetNode(currentNode, startingNodeOffset);
            //}
            //else if (isSubMenu)
            //{
            //    startingNode = SiteUtils.GetTopLevelParentNode(currentNode);
            //}

            Items = AddNodes(startingNode);
        }
Exemplo n.º 4
0
        private void BindCrumbs()
        {
            if (siteMapDataSource == null)
            {
                return;
            }

            if (!ShowHome && !currentPage.ShowHomeCrumb)
            {
                int currentPageDepth = SiteUtils.GetCurrentPageDepth(siteMapDataSource.Provider.RootNode);

                breadCrumbsControl.ParentLevelsDisplayed = currentPageDepth;
            }

            currentPageNode = SiteUtils.GetCurrentPageSiteMapNode(siteMapDataSource.Provider.RootNode);

            breadCrumbsControl.OverrideCurrentNode = currentPageNode;
            breadCrumbsControl.PathSeparator       = Separator;
            breadCrumbsControl.Provider            = siteMapDataSource.Provider;

            breadCrumbsControl.DataBind();
        }
Exemplo n.º 5
0
        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(Separator);
            string childSeparator = string.Empty;

            int addedChildren = 0;

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

                mojoSiteMapNode node = childNode as mojoSiteMapNode;

                if (!node.IncludeInMenu)
                {
                    continue;
                }

                bool remove = false;

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

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

                if (!remove)
                {
                    markup.Append(childSeparator + "<a class='"
                                  + this.cssClass + "' href='"
                                  + Page.ResolveUrl(node.Url)
                                  + "'>"
                                  + node.Title + "</a>");

                    childSeparator = " - ";

                    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;
            }
        }