// gman3001: Method Added 2004/10/06
        // Method determines if the current PageStripDetails contains the active tab, by checking all of its descendants
        /// <summary>
        /// Determines whether [is active tab in] [the specified active page ID].
        /// </summary>
        /// <param name="activePageID">The active page ID.</param>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <returns>
        ///     <c>true</c> if [is active tab in] [the specified active page ID]; otherwise, <c>false</c>.
        /// </returns>
        private bool isActiveTabIn(int activePageID, PageStripDetails PageStripDetails)
        {
            if (PageStripDetails.PageID == activePageID)
            {
                return(true);
            }
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        if (isActiveTabIn(activePageID, mySubTab))
                        {
                            return(true);
                        }
                    }
                }
                childTabs = null;
            }
            return(false);
        }
        /// <summary>
        /// Gets the tabs.
        /// </summary>
        /// <param name="parentID">The parent ID.</param>
        /// <param name="tabID">The tab ID.</param>
        /// <param name="Tabs">The tabs.</param>
        /// <returns></returns>
        private ArrayList GetTabs(int parentID, int tabID, IList Tabs)
        {
            ArrayList authorizedTabs = new ArrayList();
            int       index          = -1;

            //MH:get the selected tab for this
            int selectedPageID = GetSelectedTab(parentID, tabID, Tabs);


            // Populate Tab List with authorized tabs
            for (int i = 0; i < Tabs.Count; i++)
            {
                PageStripDetails tab = (PageStripDetails)Tabs[i];

                if (tab.ParentPageID == parentID) // Get selected row only
                {
                    if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                    {
                        index = authorizedTabs.Add(tab);

                        //MH:if (tab.PageID == tabID)
                        //MH:added to support the selected menutab in each level
                        if (tab.PageID == selectedPageID)
                        {
                            SelectedIndex = index;
                        }
                    }
                }
            }
            return(authorizedTabs);
        }
        //MH: end

        #endregion

        /// <summary>
        /// Do databind.
        /// Thanks to abain for cleaning up the code
        /// </summary>
        public override void DataBind()
        {
            bool currentTabOnly = (Bind == BindOption.BindOptionCurrentChilds);

            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Build list of tabs to be shown to user
            ArrayList authorizedTabs = new ArrayList();
            int       addedTabs      = 0;

            for (int i = 0; i < portalSettings.DesktopPages.Count; i++)
            {
                PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                {
                    authorizedTabs.Add(tab);
                }

                addedTabs++;
            }

            //Menu

            // add the shop home!
            AddShopHomeNode();

            if (!currentTabOnly)
            {
                for (int i = 0; i < authorizedTabs.Count; i++)
                {
                    PageStripDetails myTab = (PageStripDetails)authorizedTabs[i];
                    AddMenuTreeNode(i, myTab);
                }
            }
            else
            {
                if (authorizedTabs.Count >= 0)
                {
                    PageStripDetails myTab = PortalSettings.GetRootPage(portalSettings.ActivePage, authorizedTabs);

                    if (myTab.Pages.Count > 0)
                    {
                        for (int i = 0; i < myTab.Pages.Count; i++)
                        {
                            PageStripDetails mySubTab = (PageStripDetails)myTab.Pages[i];
                            AddMenuTreeNode(0, mySubTab);
                        }
                    }
                }
            }

            base.DataBind();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the pages in page.
        /// </summary>
        /// <param name="portalId">
        /// The portal ID.
        /// </param>
        /// <param name="pageId">
        /// The page ID.
        /// </param>
        /// <returns>
        /// A System.Collections.ArrayList value...
        /// </returns>
        public List <PageStripDetails> GetPagesinPage(int portalId, int pageId)
        {
            var desktopPages = new List <PageStripDetails>();

            // Create Instance of Connection and Command Object
            using (var connection = Config.SqlConnectionString)
                using (var sqlCommand = new SqlCommand("rb_GetTabsinTab", connection))
                {
                    // Mark the Command as a SPROC
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    // Add Parameters to SPROC
                    var parameterPortalId = new SqlParameter(StrPortalId, SqlDbType.Int, 4)
                    {
                        Value = portalId
                    };
                    sqlCommand.Parameters.Add(parameterPortalId);
                    var parameterPageId = new SqlParameter(StrPageId, SqlDbType.Int, 4)
                    {
                        Value = pageId
                    };
                    sqlCommand.Parameters.Add(parameterPageId);

                    // Execute the command
                    connection.Open();
                    var result = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);

                    // Read the result set
                    try
                    {
                        while (result.Read())
                        {
                            var tabDetails = new PageStripDetails
                            {
                                PageID          = (int)result["PageID"],
                                ParentPageID    = Int32.Parse("0" + result["ParentPageID"]),
                                PageName        = (string)result["PageName"],
                                PageOrder       = (int)result["PageOrder"],
                                AuthorizedRoles = (string)result["AuthorizedRoles"]
                            };

                            // Update the AuthorizedRoles Variable
                            desktopPages.Add(tabDetails);
                        }
                    }
                    finally
                    {
                        result.Close(); // by Manu, fixed bug 807858
                    }
                }

            return(desktopPages);
        }
        /// <summary>
        /// Add a Menu Tree Node if user in in the list of Authorized roles.
        /// Thanks to abain for fixing authorization bug.
        /// </summary>
        /// <param name="tabIndex">Index of the tab</param>
        /// <param name="myTab">Tab to add to the MenuTreeNodes collection</param>
        protected virtual void AddMenuTreeNode(int tabIndex, PageStripDetails myTab) //MH:
        {
            if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles))
            {
                MenuTreeNode mn = new MenuTreeNode(myTab.PageName);

                mn.Link   = giveMeUrl(myTab.PageName, myTab.PageID);
                mn.Height = Height;
                mn.Width  = Width;
                mn        = RecourseMenu(tabIndex, myTab.Pages, mn);
                Childs.Add(mn);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add a Menu Tree Node if user in in the list of Authorized roles.
        ///     Thanks to abain for fixing authorization bug.
        /// </summary>
        /// <param name="tabIndex">
        /// Index of the tab
        /// </param>
        /// <param name="mytab">
        /// Tab to add to the MenuTreeNodes collection
        /// </param>
        protected virtual void AddMenuTreeNode(int tabIndex, PageStripDetails mytab)
        {
            // MH:
            if (PortalSecurity.IsInRoles(mytab.AuthorizedRoles))
            {
                var mn = new MenuTreeNode(mytab.PageName)
                {
                    Link = this.GiveMeUrl(mytab.PageName, mytab.PageID), Height = this.Height, Width = this.Width
                };

                mn = this.RecourseMenu(tabIndex, mytab.Pages, mn);
                this.Childs.Add(mn);
            }
        }
        /// <summary>
        /// This is the recursive function to add all tabs with it's child tabs
        /// </summary>
        /// <param name="tab">The tab.</param>
        /// <param name="level">The level.</param>
        private void RecurseSitemap(PageStripDetails tab, int level)
        {
            //only add tabs we have access to
            if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
            {
                //first add the tab, then add it's children
                list.Add(new SitemapItem(tab.PageID, tab.PageName, HttpUrlBuilder.BuildUrl(tab.PageID), level));

                for (int i = 0; i < tab.Pages.Count; ++i)
                {
                    RecurseSitemap(tab.Pages[i], level + 1);
                }
            }
        }
        /// <summary>
        /// Shops the desktop navigation.
        /// </summary>
        /// <param name="myTab">My tab.</param>
        private void ShopDesktopNavigation(PageStripDetails myTab)
        {
            if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles))
            {
                MenuTreeNode mn = new MenuTreeNode(myTab.PageName);

                mn.Link =
                    HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, myTab.ParentPageID,
                                            "ItemID=" + myTab.PageID.ToString());
                mn.Height = Height;
                mn.Width  = Width;
                mn        = RecourseMenuShop(0, myTab.Pages, mn, myTab.ParentPageID);
                Childs.Add(mn);
            }
        }
        /// <summary>
        /// Gets the pagesin page.
        /// </summary>
        /// <param name="portalID">The portal ID.</param>
        /// <param name="pageID">The page ID.</param>
        /// <returns>A System.Collections.ArrayList value...</returns>
        public ArrayList GetPagesinPage(int portalID, int pageID)
        {
            ArrayList DesktopPages = new ArrayList();

            // Create Instance of Connection and Command Object
            using (SqlConnection myConnection = Config.SqlConnectionString)
            {
                using (SqlCommand myCommand = new SqlCommand("rb_GetTabsinTab", myConnection))
                {
                    // Mark the Command as a SPROC
                    myCommand.CommandType = CommandType.StoredProcedure;
                    // Add Parameters to SPROC
                    SqlParameter parameterPortalID = new SqlParameter(strPortalID, SqlDbType.Int, 4);
                    parameterPortalID.Value = portalID;
                    myCommand.Parameters.Add(parameterPortalID);
                    SqlParameter parameterPageID = new SqlParameter(strPageID, SqlDbType.Int, 4);
                    parameterPageID.Value = pageID;
                    myCommand.Parameters.Add(parameterPageID);
                    // Execute the command
                    myConnection.Open();
                    SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                    // Read the resultset
                    try
                    {
                        while (result.Read())
                        {
                            PageStripDetails tabDetails = new PageStripDetails();
                            tabDetails.PageID          = (int)result["PageID"];
                            tabDetails.ParentPageID    = Int32.Parse("0" + result["ParentPageID"]);
                            tabDetails.PageName        = (string)result["PageName"];
                            tabDetails.PageOrder       = (int)result["PageOrder"];
                            tabDetails.AuthorizedRoles = (string)result["AuthorizedRoles"];
                            // Update the AuthorizedRoles Variable
                            DesktopPages.Add(tabDetails);
                        }
                    }

                    finally
                    {
                        result.Close(); //by Manu, fixed bug 807858
                    }
                }
            }
            return(DesktopPages);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Recourses the menu.
        /// </summary>
        /// <param name="PageStripDetails">
        /// The page strip details.
        /// </param>
        /// <param name="activePageID">
        /// The active page ID.
        /// </param>
        protected virtual void RecourseMenu(PageStripDetails PageStripDetails, int activePageID)
        {
            var childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                foreach (var mySubTab in
                         childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)))
                {
                    if (mySubTab.PageImage == null)
                    {
                        mySubTab.PageImage =
                            new PageSettings().GetPageCustomSettings(mySubTab.PageID)["CustomMenuImage"].ToString();
                    }

                    if (this.products(mySubTab.PageID))
                    {
                        this.AddGraphMenuItem(
                            PageStripDetails.PageID.ToString(),
                            mySubTab.PageID.ToString(),
                            mySubTab.PageName,
                            mySubTab.PageImage,
                            this.giveMeUrl(mySubTab.PageName, mySubTab.PageID),
                            false);
                        if (activePageID == mySubTab.PageID)
                        {
                            this.ShopMenu(mySubTab, activePageID);
                        }
                    }
                    else
                    {
                        this.AddGraphMenuItem(
                            PageStripDetails.PageID.ToString(),
                            mySubTab.PageID.ToString(),
                            mySubTab.PageName,
                            mySubTab.PageImage,
                            this.giveMeUrl(mySubTab.PageName, mySubTab.PageID),
                            false);
                        this.RecourseMenu(mySubTab, activePageID);
                    }
                }

                childTabs = null;
            }
        }
        /// <summary>
        /// Do databind.
        /// Thanks to abain for cleaning up the code and fixing the bugs
        /// </summary>
        public override void DataBind()
        {
            base.DataBind();

            //bool currentTabOnly = (Bind == BindOption.BindOptionCurrentChilds);

            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Build list of tabs to be shown to user
            ArrayList authorizedTabs = setAutorizedTabsWithImage();

            for (int i = 0; i < authorizedTabs.Count; i++)
            {
                PageStripDetails myTab = (PageStripDetails)authorizedTabs[i];
                if (products(myTab.PageID))
                {
                    AddGraphMenuItem(null, myTab.PageID.ToString(), myTab.PageName, myTab.PageImage,
                                     giveMeUrl(myTab.PageName, myTab.PageID), false);
                    if (portalSettings.ActivePage.PageID == myTab.PageID)
                    {
                        ShopMenu(myTab, portalSettings.ActivePage.PageID);
                    }
                }
                else
                {
                    // gman3001: Statement Added/Modified 2004/10/06
                    // for now only set default css styles for the active root menu item, if it is not a products menu
                    if (isActiveTabIn(portalSettings.ActivePage.PageID, myTab))
                    {
                        AddGraphMenuItem(null, myTab.PageID.ToString(), myTab.PageName, myTab.PageImage,
                                         giveMeUrl(myTab.PageName, myTab.PageID), false,
                                         Attributes["MenuCSS-MenuDefaultItem"],
                                         Attributes["MenuCSS-MenuDefaultItemHighLight"]);
                    }
                    else
                    {
                        AddGraphMenuItem(null, myTab.PageID.ToString(), myTab.PageName, myTab.PageImage,
                                         giveMeUrl(myTab.PageName, myTab.PageID), false);
                    }

                    RecourseMenu(myTab, portalSettings.ActivePage.PageID);
                }
            }
        }
        /// <summary>
        /// Add a Menu Tree Node if user in in the list of Authorized roles.
        /// Thanks to abain for fixing authorization bug.
        /// </summary>
        /// <param name="tabIndex">Index of the tab</param>
        /// <param name="myTab">Tab to add to the MenuTreeNodes collection</param>
        private void AddMenuTreeNode(int tabIndex, PageStripDetails myTab)
        {
            if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles))
            {
                // get index and id from this page and transmit them
                // Obtain PortalSettings from Current Context
                PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
                int            tabIDShop      = portalSettings.ActivePage.PageID;

                MenuTreeNode mn = new MenuTreeNode(myTab.PageName);
                // change the link to stay on the same page and call a category product

                mn.Link =
                    HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIDShop, "ItemID=" + myTab.PageID);
                mn.Width = Width;
                mn       = RecourseMenu(tabIDShop, myTab.Pages, mn);
                Childs.Add(mn);
            }
        }
        //MH: end

        #endregion

        /// <summary>
        /// Do databind.
        /// Thanks to abain for cleaning up the code and fixing the bugs
        /// </summary>
        public override void DataBind()
        {
            base.DataBind();


            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Build list of tabs to be shown to user
            ArrayList authorizedTabs = new ArrayList();

            authorizedTabs = (ArrayList)GetInnerDataSource();

            for (int i = 0; i < authorizedTabs.Count; i++)
            {
                PageStripDetails myTab = (PageStripDetails)authorizedTabs[i];

                AddMenuTreeNode(0, myTab);
            }
        }
        /// <summary>
        /// Sets the autorized tabs with image.
        /// </summary>
        /// <returns></returns>
        private ArrayList setAutorizedTabsWithImage()
        {
            ArrayList authorizedTabs = (ArrayList)GetInnerDataSource();

            if (!ShowIconMenu)
            {
                return(authorizedTabs);
            }

            for (int i = 0; i < authorizedTabs.Count; i++)
            {
                PageStripDetails myTab = (PageStripDetails)authorizedTabs[i];
                if (myTab.PageImage == null)
                {
                    myTab.PageImage =
                        (new PageSettings().GetPageCustomSettings(myTab.PageID))["CustomMenuImage"].ToString();
                }
            }
            return(authorizedTabs);
        }
        /// <summary>
        /// Shops the menu.
        /// </summary>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <param name="activePageID">The active page ID.</param>
        protected virtual void ShopMenu(PageStripDetails PageStripDetails, int activePageID)
        {
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                         mySubTab.PageName, mySubTab.PageImage,
                                         HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, activePageID,
                                                                 "ItemID=" + mySubTab.PageID.ToString()), false);
                        ShopMenu(mySubTab, activePageID);
                    }
                }
                childTabs = null;
            }
        }
 /// <summary>
 /// Gets the selected tab.
 /// </summary>
 /// <param name="parentPageID">The parent page ID.</param>
 /// <param name="activePageID">The active page ID.</param>
 /// <param name="allTabs">All tabs.</param>
 /// <returns></returns>
 private int GetSelectedTab(int parentPageID, int activePageID, IList allTabs)
 {
     for (int i = 0; i < allTabs.Count; i++)
     {
         PageStripDetails tmpTab = (PageStripDetails)allTabs[i];
         if (tmpTab.PageID == activePageID)
         {
             int selectedPageID = activePageID;
             if (tmpTab.ParentPageID != parentPageID)
             {
                 selectedPageID = GetSelectedTab(parentPageID, tmpTab.ParentPageID, allTabs);
                 return(selectedPageID);
             }
             else
             {
                 return(selectedPageID);
             }
         }
     }
     return(0);
 }
        /// <summary>
        /// This function creates from the PortalSettings structure a list with the tabs in the right order
        /// </summary>
        private void MakeSitemap()
        {
            bool currentTabOnly = (Bind == BindOption.BindOptionCurrentChilds);

            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            int level = 0;

            // Add Portal Root when showing all tabs
            if (!currentTabOnly)
            {
                list.Add(new SitemapItem(0, portalSettings.PortalName, HttpUrlBuilder.BuildUrl("~/"), 0));
                level++;
            }

            // Now loop all tabs to find the right ones to init the recursive functions
            for (int i = 0; i < portalSettings.DesktopPages.Count; ++i)
            {
                PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                //if showing all tabs, look for root tabs
                if (!currentTabOnly)
                {
                    if (tab.ParentPageID == 0)
                    {
                        RecurseSitemap(tab, level);
                    }
                }
                else
                {
                    //else find the current tab
                    int tabID = (showTabID > 0) ? showTabID : portalSettings.ActivePage.PageID;
                    if (tab.PageID == tabID)
                    {
                        RecurseSitemap(tab, level);
                    }
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Shops the menu.
        /// </summary>
        /// <param name="pageStripDetails">
        /// The page strip details.
        /// </param>
        /// <param name="activePageId">
        /// The active page ID.
        /// </param>
        protected virtual void ShopMenu(PageStripDetails pageStripDetails, int activePageId)
        {
            Collection <PageStripDetails> childTabs = pageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                foreach (var mySubTab in childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)))
                {
                    this.AddGraphMenuItem(
                        pageStripDetails.PageID.ToString(),
                        mySubTab.PageID.ToString(),
                        mySubTab.PageName,
                        mySubTab.PageImage,
                        HttpUrlBuilder.BuildUrl(
                            "~/" + HttpUrlBuilder.DefaultPage, activePageId, "ItemID=" + mySubTab.PageID),
                        false);
                    this.ShopMenu(mySubTab, activePageId);
                }

                childTabs = null;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Add a Menu Tree Node if user in in the list of Authorized roles.
        ///     Thanks to abain for fixing authorization bug.
        /// </summary>
        /// <param name="mytab">
        /// Tab to add to the MenuTreeNodes collection
        /// </param>
        private void AddMenuTreeNode(PageStripDetails mytab)
        {
            if (PortalSecurity.IsInRoles(mytab.AuthorizedRoles))
            {
                // get index and id from this page and transmit them
                // Obtain PortalSettings from Current Context
                var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
                var tabIdShop      = PortalSettings.ActivePage.PageID;

                var mn = new MenuTreeNode(mytab.PageName)
                {
                    // change the link to stay on the same page and call a category product
                    Link =
                        HttpUrlBuilder.BuildUrl(
                            "~/" + HttpUrlBuilder.DefaultPage, tabIdShop, "ItemID=" + mytab.PageID),
                    Width = this.Width
                };

                mn = this.RecourseMenu(tabIdShop, mytab.Pages, mn);
                this.Childs.Add(mn);
            }
        }
 // modified to transmit the PageID and TabIndex for the shop page
 /// <summary>
 /// Recourses the menu.
 /// </summary>
 /// <param name="tabIDShop">The tab ID shop.</param>
 /// <param name="t">The t.</param>
 /// <param name="mn">The mn.</param>
 /// <returns></returns>
 private MenuTreeNode RecourseMenu(int tabIDShop, PagesBox t, MenuTreeNode mn)
 {
     if (t.Count > 0)
     {
         for (int c = 0; c < t.Count; c++)
         {
             PageStripDetails mySubTab = (PageStripDetails)t[c];
             if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
             {
                 MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);
                 // change PageID into ItemID for the product module on the same page
                 mnc.Link =
                     HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIDShop,
                                             "ItemID=" + mySubTab.PageID);
                 mnc.Width = mn.Width;
                 mnc       = RecourseMenu(tabIDShop, mySubTab.Pages, mnc);
                 mn.Childs.Add(mnc);
             }
         }
     }
     return(mn);
 }
        /// <summary>
        /// Recourses the menu.
        /// </summary>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="t">The t.</param>
        /// <param name="mn">The mn.</param>
        /// <returns></returns>
        protected virtual MenuTreeNode RecourseMenu(int tabIndex, PagesBox t, MenuTreeNode mn) //mh:
        {
            if (t.Count > 0)
            {
                for (int c = 0; c < t.Count; c++)
                {
                    PageStripDetails mySubTab = t[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);

                        mnc.Link  = giveMeUrl(mySubTab.PageName, mySubTab.PageID);
                        mnc.Width = mn.Width;

                        mnc = RecourseMenu(tabIndex, mySubTab.Pages, mnc);

                        mn.Childs.Add(mnc);
                    }
                }
            }
            return(mn);
        }
        /// <summary>
        /// Recourses the menu.
        /// </summary>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <param name="activePageID">The active page ID.</param>
        protected virtual void RecourseMenu(PageStripDetails PageStripDetails, int activePageID)
        {
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        if (mySubTab.PageImage == null)
                        {
                            mySubTab.PageImage =
                                (new PageSettings().GetPageCustomSettings(mySubTab.PageID))["CustomMenuImage"].ToString();
                        }
                        if (products(mySubTab.PageID))
                        {
                            AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                             mySubTab.PageName, mySubTab.PageImage,
                                             giveMeUrl(mySubTab.PageName, mySubTab.PageID), false);
                            if (activePageID == mySubTab.PageID)
                            {
                                ShopMenu(mySubTab, activePageID);
                            }
                        }
                        else
                        {
                            AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                             mySubTab.PageName, mySubTab.PageImage,
                                             giveMeUrl(mySubTab.PageName, mySubTab.PageID), false);
                            RecourseMenu(mySubTab, activePageID);
                        }
                    }
                }
                childTabs = null;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Determines whether [is active tab in] [the specified active page ID].
        /// </summary>
        /// <param name="activePageId">
        /// The active page ID.
        /// </param>
        /// <param name="pageStripDetails">
        /// The page strip details.
        /// </param>
        /// <returns>
        /// <c>true</c> if [is active tab in] [the specified active page ID]; otherwise, <c>false</c>.
        /// </returns>
        private bool IsActiveTabIn(int activePageId, PageStripDetails pageStripDetails)
        {
            if (pageStripDetails.PageID == activePageId)
            {
                return(true);
            }

            var childTabs = pageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                if (
                    childTabs.Where(mySubTab => PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)).Any(
                        mySubTab => this.IsActiveTabIn(activePageId, mySubTab)))
                {
                    return(true);
                }

                childTabs = null;
            }

            return(false);
        }
        /// <summary>
        /// Recourses the menu shop.
        /// </summary>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="t">The t.</param>
        /// <param name="mn">The mn.</param>
        /// <param name="idShop">The id shop.</param>
        /// <returns></returns>
        protected virtual MenuTreeNode RecourseMenuShop(int tabIndex, PagesBox t, MenuTreeNode mn, int idShop)
        {
            if (t.Count > 0)
            {
                for (int c = 0; c < t.Count; c++)
                {
                    PageStripDetails mySubTab = t[c];

                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);

                        mnc.Link =
                            HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, idShop,
                                                    "ItemID=" + mySubTab.PageID.ToString());
                        mnc.Width = mn.Width;
                        mnc       = RecourseMenuShop(tabIndex, mySubTab.Pages, mnc, idShop);
                        mn.Childs.Add(mnc);
                    }
                }
            }
            return(mn);
        }
        /// <summary>
        /// Override CreateChildControls to create the control tree.
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create an arraylist to fill with
            // the TabItems representing the Tree
            ArrayList crumbs;

            if (HttpContext.Current != null)
            {
                // Obtain PortalSettings from Current Context
                PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                //Display breadcrumbs if the user has click a tab link  (Without hit the Database again)
                if (portalSettings.ActivePage.PageID > 0)
                {
                    ArrayList authorizedTabs = new ArrayList();
                    int       addedTabs      = 0;
                    for (int i = 0; i < portalSettings.DesktopPages.Count; i++)
                    {
                        PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                        if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                        {
                            authorizedTabs.Add(tab);
                        }
                        addedTabs++;
                    }

                    crumbs = GetBreadCrumbs(portalSettings.ActivePage, authorizedTabs);
                    crumbs.Sort();
                }
                else
                {
                    crumbs = new ArrayList();
                }
            }
            else //design time
            {
                crumbs = new ArrayList();
                crumbs.Add("Item1");
                crumbs.Add("Item2");
                crumbs.Add("Item3");
            }

            if (crumbs.Count > 1)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div class='");
                sb.Append(CssClass);
                sb.Append("'>");

                int ct = 0;

                // Build the Breadcrumbs and add them to the div
                foreach (PageItem item in crumbs)
                {
                    if (ct > 0)
                    {
                        sb.Append(Separator.ToString());
                    }
                    if (ct != (crumbs.Count - 1))
                    {
                        sb.Append("<a href='");
                        sb.Append(HttpUrlBuilder.BuildUrl(item.ID));
                        sb.Append("'>");
                        sb.Append(item.Name.ToString());
                        sb.Append("</a>");
                    }
                    else
                    {
                        sb.Append(item.Name.ToString());
                    }
                    ct++;
                }
                sb.Append("</div>");
                Text = sb.ToString();
            }
            else
            {
                Visible = false;
            }
        }
        // Override CreateChildControls to create the control tree.
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            // jes1111
            if (!((Page)Page).IsCssFileRegistered("Mod_Breadcrumbs"))
            {
                ((Page)Page).RegisterCssFile("Mod_Breadcrumbs");
            }


            // Create an arraylist to fill with
            // the PageItems representing the Tree
            ArrayList crumbs;

            if (HttpContext.Current != null)
            {
                // Obtain PortalSettings from Current Context
                PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                //Changes by Indah Fuldner 25.04.2003
                //Display breadcrumbs if the user has click a tab link  (Without hit the Database again)
                if (portalSettings.ActivePage.PageID > 0)
                {
                    ArrayList authorizedTabs = new ArrayList();
                    int       addedTabs      = 0;
                    for (int i = 0; i < portalSettings.DesktopPages.Count; i++)
                    {
                        PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                        if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                        {
                            authorizedTabs.Add(tab);
                        }
                        addedTabs++;
                    }

                    crumbs = GetBreadCrumbs(portalSettings.ActivePage, authorizedTabs);
                    //crumbs.Sort();
                    //Fixing bug: http://support.rainbowportal.net/jira/browse/RBP-704
                    crumbs.Reverse();
                    //End Changes by Indah Fuldner
                }
                else
                {
                    crumbs = new ArrayList();
                }
            }
            else //design time
            {
                crumbs = new ArrayList();
                crumbs.Add("Item1");
                crumbs.Add("Item2");
                crumbs.Add("Item3");
            }

            if (crumbs.Count > 1)
            {
                TableRow  r = new TableRow();
                TableCell c = new TableCell();
                c.CssClass = "breadcrumbs";

                int ct = 0;

                // Build the Breadcrumbs and add them to the table
                foreach (PageItem item in crumbs)
                {
                    if (ct > 0)
                    {
                        Label divider = new Label();
                        divider.Text            = Separator;
                        divider.CssClass        = TextCSSClass;
                        divider.EnableViewState = false;
                        c.Controls.Add(divider);
                    }
                    if (ct != (crumbs.Count - 1))
                    {
                        HyperLink link = new HyperLink();
                        link.Text            = item.Name;
                        link.NavigateUrl     = HttpUrlBuilder.BuildUrl(item.ID);
                        link.EnableViewState = false;
                        link.CssClass        = LinkCSSClass;
                        c.Controls.Add(link);
                    }
                    else
                    {
                        Label lastlink = new Label();
                        lastlink.Text            = item.Name;
                        lastlink.CssClass        = LinkCSSClass;
                        lastlink.EnableViewState = false;
                        c.Controls.Add(lastlink);
                    }
                    ct++;
                }

                r.Cells.Add(c);
                Rows.Add(r);
            }
            else
            {
                Visible = false;
            }
        }